diff options
author | Erich Eckner <git@eckner.net> | 2018-06-07 15:29:47 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-06-07 15:29:47 +0200 |
commit | d6fa1ab345b8000166ce9d84813b13ae7ad1baf2 (patch) | |
tree | cfceb2ed3fe80dd3ba508e0d03bf84c831d73ec5 | |
parent | 06ff767c12b46a69af6839bfebac7d3c6c492389 (diff) | |
download | builder-d6fa1ab345b8000166ce9d84813b13ae7ad1baf2.tar.xz |
bin/return-assignment: possibly copy a single split package to multiple architectures
-rwxr-xr-x | bin/return-assignment | 121 |
1 files changed, 75 insertions, 46 deletions
diff --git a/bin/return-assignment b/bin/return-assignment index e8e998e..c37aef1 100755 --- a/bin/return-assignment +++ b/bin/return-assignment @@ -464,30 +464,53 @@ if [ ! -s "${tmp_dir}/package-ids" ]; then exit 4 fi -# TODO: moving from build-list to *staging needs to depend on the architecture +# TODO: we need to filter out some architectures here # shellcheck disable=SC2016 -infos=$( +{ + printf 'SELECT `binary_packages`.`id`,' + mysql_package_name_query + printf ',`t`.`id`,`t_a`.`name`,`t`.`name`' + printf ' FROM `build_assignments`' + mysql_join_build_assignments_binary_packages + mysql_join_binary_packages_architectures + mysql_join_build_assignments_package_sources + mysql_join_package_sources_upstream_repositories + mysql_join_upstream_repositories_repository_moves + printf ' JOIN `repositories` as `t` ON `t`.`id`=`repository_moves`.`to_repository`' + mysql_join_repositories_architectures 't' 't_a' + printf ' WHERE `repository_moves`.`from_repository`=%s' \ + "${repository_ids__any_build_list}" + printf ' AND `build_assignments`.`id`=from_base64("%s");\n' \ + "$( + printf '%s' "${build_assignment_id}" | \ + base64 -w0 + )" +} | \ + mysql_run_query | \ + tr '\t' ' ' | \ + sort -u > \ + "${tmp_dir}/repository-ids" + +errors=$( { - printf 'SELECT `t`.`id`,`t`.`name`' - printf ' FROM `build_assignments`' - mysql_join_build_assignments_package_sources - mysql_join_package_sources_upstream_repositories - mysql_join_upstream_repositories_repository_moves - printf ' JOIN `repositories` as `t` ON `t`.`id`=`repository_moves`.`to_repository`' - printf ' WHERE `repository_moves`.`from_repository`=%s' \ - "${repository_ids__any_build_list}" - printf ' AND `build_assignments`.`id`=from_base64("%s");\n' \ - "$( - printf '%s' "${build_assignment_id}" | \ - base64 -w0 - )" + cut -d' ' -f2 < \ + "${tmp_dir}/repository-ids" | \ + sort -u | \ + sed 's/^/repository-was-found: /' + cut -d' ' -f2 < \ + "${tmp_dir}/package-ids" | \ + sort -u | \ + sed 's/^/package-was-sent: /' } | \ - mysql_run_query | \ - tr '\t' ' ' + sort -k2 | \ + uniq -uf1 ) -if [ -z "${infos}" ]; then - >&2 echo 'I cannot determine, where this package should be published.' + +if [ -n "${errors}" ]; then + >&2 echo 'I cannot determine, where this package (or some part of it)' + >&2 echo 'should be published:' + >&2 printf '%s\n' "${errors}" >&2 echo 'This is some internal error and not (necessarily) your fault.' # We give a temporary error (although resolving this needs manual # intervention), because there is nothing wrong with the sent package @@ -495,9 +518,6 @@ if [ -z "${infos}" ]; then exit 1 fi -destination="${infos##* }" -destination_id="${infos%% *}" - while read -r package_id package_name; do # move namcap.logs mv \ @@ -519,21 +539,22 @@ done < \ # move packages -# shellcheck disable=SC2041 -for arch in 'i686'; do +cut -d' ' -f4,5 "${tmp_dir}/repository-ids" | \ + sort -u | \ + while read -r arch repo; do - mkdir "${arch}" - ${master_mirror_rsync_command} \ - "${master_mirror_rsync_directory}/i686/${destination}/${destination}.db."* \ - "${master_mirror_rsync_directory}/i686/${destination}/${destination}.files."* \ - "${arch}/" + mkdir -p "${arch}/${repo}" + ${master_mirror_rsync_command} \ + "${master_mirror_rsync_directory}/${arch}/${repo}/${repo}.db."* \ + "${master_mirror_rsync_directory}/${arch}/${repo}/${repo}.files."* \ + "${arch}/${repo}/" - xargs -r repo-add "${arch}/${destination}.db.tar.gz" < \ - "${tmp_dir}/packages" - # xargs -r repo-add -v -s -k "${repo_key}" "${destination}.db.tar.gz" < \ - # "${tmp_dir}/packages" + grep " $(str_to_regex "${arch} ${repo}")\$" "${tmp_dir}/repository-ids" | \ + cut -d' ' -f2 | \ + xargs -r repo-add "${arch}/${repo}/${repo}.db.tar.gz" + # xargs -r repo-add -v -s -k "${repo_key}" "${destination}.db.tar.gz" -done + done # upload the packages into /pool ${master_mirror_rsync_command} \ @@ -550,15 +571,23 @@ find . \( -name '*.pkg.tar.xz' -o -name '*.pkg.tar.xz.sig' \) -printf '%f\n' | \ # upload the database and the symlinks into /$arch/$repo -# shellcheck disable=SC2041 -for arch in 'i686'; do - ${master_mirror_rsync_command} -l \ - "${arch}/${destination}.db."* \ - "${arch}/${destination}.files."* \ - ./*".pkg.tar.xz" \ - ./*".pkg.tar.xz.sig" \ - "${master_mirror_rsync_directory}/${arch}/${destination}/" -done +cut -d' ' -f4,5 "${tmp_dir}/repository-ids" | \ + sort -u | \ + while read -r arch repo; do + # shellcheck disable=SC2046 + ${master_mirror_rsync_command} -l \ + "${arch}/${repo}/${repo}.db."* \ + "${arch}/${repo}/${repo}.files."* \ + $( + grep " $(str_to_regex "${arch} ${repo}")\$" "${tmp_dir}/repository-ids" | \ + cut -d' ' -f2 | \ + sed ' + p + s/$/.sig/ + ' + ) \ + "${master_mirror_rsync_directory}/${arch}/${repo}/${repo}/" + done trigger_mirror_refreshs @@ -619,13 +648,13 @@ trigger_mirror_refreshs printf 'COMMIT;\n' # insert into appropriate repositories and retrieve ids - while read -r package_id _; do + while read -r package_id _ repository_id _; do printf 'INSERT INTO `binary_packages_in_repositories` (`package`,`repository`,`is_to_be_deleted`) VALUES ' printf '(%s,%s,0);\n' \ - "${package_id}" "${destination_id}" + "${package_id}" "${repository_id}" printf 'SELECT LAST_INSERT_ID();\n' done < \ - "${tmp_dir}/package-ids" + "${tmp_dir}/repository-ids" printf 'COMMIT;\n' # remove from build-list |