From 322356cd803127f4eb5de2fdff309086d57a6828 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sun, 21 Jan 2018 15:51:23 +0100 Subject: bin/opcode, bin/check-opcodes, conf/Opcode_list: fix style, so git hook does not complain --- bin/check-opcodes | 18 +++++++++++------- bin/opcode | 49 +++++++++++++++++++++++++++---------------------- 2 files changed, 38 insertions(+), 29 deletions(-) (limited to 'bin') diff --git a/bin/check-opcodes b/bin/check-opcodes index fd740b1..c7ab4a9 100755 --- a/bin/check-opcodes +++ b/bin/check-opcodes @@ -1,5 +1,8 @@ #!/bin/sh +# shellcheck disable=SC2086 + +# shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" usage( ) { @@ -21,7 +24,7 @@ VERBOSE=0 EXIT_CODE=0 log( ) { if test $VERBOSE = 1; then - echo $* + echo "$@" fi } @@ -31,7 +34,7 @@ err( ) { } tmp_dir=$(mktemp -d "${work_dir}/tmp.check-opcodes.XXXXXX") -trap "rm -rf --one-file-system '${tmp_dir:?}'" EXIT +trap 'rm -rf --one-file-system "${tmp_dir:?}"' EXIT ARCH=i686 @@ -97,14 +100,15 @@ esac log "Checking for architecture: $ARCH ($OPCODE_ARGS)" bsdtar --no-fflags -x -C $tmp_dir -f $PACKAGE -for absfile in `find $tmp_dir -name '*.so*' -type f`; do - file=`basename $absfile` +# shellcheck disable=SC2044 +for absfile in $(find $tmp_dir -name '*.so*' -type f); do + file=$(basename $absfile) log "Checking shared library: $file" readelf -a $absfile > $tmp_dir/$file.elf objdump -f $absfile > $tmp_dir/$file.objdump file $absfile > $tmp_dir/$file.file - arch=`grep ^architecture $tmp_dir/$file.objdump | sed 's/^architecture: //g' | cut -f 1 -d ,` + arch=$(grep ^architecture $tmp_dir/$file.objdump | sed 's/^architecture: //g' | cut -f 1 -d ,) case $arch in i386:x86-64) arch='x86_64' @@ -118,7 +122,7 @@ for absfile in `find $tmp_dir -name '*.so*' -type f`; do esac log " Objdump architecture: $arch" - archelf=`grep '^ \+Class' $tmp_dir/$file.elf | cut -f 2 -d : | tr -d ' '` + archelf=$(grep '^ \+Class' $tmp_dir/$file.elf | cut -f 2 -d : | tr -d ' ') case $archelf in ELF64) archelf='x86_64' @@ -142,7 +146,7 @@ for absfile in `find $tmp_dir -name '*.so*' -type f`; do fi objdump -M intel -d $absfile > $tmp_dir/$file.asm - bad_opcodes=`cat $tmp_dir/$file.asm | ${base_dir}/bin/opcode $OPCODE_ARGS -m 1 | wc -l` + bad_opcodes=$(${base_dir}/bin/opcode $OPCODE_ARGS -m 1 < $tmp_dir/$file.asm | wc -l) if test $bad_opcodes != 0; then case $ARCH in i486) diff --git a/bin/opcode b/bin/opcode index de1b3f8..8840e97 100755 --- a/bin/opcode +++ b/bin/opcode @@ -24,6 +24,9 @@ # with Opcode_WILLAMETTE_Base # * Remove all line in Opcode_ARM_THUMB # return values + +# shellcheck disable=SC2001,SC2034,SC2086 + EXIT_FOUND=0 EXIT_NOT_FOUND=1 EXIT_USAGE=2 @@ -42,7 +45,8 @@ Line_Numbers=false Leading_Context=0 Trailing_Context=0 -source "${0%/*}/../conf/Opcode_list" # include opcodes from a separate file +# shellcheck source=lib/opcode_list +source "${0%/*}/../lib/opcode_list" # include opcodes from a separate file # GAS-specific opcodes (unofficial names) belonging to the x64 instruction set. # They are generated by GNU tools (e.g. GDB, objdump) and specify a variant of ordinal opcodes like NOP and MOV. @@ -162,7 +166,7 @@ usage() { echo "The script uses Intel opcode syntax. When used in conjunction with objdump, \`-M intel' must be set in order to prevent opcode translation using AT&T syntax." echo echo "BE AWARE THAT THE LIST OF KNOWN INSTRUCTIONS OR INSTRUCTIONS SUPPORTED BY PARTICULAR ARCHITECTURES (ESPECIALLY AMD'S) IS ONLY TENTATIVE AND MAY CONTAIN MISTAKES!" - kill -TRAP $TOP_PID + kill -TRAP "$TOP_PID" } list_contains() { # Returns 0 if $2 is in array $1, 1 otherwise. @@ -175,25 +179,25 @@ list_contains() { # Returns 0 if $2 is in array $1, 1 otherwise. build_instruction_set() { # $1 = enum { Arch, InstSet }, $2 = architecture or instruction set as obtained using -L or -l, $3 = "architecture"/"instruction set" to be used in error message local e - list_contains "`eval echo \\\$${1}List`" "$2" || (echo "$2 is not a valid $3."; usage) # Test if the architecture/instruction set is valid. - if [ -n "`eval echo \\\$${1}_${2}`" ]; then # Add the instruction set(s) if any. - for e in `eval echo \\\$${1}_${2}`; do # Skip duplicates. + list_contains "$(eval echo \\\$${1}List)" "$2" || (echo "$2 is not a valid $3."; usage) # Test if the architecture/instruction set is valid. + if [ -n "$(eval echo \\\$${1}_${2})" ]; then # Add the instruction set(s) if any. + for e in $(eval echo \\\$${1}_${2}); do # Skip duplicates. list_contains "$InstSet_Base" $e || InstSet_Base="$e $InstSet_Base" done fi if [ $Recursive = true ]; then - for a in `eval echo \\\$${1}Dep_$2`; do + for a in $(eval echo \\\$${1}Dep_$2); do build_instruction_set $1 $a "$3" done fi - InstSet_Base="`echo $InstSet_Base | sed 's/$ *//'`" # Remove trailing space. + InstSet_Base=$(echo $InstSet_Base | sed 's/$ *//') # Remove trailing space. } -trap "exit $EXIT_USAGE" TRAP # Allow usage() function to abort script execution. +trap 'exit $EXIT_USAGE' TRAP # Allow usage() function to abort script execution. export TOP_PID=$$ # PID of executing process. # Parse command line arguments. -while getopts ":ra:s:LliIcf:Fd:D:CvVm:nB:A:h" o; do +while getopts ":ra:s:LliIcf:d:D:CvVm:nB:A:h" o; do case $o in r) Recursive=true ;; a) build_instruction_set Arch "$OPTARG" "architecture" ;; @@ -205,19 +209,19 @@ while getopts ":ra:s:LliIcf:Fd:D:CvVm:nB:A:h" o; do echo $InstSet_Base exit $EXIT_USAGE else - echo -e "No instruction set or architecture set.\n" + echo -e "No instruction set or architecture set.\\n" usage fi ;; I) if [ -n "$InstSet_Base" ]; then for s in $InstSet_Base; do - echo -ne "\e[31;1m$s:\e[0m " + echo -ne "\\e[31;1m$s:\\e[0m " eval echo "\$Opcode_$s" done exit $EXIT_USAGE else - echo -e "No instruction set or architecture set.\n" + echo -e "No instruction set or architecture set.\\n" usage fi ;; @@ -226,12 +230,12 @@ while getopts ":ra:s:LliIcf:Fd:D:CvVm:nB:A:h" o; do # Unlike architectures, instruction sets are disjoint. Found=false for s in $InstSetList; do - for b in `eval echo \\\$InstSet_$s`; do + for b in $(eval echo \\\$InstSet_$s); do Found_In_Base=false - for i in `eval echo \\\$Opcode_$b`; do + for i in $(eval echo \\\$Opcode_$b); do if [[ "$i" =~ ^$OPTARG$ ]]; then - $Found_In_Base || echo -ne "Instruction set \e[33;1m$s\e[0m (base instruction set \e[32;1m$b\e[0m):" - echo -ne " \e[31;1m$i\e[0m" + $Found_In_Base || echo -ne "Instruction set \\e[33;1m$s\\e[0m (base instruction set \\e[32;1m$b\\e[0m):" + echo -ne " \\e[31;1m$i\\e[0m" Found_In_Base=true Found=true fi @@ -240,7 +244,7 @@ while getopts ":ra:s:LliIcf:Fd:D:CvVm:nB:A:h" o; do done done if [ $Found = false ]; then - echo -e "Operation code \e[31;1m$OPTARG\e[0m has not been found in the database of known instructions." \ + echo -e "Operation code \\e[31;1m$OPTARG\\e[0m has not been found in the database of known instructions." \ "Perhaps it is translated using other than Intel syntax. If obtained from objdump, check if the \`-M intel' flag is set." \ "Be aware that the search is case sensitive by default (you may use the -C flag, otherwise only lower case opcodes are accepted)." exit $EXIT_NOT_FOUND @@ -259,13 +263,13 @@ while getopts ":ra:s:LliIcf:Fd:D:CvVm:nB:A:h" o; do A) Trailing_Context=$OPTARG ;; h) usage ;; \?) - echo -e "Unknown option: -$OPTARG\n" + echo -e "Unknown option: -$OPTARG\\n" usage ;; esac done shift $((OPTIND-1)) -[ -n "$1" ] && echo -e "Unknown command line parameter: $1\n" && usage +[ -n "$1" ] && echo -e "Unknown command line parameter: $1\\n" && usage [ -z "$InstSet_Base" ] && usage # Create list of grep parameters. @@ -279,12 +283,13 @@ Grep_Params="--color=auto -B $Leading_Context -A $Trailing_Context" # Build regular expression for use in grep. RegEx="" for s in $InstSet_Base; do - eval RegEx=\"$RegEx \$Opcode_$s\" + eval 'RegEx="$RegEx $Opcode_'"$s"'"' done # Add leading and trailing opcode separators to prevent false positives. -RegEx="$Leading_Separator`echo $RegEx | sed "s/ /$(echo "$Trailing_Separator"|sed 's/[\/&]/\\\&/g')|$(echo "$Leading_Separator"|sed 's/[\/&]/\\\&/g')/g"`$Trailing_Separator" +RegEx="$Leading_Separator$(echo $RegEx | sed "s/ /$(echo "$Trailing_Separator"|sed 's/[\/&]/\\\&/g')|$(echo "$Leading_Separator"|sed 's/[\/&]/\\\&/g')/g")$Trailing_Separator" -[ $Verbose = true -a $Count_Matching = false ] && RegEx="$RegEx|\$" +[ $Verbose = true ] && [ $Count_Matching = false ] && RegEx="$RegEx|\$" +# shellcheck disable=SC2086 # The actual search. grep $Grep_Params -E "$RegEx" && exit $EXIT_FOUND || exit $EXIT_NOT_FOUND -- cgit v1.2.3-70-g09d2 From 14b3fccef66633414be935a3d163db9d253225c6 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sun, 21 Jan 2018 15:52:26 +0100 Subject: bin/mysql-functions: style --- bin/mysql-functions | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/mysql-functions b/bin/mysql-functions index 7b9e724..b5c7d80 100755 --- a/bin/mysql-functions +++ b/bin/mysql-functions @@ -191,16 +191,19 @@ mysql_generate_package_metadata() { ''|*[!0-9]*) unset forced_sub_pkgrel current_repository=$( - echo 'build-list' | \ - base64_encode_each + printf 'build-list' | \ + base64 -w0 ) ;; *) - forced_sub_pkgrel="$1" + forced_sub_pkgrel=$( + printf '%s' "$1" | \ + base64 -w0 + ) shift current_repository=$( - echo "$1" | \ - base64_encode_each + printf '%s' "$1" | \ + base64 -w0 ) shift ;; -- cgit v1.2.3-70-g09d2 From 958fb1a5f5900972f3eb37a3e299c2dcad30d03a Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sun, 21 Jan 2018 21:08:05 +0100 Subject: bin/mysql-functions: allow for longer mysql commands --- bin/mysql-functions | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/mysql-functions b/bin/mysql-functions index b5c7d80..d3c7ec4 100755 --- a/bin/mysql-functions +++ b/bin/mysql-functions @@ -567,7 +567,7 @@ mysql_generate_package_metadata() { done printf '.' >&2 - ${mysql_command} -e "$( + { if [ -s "${temp_dir}/add-build-assignments-command" ]; then cat "${temp_dir}/add-build-assignments-command" fi @@ -577,7 +577,8 @@ mysql_generate_package_metadata() { if [ -s "${temp_dir}/add-install-targets-command" ]; then cat "${temp_dir}/add-install-targets-command" fi - )" + } | \ + ${mysql_command} printf '.' >&2 ) -- cgit v1.2.3-70-g09d2 From bf62bc549644c36440ab22b4feb9b50ed29db971 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sun, 21 Jan 2018 21:10:10 +0100 Subject: bin/mysql-functions: repair mysql_generate_package_metadata --- bin/mysql-functions | 72 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 28 deletions(-) (limited to 'bin') diff --git a/bin/mysql-functions b/bin/mysql-functions index d3c7ec4..ff8fe45 100755 --- a/bin/mysql-functions +++ b/bin/mysql-functions @@ -403,30 +403,45 @@ mysql_generate_package_metadata() { sed 's/[<>=].*$//' | \ base64_encode_each ) - sub_pkgrel=$( - if [ -n "${forced_sub_pkgrel}" ]; then - echo "${forced_sub_pkgrel}" - else - ${mysql_command} -e "$( - 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 - ) + if [ -n "${forced_sub_pkgrel}" ]; then + sub_pkgrel='from_base64("'"${forced_sub_pkgrel}"'")' + else + sub_pkgrel=$( + printf '(SELECT COALESCE(' + # do not add binary packages which are currently on the build-list + printf '(SELECT `sub_pkgrel` FROM `binary_packages`' + printf ' JOIN `architectures` ON `binary_packages`.`architecture`=`architectures`.`id`' + printf ' JOIN `repositories` ON `binary_packages`.`repository`=`repositories`.`id`' + printf ' WHERE' + printf ' `binary_packages`.`%s`=from_base64("%s") AND' \ + 'epoch' "${epoch}" \ + 'pkgver' "${pkgver}" \ + 'pkgrel' "${pkgrel}" \ + 'pkgname' "${pkgname}" + printf ' `architectures`.`name`=from_base64("%s")' \ + "${arch}" + printf ' AND `repositories`.`name`="build-list"),' + # max(sub_pkgrel)+1 + printf '(SELECT 1+MAX(`binary_packages`.`sub_pkgrel`) FROM `binary_packages`' + printf ' JOIN `architectures` ON `binary_packages`.`architecture`=`architectures`.`id`' + printf ' 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 + printf ')' + printf ',0))' + ) + fi { printf 'INSERT IGNORE INTO `binary_packages` (' printf '`%s`,' \ @@ -436,8 +451,8 @@ mysql_generate_package_metadata() { 'epoch' \ 'pkgver' \ 'pkgrel' \ - 'sub_pkgrel' \ 'pkgname' \ + 'sub_pkgrel' \ 'has_issues' \ 'is_tested' printf ') SELECT ' @@ -449,9 +464,9 @@ mysql_generate_package_metadata() { "${epoch}" \ "${pkgver}" \ "${pkgrel}" \ - "${sub_pkgrel}" \ "${pkgname}" - printf '0,0 FROM' + printf '%s,0,0 FROM' \ + "${sub_pkgrel}" printf ' `%s` JOIN' \ 'repositories' \ 'architectures' \ @@ -550,8 +565,9 @@ mysql_generate_package_metadata() { 'epoch' "${epoch}" \ 'pkgver' "${pkgver}" \ 'pkgrel' "${pkgrel}" \ - 'sub_pkgrel' "${sub_pkgrel}" \ 'pkgname' "${pkgname}" + printf ' `binary_packages`.`sub_pkgrel` = %s AND' \ + "${sub_pkgrel}" printf ' `architectures`.`name` = from_base64("%s") AND' \ "${arch}" printf ' `repositories`.`name` = from_base64("%s");\n' \ -- cgit v1.2.3-70-g09d2 From 9ff95b0b5b89d3b0b415e539035cb7876f6bac56 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sun, 21 Jan 2018 21:11:34 +0100 Subject: bin/get-package-updates: update mysql database with new build-list packages --- bin/get-package-updates | 1 + 1 file changed, 1 insertion(+) (limited to 'bin') diff --git a/bin/get-package-updates b/bin/get-package-updates index cbe8b14..2666629 100755 --- a/bin/get-package-updates +++ b/bin/get-package-updates @@ -287,6 +287,7 @@ mkdir -p "${work_dir}/package-infos" while read -r package git_revision mod_git_revision repository; do generate_package_metadata "${package}" "${git_revision}" "${mod_git_revision}" "${repository}" + myqsl_generate_package_metadata "${package}" "${git_revision}" "${mod_git_revision}" "${repository}" done < "${work_dir}/build-list.new" -- cgit v1.2.3-70-g09d2 From ac158e4b3c459b615ecff930181d81f587d6a414 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sun, 21 Jan 2018 21:37:46 +0100 Subject: bin/get-package-updates: accelleration and bugfix --- bin/get-package-updates | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/get-package-updates b/bin/get-package-updates index 2666629..763d01a 100755 --- a/bin/get-package-updates +++ b/bin/get-package-updates @@ -7,6 +7,8 @@ # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" +. "${base_dir}/bin/mysql-functions" + # TODO: Find out, why sometimes package updates are missed. # shellcheck disable=SC2016 @@ -268,6 +270,7 @@ done | \ echo "${package} ${git_revision} ${new_repo_revisions__archlinux32} ${repository}" >> \ "${work_dir}/build-list.new" sed -i "/^$(str_to_regex "${package}")\$/d" "${work_dir}/deletion-list.new" + mysql_generate_package_metadata "${package}" "${git_revision}" "${new_repo_revisions__archlinux32}" "${repository}" continue fi @@ -287,7 +290,6 @@ mkdir -p "${work_dir}/package-infos" while read -r package git_revision mod_git_revision repository; do generate_package_metadata "${package}" "${git_revision}" "${mod_git_revision}" "${repository}" - myqsl_generate_package_metadata "${package}" "${git_revision}" "${mod_git_revision}" "${repository}" done < "${work_dir}/build-list.new" -- cgit v1.2.3-70-g09d2 From 4697dbe5bb3d088a1007a3d39274a1522e832fc4 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sun, 21 Jan 2018 21:40:07 +0100 Subject: bin/return-assignment: started to track package movement in database --- bin/return-assignment | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'bin') diff --git a/bin/return-assignment b/bin/return-assignment index ebaa73a..48c6914 100755 --- a/bin/return-assignment +++ b/bin/return-assignment @@ -368,6 +368,21 @@ if ! [ "${destination}" = 'build-support' ]; then printf '%s\n' ${packages} > \ "${work_dir}/package-states/$1.$2.$3.$4.done" fi +# TODO: mark packages in correct repository in database +${mysql_command} -e "$( + # shellcheck disable=SC2016 + printf 'UPDATE `build_assignments`' + # shellcheck disable=SC2016 + printf ' JOIN `build_slaves` ON `build_slaves`.`currently_building`=`build_assignments`.`id`' + # shellcheck disable=SC2016 + printf ' SET `build_assignments`.`is_broken`=0, `build_slaves`.`currently_building`=NULL' + # shellcheck disable=SC2016 + printf ' WHERE `build_slaves`.`name`=from_base64("%s");\n' \ + "$( + printf '%s' "${slave}" | \ + base64 -w0 + )" +)" rm -f \ "${work_dir}/package-states/$1.$2.$3.$4.locked" \ "${work_dir}/package-states/$1.$2.$3.$4.broken" -- cgit v1.2.3-70-g09d2 From 44e86866de30f7c9caaf0af1e4c632af61d95812 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 08:52:35 +0100 Subject: bin/return-assignment: mark packages in correct repository in database --- bin/return-assignment | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'bin') diff --git a/bin/return-assignment b/bin/return-assignment index 48c6914..c47b01c 100755 --- a/bin/return-assignment +++ b/bin/return-assignment @@ -368,21 +368,28 @@ if ! [ "${destination}" = 'build-support' ]; then printf '%s\n' ${packages} > \ "${work_dir}/package-states/$1.$2.$3.$4.done" fi -# TODO: mark packages in correct repository in database -${mysql_command} -e "$( - # shellcheck disable=SC2016 +# shellcheck disable=SC2016 +{ printf 'UPDATE `build_assignments`' - # shellcheck disable=SC2016 printf ' JOIN `build_slaves` ON `build_slaves`.`currently_building`=`build_assignments`.`id`' - # shellcheck disable=SC2016 - printf ' SET `build_assignments`.`is_broken`=0, `build_slaves`.`currently_building`=NULL' - # shellcheck disable=SC2016 + printf ' JOIN `binary_packages` ON `binary_packages`.`build_assignment`=`build_assignments`.`id`' + printf ' SET' + printf ' `build_assignments`.`is_broken`=0,' + printf ' `build_slaves`.`currently_building`=NULL,' + printf ' `binary_packages`.`repository`=(SELECT `repositories`.`id` FROM `repositories` WHERE `repositories`.`name`=from_base64("%s")),' \ + "$( + printf '%s' "${destination}" | \ + base64 -w0 + )" + printf ' `binary_packages`.`has_issues`=0,' + printf ' `binary_packages`.`is_tested`=0' printf ' WHERE `build_slaves`.`name`=from_base64("%s");\n' \ "$( printf '%s' "${slave}" | \ base64 -w0 )" -)" +} | \ + ${mysql_command} rm -f \ "${work_dir}/package-states/$1.$2.$3.$4.locked" \ "${work_dir}/package-states/$1.$2.$3.$4.broken" -- cgit v1.2.3-70-g09d2 From f8ffc4a1e58df67045f9e88e6b8c99490f0e1134 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 08:54:47 +0100 Subject: bin/build-master-status-from-mysql: style --- bin/build-master-status-from-mysql | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'bin') diff --git a/bin/build-master-status-from-mysql b/bin/build-master-status-from-mysql index 6dacc5e..85185b7 100755 --- a/bin/build-master-status-from-mysql +++ b/bin/build-master-status-from-mysql @@ -8,15 +8,16 @@ . "${base_dir}/bin/mysql-functions" # shellcheck disable=SC2016 -${mysql_command} -e ' - SELECT `build_slaves`.`name`,`build_slaves`.`operator`,`package_sources`.`pkgbase`,`build_slaves`.`last_connection` - FROM `build_slaves` - LEFT JOIN `build_assignments` ON - `build_slaves`.`currently_building`=`build_assignments`.`id` - LEFT JOIN `package_sources` ON - `build_assignments`.`package_source`=`package_sources`.`id` - ORDER BY `build_slaves`.`last_connection` -' --html | \ +{ + printf 'SELECT `build_slaves`.`name`,`build_slaves`.`operator`,`package_sources`.`pkgbase`,`build_slaves`.`last_connection`' + printf ' FROM `build_slaves`' + printf ' LEFT JOIN `build_assignments` ON' + printf ' `build_slaves`.`currently_building`=`build_assignments`.`id`' + printf ' LEFT JOIN `package_sources` ON' + printf ' `build_assignments`.`package_source`=`package_sources`.`id`' + printf ' ORDER BY `build_slaves`.`last_connection`' +} | \ + ${mysql_command} --html | \ sed ' s,,\0\n,g ' | \ -- cgit v1.2.3-70-g09d2 From 3c2d64c5f91da9f24ff69af4a76bb8712d23a0ec Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 09:03:53 +0100 Subject: style: "${mysql_command} -e $(...)" -> {...} | ${mysql_command} --- bin/get-assignment | 15 ++--- bin/mysql-functions | 174 ++++++++++++++++++++++++------------------------ bin/return-assignment | 10 ++- bin/slave-build-connect | 9 ++- 4 files changed, 98 insertions(+), 110 deletions(-) (limited to 'bin') diff --git a/bin/get-assignment b/bin/get-assignment index a81a54d..d256248 100755 --- a/bin/get-assignment +++ b/bin/get-assignment @@ -50,33 +50,26 @@ hand_out_assignment() { } | \ sort -u | \ sponge "${work_dir}/package-states/$1.$2.$3.$4.locked" - ${mysql_command} -e "$( - # shellcheck disable=SC2016 + # shellcheck disable=SC2016 + { printf 'UPDATE `build_slaves`' - # shellcheck disable=SC2016 printf ' SET `currently_building` = (' - # shellcheck disable=SC2016 printf ' SELECT `build_assignments`.`id`' - # shellcheck disable=SC2016 printf ' FROM `build_assignments`' - # shellcheck disable=SC2016 printf ' JOIN `package_sources` ON `build_assignments`.`package_source`=`package_sources`.`id`' - # shellcheck disable=SC2016 printf ' JOIN `upstream_repositories` ON `package_sources`.`upstream_package_repository`=`upstream_repositories`.`id`' printf ' WHERE' - # shellcheck disable=SC2016 printf ' `package_sources`.`%s` = from_base64("%s") AND' \ 'pkgbase' "$(printf '%s' "$1" | base64 -w0)" \ 'git_revision' "$(printf '%s' "$2" | base64 -w0)" \ 'mod_git_revision' "$(printf '%s' "$3" | base64 -w0)" - # shellcheck disable=SC2016 printf ' `upstream_repositories`.`name` = from_base64("%s")' \ "$(printf '%s' "$4" | base64 -w0)" printf ')' - # shellcheck disable=SC2016 printf ' WHERE `build_slaves`.`name`=from_base64("%s");' \ "$(printf '%s' "${slave}" | base64 -w0)" - )" + } | \ + ${mysql_command} # lock every loop this package breaks find "${work_dir}/build-list.loops" -maxdepth 1 -regextype grep \ diff --git a/bin/mysql-functions b/bin/mysql-functions index ff8fe45..7347994 100755 --- a/bin/mysql-functions +++ b/bin/mysql-functions @@ -37,20 +37,19 @@ mysql_add_package_source() { done values="${values% }" - ${mysql_command} -e "$( + { printf 'INSERT IGNORE INTO package_sources' - { - printf ' (' - printf '`%s`, ' ${names} - printf ') SELECT' - printf ' from_base64("%s"), ' ${values% *} - printf ' `upstream_repositories`.`id`' - printf ' FROM `upstream_repositories`' - printf ' WHERE `upstream_repositories`.`name` = from_base64("%s");' \ - "${values##* }" - } | \ - sed 's|, )|)|g' - )" + printf ' (' + printf '`%s`, ' ${names} + printf ') SELECT' + printf ' from_base64("%s"), ' ${values% *} + printf ' `upstream_repositories`.`id`' + printf ' FROM `upstream_repositories`' + printf ' WHERE `upstream_repositories`.`name` = from_base64("%s");' \ + "${values##* }" + } | \ + sed 's|, )|)|g' | \ + ${mysql_command} } # mysql_add_binary_package $pkgbase $git_revision $mod_git_revision $upstream_package_repository $pkgname $sub_pkgrel $architecture $repository @@ -68,33 +67,32 @@ mysql_add_binary_package() { shift done - ${mysql_command} -e "$( + { printf 'INSERT IGNORE INTO binary_packages' - { - printf ' (' - printf '`%s`, ' 'sub_pkgrel' 'pkgname' 'package_source' 'repository' 'architecture' - printf ') SELECT' - printf ' from_base64("%s"), ' "${sub_pkgrel}" "${pkgname}" - printf ' `%s`.`id`,' 'package_sources' 'repositories' 'architectures' - printf ' FROM' - printf ' `%s` JOIN' 'package_sources' 'repositories' 'architectures' - printf ' `upstream_repositories` ON `package_sources`.`upstream_package_repository` = `upstream_repositories`.`id`' - printf ' WHERE' - printf ' `%s`.`name` = from_base64("%s") AND' \ - 'repositories' "${repository}" \ - 'architectures' "${architecture}" - printf ' `package_sources`.`%s` = from_base64("%s") AND' \ - 'pkgbase' "${pkgbase}" \ - 'git_revision' "${git_revision}" \ - 'mod_git_revision' "${mod_git_revision}" - printf ' `upstream_repositories`.`name` = from_base64("%s")' \ - "${upstream_package_repository}" - } | \ - sed ' - s|, )|)|g - s|, FROM| FROM|g - ' - )" + printf ' (' + printf '`%s`, ' 'sub_pkgrel' 'pkgname' 'package_source' 'repository' 'architecture' + printf ') SELECT' + printf ' from_base64("%s"), ' "${sub_pkgrel}" "${pkgname}" + printf ' `%s`.`id`,' 'package_sources' 'repositories' 'architectures' + printf ' FROM' + printf ' `%s` JOIN' 'package_sources' 'repositories' 'architectures' + printf ' `upstream_repositories` ON `package_sources`.`upstream_package_repository` = `upstream_repositories`.`id`' + printf ' WHERE' + printf ' `%s`.`name` = from_base64("%s") AND' \ + 'repositories' "${repository}" \ + 'architectures' "${architecture}" + printf ' `package_sources`.`%s` = from_base64("%s") AND' \ + 'pkgbase' "${pkgbase}" \ + 'git_revision' "${git_revision}" \ + 'mod_git_revision' "${mod_git_revision}" + printf ' `upstream_repositories`.`name` = from_base64("%s")' \ + "${upstream_package_repository}" + } | \ + sed ' + s|, )|)|g + s|, FROM| FROM|g + ' | \ + ${mysql_command} } # mysql_show_binary_package $pkgname $pkgver $pkgrel $sub_pkgrel @@ -113,45 +111,44 @@ mysql_show_binary_package() { done local joint - ${mysql_command} -e "$( - { - printf 'SELECT' - printf ' `%s`.`%s`,' \ - 'repositories' 'name' \ - 'binary_packages' 'pkgname' \ - 'package_sources' 'pkgver' \ - 'package_sources' 'pkgrel' \ - 'binary_packages' 'sub_pkgrel' \ - 'architectures' 'name' \ - 'package_sources' 'pkgbase' \ - 'package_sources' 'git_revision' \ - 'package_sources' 'mod_git_revision' \ - 'upstream_repositories' 'name' - printf ' FROM `binary_packages`' - for joint in \ - 'architectures:binary_packages:architecture' \ - 'package_sources:binary_packages:package_source' \ - 'repositories:binary_packages:repository' \ - 'upstream_repositories:package_sources:upstream_package_repository'; do - printf ' JOIN `%s` ON `%s`.`id` =' \ - "${joint%%:*}" "${joint%%:*}" - joint="${joint#*:}" - printf ' `%s`.`%s`' \ - "${joint%:*}" "${joint#*:}" - done - printf ' WHERE' - printf ' `%s`.`%s` = from_base64("%s") AND' \ - 'binary_packages' 'pkgname' "${pkgname}" \ - 'binary_packages' 'sub_pkgrel' "${sub_pkgrel}" \ - 'package_sources' 'pkgver' "${pkgver}" \ - 'package_sources' 'pkgrel' "${pkgrel}" - printf ';' - } | \ - sed ' - s|, FROM| FROM|g - s|AND;|;|g - ' - )" --html + { + printf 'SELECT' + printf ' `%s`.`%s`,' \ + 'repositories' 'name' \ + 'binary_packages' 'pkgname' \ + 'package_sources' 'pkgver' \ + 'package_sources' 'pkgrel' \ + 'binary_packages' 'sub_pkgrel' \ + 'architectures' 'name' \ + 'package_sources' 'pkgbase' \ + 'package_sources' 'git_revision' \ + 'package_sources' 'mod_git_revision' \ + 'upstream_repositories' 'name' + printf ' FROM `binary_packages`' + for joint in \ + 'architectures:binary_packages:architecture' \ + 'package_sources:binary_packages:package_source' \ + 'repositories:binary_packages:repository' \ + 'upstream_repositories:package_sources:upstream_package_repository'; do + printf ' JOIN `%s` ON `%s`.`id` =' \ + "${joint%%:*}" "${joint%%:*}" + joint="${joint#*:}" + printf ' `%s`.`%s`' \ + "${joint%:*}" "${joint#*:}" + done + printf ' WHERE' + printf ' `%s`.`%s` = from_base64("%s") AND' \ + 'binary_packages' 'pkgname' "${pkgname}" \ + 'binary_packages' 'sub_pkgrel' "${sub_pkgrel}" \ + 'package_sources' 'pkgver' "${pkgver}" \ + 'package_sources' 'pkgrel' "${pkgrel}" + printf ';' + } | \ + sed ' + s|, FROM| FROM|g + s|AND;|;|g + ' | \ + ${mysql_command} --html } # mysql_add_install_target $install_target @@ -164,12 +161,12 @@ mysql_add_install_target() { base64 -w0 ) - ${mysql_command} -e "$( + { printf 'INSERT IGNORE INTO `install_targets` (`name`)' printf ' VALUES (from_base64("%s"))' \ "${install_target}" - printf '\n' - )" + } | \ + ${mysql_command} } # mysql_generate_package_metadata $package $git_revision $mod_git_revision $repository @@ -623,13 +620,14 @@ mysql_sanity_check() { "${temp_dir}/master-mirror-listing" # shellcheck disable=SC2016 - ${mysql_command} -e ' - SELECT `repositories`.`name`,`pkgname`,`epoch`,`pkgver`,`pkgrel`,`sub_pkgrel`,`architectures`.`name` - FROM `binary_packages` - JOIN `architectures` ON `binary_packages`.`architecture`=`architectures`.`id` - JOIN `repositories` ON `binary_packages`.`repository`=`repositories`.`id` - WHERE `repositories`.`is_on_master_mirror` - ' --batch | \ + { + printf 'SELECT `repositories`.`name`,`pkgname`,`epoch`,`pkgver`,`pkgrel`,`sub_pkgrel`,`architectures`.`name`' + printf ' FROM `binary_packages`' + printf ' JOIN `architectures` ON `binary_packages`.`architecture`=`architectures`.`id`' + printf ' JOIN `repositories` ON `binary_packages`.`repository`=`repositories`.`id`' + printf ' WHERE `repositories`.`is_on_master_mirror`' + } | \ + ${mysql_command} --batch | \ sed ' 1d s,\t,/, diff --git a/bin/return-assignment b/bin/return-assignment index c47b01c..11ad2a9 100755 --- a/bin/return-assignment +++ b/bin/return-assignment @@ -76,20 +76,18 @@ if [ "$5" = 'ERROR' ]; then # shellcheck disable=SC2154 echo "${slave}" >> \ "${work_dir}/package-states/$1.$2.$3.$4.broken" - ${mysql_command} -e "$( - # shellcheck disable=SC2016 + # shellcheck disable=SC2016 + { printf 'UPDATE `build_assignments`' - # shellcheck disable=SC2016 printf ' JOIN `build_slaves` ON `build_slaves`.`currently_building`=`build_assignments`.`id`' - # shellcheck disable=SC2016 printf ' SET `build_assignments`.`is_broken`=1, `build_slaves`.`currently_building`=NULL' - # shellcheck disable=SC2016 printf ' WHERE `build_slaves`.`name`=from_base64("%s");\n' \ "$( printf '%s' "${slave}" | \ base64 -w0 )" - )" + } | \ + ${mysql_command} # shellcheck disable=SC2154 sed -i ' diff --git a/bin/slave-build-connect b/bin/slave-build-connect index 86ab14b..2ca72a3 100755 --- a/bin/slave-build-connect +++ b/bin/slave-build-connect @@ -18,18 +18,17 @@ if [ "${SSH_ORIGINAL_COMMAND%% *}" = "get-assignment" ] || \ printf '%s %s %s\n' "$(date '+%F %T')" "$1" "${SSH_ORIGINAL_COMMAND}" >> \ "${work_dir}/ssh-log" - ${mysql_command} -e "$( - # shellcheck disable=SC2016 + # shellcheck disable=SC2016 + { printf 'UPDATE `build_slaves`' - # shellcheck disable=SC2016 printf ' SET `build_slaves`.`last_connection`=NOW()' - # shellcheck disable=SC2016 printf ' WHERE `build_slaves`.`name`=from_base64("%s")\n' \ "$( printf '%s' "$1" | \ base64 -w0 )" - )" + } | \ + ${mysql_command} slave="$1" /bin/sh -c "${base_dir}/bin/${SSH_ORIGINAL_COMMAND}" -- cgit v1.2.3-70-g09d2 From 4f6f142c0f15fae17269a23d917e67768fc1b083 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 09:08:10 +0100 Subject: bin/db-update: check for existence of signature(s), too, before moving packages around --- bin/db-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/db-update b/bin/db-update index 827dc05..9eee60e 100755 --- a/bin/db-update +++ b/bin/db-update @@ -160,7 +160,7 @@ move_packages() { exit 2 fi done < \ - "${tmp_dir}/tmp/${package}.parts" + "${tmp_dir}/tmp/${package}.parts_and_signatures" mkdir -p "${tmp_dir}/tmp/${from_repo}" mkdir -p "${tmp_dir}/tmp/${to_repo}" -- cgit v1.2.3-70-g09d2 From 129376a8164894b9878950ca3b3b02f278234ac9 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 09:10:35 +0100 Subject: bin/common-functions: delete temp_dir --- bin/common-functions | 1 + 1 file changed, 1 insertion(+) (limited to 'bin') diff --git a/bin/common-functions b/bin/common-functions index 1fd5db7..f512b89 100755 --- a/bin/common-functions +++ b/bin/common-functions @@ -1233,6 +1233,7 @@ next_sub_pkgrel() { git_repo=$(find_git_repository_to_package_repository "${repository}") temp_dir=$(mktemp -d 'tmp.common-functions.next_sub_pkgrel.XXXXXXXXXX' --tmpdir) + trap 'rm -rf --one-file-system "${temp_dir}"' EXIT find_pkgbuilds "${package}" "${repository}" "${git_repo}" "${git_revision}" "${mod_git_revision}" extract_source_directory "${git_repo}" "${git_revision}" "${mod_git_revision}" "${temp_dir}" '0' -- cgit v1.2.3-70-g09d2 From 0f94a77dc2f8ec2c8b3d6f984dddb37b4965dd3d Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 09:46:39 +0100 Subject: bin/db-update: track movement of packages with database --- bin/db-update | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/db-update b/bin/db-update index 9eee60e..fbbad2c 100755 --- a/bin/db-update +++ b/bin/db-update @@ -323,9 +323,58 @@ move_packages() { done < \ "${tmp_dir}/tmp/packages" - if ! ${no_action}; then - ${dummynator} trigger_mirror_refreshs - fi + # shellcheck disable=SC2016 + while read -r package; do + while read -r part; do + printf 'UPDATE `binary_packages`' + printf ' JOIN `repositories` ON `binary_packages`.`repository`=`repositories`.`id`' + printf ' JOIN `architectures` ON `binary_packages`.`architecture`=`architectures`.`id`' + printf ' SET `binary_packages`.`repository`=(SELECT `repositories`.`id` FROM `repositories` WHERE `repositories`.`name`=from_base64("%s"))' \ + "$( + base64_encode_each < \ + "${tmp_dir}/tmp/${package}.to_repo" + )" + printf ' WHERE' + printf ' `architectures`.`name`=from_base64("%s")' \ + "$( + base64_encode_each < \ + "${tmp_dir}/tmp/${package}.from_repo" + )" + printf '%s\n' "${part}" | \ + sed ' + s/\.pkg\.tar\.xz$// + s/-\([^-.]\+\)\(-[^-]\+\)$/-\1.0\2/ + s/-\([^-:]\+\)\(\(-[^-]\+\)\{2\}\)$/-0:\1\2/ + s/^\(.\+\)-\([^-:]\+\):\([^-:]\+\)-\([^-.]\+\)\.\([^-.]\+\)-\([^-]\+\)$/\1\n\2\n\3\n\4\n\5\n\6/ + ' | \ + base64_encode_each | \ + tr '\n' ' ' | \ + sed ' + s,\(\S\+\) \(\S\+\) \(\S\+\) \(\S\+\) \(\S\+\) \(\S\+\) $,'"$( + printf ' AND `binary_packages`.`%s`=from_base64("%s")' \ + 'pkgname' '\1' \ + 'epoch' '\2' \ + 'pkgver' '\3' \ + 'pkgrel' '\4' \ + 'sub_pkgrel' '\5' + printf ' AND `architectures`.`name`=from_base64("\6")' + )"', + ' + printf ' AND `binary_packages`.`%s`=from_base64("%s")' \ + 'epoch' "$( + )" + printf ';\n' + done < \ + "${tmp_dir}/tmp/${package}.parts" + done < \ + "${tmp_dir}/tmp/packages" | \ + if ${no_action}; then + sed 's|^|mysql: |' + else + ${mysql_command} + fi + + ${dummynator} trigger_mirror_refreshs rm -rf --one-file-system "${tmp_dir:?}/tmp" -- cgit v1.2.3-70-g09d2 From 9cae7aa539fa6c3bee8d5af0ba4504a98e1a3cc2 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 09:49:45 +0100 Subject: bin/db-update: source mysql-functions, it is needed --- bin/db-update | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bin') diff --git a/bin/db-update b/bin/db-update index fbbad2c..9ba65ce 100755 --- a/bin/db-update +++ b/bin/db-update @@ -24,6 +24,8 @@ # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" +. "${base_dir}/bin/mysql-functions" + # shellcheck disable=SC2016 usage() { >&2 echo '' -- cgit v1.2.3-70-g09d2 From e542cd450cd69a07eff6fac75790e6182f42c0e6 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 10:00:28 +0100 Subject: bin/db-update: add TODOs --- bin/db-update | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'bin') diff --git a/bin/db-update b/bin/db-update index 9ba65ce..343b9d4 100755 --- a/bin/db-update +++ b/bin/db-update @@ -20,6 +20,11 @@ # track packages in stable, too # know _exactly_ in which repository the packages are +# TODO: fully integrate database (in other scripts too) - e.g. rely on +# info in db instead of state-files + +# TODO: remove replaced packages in database, too + # shellcheck disable=SC2039 # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" -- cgit v1.2.3-70-g09d2 From bbcdedc4794cda338ae005b4d3361cde4fffd9ce Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 10:13:27 +0100 Subject: bin/db-update: fix mysql query --- bin/db-update | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/db-update b/bin/db-update index 343b9d4..1417820 100755 --- a/bin/db-update +++ b/bin/db-update @@ -342,7 +342,7 @@ move_packages() { "${tmp_dir}/tmp/${package}.to_repo" )" printf ' WHERE' - printf ' `architectures`.`name`=from_base64("%s")' \ + printf ' `repositories`.`name`=from_base64("%s")' \ "$( base64_encode_each < \ "${tmp_dir}/tmp/${package}.from_repo" @@ -364,12 +364,9 @@ move_packages() { 'pkgver' '\3' \ 'pkgrel' '\4' \ 'sub_pkgrel' '\5' - printf ' AND `architectures`.`name`=from_base64("\6")' + printf ' AND `architectures`.`name`=from_base64("\\6")' )"', ' - printf ' AND `binary_packages`.`%s`=from_base64("%s")' \ - 'epoch' "$( - )" printf ';\n' done < \ "${tmp_dir}/tmp/${package}.parts" -- cgit v1.2.3-70-g09d2 From fe3add81cf6be1f717842dfb3335f631e7aa4b19 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 10:23:56 +0100 Subject: bin/common-functions: fix typo in comment --- bin/common-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/common-functions b/bin/common-functions index f512b89..40e52f2 100755 --- a/bin/common-functions +++ b/bin/common-functions @@ -522,7 +522,7 @@ remove_old_package_versions() { ' | \ sort -u > \ "${tmp_dir}/packages-to-delete" - # this file contains a list of packages to be delete, one on each line: + # this file contains a list of packages to be deleted, one on each line: # $architecture-directory $repository-directory $package-name $pkgver-$pkgrel-$package-architecture.pkg.tar.xz cut -d' ' -f1,2 < \ -- cgit v1.2.3-70-g09d2 From d384cd8395fb0a0e0686f3c1ddac883002563f9a Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 10:27:41 +0100 Subject: source bin/mysql-functions in conf/default.conf - just like bin/common-functions - because it is now needed almost everywhere --- bin/bootstrap-mysql | 2 -- bin/build-master-status-from-mysql | 2 -- bin/db-update | 2 -- bin/get-package-updates | 2 -- conf/default.conf | 2 ++ 5 files changed, 2 insertions(+), 8 deletions(-) (limited to 'bin') diff --git a/bin/bootstrap-mysql b/bin/bootstrap-mysql index 3069863..fcb2f7e 100755 --- a/bin/bootstrap-mysql +++ b/bin/bootstrap-mysql @@ -2,8 +2,6 @@ # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" -# shellcheck source=bin/mysql-functions -. "${base_dir}/bin/mysql-functions" tmp_dir=$(mktemp -d 'tmp.bootstrap-mysql.XXXXXXXXXX' --tmpdir) trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT diff --git a/bin/build-master-status-from-mysql b/bin/build-master-status-from-mysql index 85185b7..12278be 100755 --- a/bin/build-master-status-from-mysql +++ b/bin/build-master-status-from-mysql @@ -4,8 +4,6 @@ # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" -# shellcheck source=bin/mysql-functions -. "${base_dir}/bin/mysql-functions" # shellcheck disable=SC2016 { diff --git a/bin/db-update b/bin/db-update index 1417820..5b32214 100755 --- a/bin/db-update +++ b/bin/db-update @@ -29,8 +29,6 @@ # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" -. "${base_dir}/bin/mysql-functions" - # shellcheck disable=SC2016 usage() { >&2 echo '' diff --git a/bin/get-package-updates b/bin/get-package-updates index 763d01a..daa68a7 100755 --- a/bin/get-package-updates +++ b/bin/get-package-updates @@ -7,8 +7,6 @@ # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" -. "${base_dir}/bin/mysql-functions" - # TODO: Find out, why sometimes package updates are missed. # shellcheck disable=SC2016 diff --git a/conf/default.conf b/conf/default.conf index b2882ac..6ee991b 100755 --- a/conf/default.conf +++ b/conf/default.conf @@ -16,6 +16,8 @@ fi # shellcheck source=bin/common-functions . "${base_dir}/bin/common-functions" +# shellcheck source=bin/mysql-functions +. "${base_dir}/bin/mysql-functions" work_dir="${base_dir}/work" -- cgit v1.2.3-70-g09d2 From 6c6809e9503d7791e22f295351098fd709410921 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 10:52:34 +0100 Subject: bin/common-functions: remove replaced packages in database, too --- bin/common-functions | 26 ++++++++++++++++++++++++++ bin/db-update | 2 -- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/common-functions b/bin/common-functions index 40e52f2..3801967 100755 --- a/bin/common-functions +++ b/bin/common-functions @@ -560,6 +560,32 @@ remove_old_package_versions() { done < \ "${tmp_dir}/repositories-to-modify" + # shellcheck disable=SC2016 + sed ' + s/\.pkg\.tar\.xz$// + s/^\S\+ // + s/-\([^-. ]\+\)\(-[^- ]\+\)$/-\1.0\2/ + s/ \([^-: ]\+\(-[^- ]\+\)\{2\}\)$/ 0:\1/ + s/ \([^-.]\+\):\([^-:]\+\)-\([^-.]\+\)\.\([^-.]\+\)-\([^-]\+\)$/ \1 \2 \3 \4 \5/ + ' "${tmp_dir}/packages-to-delete" | \ + while read -r repo pkgname epoch pkgver pkgrel sub_pkgrel arch; do + printf 'DELETE FROM `binary_packages`' + printf ' JOIN `architectures` ON `binary_packages`.`architecture`=`architectures`.`id`' + printf ' JOIN `repositories` ON `binary_packages`.`repository`=`repositories`.`id`' + printf ' WHERE' + printf ' `binary_packages`.`%s`=from_base64("%s") AND' \ + 'pkgname' "$(printf '%s' "${pkgname}" | base64 -w0)" \ + 'epoch' "$(printf '%s' "${epoch}" | base64 -w0)" \ + 'pkgver' "$(printf '%s' "${pkgver}" | base64 -w0)" \ + 'pkgrel' "$(printf '%s' "${pkgrel}" | base64 -w0)" \ + 'sub_pkgrel' "$(printf '%s' "${sub_pkgrel}" | base64 -w0)" + printf ' `repositories`.`name`=from_base64("%s") AND' \ + "$(printf '%s' "${repo}" | base64 -w0)" + printf ' `architectures`.`name`=from_base64("%s")' \ + "$(printf '%s' "${arch}" | base64 -w0)" + printf ';\n' + done + sed ' s| \(\S\+\)$|-\1| y| |/| diff --git a/bin/db-update b/bin/db-update index 5b32214..b11945c 100755 --- a/bin/db-update +++ b/bin/db-update @@ -23,8 +23,6 @@ # TODO: fully integrate database (in other scripts too) - e.g. rely on # info in db instead of state-files -# TODO: remove replaced packages in database, too - # shellcheck disable=SC2039 # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" -- cgit v1.2.3-70-g09d2 From fdb0d1b3ee103ab87fbe15c492402fb4f23846ce Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 10:59:24 +0100 Subject: bin/bootstrap-mysql: lock everything --- bin/bootstrap-mysql | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'bin') diff --git a/bin/bootstrap-mysql b/bin/bootstrap-mysql index fcb2f7e..b67be6f 100755 --- a/bin/bootstrap-mysql +++ b/bin/bootstrap-mysql @@ -6,6 +6,22 @@ tmp_dir=$(mktemp -d 'tmp.bootstrap-mysql.XXXXXXXXXX' --tmpdir) trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT +exec 9> "${build_list_lock_file}" +if ! flock -n 9; then + >&2 echo 'Cannot get build-list lock.' + exit 1 +fi +exec 8> "${sanity_check_lock_file}" +if ! flock -s -n 9; then + >&2 echo 'Cannot get sanity-check lock.' + exit 1 +fi +exec 7> "${package_database_lock_file}" +if ! flock -s -n 7; then + >&2 echo 'Cannot get package-database lock.' + exit 1 +fi + for dir in $(ls_master_mirror 'i686'); do ls_master_mirror "i686/${dir}" | \ sed ' -- cgit v1.2.3-70-g09d2 From 0cc08099ad33ca13cbf4b7cbeb6e98bf89935b79 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 11:35:11 +0100 Subject: new todos --- bin/db-update | 3 +++ bin/delete-packages | 2 ++ bin/get-package-updates | 2 ++ bin/seed-build-list | 2 ++ 4 files changed, 9 insertions(+) (limited to 'bin') diff --git a/bin/db-update b/bin/db-update index b11945c..fe45f41 100755 --- a/bin/db-update +++ b/bin/db-update @@ -23,6 +23,9 @@ # TODO: fully integrate database (in other scripts too) - e.g. rely on # info in db instead of state-files +# TODO: add possibility to manually clone a (binary) package (e.g. +# for build-support) - this should also be possible via email + # shellcheck disable=SC2039 # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" diff --git a/bin/delete-packages b/bin/delete-packages index a6e3f14..26d323a 100755 --- a/bin/delete-packages +++ b/bin/delete-packages @@ -13,6 +13,8 @@ # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" +# TODO: finish this + # shellcheck disable=SC2016 usage() { >&2 echo '' diff --git a/bin/get-package-updates b/bin/get-package-updates index daa68a7..2d113f1 100755 --- a/bin/get-package-updates +++ b/bin/get-package-updates @@ -9,6 +9,8 @@ # TODO: Find out, why sometimes package updates are missed. +# TODO: mark loops in mysql database + # shellcheck disable=SC2016 usage() { >&2 echo '' diff --git a/bin/seed-build-list b/bin/seed-build-list index feea704..78b29ba 100755 --- a/bin/seed-build-list +++ b/bin/seed-build-list @@ -5,6 +5,8 @@ # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" +# TODO: put new packages also in mysql database + # shellcheck disable=SC2016 usage() { >&2 echo '' -- cgit v1.2.3-70-g09d2 From 2134c5f3aaecc5c64caacf550ee413d5ad96b7cf Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 11:43:08 +0100 Subject: bin/bootstrap-mysql: new tables to track build errors, too --- bin/bootstrap-mysql | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/bootstrap-mysql b/bin/bootstrap-mysql index b67be6f..69bc015 100755 --- a/bin/bootstrap-mysql +++ b/bin/bootstrap-mysql @@ -111,7 +111,17 @@ if [ ! "$1" = 'slim' ]; then ' head VARCHAR(40)' \ ' UNIQUE name' \ ' UNIQUE url' \ - ' UNIQUE directory' + ' UNIQUE directory' \ + 'fail_reasons SMALLINT' \ + ' name VARCHAR(32)' \ + ' severity SMALLINT' \ + ' UNIQUE name' \ + 'failed_builds MEDIUMINT' \ + ' build_slave MEDIUMINT :build_slaves' \ + ' build_assignment BIGINT :build_assignments' \ + ' date DATETIME' \ + ' reason SMALLINT :fail_reasons' \ + ' log_file VARCHAR(128)' ) { -- cgit v1.2.3-70-g09d2 From 571c771968611c942162fe5b3132c76ed51af146 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 13:28:39 +0100 Subject: bin/bootstrap-mysql: initialize `fail_reasons`, too --- bin/bootstrap-mysql | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/bootstrap-mysql b/bin/bootstrap-mysql index 69bc015..1eb98a2 100755 --- a/bin/bootstrap-mysql +++ b/bin/bootstrap-mysql @@ -114,6 +114,7 @@ if [ ! "$1" = 'slim' ]; then ' UNIQUE directory' \ 'fail_reasons SMALLINT' \ ' name VARCHAR(32)' \ + ' identifier VARCHAR(64)' \ ' severity SMALLINT' \ ' UNIQUE name' \ 'failed_builds MEDIUMINT' \ @@ -121,7 +122,7 @@ if [ ! "$1" = 'slim' ]; then ' build_assignment BIGINT :build_assignments' \ ' date DATETIME' \ ' reason SMALLINT :fail_reasons' \ - ' log_file VARCHAR(128)' + ' log_file VARCHAR(512)' ) { @@ -232,6 +233,43 @@ fi sed 's|,$||' printf ';\n' # shellcheck disable=SC2016 + printf 'INSERT IGNORE INTO `fail_reasons` (`name`,`identifier`,`severity`) VALUES ' + printf '(from_base64("%s"),"%s",%s),' \ + "$( + printf '%s' '==> ERROR: A failure occurred in build()\.' | \ + base64 -w0 + )" 'build()' 0 \ + "$( + printf '%s' '==> ERROR: Could not download sources\.' | \ + base64 -w0 + )" 'source' 1 \ + "$( + printf '%s' '.*error: failed to commit transaction (invalid or corrupted package)' | \ + base64 -w0 + )" 'package-cache' 2 \ + "$( + printf '%s' '==> ERROR: A failure occurred in prepare()\.' | \ + base64 -w0 + )" 'prepare()' 2 \ + "$( + printf '%s' '==> ERROR: A failure occurred in package\(_\S\+\)\?()\.' | \ + base64 -w0 + )" 'package()' 3 \ + "$( + printf '%s' '==> ERROR: A failure occurred in check()\.' | \ + base64 -w0 + )" 'check()' 4 \ + "$( + printf '%s' '==> ERROR: '"'"'pacman'"'"' failed to install missing dependencies\.' | \ + base64 -w0 + )" 'dependencies' 1 \ + "$( + printf '%s' '==> ERROR: Running makepkg as root is not allowed as it can cause permanent,.*' | \ + base64 -w0 + )" 'run-as-root' 1 | \ + sed 's|,$||' + printf ';\n' + # shellcheck disable=SC2016 printf 'INSERT IGNORE INTO `git_repositories` (`name`,`url`,`directory`,`head`) VALUES' { for repo in ${repo_names}; do -- cgit v1.2.3-70-g09d2 From 3c6f639d1f04ce849f1ae92fb1b87ae16d1284a2 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 13:34:42 +0100 Subject: bin/bootstrap-mysql: assume only one package version is available for each build assignment --- bin/bootstrap-mysql | 1 + 1 file changed, 1 insertion(+) (limited to 'bin') diff --git a/bin/bootstrap-mysql b/bin/bootstrap-mysql index 1eb98a2..62dad81 100755 --- a/bin/bootstrap-mysql +++ b/bin/bootstrap-mysql @@ -425,6 +425,7 @@ find "${work_dir}/package-states" \ -name '*.tested' \ \) \ -exec sed ' + 1!d s@^.*-\([^-]\+\)-\([^-.]\+\)\.pkg\.tar\.xz$@{} \1 \2 \0@ s@^\S*/@@ s/^\(\S\+\)\.\(done\|testing\|tested\) /\1 / -- cgit v1.2.3-70-g09d2 From 195f789f10cf251d5c2736ba52ebc50420694609 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 13:37:26 +0100 Subject: bin/return-assignment: trace log files/failure reasons --- bin/return-assignment | 63 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/return-assignment b/bin/return-assignment index 11ad2a9..545d064 100755 --- a/bin/return-assignment +++ b/bin/return-assignment @@ -60,12 +60,14 @@ if [ "$5" = 'ERROR' ]; then fi # save sent build logs - tar -x \ - -C "${build_log_directory}/error" \ - --wildcards \ - --no-wildcards-match-slash \ - --transform="s|^|$1.$2.$3.$4.|" \ - '*.build-log.gz' + saved_build_logs=$( + tar -vx \ + -C "${build_log_directory}/error" \ + --wildcards \ + --no-wildcards-match-slash \ + --transform="s|^|$1.$2.$3.$4.|" \ + '*.build-log.gz' + ) if [ -f "${work_dir}/package-states/$1.$2.$3.$4.broken" ]; then was_broken_before=true @@ -78,6 +80,55 @@ if [ "$5" = 'ERROR' ]; then "${work_dir}/package-states/$1.$2.$3.$4.broken" # shellcheck disable=SC2016 { + if [ -n "${saved_build_logs}" ]; then + printf 'CREATE TEMPORARY TABLE `failures` (' + printf '`%s` %s,' \ + 'date' 'DATETIME' \ + 'reason' 'SMALLINT' \ + 'log_file' 'VARCHAR(512)' | \ + sed 's/,$//' + printf ');' + printf 'INSERT INTO `failures` (`date`,`reason`,`log_file`) VALUES' + fail_reason_identifiers=$( + printf 'SELECT `fail_reasons`.`id`,to_base64(`fail_reasons`.`identifier`) FROM `fail_reasons` ORDER BY `fail_reasons`.`severity`' | \ + ${mysql_command} --batch + ) + for saved_build_log in ${saved_build_logs}; do + printf '%s' "${fail_reason_identifiers}" | \ + while read -r reason_id identifier; do + if zgrep -q "^$(printf '%s' "${identifier}" | base64 -d)\$" "${build_log_directory}/error/${saved_build_log}"; then + printf ' (from_base64("%s"),%s,from_base64("%s")),' \ + "$( + printf '%s' "${saved_build_log}" | \ + sed 's|\.build-log\.gz$||;s|^.*\.||' | \ + base64 -w0 + )" \ + "${reason_id}" \ + "$( + printf '%s' "${saved_build_log}" | \ + base64 -w0 + )" + break + fi + done + done | \ + sed 's/,$//' + printf ';\n' + printf 'INSERT INTO `failed_builds` (`build_slave`,`build_assignment`,`date`,`reason`,`log_file`)' + printf ' SELECT ' + printf '`build_slaves`.`%s`,' \ + 'id' 'currently_building' + printf '`failures`.`%s`,' \ + 'date' 'reason' 'log_file' | \ + sed 's/,$//' + printf ' FROM `build_slaves` JOIN `failures`' + printf ' WHERE `build_slaves`.`name`=from_base64("%s");\n' \ + "$( + printf '%s' "${slave}" | \ + base64 -w0 + )" + printf 'DROP TABLE `failures`;\n' + fi printf 'UPDATE `build_assignments`' printf ' JOIN `build_slaves` ON `build_slaves`.`currently_building`=`build_assignments`.`id`' printf ' SET `build_assignments`.`is_broken`=1, `build_slaves`.`currently_building`=NULL' -- cgit v1.2.3-70-g09d2 From 511834749b219fb3ea7f52dbe14a9634c156f0ac Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 13:46:36 +0100 Subject: bin/bootstrap-mysql: whoops, fix column orderd --- bin/bootstrap-mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/bootstrap-mysql b/bin/bootstrap-mysql index 62dad81..6da2c86 100755 --- a/bin/bootstrap-mysql +++ b/bin/bootstrap-mysql @@ -233,7 +233,7 @@ fi sed 's|,$||' printf ';\n' # shellcheck disable=SC2016 - printf 'INSERT IGNORE INTO `fail_reasons` (`name`,`identifier`,`severity`) VALUES ' + printf 'INSERT IGNORE INTO `fail_reasons` (`identifier`,`name`,`severity`) VALUES ' printf '(from_base64("%s"),"%s",%s),' \ "$( printf '%s' '==> ERROR: A failure occurred in build()\.' | \ -- cgit v1.2.3-70-g09d2 From 423cf0b000964db5456f3238febac4809ef8f16c Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 13:57:14 +0100 Subject: bin/return-assignment: fix extraction of fail-reason identifier --- bin/return-assignment | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/return-assignment b/bin/return-assignment index 545d064..e14e93e 100755 --- a/bin/return-assignment +++ b/bin/return-assignment @@ -91,7 +91,8 @@ if [ "$5" = 'ERROR' ]; then printf 'INSERT INTO `failures` (`date`,`reason`,`log_file`) VALUES' fail_reason_identifiers=$( printf 'SELECT `fail_reasons`.`id`,to_base64(`fail_reasons`.`identifier`) FROM `fail_reasons` ORDER BY `fail_reasons`.`severity`' | \ - ${mysql_command} --batch + ${mysql_command} --raw --batch | \ + sed '1d' ) for saved_build_log in ${saved_build_logs}; do printf '%s' "${fail_reason_identifiers}" | \ -- cgit v1.2.3-70-g09d2 From c3981b65615fd29d16e15860ee5872a996efb90e Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 15:13:09 +0100 Subject: bin/bootstrap-mysql: one binary package may be in multiple repositories with identical versions/git hashes (e.g. "build-support"!) --- bin/bootstrap-mysql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/bootstrap-mysql b/bin/bootstrap-mysql index 6da2c86..35391f3 100755 --- a/bin/bootstrap-mysql +++ b/bin/bootstrap-mysql @@ -63,8 +63,8 @@ if [ ! "$1" = 'slim' ]; then ' is_tested BIT' \ ' pkgname VARCHAR(64)' \ ' architecture SMALLINT :architectures' \ - ' UNIQUE content build_assignment sub_pkgrel pkgname architecture' \ - ' UNIQUE file_name pkgname epoch pkgver pkgrel sub_pkgrel architecture' \ + ' UNIQUE content build_assignment sub_pkgrel pkgname architecture repository' \ + ' UNIQUE file_name pkgname epoch pkgver pkgrel sub_pkgrel architecture repository' \ 'repositories MEDIUMINT' \ ' name VARCHAR(64)' \ ' stability MEDIUMINT :repository_stabilities' \ -- cgit v1.2.3-70-g09d2 From 22fed81b1fbce3431d4c2349b0694d3bb7c6a36b Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 15:51:25 +0100 Subject: bin/build-master-status-from-mysql: include build list in sanity check --- bin/build-master-status-from-mysql | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/build-master-status-from-mysql b/bin/build-master-status-from-mysql index 12278be..2ed9a24 100755 --- a/bin/build-master-status-from-mysql +++ b/bin/build-master-status-from-mysql @@ -32,7 +32,31 @@ ' | \ sponge "${webserver_directory}/build-slaves.html" -mysql_sanity_check | \ +{ + mysql_sanity_check || true + { + # shellcheck disable=SC2016 + { + printf 'SELECT `package_sources`.`pkgbase`,`package_sources`.`git_revision`,`package_sources`.`mod_git_revision`,`upstream_repositories`.`name`' + printf ' FROM `package_sources`' + printf ' JOIN `%s` ON `%s`.`%s`=`%s`.`id`' \ + 'upstream_repositories' 'package_sources' 'upstream_package_repository' 'upstream_repositories' \ + 'build_assignments' 'build_assignments' 'package_source' 'package_sources' \ + 'binary_packages' 'binary_packages' 'build_assignment' 'build_assignments' \ + 'repositories' 'binary_packages' 'repository' 'repositories' + printf ' WHERE `repositories`.`name`="build-list"' + } | \ + ${mysql_command} --batch | \ + sed ' + 1d + y/\t/ / + s/^/+ / + ' + sed 's/^/- /' "${work_dir}/build-list" + } | \ + sort -k2 -k1,1 | \ + uniq -uf1 +} | \ sed ' s,^-.*$,\0, s,^+.*$,\0, -- cgit v1.2.3-70-g09d2 From 69387349879acc40799478b92c8f693c7fceae4d Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 16:16:36 +0100 Subject: bin/return-assignment: split mysql update in two steps to not lose the connection between entries --- bin/return-assignment | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/return-assignment b/bin/return-assignment index e14e93e..c504bf6 100755 --- a/bin/return-assignment +++ b/bin/return-assignment @@ -425,7 +425,6 @@ fi printf ' JOIN `binary_packages` ON `binary_packages`.`build_assignment`=`build_assignments`.`id`' printf ' SET' printf ' `build_assignments`.`is_broken`=0,' - printf ' `build_slaves`.`currently_building`=NULL,' printf ' `binary_packages`.`repository`=(SELECT `repositories`.`id` FROM `repositories` WHERE `repositories`.`name`=from_base64("%s")),' \ "$( printf '%s' "${destination}" | \ @@ -438,6 +437,13 @@ fi printf '%s' "${slave}" | \ base64 -w0 )" + printf 'UPDATE `build_slaves` SET' + printf ' `build_slaves`.`currently_building`=NULL' + printf ' WHERE `build_slaves`.`name`=from_base64("%s");\n' \ + "$( + printf '%s' "${slave}" | \ + base64 -w0 + )" } | \ ${mysql_command} rm -f \ -- cgit v1.2.3-70-g09d2 From 4701ae8f29f2d69a1aaacad65c298258177724fa Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 16:29:21 +0100 Subject: bin/common-functions: bugfix in remove_old_package_versions: fix mysql and actually call mysql in the end :-) --- bin/common-functions | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'bin') diff --git a/bin/common-functions b/bin/common-functions index 3801967..d5b6eaa 100755 --- a/bin/common-functions +++ b/bin/common-functions @@ -569,22 +569,20 @@ remove_old_package_versions() { s/ \([^-.]\+\):\([^-:]\+\)-\([^-.]\+\)\.\([^-.]\+\)-\([^-]\+\)$/ \1 \2 \3 \4 \5/ ' "${tmp_dir}/packages-to-delete" | \ while read -r repo pkgname epoch pkgver pkgrel sub_pkgrel arch; do - printf 'DELETE FROM `binary_packages`' - printf ' JOIN `architectures` ON `binary_packages`.`architecture`=`architectures`.`id`' - printf ' JOIN `repositories` ON `binary_packages`.`repository`=`repositories`.`id`' - printf ' WHERE' + printf 'DELETE FROM `binary_packages` WHERE' + printf ' `binary_packages`.`%s`=(SELECT `%s`.`id` FROM `%s` WHERE `%s`.`name`=from_base64("%s")) AND' \ + 'architecture' 'architectures' 'architectures' 'architectures' "$(printf '%s' "${arch}" | base64 -w0)" \ + 'repository' 'repositories' 'repositories' 'repositories' "$(printf '%s' "${repo}" | base64 -w0)" printf ' `binary_packages`.`%s`=from_base64("%s") AND' \ 'pkgname' "$(printf '%s' "${pkgname}" | base64 -w0)" \ 'epoch' "$(printf '%s' "${epoch}" | base64 -w0)" \ 'pkgver' "$(printf '%s' "${pkgver}" | base64 -w0)" \ 'pkgrel' "$(printf '%s' "${pkgrel}" | base64 -w0)" \ - 'sub_pkgrel' "$(printf '%s' "${sub_pkgrel}" | base64 -w0)" - printf ' `repositories`.`name`=from_base64("%s") AND' \ - "$(printf '%s' "${repo}" | base64 -w0)" - printf ' `architectures`.`name`=from_base64("%s")' \ - "$(printf '%s' "${arch}" | base64 -w0)" + 'sub_pkgrel' "$(printf '%s' "${sub_pkgrel}" | base64 -w0)" | \ + sed 's/ AND$//' printf ';\n' - done + done | \ + ${mysql_command} sed ' s| \(\S\+\)$|-\1| -- cgit v1.2.3-70-g09d2 From 59103fabbb2583e627452750f7043633d21a7b45 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 19:34:58 +0100 Subject: bin/bootstrap-mysql: deletion-list should be tracked, too --- bin/bootstrap-mysql | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/bootstrap-mysql b/bin/bootstrap-mysql index 35391f3..f67b779 100755 --- a/bin/bootstrap-mysql +++ b/bin/bootstrap-mysql @@ -369,7 +369,8 @@ fi 'testing' '"Packages:Testing"' \ 'staging' 'NULL' \ 'standalone' 'NULL' \ - 'unbuilt' '"Packages:Build-list"' + 'unbuilt' '"Packages:Build-list"' \ + 'forbidden' 'NULL' printf ';\n' } | \ sed 's|,;|;|' @@ -383,7 +384,8 @@ fi 'community-testing:testing:AQ==' \ 'staging:staging:AQ==' \ 'community-staging:staging:AQ==' \ - 'build-list:unbuilt:AA=='; do + 'build-list:unbuilt:AA==' \ + 'deletion-list:forbidden:AA=='; do # shellcheck disable=SC2016 printf 'INSERT IGNORE INTO `repositories` (`name`,`stability`,`is_on_master_mirror`) SELECT' # shellcheck disable=SC2016 -- cgit v1.2.3-70-g09d2 From b1bf479514f9b796169df90f6b8097b91600620a Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 20:14:36 +0100 Subject: bin/get-package-updates: mark packages as on deletion-list in mysql database --- bin/get-package-updates | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'bin') diff --git a/bin/get-package-updates b/bin/get-package-updates index 2d113f1..cea1ec1 100755 --- a/bin/get-package-updates +++ b/bin/get-package-updates @@ -90,6 +90,20 @@ delete_package() { echo "$1" >> \ "${work_dir}/deletion-list.new" sed -i "/^$(str_to_regex "${1}") /d" "${work_dir}/build-list.new" + # shellcheck disable=SC2016 + { + printf 'UPDATE `binary_packages`' + printf ' JOIN `%s` ON `%s`.`id`=`binary_packages`.`%s`' \ + 'repositories' 'repositories' 'repository' \ + 'build_assignments' 'build_assignments' 'build_assignment' + printf ' JOIN `%s` ON `%s`.`id`=`%s`.`%s`' \ + 'package_sources' 'package_sources' 'build_assignments' 'package_source' + printf ' WHERE `repositories`.`name`="build-list"' + printf ' AND `package_sources`.`pkgbase`=from_base64("%s")' \ + "$(printf '%s' "$1" | base64 -w0)" + printf ' SET `binary_packages`.`repository`=(SELECT `repositories`.`id` FROM `repositories` WHERE `repositories`.`name`="deletion-list");' + } | \ + ${mysql_command} } # create tmp_dir and trap -- cgit v1.2.3-70-g09d2 From 170263108c8a6bf53fbfb22f8c7275bfff784edf Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 20:29:15 +0100 Subject: bin/get-package-updates: bugfix mysql expression --- bin/get-package-updates | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/get-package-updates b/bin/get-package-updates index cea1ec1..47c8824 100755 --- a/bin/get-package-updates +++ b/bin/get-package-updates @@ -98,10 +98,10 @@ delete_package() { 'build_assignments' 'build_assignments' 'build_assignment' printf ' JOIN `%s` ON `%s`.`id`=`%s`.`%s`' \ 'package_sources' 'package_sources' 'build_assignments' 'package_source' + printf ' SET `binary_packages`.`repository`=(SELECT `repositories`.`id` FROM `repositories` WHERE `repositories`.`name`="deletion-list")' printf ' WHERE `repositories`.`name`="build-list"' - printf ' AND `package_sources`.`pkgbase`=from_base64("%s")' \ + printf ' AND `package_sources`.`pkgbase`=from_base64("%s");' \ "$(printf '%s' "$1" | base64 -w0)" - printf ' SET `binary_packages`.`repository`=(SELECT `repositories`.`id` FROM `repositories` WHERE `repositories`.`name`="deletion-list");' } | \ ${mysql_command} } -- cgit v1.2.3-70-g09d2 From 7d67a5bf7d76d8a5b2b11b77a3c17eb37b66be96 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 20:33:40 +0100 Subject: use sponge to send irc messages w/o being interrupted --- bin/ii-connect | 12 ++++++------ bin/return-assignment | 5 ++--- bin/sanity-check | 8 ++++---- 3 files changed, 12 insertions(+), 13 deletions(-) (limited to 'bin') diff --git a/bin/ii-connect b/bin/ii-connect index b703d77..54e1eb0 100755 --- a/bin/ii-connect +++ b/bin/ii-connect @@ -15,8 +15,8 @@ fi # register if not yet done if tail -n1 "${irc_dir}/nickserv/out" 2> /dev/null | \ grep -qF 'This nickname is registered. Please choose a different nickname'; then - printf 'identify %s\n' "${irc_password}" > \ - "${irc_dir}/nickserv/in" + printf 'identify %s\n' "${irc_password}" | \ + sponge "${irc_dir}/nickserv/in" fi # join #archlinux-ports if not yet done @@ -26,8 +26,8 @@ if ! grep ' buildmaster\.archlinux32\.org .* buildmaster$' "${irc_dir}/out" | \ { echo '/j #archlinux-ports' echo '/WHO buildmaster' - } > \ - "${irc_dir}/in" + } | \ + sponge "${irc_dir}/in" fi # start watch daemon if not running yet @@ -69,8 +69,8 @@ if [ "$1" = 'watch' ]; then echo "${reason}" | \ head -n5 printf '... (%s lines total)\n' "$(echo "${reason}" | wc -l)" - fi > \ - "${out_file%/out}/in" + fi | \ + sponge "${out_file%/out}/in" done sed -i "/${regex}/d" "${out_file}" fi diff --git a/bin/return-assignment b/bin/return-assignment index c504bf6..a2961f2 100755 --- a/bin/return-assignment +++ b/bin/return-assignment @@ -213,9 +213,8 @@ if [ "$5" = 'ERROR' ]; then sed 's/,$/./' fi printf '\n' - } | tee /dev/stderr > \ - "${irc_dir}/#archlinux-ports/in" - # why do we need tee there in order for the redirection to work??? + } | \ + sponge "${irc_dir}/#archlinux-ports/in" fi fi diff --git a/bin/sanity-check b/bin/sanity-check index 65ac5f3..8736d47 100755 --- a/bin/sanity-check +++ b/bin/sanity-check @@ -19,8 +19,8 @@ usage() { i_am_insane() { if [ ! -s "${work_dir}/build-master-sanity" ]; then - printf '\001ACTION goes insane.\001\n' > \ - "${irc_dir}/#archlinux-ports/in" + printf '\001ACTION goes insane.\001\n' | \ + sponge "${irc_dir}/#archlinux-ports/in" fi echo 'build master is insane' > \ "${work_dir}/build-master-sanity" @@ -398,6 +398,6 @@ done if [ -f "${work_dir}/build-master-sanity" ]; then rm "${work_dir}/build-master-sanity" - printf '\001ACTION resumes sanity.\001\n' > \ - "${irc_dir}/#archlinux-ports/in" + printf '\001ACTION resumes sanity.\001\n' | \ + sponge "${irc_dir}/#archlinux-ports/in" fi -- cgit v1.2.3-70-g09d2 From 09b5e8d6da292ceb6f9bb4a442d292f2e193330a Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 20:42:54 +0100 Subject: bin/seed-build-list: update database, too --- bin/seed-build-list | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'bin') diff --git a/bin/seed-build-list b/bin/seed-build-list index 78b29ba..acf25c3 100755 --- a/bin/seed-build-list +++ b/bin/seed-build-list @@ -284,6 +284,11 @@ if ${update}; then "${tmp_dir}/build-list.new" | \ tee -a "${work_dir}/build-list" + while read -r git_revision mod_git_revision repository pkgbase; do + mysql_generate_package_metadata "${pkgbase}" "${git_revision}" "${mod_git_revision}" "${repository}" + done < \ + "${tmp_dir}/build-list.new" + # Remove the lock file rm -f "${build_list_lock_file}" -- cgit v1.2.3-70-g09d2 From 14c4f3b1c5e69c903998068dcb8bb26f45a144a3 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Jan 2018 21:06:21 +0100 Subject: bin/return-assignment: zgrep the correct file - we prepended something! --- bin/return-assignment | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/return-assignment b/bin/return-assignment index a2961f2..a2b4c88 100755 --- a/bin/return-assignment +++ b/bin/return-assignment @@ -97,7 +97,7 @@ if [ "$5" = 'ERROR' ]; then for saved_build_log in ${saved_build_logs}; do printf '%s' "${fail_reason_identifiers}" | \ while read -r reason_id identifier; do - if zgrep -q "^$(printf '%s' "${identifier}" | base64 -d)\$" "${build_log_directory}/error/${saved_build_log}"; then + if zgrep -q "^$(printf '%s' "${identifier}" | base64 -d)\$" "${build_log_directory}/error/$1.$2.$3.$4.${saved_build_log}"; then printf ' (from_base64("%s"),%s,from_base64("%s")),' \ "$( printf '%s' "${saved_build_log}" | \ @@ -106,7 +106,7 @@ if [ "$5" = 'ERROR' ]; then )" \ "${reason_id}" \ "$( - printf '%s' "${saved_build_log}" | \ + printf '%s' "$1.$2.$3.$4.${saved_build_log}" | \ base64 -w0 )" break -- cgit v1.2.3-70-g09d2 From 9843dd27008a7ed749c4feffab76c7688035d49c Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 23 Jan 2018 08:42:04 +0100 Subject: bin/get-package-updates: fix typos --- bin/get-package-updates | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/get-package-updates b/bin/get-package-updates index 47c8824..5b8bcea 100755 --- a/bin/get-package-updates +++ b/bin/get-package-updates @@ -11,6 +11,8 @@ # TODO: mark loops in mysql database +# TODO: test_exclusion does not yet cooperate with the database + # shellcheck disable=SC2016 usage() { >&2 echo '' @@ -56,7 +58,7 @@ do -x|--test-exclusion) shift if [ -n "${test_exclusion}" ]; then - >&2 printf 'I already have --test-exlusion=%s and you gave me another one.\n' "${test_exclusion}" + >&2 printf 'I already have --test-exclusion=%s and you gave me another one.\n' "${test_exclusion}" >&2 printf 'But I can only handle one exclusion test at a time.\n' exit 2 fi -- cgit v1.2.3-70-g09d2 From c4bb6a739aa4887525535cdbe38edfb93aac2edb Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 23 Jan 2018 08:42:57 +0100 Subject: bin/get-package-updates: remove older versions of new build assignments from build- and deletion-list --- bin/get-package-updates | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'bin') diff --git a/bin/get-package-updates b/bin/get-package-updates index 5b8bcea..7c57e03 100755 --- a/bin/get-package-updates +++ b/bin/get-package-updates @@ -286,6 +286,24 @@ done | \ echo "${package} ${git_revision} ${new_repo_revisions__archlinux32} ${repository}" >> \ "${work_dir}/build-list.new" sed -i "/^$(str_to_regex "${package}")\$/d" "${work_dir}/deletion-list.new" + # shellcheck disable=SC2016 + { + # delete old build assignment and associated binary packages + # which are not yet build or on the deletion list + printf 'DELETE `build_assignments`,`binary_pacakges`' + printf ' FROM `binary_packages`' + printf ' JOIN `%s` ON `%s`.`id`=`%s`.`%s`' \ + 'build_assignments' 'build_assignments' 'binary_packages' 'build_assignment' \ + 'package_sources' 'package_sources' 'build_assignments' 'package_source' \ + 'repositories' 'repositories' 'binary_packages' 'repository' + printf ' WHERE `package_sources`.`pkgbase`=from_base64("%s")' \ + "$( + printf '%s' "${package}" | \ + base64 -w0 + )" + printf ' AND (`repositories`.`name`="build-list" OR `repositories`.`name`="deletion-list");\n' + } | \ + ${mysql_command} mysql_generate_package_metadata "${package}" "${git_revision}" "${new_repo_revisions__archlinux32}" "${repository}" continue fi -- cgit v1.2.3-70-g09d2 From ac83a4dc2c5f4dbb3310eba3651dd35e06fbd5f2 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 23 Jan 2018 08:46:50 +0100 Subject: bin/get-package-updates: fix typo in mysql query --- bin/get-package-updates | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/get-package-updates b/bin/get-package-updates index 7c57e03..801aadd 100755 --- a/bin/get-package-updates +++ b/bin/get-package-updates @@ -290,7 +290,7 @@ done | \ { # delete old build assignment and associated binary packages # which are not yet build or on the deletion list - printf 'DELETE `build_assignments`,`binary_pacakges`' + printf 'DELETE `build_assignments`,`binary_packages`' printf ' FROM `binary_packages`' printf ' JOIN `%s` ON `%s`.`id`=`%s`.`%s`' \ 'build_assignments' 'build_assignments' 'binary_packages' 'build_assignment' \ -- cgit v1.2.3-70-g09d2 From 6a6d23c6a2246007ae7a7c2b2f0b79c5d9056fb9 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 23 Jan 2018 09:28:08 +0100 Subject: bin/bootstrap-mysql: user "http" needs access, too --- bin/bootstrap-mysql | 3 +++ 1 file changed, 3 insertions(+) (limited to 'bin') diff --git a/bin/bootstrap-mysql b/bin/bootstrap-mysql index f67b779..343e64e 100755 --- a/bin/bootstrap-mysql +++ b/bin/bootstrap-mysql @@ -220,6 +220,9 @@ if [ ! "$1" = 'slim' ]; then 'SELECT' 'buildmaster.*' \ 'UPDATE' 'buildmaster.*' \ 'RELOAD' '*.*' + printf 'GRANT %s ON %s TO '"'"'http'"'"'@'"'"'localhost'"'"';\n' \ + 'SHOW VIEW' 'buildmaster.*' \ + 'SELECT' 'buildmaster.*' printf 'FLUSH PRIVILEGES;\n' } | \ mysql -u root -p buildmaster -- cgit v1.2.3-70-g09d2 From f0c0454a6ad998bc994d8fdaa0be47944fbed4b7 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 23 Jan 2018 09:30:41 +0100 Subject: bin/build-master-status-from-mysql: remove obsolete output --- bin/build-master-status-from-mysql | 27 --------------------------- 1 file changed, 27 deletions(-) (limited to 'bin') diff --git a/bin/build-master-status-from-mysql b/bin/build-master-status-from-mysql index 2ed9a24..a0c2b4f 100755 --- a/bin/build-master-status-from-mysql +++ b/bin/build-master-status-from-mysql @@ -5,33 +5,6 @@ # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" -# shellcheck disable=SC2016 -{ - printf 'SELECT `build_slaves`.`name`,`build_slaves`.`operator`,`package_sources`.`pkgbase`,`build_slaves`.`last_connection`' - printf ' FROM `build_slaves`' - printf ' LEFT JOIN `build_assignments` ON' - printf ' `build_slaves`.`currently_building`=`build_assignments`.`id`' - printf ' LEFT JOIN `package_sources` ON' - printf ' `build_assignments`.`package_source`=`package_sources`.`id`' - printf ' ORDER BY `build_slaves`.`last_connection`' -} | \ - ${mysql_command} --html | \ - sed ' - s,,\0\n,g - ' | \ - sed ' - \,$, { - s,pkgbase,currently building, - y,_, , - } - \,$, ! { - s,NULL,\ , - } - 1 i list of build slaves - $ a - ' | \ - sponge "${webserver_directory}/build-slaves.html" - { mysql_sanity_check || true { -- cgit v1.2.3-70-g09d2 From 80a82f28781f9d6723e39341a697c1be0e287a93 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 23 Jan 2018 10:33:49 +0100 Subject: bin/mysql-functions: new packages have is_blocked=NULL, not is_blocked=0 --- bin/mysql-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/mysql-functions b/bin/mysql-functions index 7347994..ec2bf4c 100755 --- a/bin/mysql-functions +++ b/bin/mysql-functions @@ -292,7 +292,7 @@ mysql_generate_package_metadata() { } | \ while read -r arch; do printf 'INSERT IGNORE INTO `build_assignments` (`package_source`,`architecture`,`is_blocked`)' - printf ' SELECT `package_sources`.`id`,`architectures`.`id`,0' + printf ' SELECT `package_sources`.`id`,`architectures`.`id`,NULL' printf ' FROM `architectures` JOIN `package_sources`' printf ' WHERE `architectures`.`name` = from_base64("%s")' \ "$( -- cgit v1.2.3-70-g09d2 From fa31b12beae5c7b6a157dd3c9c7b534975e3e3b2 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 23 Jan 2018 11:20:19 +0100 Subject: bin/bootstrap-mysql: mark blocked packages in database, too --- bin/bootstrap-mysql | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'bin') diff --git a/bin/bootstrap-mysql b/bin/bootstrap-mysql index 343e64e..2d56aad 100755 --- a/bin/bootstrap-mysql +++ b/bin/bootstrap-mysql @@ -458,6 +458,32 @@ tr ' ' '.' < \ mysql_generate_package_metadata "${state_file}" done +# shellcheck disable=SC2016 +find "${work_dir}/package-states" -name '*.blocked' -printf '%p %f\n' | \ + sed ' + s|\.\([^. ]\+\)\.\([^. ]\+\)\.\([^. ]\+\)\.blocked$| \1 \2 \3| + ' | \ + while read -r state_file pkgbase git_revision mod_git_revision repository; do + printf 'UPDATE `build_assignments`' + printf ' JOIN `%s` ON `%s`.`id`=`%s`.`%s`' \ + 'package_sources' 'package_sources' 'build_assignments' 'package_source' \ + 'upstream_repositories' 'upstream_repositories' 'package_sources' 'upstream_package_repository' + printf ' SET `build_assignments`.`is_blocked`=from_base64("%s")' \ + "$( + tr -d '\n' < \ + "${state_file}" | \ + base64 -w0 + )" + printf ' WHERE' + printf ' `package_sources`.`%s`=from_base64("%s") AND' \ + 'pkgbase' "$(printf '%s' "${pkgbase}" | base64 -w0)" \ + 'git_revision' "$(printf '%s' "${git_revision}" | base64 -w0)" \ + 'mod_git_revision' "$(printf '%s' "${mod_git_revision}" | base64 -w0)" + printf ' `upstream_repositories`.`name`=from_base64("%s");\n' \ + "$(printf '%s' "${repository}" | base64 -w0)" + done | \ + ${mysql_command} + grep '^\('"$( # shellcheck disable=SC2086 printf '%s\\|' ${standalone_package_repositories} ${stable_package_repositories} -- cgit v1.2.3-70-g09d2 From ef0f12279a548aa30e987a29732b82622d302422 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 23 Jan 2018 12:05:00 +0100 Subject: bin/return-assignment: fix multy-line output from mysql query --- bin/return-assignment | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/return-assignment b/bin/return-assignment index a2b4c88..2253986 100755 --- a/bin/return-assignment +++ b/bin/return-assignment @@ -87,17 +87,33 @@ if [ "$5" = 'ERROR' ]; then 'reason' 'SMALLINT' \ 'log_file' 'VARCHAR(512)' | \ sed 's/,$//' - printf ');' + printf ');\n' printf 'INSERT INTO `failures` (`date`,`reason`,`log_file`) VALUES' fail_reason_identifiers=$( - printf 'SELECT `fail_reasons`.`id`,to_base64(`fail_reasons`.`identifier`) FROM `fail_reasons` ORDER BY `fail_reasons`.`severity`' | \ + { + printf 'SELECT `fail_reasons`.`id`,to_base64(`fail_reasons`.`identifier`),"%%END%%"' + printf ' FROM `fail_reasons` ORDER BY `fail_reasons`.`severity`' + } | \ ${mysql_command} --raw --batch | \ - sed '1d' + sed ' + 1d + :start + s/\s%END%$// + t + N + s/\n//g + b start + ' ) for saved_build_log in ${saved_build_logs}; do printf '%s' "${fail_reason_identifiers}" | \ while read -r reason_id identifier; do - if zgrep -q "^$(printf '%s' "${identifier}" | base64 -d)\$" "${build_log_directory}/error/$1.$2.$3.$4.${saved_build_log}"; then + if zgrep -q "^$( + printf '%s' "${identifier}" | \ + base64 -d + )\$" \ + "${build_log_directory}/error/$1.$2.$3.$4.${saved_build_log}"; then + printf ' (from_base64("%s"),%s,from_base64("%s")),' \ "$( printf '%s' "${saved_build_log}" | \ -- cgit v1.2.3-70-g09d2 From 73127e25b97cd6230c0ab9b8a64af0db04c2d9e1 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 23 Jan 2018 12:10:51 +0100 Subject: bin/return-assignment: cleanup linebreakremovalmess --- bin/return-assignment | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'bin') diff --git a/bin/return-assignment b/bin/return-assignment index 2253986..cd6d30e 100755 --- a/bin/return-assignment +++ b/bin/return-assignment @@ -91,19 +91,11 @@ if [ "$5" = 'ERROR' ]; then printf 'INSERT INTO `failures` (`date`,`reason`,`log_file`) VALUES' fail_reason_identifiers=$( { - printf 'SELECT `fail_reasons`.`id`,to_base64(`fail_reasons`.`identifier`),"%%END%%"' + printf 'SELECT `fail_reasons`.`id`,replace(to_base64(`fail_reasons`.`identifier`),"\\n","")' printf ' FROM `fail_reasons` ORDER BY `fail_reasons`.`severity`' } | \ ${mysql_command} --raw --batch | \ - sed ' - 1d - :start - s/\s%END%$// - t - N - s/\n//g - b start - ' + sed '1d' ) for saved_build_log in ${saved_build_logs}; do printf '%s' "${fail_reason_identifiers}" | \ -- cgit v1.2.3-70-g09d2 From c6ef11b46979de123f55a7fa286c3e0cd59f0b56 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 23 Jan 2018 12:27:46 +0100 Subject: bin/bootstrap-mysql: add "unknown" build error type --- bin/bootstrap-mysql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/bootstrap-mysql b/bin/bootstrap-mysql index 2d56aad..46678f7 100755 --- a/bin/bootstrap-mysql +++ b/bin/bootstrap-mysql @@ -269,7 +269,11 @@ fi "$( printf '%s' '==> ERROR: Running makepkg as root is not allowed as it can cause permanent,.*' | \ base64 -w0 - )" 'run-as-root' 1 | \ + )" 'run-as-root' 1 \ + "$( + printf '.*' | \ + base64 -w0 + )" 'unknown' 100 | \ sed 's|,$||' printf ';\n' # shellcheck disable=SC2016 -- cgit v1.2.3-70-g09d2