diff options
author | Erich Eckner <git@eckner.net> | 2018-01-22 10:52:34 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-01-22 10:52:34 +0100 |
commit | 6c6809e9503d7791e22f295351098fd709410921 (patch) | |
tree | 9d70a04ee71a042fc8f07ea7ddd1d36a344e2158 | |
parent | d384cd8395fb0a0e0686f3c1ddac883002563f9a (diff) | |
download | builder-6c6809e9503d7791e22f295351098fd709410921.tar.xz |
bin/common-functions: remove replaced packages in database, too
-rwxr-xr-x | bin/common-functions | 26 | ||||
-rwxr-xr-x | bin/db-update | 2 |
2 files changed, 26 insertions, 2 deletions
diff --git a/bin/common-functions b/bin/common-functions index 40e52f2..3801967 100755 --- a/bin/common-functions +++ b/bin/common-functions @@ -560,6 +560,32 @@ remove_old_package_versions() { done < \ "${tmp_dir}/repositories-to-modify" + # shellcheck disable=SC2016 + sed ' + s/\.pkg\.tar\.xz$// + s/^\S\+ // + s/-\([^-. ]\+\)\(-[^- ]\+\)$/-\1.0\2/ + s/ \([^-: ]\+\(-[^- ]\+\)\{2\}\)$/ 0:\1/ + s/ \([^-.]\+\):\([^-:]\+\)-\([^-.]\+\)\.\([^-.]\+\)-\([^-]\+\)$/ \1 \2 \3 \4 \5/ + ' "${tmp_dir}/packages-to-delete" | \ + while read -r repo pkgname epoch pkgver pkgrel sub_pkgrel arch; do + printf 'DELETE FROM `binary_packages`' + printf ' JOIN `architectures` ON `binary_packages`.`architecture`=`architectures`.`id`' + printf ' JOIN `repositories` ON `binary_packages`.`repository`=`repositories`.`id`' + printf ' WHERE' + printf ' `binary_packages`.`%s`=from_base64("%s") AND' \ + 'pkgname' "$(printf '%s' "${pkgname}" | base64 -w0)" \ + 'epoch' "$(printf '%s' "${epoch}" | base64 -w0)" \ + 'pkgver' "$(printf '%s' "${pkgver}" | base64 -w0)" \ + 'pkgrel' "$(printf '%s' "${pkgrel}" | base64 -w0)" \ + 'sub_pkgrel' "$(printf '%s' "${sub_pkgrel}" | base64 -w0)" + printf ' `repositories`.`name`=from_base64("%s") AND' \ + "$(printf '%s' "${repo}" | base64 -w0)" + printf ' `architectures`.`name`=from_base64("%s")' \ + "$(printf '%s' "${arch}" | base64 -w0)" + printf ';\n' + done + sed ' s| \(\S\+\)$|-\1| y| |/| diff --git a/bin/db-update b/bin/db-update index 5b32214..b11945c 100755 --- a/bin/db-update +++ b/bin/db-update @@ -23,8 +23,6 @@ # TODO: fully integrate database (in other scripts too) - e.g. rely on # info in db instead of state-files -# TODO: remove replaced packages in database, too - # shellcheck disable=SC2039 # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" |