Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-05-31 12:15:11 +0200
committerErich Eckner <git@eckner.net>2018-05-31 12:15:11 +0200
commit13a67a1ab8d15a77c539b5e141dd208eca4e96fd (patch)
tree978a84745e9d276a6a34c4821e4febbe77d870a3
parent26e44f205c0db16d1e74427e5320b6a56ae320a4 (diff)
lib/common-functions: remove_old_package_versions() acts now on binary_packages_in_repositories
-rwxr-xr-xbin/copy-to-build-support55
-rwxr-xr-xbin/return-assignment27
-rwxr-xr-xlib/common-functions57
3 files changed, 63 insertions, 76 deletions
diff --git a/bin/copy-to-build-support b/bin/copy-to-build-support
index f4647e1..a42ca31 100755
--- a/bin/copy-to-build-support
+++ b/bin/copy-to-build-support
@@ -70,7 +70,6 @@ trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT
export TMPDIR="${tmp_dir}"
-to_copy='build_assignment epoch pkgver pkgrel sub_pkgrel has_issues is_tested pkgname architecture'
sed -n '
s/.\+/\0 \0/
T
@@ -85,10 +84,8 @@ sed -n '
# shellcheck disable=SC2016
id=$(
{
- printf 'SELECT `binary_packages`.`id`,`repositories`.`name`'
+ printf 'SELECT `binary_packages`.`id`'
printf ' FROM `binary_packages`'
- mysql_join_binary_packages_binary_packages_in_repositories
- mysql_join_binary_packages_in_repositories_repositories
mysql_join_binary_packages_architectures
printf ' WHERE'
printf ' `binary_packages`.`%s`=from_base64("%s") AND' \
@@ -101,29 +98,24 @@ sed -n '
"$(printf '%s' "${architecture}" | base64 -w0)"
printf ' LIMIT 1;\n'
} | \
- mysql_run_query | \
- tr '\t' ' '
+ mysql_run_query
)
if [ -z "${id}" ]; then
continue
fi
- repository="${id#* }"
- id="${id%% *}"
- printf '%s\n' "${id}" >> \
- "${tmp_dir}/package-ids"
+ printf '%s\n' "${package}" >> \
+ "${tmp_dir}/packages"
for suffix in '' '.sig'; do
- printf 'ln "i686/%s/%s%s" "i686/build-support/%s%s"\n' \
- "${repository}" \
+ printf 'ln -s "pool/%s%s" "i686/build-support/%s%s"\n' \
"${package}" \
"${suffix}" \
"${package}" \
"${suffix}"
done >> \
"${tmp_dir}/sftp-command"
- printf '%s/i686/%s/%s\n' \
+ printf '%s/pool/%s\n' \
"${master_mirror_rsync_directory}" \
- "${repository}" \
"${package}" | \
sed '
p
@@ -133,25 +125,13 @@ sed -n '
# shellcheck disable=SC2016
{
- printf 'INSERT IGNORE INTO `binary_packages` ('
- # shellcheck disable=SC2086
- printf ',`%s`' ${to_copy} | \
- sed 's/^,//'
- printf ')'
- printf ' SELECT'
- # shellcheck disable=SC2086
- printf ',`binary_packages`.`%s`' ${to_copy} | \
- sed 's/^,//'
- printf ' FROM `binary_packages`'
- mysql_join_binary_packages_architectures
- printf ' WHERE'
- printf ' `binary_packages`.`id`=%s;\n' \
- "${id}"
printf 'INSERT IGNORE INTO `binary_packages_in_repositories`'
printf ' (`repository`,`package`)'
# shellcheck disable=SC2154
- printf ' SELECT %s,LAST_INSERT_ID();\n' \
- "${repository_ids__i686_build_support}"
+ printf ' VALUES (%s,%s);\n' \
+ "${repository_ids__i686_build_support}" \
+ "${id}"
+ printf 'SELECT LAST_INSERT_ID();\n'
} >> \
"${tmp_dir}/mysql-command"
done
@@ -183,17 +163,14 @@ ${master_mirror_rsync_command} \
if [ -s "${tmp_dir}/mysql-command" ]; then
mysql_run_query < \
- "${tmp_dir}/mysql-command"
-fi
-
-if [ -s "${tmp_dir}/package-ids" ]; then
- while read -r package_id; do
- remove_old_package_versions "${package_id}"
- done < \
- "${tmp_dir}/package-ids"
+ "${tmp_dir}/mysql-command" | \
+ sort -u | \
+ while read -r bpir_id; do
+ remove_old_package_versions "${bpir_id}"
+ done
fi
if [ -w "$1" ]; then
- cat "${tmp_dir}/package-ids" > \
+ cat "${tmp_dir}/packages" > \
"$1"
fi
diff --git a/bin/return-assignment b/bin/return-assignment
index 51f5717..75f45f0 100755
--- a/bin/return-assignment
+++ b/bin/return-assignment
@@ -600,15 +600,14 @@ trigger_mirror_refreshs
)"
printf 'COMMIT;\n'
- # insert into appropriate repositories
- printf 'INSERT INTO `binary_packages_in_repositories` (`package`,`repository`) VALUES '
- cut -d' ' -f1 < \
- "${tmp_dir}/package-ids" | \
- sed '
- s/^/(/
- s/$/,'"${destination_id}"'),/
- $ s/,$/;/
- '
+ # insert into appropriate repositories and retrieve ids
+ while read -r package_id _; do
+ printf 'INSERT INTO `binary_packages_in_repositories` (`package`,`repository`) VALUES '
+ printf '(%s,%s);\n' \
+ "${package_id}" "${destination_id}"
+ printf 'SELECT LAST_INSERT_ID();\n'
+ done < \
+ "${tmp_dir}/package-ids"
printf 'COMMIT;\n'
# remove from build-list
@@ -670,10 +669,8 @@ trigger_mirror_refreshs
printf ');\n'
printf 'DROP TEMPORARY TABLE `loops_to_delete`;\n'
} | \
- mysql_run_query
-
-cut -d' ' -f1 < \
- "${tmp_dir}/package-ids" | \
- while read -r package_id; do
- remove_old_package_versions "${package_id}"
+ mysql_run_query | \
+ sort -u | \
+ while read -r bpir_id; do
+ remove_old_package_versions "${bpir_id}"
done
diff --git a/lib/common-functions b/lib/common-functions
index 45b1d03..c4f9d82 100755
--- a/lib/common-functions
+++ b/lib/common-functions
@@ -112,10 +112,7 @@ ls_master_mirror() {
}
-# TODO: once binary_packages_in_repositories is funcitonal, we should
-# use the id of that
-
-# remove_old_package_versions $binary_package_id
+# remove_old_package_versions $binary_package_in_repository_id
# removes all older versions of the given package from all repositories
# less[1] stable than the current repository, as well as any different
@@ -130,13 +127,13 @@ remove_old_package_versions() {
tmp_dir=$(mktemp -d 'tmp.common-functions.remove_old_package_versions.XXXXXXXXXX' --tmpdir)
trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT
- binary_package_id="$1"
+ bpir_id="$1"
# shellcheck disable=SC2016
{
printf 'SELECT '
- printf '`d_bp`.`id`,'
- printf 'IF(`d_r`.`stability`=`o_r`.`stability` AND `d_bp`.`id`!=`o_bp`.`id`,1,0),'
+ printf '`d_bpir`.`id`,'
+ printf 'IF(`d_r`.`stability`=`o_r`.`stability` AND `d_bpir`.`id`!=`o_bpir`.`id`,1,0),'
printf 'CONCAT('
printf 'IF(`d_bp`.`epoch`=0,"",CONCAT(`d_bp`.`epoch`,":")),'
printf '`d_bp`.`pkgver`,"-",'
@@ -165,9 +162,9 @@ remove_old_package_versions() {
printf ' JOIN `repository_stability_relations`'
printf ' ON `repository_stability_relations`.`less_stable`=`d_r`.`stability`'
printf ' AND `repository_stability_relations`.`more_stable`=`o_r`.`stability`'
- printf ' WHERE `o_bp`.`id`=from_base64("%s")' \
+ printf ' WHERE `o_bpir`.`id`=from_base64("%s")' \
"$(
- printf '%s' "${binary_package_id}" | \
+ printf '%s' "${bpir_id}" | \
base64 -w0
)"
printf ';\n'
@@ -178,7 +175,7 @@ remove_old_package_versions() {
sort -k3V,3 -k2r,2 | \
shrink_version 3 | \
sed -n '
- /^'"${binary_package_id}"' /q
+ /^'"${bpir_id}"' /q
s/^\([0-9]\+ \)\(\S\+ \)\{2\}/\1/
h
/^[0-9]\+ 0 / {
@@ -212,6 +209,34 @@ remove_old_package_versions() {
done < \
"${tmp_dir}/repo-removes"
+ # db-remove packages
+ if [ -s "${tmp_dir}/db-removes" ]; then
+ # shellcheck disable=SC2016
+ {
+ printf 'CREATE TEMPORARY TABLE `del` (`id` BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`));\n'
+ printf 'LOAD DATA LOCAL INFILE "%s" INTO TABLE `del` (`id`);\n' \
+ "${tmp_dir}/db-removes"
+ printf 'DELETE `binary_packages_in_repositories` FROM `binary_packages_in_repositories`'
+ printf ' JOIN `del` ON `binary_packages_in_repositories`.`id`=`del`.`id`;\n'
+ printf 'SELECT CONCAT("pool/",'
+ mysql_package_name_query
+ printf ') FROM `binary_packages`'
+ mysql_join_binary_packages_architectures
+ printf ' WHERE NOT EXISTS ('
+ printf 'SELECT 1 FROM `binary_packages_in_repositories`'
+ printf ' WHERE `binary_packages_in_repositories`.`package`=`binary_packages`.`id`'
+ printf ');\n'
+ printf 'DELETE `binary_packages` FROM `binary_packages`'
+ printf ' WHERE NOT EXISTS ('
+ printf 'SELECT 1 FROM `binary_packages_in_repositories`'
+ printf ' WHERE `binary_packages_in_repositories`.`package`=`binary_packages`.`id`'
+ printf ');\n'
+ } | \
+ mysql_run_query | \
+ sort -u >> \
+ "${tmp_dir}/sftp-removes"
+ fi
+
# sftp-remove packages
if [ -s "${tmp_dir}/sftp-removes" ]; then
sed '
@@ -221,18 +246,6 @@ remove_old_package_versions() {
${master_mirror_sftp_command}
fi
- # db-remove packages
- if [ -s "${tmp_dir}/db-removes" ]; then
- # shellcheck disable=SC2016
- {
- printf 'CREATE TEMPORARY TABLE `del` (`id` BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`));\n'
- printf 'LOAD DATA LOCAL INFILE "%s" INTO TABLE `del` (`id`);\n' "${tmp_dir}/db-removes"
- printf 'DELETE `binary_packages` FROM `binary_packages` JOIN `del` ON `binary_packages`.`id`=`del`.`id`;\n'
- printf 'DELETE `binary_packages_in_repositories` FROM `binary_packages_in_repositories` JOIN `del` ON `binary_packages_in_repositories`.`package`=`del`.`id`;\n'
- } | \
- mysql_run_query
- fi
-
)
}