summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-03-01 09:05:51 +0100
committerErich Eckner <git@eckner.net>2018-03-01 09:05:51 +0100
commit496c571cd233a8646351ba241c3119ceaf2b8063 (patch)
tree3018e0a5a4ed78158c57a5b09d4b9e87fd3246d5
parent6047f2686cfe623e08fbaf4eae0a552ded731eb1 (diff)
downloadbuilder-496c571cd233a8646351ba241c3119ceaf2b8063.tar.xz
use "mysql -N" instead of cumbersome sedding
-rwxr-xr-xbin/build-master-status5
-rwxr-xr-xbin/build-master-status-from-mysql46
-rwxr-xr-xbin/check-bugtracker5
-rwxr-xr-xbin/copy-to-build-support7
-rwxr-xr-xbin/db-update14
-rwxr-xr-xbin/get-assignment16
-rwxr-xr-xbin/get-package-updates6
-rwxr-xr-xbin/modify-package-state3
-rwxr-xr-xbin/return-assignment20
-rwxr-xr-xbin/seed-build-list13
-rwxr-xr-xbin/show-dependencies3
-rwxr-xr-xbin/why-dont-you7
-rwxr-xr-xlib/common-functions7
-rwxr-xr-xlib/mysql-functions19
14 files changed, 51 insertions, 120 deletions
diff --git a/bin/build-master-status b/bin/build-master-status
index 9be7823..deb58da 100755
--- a/bin/build-master-status
+++ b/bin/build-master-status
@@ -562,10 +562,9 @@ if ${web}; then
# shellcheck disable=SC2016
{
printf 'SHOW CREATE TABLE `todos`' | \
- mysql_run_query --raw --batch | \
+ mysql_run_query -N --raw --batch | \
sed '
- 1d
- 2s/^\S\+\s\+CREATE TABLE `todos` /CREATE TEMPORARY TABLE `td` /
+ 1s/^\S\+\s\+CREATE TABLE `todos` /CREATE TEMPORARY TABLE `td` /
'
printf ';\n'
printf 'INSERT INTO `td` (`file`,`line`,`description`) VALUES '
diff --git a/bin/build-master-status-from-mysql b/bin/build-master-status-from-mysql
index fa54177..d1985e7 100755
--- a/bin/build-master-status-from-mysql
+++ b/bin/build-master-status-from-mysql
@@ -27,11 +27,8 @@ fi
mysql_join_binary_packages_repositories
printf ' WHERE `repositories`.`name`="build-list"'
} | \
- mysql_run_query --batch | \
- sed '
- 1d
- y/\t/ /
- ' | \
+ mysql_run_query -N --raw --batch | \
+ tr '\t' ' ' | \
sort > \
"${tmp_dir}/build-list.mysql"
sort "${work_dir}/build-list" > \
@@ -48,11 +45,8 @@ sort "${work_dir}/build-list" > \
mysql_join_build_assignments_package_sources
mysql_join_package_sources_upstream_repositories
} | \
- mysql_run_query --raw --batch | \
- sed '
- 1d
- y/\t/ /
- ' | \
+ mysql_run_query -N --raw --batch | \
+ tr '\t' ' ' | \
sort > \
"${tmp_dir}/locked.mysql"
find "${work_dir}/package-states" -mindepth 1 -maxdepth 1 -name '*.locked' -printf '%f\n' | \
@@ -72,11 +66,7 @@ find "${work_dir}/package-states" -mindepth 1 -maxdepth 1 -name '*.locked' -prin
printf ' WHERE `repositories`.`name`="deletion-list"'
printf ' OR `binary_packages`.`is_to_be_deleted`;\n'
} | \
- mysql_run_query --batch | \
- sed '
- 1d
- y/\t/ /
- ' | \
+ mysql_run_query -N --raw --batch | \
sort > \
"${tmp_dir}/deletion-list.mysql"
sort "${work_dir}/deletion-list" > \
@@ -90,11 +80,7 @@ sort "${work_dir}/deletion-list" > \
mysql_join_build_assignments_build_dependency_loops
printf ';\n'
} | \
- mysql_run_query --batch | \
- sed '
- 1d
- y/\t/ /
- ' | \
+ mysql_run_query -N --raw --batch | \
sort > \
"${tmp_dir}/loops.mysql"
find "${work_dir}/build-list.loops" -regextype grep -mindepth 1 -maxdepth 1 \
@@ -121,9 +107,8 @@ find "${work_dir}/build-list.loops" -regextype grep -mindepth 1 -maxdepth 1 \
printf ' AND NOT `binary_packages`.`has_issues`'
printf ' AND `repository_stabilities`.`name`="testing"'
} | \
- mysql_run_query --batch | \
+ mysql_run_query -N --raw --batch | \
sed '
- 1d
s/^\(\S\+\)\s\(\S\+\)\s\(\S\+\)\s\(\S\+\)\s\(\S\+\)\s\(\S\+\)$/\1-\2:\3-\4.\5-\6.pkg.tar.xz/
' | \
sort -u > \
@@ -156,9 +141,8 @@ find "${work_dir}/package-states" -mindepth 1 -maxdepth 1 \
printf ' AND NOT `binary_packages`.`has_issues`'
printf ' AND `repository_stabilities`.`name`="testing"'
} | \
- mysql_run_query --batch | \
+ mysql_run_query -N --raw --batch | \
sed '
- 1d
s/^\(\S\+\)\s\(\S\+\)\s\(\S\+\)\s\(\S\+\)\s\(\S\+\)\s\(\S\+\)$/\1-\2:\3-\4.\5-\6.pkg.tar.xz/
' | \
sort -u > \
@@ -190,11 +174,8 @@ find "${work_dir}/package-states" -mindepth 1 -maxdepth 1 \
mysql_join_package_sources_upstream_repositories
printf ' WHERE `dependency_types`.`relevant_for_building`'
} | \
- mysql_run_query --raw --batch | \
- sed '
- 1d
- y/\t/ /
- ' | \
+ mysql_run_query -N --raw --batch | \
+ tr '\t' ' ' | \
sort -u > \
"${tmp_dir}/build-dependencies.mysql"
{
@@ -210,11 +191,8 @@ find "${work_dir}/package-states" -mindepth 1 -maxdepth 1 \
mysql_join_package_sources_build_assignments
mysql_join_build_assignments_binary_packages
} | \
- mysql_run_query --raw --batch | \
- sed '
- 1d
- y/\t/ /
- ' | \
+ mysql_run_query -N --raw --batch | \
+ tr '\t' ' ' | \
while read -r pkgbase git_revision mod_git_revision repository; do
if [ -f "${work_dir}/package-infos/${pkgbase}.${git_revision}.${mod_git_revision}.${repository}.build-depends" ]; then
# TODO: consider versions dependencies, too
diff --git a/bin/check-bugtracker b/bin/check-bugtracker
index f15757b..156f438 100755
--- a/bin/check-bugtracker
+++ b/bin/check-bugtracker
@@ -26,8 +26,7 @@ bug_list=$(
printf ' FROM `repository_stabilities`'
printf ' WHERE NOT `repository_stabilities`.`bugtracker_category` IS NULL'
} | \
- mysql_run_query --raw --batch | \
- sed '1d' | \
+ mysql_run_query -N --raw --batch | \
while read -r stability_id category; do
for has_issues in '1:' '0:NOT '; do
printf 'UPDATE `binary_packages`'
@@ -61,5 +60,5 @@ bug_list=$(
tr '\n' ','
printf '"");\n'
done
- done | tee /dev/stderr | \
+ done | \
mysql_run_query
diff --git a/bin/copy-to-build-support b/bin/copy-to-build-support
index 0b87107..e447596 100755
--- a/bin/copy-to-build-support
+++ b/bin/copy-to-build-support
@@ -44,11 +44,8 @@ sed -n '
"$(printf '%s' "${architecture}" | base64 -w0)"
printf ' LIMIT 1;\n'
} | \
- mysql_run_query --raw --batch | \
- sed '
- 1d
- y/\t/ /
- '
+ mysql_run_query -N --raw --batch | \
+ tr '\t' ' '
)
if [ -z "${id}" ]; then
continue
diff --git a/bin/db-update b/bin/db-update
index 534c245..78ff622 100755
--- a/bin/db-update
+++ b/bin/db-update
@@ -457,11 +457,8 @@ errors=$(
printf ' JOIN `repository_stabilities` ON `repository_stability_relations`.`more_stable`=`repository_stabilities`.`id`'
printf ' WHERE `repository_stabilities`.`name` = "testing"'
} | \
- mysql_run_query --raw --batch | \
- sed '
- 1d
- p
- '
+ mysql_run_query -N --raw --batch | \
+ sed 'p'
# shellcheck disable=SC2086
printf '%s\n' ${packages_to_force_stabilize} | \
sort -u
@@ -496,11 +493,8 @@ errors=$(
printf ' JOIN `repository_stabilities` ON `repository_stability_relations`.`more_stable`=`repository_stabilities`.`id`'
printf ' WHERE `repository_stabilities`.`name` = "staging"'
} | \
- mysql_run_query --raw --batch | \
- sed '
- 1d
- p
- '
+ mysql_run_query -N --raw --batch | \
+ sed 'p'
# shellcheck disable=SC2086
printf '%s\n' ${packages_to_force_unstage} | \
sort -u
diff --git a/bin/get-assignment b/bin/get-assignment
index bc67fab..964c6b7 100755
--- a/bin/get-assignment
+++ b/bin/get-assignment
@@ -58,11 +58,8 @@ hand_out_assignment() {
"$(printf '%s' "$4" | base64 -w0)"
printf ' LIMIT 1;\n'
} | \
- mysql_run_query --raw --batch | \
- sed '
- 1d
- y/\t/ /
- '
+ mysql_run_query -N --raw --batch | \
+ tr '\t' ' '
{
# shellcheck disable=SC2154
@@ -157,8 +154,7 @@ currently_building=$(
printf ' AND `repositories`.`name`="build-list"'
printf ' LIMIT 1;\n'
} | \
- mysql_run_query --batch --raw | \
- sed '1d'
+ mysql_run_query -N --batch --raw
)
if [ -n "${currently_building}" ]; then
@@ -214,9 +210,8 @@ next_building=$(
printf ' ORDER BY `requested` DESC, `priority` DESC, `last_trial`, `part_of_loop`, `build_assignments`.`id`'
printf ' LIMIT 1;\n'
} | \
- mysql_run_query --batch --raw | \
+ mysql_run_query -N --batch --raw | \
sed '
- 1d
y/\t/ /
s/^.* \(\S\+\( \S\+\)\{3\}\)$/\1/
'
@@ -238,8 +233,7 @@ count_pending=$(
printf ' AND `build_assignments`.`is_blocked` IS NULL'
printf ';\n'
} | \
- mysql_run_query --batch --raw | \
- sed '1d'
+ mysql_run_query -N --batch --raw
)
if [ "${count_pending}" -eq 0 ]; then
diff --git a/bin/get-package-updates b/bin/get-package-updates
index 11f384c..e855b19 100755
--- a/bin/get-package-updates
+++ b/bin/get-package-updates
@@ -391,8 +391,7 @@ black_listed_new=$(
printf ' FROM `package_sources`'
printf ' WHERE `package_sources`.`pkgbase` LIKE "lib32-%%"'
} | \
- mysql_run_query --raw --batch | \
- sed '1d'
+ mysql_run_query -N --raw --batch
} | \
sort -u
)
@@ -443,8 +442,7 @@ while [ -n "${black_listed_new}" ]; do
printf ' WHERE `install_target_providers`.`install_target`=`dependencies`.`depending_on`'
printf ');\n'
} | \
- mysql_run_query --raw --batch | \
- sed '1d' | \
+ mysql_run_query -N --raw --batch | \
sort -u
} | \
grep -vxF '' | \
diff --git a/bin/modify-package-state b/bin/modify-package-state
index 8c5fac7..68b2384 100755
--- a/bin/modify-package-state
+++ b/bin/modify-package-state
@@ -225,8 +225,7 @@ while read -r package reason; do
;;
esac
if printf 'SELECT 1 FROM %s %s AND %s LIMIT 1' "${combiner}" "${selector}" "${tester}" | \
- mysql_run_query --raw --batch | \
- sed '1d' | \
+ mysql_run_query -N --raw --batch | \
grep -qxF '1'; then
# shellcheck disable=SC2016
{
diff --git a/bin/return-assignment b/bin/return-assignment
index ed29f34..a7e6623 100755
--- a/bin/return-assignment
+++ b/bin/return-assignment
@@ -70,11 +70,8 @@ if [ "$5" = 'ERROR' ]; then
"$(printf '%s' "$4" | base64 -w0)"
printf ' AND `repositories`.`name`="build-list"'
} | \
- mysql_run_query --raw --batch | \
- sed '
- 1d
- y/\t/ /
- '
+ mysql_run_query -N --raw --batch | \
+ tr '\t' ' '
)
if [ -z "${infos}" ]; then
>&2 echo 'You do not build this package (anymore) - move on.'
@@ -111,8 +108,7 @@ if [ "$5" = 'ERROR' ]; then
printf 'SELECT `fail_reasons`.`id`,replace(to_base64(`fail_reasons`.`identifier`),"\\n","")'
printf ' FROM `fail_reasons` ORDER BY `fail_reasons`.`severity`'
} | \
- mysql_run_query --raw --batch | \
- sed '1d'
+ mysql_run_query -N --raw --batch
)
for saved_build_log in ${saved_build_logs}; do
printf '%s' "${fail_reason_identifiers}" | \
@@ -283,9 +279,8 @@ if ! {
printf ' AND `binary_packages`.`sub_pkgrel`=from_base64("%s");\n' \
"$(printf '%s' "$5" | base64 -w0)"
} | \
- mysql_run_query --raw --batch | \
- sed '1d' | \
- grep -vxF '0'; then
+ mysql_run_query -N --raw --batch | \
+ grep -qvxF '0'; then
>&2 echo 'Sorry, the sent package is outdated.'
exit 2
fi
@@ -441,10 +436,7 @@ package_errors=$(
printf ' AND `repositories`.`name`="build-list"'
printf ';\n'
} | \
- mysql_run_query --raw --batch | \
- sed '
- 1d
- '
+ mysql_run_query -N --raw --batch
} | \
sort -k2 | \
uniq -u -f1
diff --git a/bin/seed-build-list b/bin/seed-build-list
index b9ae193..def9d56 100755
--- a/bin/seed-build-list
+++ b/bin/seed-build-list
@@ -125,9 +125,8 @@ if [ -s "${tmp_dir}/mirrors" ]; then
printf ' FROM `binary_packages`'
mysql_join_binary_packages_architectures
} | \
- mysql_run_query --raw --batch | \
+ mysql_run_query -N --raw --batch | \
sed '
- 1d
s/^\(.*\)-\([^-]\+-[^-]\+\)-\([^-]\+\)/ours \2 \3 \1/
'
} | \
@@ -206,8 +205,7 @@ printf 'CREATE TEMPORARY TABLE `pkgbases` (`pkgbase` VARCHAR(64), `repository` V
printf ' WHERE `ignore_packages`.`pkgname`=`must_haves`.`pkgname`'
printf ') AND NOT `must_haves`.`pkgname` LIKE "lib32-%%";\n'
} | \
- mysql_run_query --raw --batch | \
- sed '1d' | \
+ mysql_run_query -N --raw --batch | \
while read -r pkgname; do
content=$(
curl -Ss 'https://www.archlinux.org/packages/search/json/?name='"${pkgname}" | \
@@ -294,12 +292,9 @@ printf 'CREATE TEMPORARY TABLE `pkgbases` (`pkgbase` VARCHAR(64), `repository` V
printf ' WHERE `ignore_packages`.`pkgname`=`binary_packages`.`pkgname`'
printf ');\n'
} | \
- mysql_run_query --raw --batch | \
+ mysql_run_query -N --raw --batch | \
sort -u | \
- sed '
- y/\t/ /
- / [0-9a-f]\{40\} [0-9a-f]\{40\} /!d
- ' | \
+ tr '\t' ' ' | \
if ${update}; then
# always block if locked
exec 9> "${build_list_lock_file}"
diff --git a/bin/show-dependencies b/bin/show-dependencies
index 9e94fe3..ed7ca87 100755
--- a/bin/show-dependencies
+++ b/bin/show-dependencies
@@ -10,9 +10,8 @@
if [ $# -eq 0 ]; then
broken=$(
printf 'CALL show_broken_packages_and_dependencies;\n' | \
- mysql_run_query --raw --batch | \
+ mysql_run_query -N --raw --batch | \
sed '
- 1d
s/\s.*$//
' | \
sort -u
diff --git a/bin/why-dont-you b/bin/why-dont-you
index b5d73c5..35b9419 100755
--- a/bin/why-dont-you
+++ b/bin/why-dont-you
@@ -85,11 +85,8 @@ case "${action}" in
printf ' LEFT JOIN `build_slaves` ON `build_slaves`.`currently_building`=`to_build`.`ba_id`'
printf ';\n'
} | \
- mysql_run_query --raw --batch | \
- sed '
- 1d
- y/\t/ /
- ' | \
+ mysql_run_query -N --raw --batch | \
+ tr '\t' ' ' | \
sort -k7,7 -k6,6 -k5,5 | \
sed '
/ NULL \S\+$/ b multi-dep
diff --git a/lib/common-functions b/lib/common-functions
index 740c266..ba434ad 100755
--- a/lib/common-functions
+++ b/lib/common-functions
@@ -501,11 +501,8 @@ remove_old_package_versions() {
"$(printf '%s' "${repository}" | base64 -w0)"
printf ';\n'
} | \
- mysql_run_query --raw --batch | \
- sed '
- /^\S\+\sCONCAT(/d
- y/\t/ /
- ' | \
+ mysql_run_query -N --raw --batch | \
+ tr '\t' ' ' | \
expand_version 4 | \
sort -k4V,4 -k3r,3 | \
shrink_version 4 | \
diff --git a/lib/mysql-functions b/lib/mysql-functions
index 6cbc502..3e7e19f 100755
--- a/lib/mysql-functions
+++ b/lib/mysql-functions
@@ -668,9 +668,8 @@ mysql_sanity_check() {
'a' 'b'
printf ';\n'
} | \
- mysql_run_query --raw --batch | \
+ mysql_run_query -N --raw --batch | \
sed '
- /^CONCAT("/d
s,^,<font color="#FF0000">,
s,$,</font>,
'
@@ -699,9 +698,8 @@ mysql_sanity_check() {
mysql_join_binary_packages_repositories
printf ' WHERE `repositories`.`is_on_master_mirror`'
} | \
- mysql_run_query --batch | \
+ mysql_run_query -N --raw --batch | \
sed '
- 1d
s,\t,/,
s,\t,-,
s,\t,:,
@@ -730,11 +728,8 @@ mysql_find_build_assignment_loops() {
mysql_join_binary_packages_repositories 'packages_dependent' 'repositories_dependent'
printf ' WHERE `repositories_dependent`.`name`="build-list" AND `repositories_dependency`.`name`="build-list"'
} | \
- mysql_run_query --raw --batch | \
- sed '
- 1d
- y/\t/ /
- ' | \
+ mysql_run_query -N --raw --batch | \
+ tr '\t' ' ' | \
tsort 2>&1 >/dev/null | \
sed 's/^tsort:\s*//' | \
{
@@ -910,8 +905,7 @@ mysql_repair_binary_packages_without_build_assignment() {
mysql_join_binary_packages_architectures
printf ' WHERE `binary_packages`.`build_assignment`<0'
} | \
- mysql_run_query --raw --batch | \
- sed '1d' | \
+ mysql_run_query -N --raw --batch | \
while read -r id pkgname arch; do
pkgname=$(
printf '%s' "${pkgname}" | \
@@ -939,8 +933,7 @@ mysql_repair_binary_packages_without_build_assignment() {
printf ' WHERE `package_sources`.`pkgbase`=from_base64("%s")' \
"$(printf '%s' "${pkgname}" | base64 -w0)"
} | \
- mysql_run_query --raw --batch | \
- sed '1d' | \
+ mysql_run_query -N --raw --batch | \
grep -qvxF '0'; then
pkgbase="${pkgname}"
fi