From 4f6f142c0f15fae17269a23d917e67768fc1b083 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 09:08:10 +0100 Subject: bin/db-update: check for existence of signature(s), too, before moving packages around --- bin/db-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/db-update') diff --git a/bin/db-update b/bin/db-update index 827dc05..9eee60e 100755 --- a/bin/db-update +++ b/bin/db-update @@ -160,7 +160,7 @@ move_packages() { exit 2 fi done < \ - "${tmp_dir}/tmp/${package}.parts" + "${tmp_dir}/tmp/${package}.parts_and_signatures" mkdir -p "${tmp_dir}/tmp/${from_repo}" mkdir -p "${tmp_dir}/tmp/${to_repo}" -- cgit v1.2.3-70-g09d2 From 0f94a77dc2f8ec2c8b3d6f984dddb37b4965dd3d Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 09:46:39 +0100 Subject: bin/db-update: track movement of packages with database --- bin/db-update | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) (limited to 'bin/db-update') diff --git a/bin/db-update b/bin/db-update index 9eee60e..fbbad2c 100755 --- a/bin/db-update +++ b/bin/db-update @@ -323,9 +323,58 @@ move_packages() { done < \ "${tmp_dir}/tmp/packages" - if ! ${no_action}; then - ${dummynator} trigger_mirror_refreshs - fi + # shellcheck disable=SC2016 + while read -r package; do + while read -r part; do + printf 'UPDATE `binary_packages`' + printf ' JOIN `repositories` ON `binary_packages`.`repository`=`repositories`.`id`' + printf ' JOIN `architectures` ON `binary_packages`.`architecture`=`architectures`.`id`' + printf ' SET `binary_packages`.`repository`=(SELECT `repositories`.`id` FROM `repositories` WHERE `repositories`.`name`=from_base64("%s"))' \ + "$( + base64_encode_each < \ + "${tmp_dir}/tmp/${package}.to_repo" + )" + printf ' WHERE' + printf ' `architectures`.`name`=from_base64("%s")' \ + "$( + base64_encode_each < \ + "${tmp_dir}/tmp/${package}.from_repo" + )" + printf '%s\n' "${part}" | \ + sed ' + s/\.pkg\.tar\.xz$// + s/-\([^-.]\+\)\(-[^-]\+\)$/-\1.0\2/ + s/-\([^-:]\+\)\(\(-[^-]\+\)\{2\}\)$/-0:\1\2/ + s/^\(.\+\)-\([^-:]\+\):\([^-:]\+\)-\([^-.]\+\)\.\([^-.]\+\)-\([^-]\+\)$/\1\n\2\n\3\n\4\n\5\n\6/ + ' | \ + base64_encode_each | \ + tr '\n' ' ' | \ + sed ' + s,\(\S\+\) \(\S\+\) \(\S\+\) \(\S\+\) \(\S\+\) \(\S\+\) $,'"$( + printf ' AND `binary_packages`.`%s`=from_base64("%s")' \ + 'pkgname' '\1' \ + 'epoch' '\2' \ + 'pkgver' '\3' \ + 'pkgrel' '\4' \ + 'sub_pkgrel' '\5' + printf ' AND `architectures`.`name`=from_base64("\6")' + )"', + ' + printf ' AND `binary_packages`.`%s`=from_base64("%s")' \ + 'epoch' "$( + )" + printf ';\n' + done < \ + "${tmp_dir}/tmp/${package}.parts" + done < \ + "${tmp_dir}/tmp/packages" | \ + if ${no_action}; then + sed 's|^|mysql: |' + else + ${mysql_command} + fi + + ${dummynator} trigger_mirror_refreshs rm -rf --one-file-system "${tmp_dir:?}/tmp" -- cgit v1.2.3-70-g09d2 From 9cae7aa539fa6c3bee8d5af0ba4504a98e1a3cc2 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 09:49:45 +0100 Subject: bin/db-update: source mysql-functions, it is needed --- bin/db-update | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bin/db-update') diff --git a/bin/db-update b/bin/db-update index fbbad2c..9ba65ce 100755 --- a/bin/db-update +++ b/bin/db-update @@ -24,6 +24,8 @@ # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" +. "${base_dir}/bin/mysql-functions" + # shellcheck disable=SC2016 usage() { >&2 echo '' -- cgit v1.2.3-70-g09d2 From e542cd450cd69a07eff6fac75790e6182f42c0e6 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 10:00:28 +0100 Subject: bin/db-update: add TODOs --- bin/db-update | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'bin/db-update') diff --git a/bin/db-update b/bin/db-update index 9ba65ce..343b9d4 100755 --- a/bin/db-update +++ b/bin/db-update @@ -20,6 +20,11 @@ # track packages in stable, too # know _exactly_ in which repository the packages are +# 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" -- cgit v1.2.3-70-g09d2 From bbcdedc4794cda338ae005b4d3361cde4fffd9ce Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 10:13:27 +0100 Subject: bin/db-update: fix mysql query --- bin/db-update | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'bin/db-update') diff --git a/bin/db-update b/bin/db-update index 343b9d4..1417820 100755 --- a/bin/db-update +++ b/bin/db-update @@ -342,7 +342,7 @@ move_packages() { "${tmp_dir}/tmp/${package}.to_repo" )" printf ' WHERE' - printf ' `architectures`.`name`=from_base64("%s")' \ + printf ' `repositories`.`name`=from_base64("%s")' \ "$( base64_encode_each < \ "${tmp_dir}/tmp/${package}.from_repo" @@ -364,12 +364,9 @@ move_packages() { 'pkgver' '\3' \ 'pkgrel' '\4' \ 'sub_pkgrel' '\5' - printf ' AND `architectures`.`name`=from_base64("\6")' + printf ' AND `architectures`.`name`=from_base64("\\6")' )"', ' - printf ' AND `binary_packages`.`%s`=from_base64("%s")' \ - 'epoch' "$( - )" printf ';\n' done < \ "${tmp_dir}/tmp/${package}.parts" -- cgit v1.2.3-70-g09d2 From d384cd8395fb0a0e0686f3c1ddac883002563f9a Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 10:27:41 +0100 Subject: source bin/mysql-functions in conf/default.conf - just like bin/common-functions - because it is now needed almost everywhere --- bin/bootstrap-mysql | 2 -- bin/build-master-status-from-mysql | 2 -- bin/db-update | 2 -- bin/get-package-updates | 2 -- conf/default.conf | 2 ++ 5 files changed, 2 insertions(+), 8 deletions(-) (limited to 'bin/db-update') diff --git a/bin/bootstrap-mysql b/bin/bootstrap-mysql index 3069863..fcb2f7e 100755 --- a/bin/bootstrap-mysql +++ b/bin/bootstrap-mysql @@ -2,8 +2,6 @@ # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" -# shellcheck source=bin/mysql-functions -. "${base_dir}/bin/mysql-functions" tmp_dir=$(mktemp -d 'tmp.bootstrap-mysql.XXXXXXXXXX' --tmpdir) trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT diff --git a/bin/build-master-status-from-mysql b/bin/build-master-status-from-mysql index 85185b7..12278be 100755 --- a/bin/build-master-status-from-mysql +++ b/bin/build-master-status-from-mysql @@ -4,8 +4,6 @@ # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" -# shellcheck source=bin/mysql-functions -. "${base_dir}/bin/mysql-functions" # shellcheck disable=SC2016 { diff --git a/bin/db-update b/bin/db-update index 1417820..5b32214 100755 --- a/bin/db-update +++ b/bin/db-update @@ -29,8 +29,6 @@ # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" -. "${base_dir}/bin/mysql-functions" - # shellcheck disable=SC2016 usage() { >&2 echo '' diff --git a/bin/get-package-updates b/bin/get-package-updates index 763d01a..daa68a7 100755 --- a/bin/get-package-updates +++ b/bin/get-package-updates @@ -7,8 +7,6 @@ # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" -. "${base_dir}/bin/mysql-functions" - # TODO: Find out, why sometimes package updates are missed. # shellcheck disable=SC2016 diff --git a/conf/default.conf b/conf/default.conf index b2882ac..6ee991b 100755 --- a/conf/default.conf +++ b/conf/default.conf @@ -16,6 +16,8 @@ fi # shellcheck source=bin/common-functions . "${base_dir}/bin/common-functions" +# shellcheck source=bin/mysql-functions +. "${base_dir}/bin/mysql-functions" work_dir="${base_dir}/work" -- cgit v1.2.3-70-g09d2 From 6c6809e9503d7791e22f295351098fd709410921 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 10:52:34 +0100 Subject: bin/common-functions: remove replaced packages in database, too --- bin/common-functions | 26 ++++++++++++++++++++++++++ bin/db-update | 2 -- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'bin/db-update') 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" -- cgit v1.2.3-70-g09d2 From 0cc08099ad33ca13cbf4b7cbeb6e98bf89935b79 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 11:35:11 +0100 Subject: new todos --- bin/db-update | 3 +++ bin/delete-packages | 2 ++ bin/get-package-updates | 2 ++ bin/seed-build-list | 2 ++ 4 files changed, 9 insertions(+) (limited to 'bin/db-update') diff --git a/bin/db-update b/bin/db-update index b11945c..fe45f41 100755 --- a/bin/db-update +++ b/bin/db-update @@ -23,6 +23,9 @@ # TODO: fully integrate database (in other scripts too) - e.g. rely on # info in db instead of state-files +# TODO: add possibility to manually clone a (binary) package (e.g. +# for build-support) - this should also be possible via email + # shellcheck disable=SC2039 # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" diff --git a/bin/delete-packages b/bin/delete-packages index a6e3f14..26d323a 100755 --- a/bin/delete-packages +++ b/bin/delete-packages @@ -13,6 +13,8 @@ # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" +# TODO: finish this + # shellcheck disable=SC2016 usage() { >&2 echo '' diff --git a/bin/get-package-updates b/bin/get-package-updates index daa68a7..2d113f1 100755 --- a/bin/get-package-updates +++ b/bin/get-package-updates @@ -9,6 +9,8 @@ # TODO: Find out, why sometimes package updates are missed. +# TODO: mark loops in mysql database + # shellcheck disable=SC2016 usage() { >&2 echo '' diff --git a/bin/seed-build-list b/bin/seed-build-list index feea704..78b29ba 100755 --- a/bin/seed-build-list +++ b/bin/seed-build-list @@ -5,6 +5,8 @@ # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" +# TODO: put new packages also in mysql database + # shellcheck disable=SC2016 usage() { >&2 echo '' -- cgit v1.2.3-70-g09d2