diff options
author | Erich Eckner <git@eckner.net> | 2018-01-17 09:39:36 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-01-17 09:39:36 +0100 |
commit | faff85d37abe9f11a8ab77fd14d70e04e6a932d5 (patch) | |
tree | f7bed19b76fc6f1ffaa0d35106216ddf2221443b /bin/mysql-functions | |
parent | 45d71a6464f8f791cad5f699cc48dc131466449b (diff) | |
download | builder-faff85d37abe9f11a8ab77fd14d70e04e6a932d5.tar.xz |
bin/mysql-functions: allow to force sub_pkgrel and package_repository
Diffstat (limited to 'bin/mysql-functions')
-rwxr-xr-x | bin/mysql-functions | 67 |
1 files changed, 48 insertions, 19 deletions
diff --git a/bin/mysql-functions b/bin/mysql-functions index 8331cbf..340f9d5 100755 --- a/bin/mysql-functions +++ b/bin/mysql-functions @@ -168,12 +168,36 @@ mysql_add_install_target() { # mysql_generate_package_metadata $package $git_revision $mod_git_revision $repository # or # mysql_generate_package_metadata $package.$git_revision.$mod_git_revision.$repository +# if sub_pkgrel should be determined automatically and the package is on the build-list +# and +# mysql_generate_package_metadata $sub_pkgrel $package $current_repository $git_revision $mod_git_revision $repository +# or +# mysql_generate_package_metadata $sub_pkgrel $current_repository $package.$git_revision.$mod_git_revision.$repository +# if $sub_pkgrel should be forced and the package is currently in $current_repository # generate the meta data of a package (dependencies, built packages, ...) in the database # shellcheck disable=SC2016 mysql_generate_package_metadata() { ( # new shell is intentional + case "$1" in + ''|*[!0-9]*) + unset forced_sub_pkgrel + current_repository=$( + echo 'build-list' | \ + base64_encode_each + ) + ;; + *) + forced_sub_pkgrel="$1" + shift + current_repository=$( + echo "$1" | \ + base64_encode_each + ) + shift + ;; + esac package="$1" git_revision="$2" mod_git_revision="$3" @@ -370,23 +394,27 @@ mysql_generate_package_metadata() { base64_encode_each ) sub_pkgrel=$( - ${mysql_command} "$( - printf 'SELECT count(*) FROM `binary_packages` JOIN `architectures` ON `binary_packages`.`architecture`=`architectures`.`id` WHERE' - printf ' `binary_packages`.`%s`=from_base64("%s") AND' \ - 'epoch' "${epoch}" \ - 'pkgver' "${pkgver}" \ - 'pkgrel' "${pkgrel}" \ - 'pkgname' "${pkgname}" - if printf '%s' "${arch}" | base64 -d | grep -qxF 'any'; then - # 'any' gets higher sub_pkgrel than any architecture - printf ' 1' - else - # not-'any' gets higher sub_pkgrel than same or 'any' architecture - printf ' (`architectures`.`name`=from_base64("%s") OR `architectures`.`name`="any")' \ - "${arch}" - fi - )" | \ - tail -n1 | \ + if [ -n "${forced_sub_pkgrel}" ]; then + echo "${forced_sub_pkgrel}" + else + ${mysql_command} "$( + printf 'SELECT count(*) FROM `binary_packages` JOIN `architectures` ON `binary_packages`.`architecture`=`architectures`.`id` WHERE' + printf ' `binary_packages`.`%s`=from_base64("%s") AND' \ + 'epoch' "${epoch}" \ + 'pkgver' "${pkgver}" \ + 'pkgrel' "${pkgrel}" \ + 'pkgname' "${pkgname}" + if printf '%s' "${arch}" | base64 -d | grep -qxF 'any'; then + # 'any' gets higher sub_pkgrel than any architecture + printf ' 1' + else + # not-'any' gets higher sub_pkgrel than same or 'any' architecture + printf ' (`architectures`.`name`=from_base64("%s") OR `architectures`.`name`="any")' \ + "${arch}" + fi + )" | \ + tail -n1 + fi | \ base64_encode_each ) { @@ -425,7 +453,7 @@ mysql_generate_package_metadata() { printf ' ON `package_sources`.`upstream_package_repository` = `upstream_repositories`.`id`' printf ' WHERE' printf ' `%s`.`%s` = from_base64("%s") AND' \ - 'repositories' 'name' "$(printf 'build-list' | base64 -w0)" \ + 'repositories' 'name' "${current_repository}" \ 'architectures' 'name' "${arch}" \ 'package_sources' 'pkgbase' "${pkgbase}" \ 'package_sources' 'git_revision' "${git_revision}" \ @@ -517,7 +545,8 @@ mysql_generate_package_metadata() { 'pkgname' "${pkgname}" printf ' `architectures`.`name` = from_base64("%s") AND' \ "${arch}" - printf ' `repositories`.`name` = "build-list";\n' + printf ' `repositories`.`name` = from_base64("%s");\n' \ + "${current_repository}" done printf 'DROP TABLE `%s`;\n' \ |