From 1f60caaf2c601a18ecf25dd130fa185d4a098eea Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 11 Oct 2018 10:47:43 +0200 Subject: lib/mysql-functions: mysql_generate_package_metadata() should remove identical binary_packages which are unbuilt before inserting new ones --- lib/mysql-functions | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/mysql-functions b/lib/mysql-functions index 1eca658..e1f0d6c 100755 --- a/lib/mysql-functions +++ b/lib/mysql-functions @@ -216,7 +216,7 @@ mysql_generate_package_metadata() { trap 'rm -rf --one-file-system "${temp_dir}"' EXIT if ! make_source_info "${package}" "${repository}" "${git_revision}" "${mod_git_revision}" "${temp_dir}/SRCINFO"; then - printf '"make_source_info %s %s %s %s %s" failed.\n' "${package}" "${repository}" "${git_revision}" "${mod_git_revision}" "${temp_dir}/SRCINFO" + >&2 printf '"make_source_info %s %s %s %s %s" failed.\n' "${package}" "${repository}" "${git_revision}" "${mod_git_revision}" "${temp_dir}/SRCINFO" exit 2 fi # remove empty lines and unsupported architectures @@ -420,6 +420,35 @@ mysql_generate_package_metadata() { printf ' ON `architectures`.`name`=`links`.`build_architecture`' printf ' WHERE `links`.`type`="arch";\n' + # we delete unbuilt binary_packages of identical version prior to + # inserting, so we can _update_ a build list entry (e.g. because + # the source changed, but the version stays the same) + printf 'DELETE `binary_packages`' + printf ' FROM `links`' + printf ' JOIN `architectures`' + printf ' ON `links`.`architecture`=`architectures`.`name`' + printf ' JOIN `architectures` AS `ba_a`' + printf ' ON `ba_a`.`name`=`links`.`build_architecture`' + mysql_join_architectures_build_assignments 'ba_a' + mysql_join_build_assignments_binary_packages + printf ' AND `binary_packages`.`%s`=`links`.`%s`' \ + 'pkgname' 'pkgname' \ + 'epoch' 'epoch' \ + 'pkgver' 'pkgver' \ + 'pkgrel' 'pkgrel' + printf ' AND `binary_packages`.`sub_pkgrel`=@sub_pkgrel' + printf ' AND `binary_packages`.`architecture`=`architectures`.`id`' + printf ' WHERE `links`.`type`="arch"' + # the below test should always give "true", but it is a useful + # safeguard to not delete built packages from the database + printf ' AND NOT EXISTS(' + printf 'SELECT 1' + printf ' FROM `binary_packages_in_repositories`' + mysql_join_binary_packages_in_repositories_repositories + printf ' WHERE `repositories`.`is_on_master_mirror`' + printf ' AND `binary_packages_in_repositories`.`package`=`binary_packages`.`id`' + printf ');\n' + printf 'INSERT IGNORE INTO `binary_packages` (' printf '`build_assignment`,' printf '`pkgname`,' -- cgit v1.2.3-70-g09d2