#!/bin/sh # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" if [ $# -ne 1 ]; then echo 'Usage: prioritize-build-list pkg-regex' echo ' moves packages matching pkg-regex to front of build list' exit 2 fi # Create a lock file for build list. exec 9> "${build_list_lock_file}" if ! flock -n 9; then >&2 echo 'come back (shortly) later - I cannot lock build list.' exit 1 fi exec 8> "${sanity_check_lock_file}" if ! flock -s -n 8; then >&2 echo 'come back (shortly) later - sanity-check running.' exit 1 fi { sed -n "/^$1/p" "${work_dir}/build-list" sed "/^$1/d" "${work_dir}/build-list" } | \ sponge "${work_dir}/build-list" # shellcheck disable=SC2016 { printf 'UPDATE `build_assignments`' mysql_join_build_assignments_package_sources mysql_join_build_assignments_binary_packages mysql_join_binary_packages_repositories printf ' SET `build_assignments`.`priority`=(' printf 'SELECT COALESCE(MAX(`all_priorities`.`priority`),0)+1' printf ' FROM (' printf 'SELECT `others`.`priority`' printf ' FROM `build_assignments` AS `others`' printf ') AS `all_priorities`' printf ')' printf ' WHERE `package_sources`.`pkgbase` REGEXP from_base64("%s")' \ "$(printf '%s' "$1" | base64 -w0)" printf ' AND `repositories`.`name`="build-list";\n' } | \ mysql_run_query # Remove the lock file rm -f "${build_list_lock_file}"