summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-06-14 16:11:08 +0200
committerErich Eckner <git@eckner.net>2017-06-14 16:11:08 +0200
commit6c9ef1ccaca1763d6a9e46c71ed9c67f6139c5bc (patch)
treee1d1bf6f08fc8d0c6486bed5590fda3d1f9b3946
parentf25f9462a68a968a676d555613cdfa6e7516cad1 (diff)
downloadbuilder-6c9ef1ccaca1763d6a9e46c71ed9c67f6139c5bc.tar.xz
remove bashisms - only "bash arrays" and "bash string substituions" left
-rwxr-xr-xbin/build-master-status18
-rwxr-xr-xbin/build-packages24
-rwxr-xr-xbin/common-functions23
-rwxr-xr-xbin/db-update14
-rwxr-xr-xbin/get-assignment4
-rwxr-xr-xbin/get-package-updates26
-rwxr-xr-xbin/return-assignment15
-rwxr-xr-xbin/slave-build-connect4
-rwxr-xr-xconf/default.conf6
9 files changed, 88 insertions, 46 deletions
diff --git a/bin/build-master-status b/bin/build-master-status
index 85e65f7..ba1dba3 100755
--- a/bin/build-master-status
+++ b/bin/build-master-status
@@ -48,9 +48,9 @@ looped_packages="$(
printf 'The mirror master contains %d stable packages (vs. ca. %d planned).\n' \
"${stable}" \
- "$[${staging}+${testing}+${pending_packages}]"
+ "$((${staging}+${testing}+${pending_packages}))"
printf 'The build list contains %d tasks (incl. broken: %d, leading to %d packages).\n' \
- "$[${tasks}-${broken}]" \
+ "$((${tasks}-${broken}))" \
"${tasks}" \
"${pending_packages}"
printf 'There are %d testing and %d staging packages.\n' \
@@ -63,11 +63,17 @@ if [ "${loops}" -ne 0 ]; then
"${loops}" \
"${looped_packages}"
fi
-if [ $[${broken}+${testing}+${staging}] -ne 0 ]; then
+if [ $((${broken}+${testing}+${staging})) -ne 0 ]; then
printf '%.1f%% of all packages are broken.\n' \
- "$(bc <<< "scale=10; 100*${broken}/(${broken}+${testing}+${staging})")"
+ "$(
+ echo "scale=10; 100*${broken}/(${broken}+${testing}+${staging})" | \
+ bc
+ )"
fi
-if [ $[${testing}+${staging}+${pending_packages}-${broken}] -ne 0 ]; then
+if [ $((${testing}+${staging}+${pending_packages}-${broken})) -ne 0 ]; then
printf '%.1f%% of the planned work has been done.\n' \
- "$(bc <<< "scale=10; 100*(${testing}+${staging})/(${testing}+${staging}+${pending_packages}-${broken})")"
+ "$(
+ echo "scale=10; 100*(${testing}+${staging})/(${testing}+${staging}+${pending_packages}-${broken})" | \
+ bc
+ )"
fi
diff --git a/bin/build-packages b/bin/build-packages
index c054f87..4130738 100755
--- a/bin/build-packages
+++ b/bin/build-packages
@@ -63,7 +63,7 @@ do
;;
*)
>&2 echo 'Whoops, forgot to implement option "'"$1"'" internally.'
- exit -1
+ exit 42
;;
esac
shift
@@ -83,7 +83,7 @@ if [ -z "${count}" ]; then
fi
if [ ${timeout} -ne 0 ]; then
- timeout=$[${timeout}+$(date +%s)]
+ timeout=$((${timeout}+$(date +%s)))
fi
while [ ${count} -ne 0 ]; do
@@ -107,7 +107,7 @@ while [ ${count} -ne 0 ]; do
# 0: ok, I gave you an assignment
0)
[ ${count} -gt 0 ] && \
- count=$[${count}-1]
+ count=$((${count}-1))
repository="${package##* }"
package="${package% *}"
mod_git_revision="${package##* }"
@@ -124,8 +124,8 @@ while [ ${count} -ne 0 ]; do
git -C "${repo}" pull || true
done
- git -C "${repo_paths["$(find_repository_with_commit "${git_revision}")"]}" checkout "${git_revision}" &> /dev/null
- git -C "${repo_paths["archlinux32"]}" checkout "${mod_git_revision}" &> /dev/null
+ git -C "${repo_paths["$(find_repository_with_commit "${git_revision}")"]}" checkout "${git_revision}" > /dev/null 2>&1
+ git -C "${repo_paths["archlinux32"]}" checkout "${mod_git_revision}" > /dev/null 2>&1
PKGBUILD="$(find_pkgbuild "${package}" "${repository}")"
@@ -172,7 +172,7 @@ while [ ${count} -ne 0 ]; do
fi
for parameters in '' '-c'; do
- rm -f *.pkg.tar.xz{,.sig}
+ rm -f *".pkg.tar.xz" *".pkg.tar.xz.sig"
if staging-i686-build ${parameters} -- archlinux32-keyring; then
# build successful
ls -1 *.pkg.tar.xz | \
@@ -198,18 +198,18 @@ while [ ${count} -ne 0 ]; do
;;
1)
# 'return-assignment' was running already
- sleep $[15+$RANDOM%30]
+ wait_some_time 15
;;
2)
>&2 echo 'I was too slow, the package is outdated. I will continue ...'
break
;;
3)
- >& echo "'return-assignment' reports a signature error."
+ >&2 echo "'return-assignment' reports a signature error."
exit 1
;;
4)
- >& echo "'return-assignment' reports too many or missing packages."
+ >&2 echo "'return-assignment' reports too many or missing packages."
exit 1
;;
*)
@@ -232,7 +232,7 @@ while [ ${count} -ne 0 ]; do
-p "${master_build_server_port}" \
"${master_build_server_user}@${master_build_server}" \
'return-assignment' "${package}" "${git_revision}" "${mod_git_revision}" "${repository}" 'ERROR'; do
- sleep $[15+$RANDOM%30]
+ wait_some_time 15
done
if ${exit_after_failure}; then
>&2 echo 'Build failed, exiting now'
@@ -246,14 +246,14 @@ while [ ${count} -ne 0 ]; do
# 1: come back (shortly) later - I was running already
1)
- sleep $[15+$RANDOM%30]
+ wait_some_time 15
continue
;;
# 2: come back later - there are still packages to be built,
# but currently none has all its dependencies ready
2)
- sleep $[60+$RANDOM%30]
+ wait_some_time 60
continue
;;
diff --git a/bin/common-functions b/bin/common-functions
index d954a36..c3301f0 100755
--- a/bin/common-functions
+++ b/bin/common-functions
@@ -23,7 +23,7 @@ find_pkgbuild() {
fi
for repo in "${!repo_paths[@]}"; do
- if [ "${repo}" == "archlinux32" ]; then
+ if [ "${repo}" = "archlinux32" ]; then
# this is not a repository of packages
continue
fi
@@ -112,7 +112,7 @@ find_git_repository_to_package_repository() {
local repository
for repository in "${!repo_paths[@]}"; do
- if [ "${repository}" == "archlinux32" ]; then
+ if [ "${repository}" = "archlinux32" ]; then
continue
fi
if [ -n "$(
@@ -304,3 +304,22 @@ remove_old_package_versions() {
xargs -rn1 rm
}
+
+# wait_some_time $minimum $maximum-$minimum
+wait_some_time() {
+ local minimum=$1
+ local diff=$2
+ local random
+
+ if [ -z "${diff}" ]; then
+ diff=30
+ fi
+
+ random="$(
+ dd if='/dev/urandom' count=1 2> /dev/null | \
+ cksum | \
+ cut -d' ' -f1
+ )"
+
+ sleep $((${minimum} + ${random} % ${diff}))
+}
diff --git a/bin/db-update b/bin/db-update
index 7e95460..57c8111 100755
--- a/bin/db-update
+++ b/bin/db-update
@@ -53,7 +53,7 @@ do
;;
*)
>&2 echo 'Whoops, forgot to implement option "'"$1"'" internally.'
- exit -1
+ exit 42
;;
esac
shift
@@ -85,7 +85,7 @@ if ! flock ${block_flag} 8; then
exit 1
fi
-function clean_up_lock_file {
+clean_up_lock_file() {
rm -f "${package_database_lock_file}" "${build_list_lock_file}"
}
@@ -183,7 +183,7 @@ done
rm -f "${build_list_lock_file}"
flock -u 9
-function clean_up_lock_file {
+clean_up_lock_file() {
rm -f "${package_database_lock_file}"
}
@@ -217,7 +217,7 @@ for package in ${done_packages}; do
mkdir -p "../${is_community}testing"
repo-remove "${is_community}staging.db.tar.gz" "${parts_names[@]}"
for part in "${parts[@]}"; do
- mv "${part}"{,.sig} "../${is_community}testing/"
+ mv "${part}" "${part}.sig" "../${is_community}testing/"
updated_package_database=true
done
popd > /dev/null
@@ -228,7 +228,9 @@ for package in ${done_packages}; do
done
popd > /dev/null
- mv "${work_dir}/package-states/${package}."{done,testing}
+ mv \
+ "${work_dir}/package-states/${package}.done" \
+ "${work_dir}/package-states/${package}.testing"
done
# move packages in packages_to_stabilize from *testing/ to the stable repos
@@ -245,7 +247,7 @@ for package in "${packages_to_stabilize[@]}"; do
pushd "${master_mirror_directory}/i686/${source}" > /dev/null
repo-remove "${source}.db.tar.gz" "${parts_names[@]}"
for part in "${parts[@]}"; do
- mv "${part}"{,.sig} "../${destination}/"
+ mv "${part}" "${part}.sig" "../${destination}/"
updated_package_database=true
done
popd > /dev/null
diff --git a/bin/get-assignment b/bin/get-assignment
index 250a4f9..7b0a5da 100755
--- a/bin/get-assignment
+++ b/bin/get-assignment
@@ -57,7 +57,7 @@ if ! flock -n 9; then
exit 1
fi
-function clean_up {
+clean_up() {
rm -f "${build_list_lock_file}"
}
@@ -79,7 +79,7 @@ while read -r package git_revision mod_git_revision repository; do
if [ -f "${work_dir}/package-states/${package}.${git_revision}.${mod_git_revision}.${repository}.locked" ];
then
if [ "${slave}" = "$(head -n1 "${work_dir}/package-states/${package}.${git_revision}.${mod_git_revision}.${repository}.locked")" ]; then
- num_jobs=$[${num_jobs}+1];
+ num_jobs=$((${num_jobs}+1));
fi
else
pending_packages=true
diff --git a/bin/get-package-updates b/bin/get-package-updates
index 1db1ba0..09f2958 100755
--- a/bin/get-package-updates
+++ b/bin/get-package-updates
@@ -55,7 +55,7 @@ do
;;
*)
>&2 echo 'Whoops, forgot to implement option "'"$1"'" internally.'
- exit -1
+ exit 42
;;
esac
shift
@@ -118,13 +118,17 @@ echo 'Check modified packages from the last update, and put them to the build li
# If a package is deleted, remove from the rebuild list, and add it to the deletion list.
# If a new package is added, then ensure that it's not on the deletion list.
-cp "${work_dir}/build-list"{,.new}
-cp "${work_dir}/deletion-list"{,.new}
+cp \
+ "${work_dir}/build-list" \
+ "${work_dir}/build-list.new"
+cp \
+ "${work_dir}/deletion-list" \
+ "${work_dir}/deletion-list.new"
for repo in "${!repo_paths[@]}"; do
(
# if old revision unknown, mimic "git diff"-output
- if [ "${old_repo_revisions["${repo}"]}" == "NONE" ]; then
+ if [ "${old_repo_revisions["${repo}"]}" = "NONE" ]; then
git -C "${repo_paths["${repo}"]}" archive --format=tar HEAD | \
tar -t | \
sed 's|^|A\t|'
@@ -134,7 +138,7 @@ for repo in "${!repo_paths[@]}"; do
) | \
# only track changes in PKGBUILDs
grep '/PKGBUILD$' | \
- if [ "${repo}" == "archlinux32" ]; then
+ if [ "${repo}" = "archlinux32" ]; then
# modify the directory structure from the modifiaction-repository
# to the one of an original source repository
sed 's|^\(.\t\)\([^/]\+\)/\([^/]\+\)/\(.\+\)$|\2 \1\3/repos/\2-x86_64/\4|' | \
@@ -179,7 +183,9 @@ done | \
sort -u "${work_dir}/deletion-list.new" > \
"${work_dir}/deletion-list.new.new"
-mv "${work_dir}/deletion-list.new"{.new,}
+mv \
+ "${work_dir}/deletion-list.new.new" \
+ "${work_dir}/deletion-list.new"
echo 'Extract dependencies of packages.'
@@ -240,7 +246,9 @@ echo "${black_listed}" | \
sort -u "${work_dir}/deletion-list.new" > \
"${work_dir}/deletion-list.new.new"
-mv "${work_dir}/deletion-list.new"{.new,}
+mv \
+ "${work_dir}/deletion-list.new.new" \
+ "${work_dir}/deletion-list.new"
# Now we create the partial order.
@@ -303,7 +311,9 @@ if [ -s "${work_dir}/tsort.error" ]; then
sort | \
uniq -d > \
"${work_dir}/build-list.loops.new/${loop}.new"
- mv "${work_dir}/build-list.loops.new/${loop}"{.new,}
+ mv \
+ "${work_dir}/build-list.loops.new/${loop}.new" \
+ "${work_dir}/build-list.loops.new/${loop}"
done
else
diff --git a/bin/return-assignment b/bin/return-assignment
index 9fd6591..715a896 100755
--- a/bin/return-assignment
+++ b/bin/return-assignment
@@ -32,14 +32,14 @@ if ! flock -n 8; then
exit 1
fi
-function clean_up_lock_file {
+clean_up_lock_file() {
rm -f "${build_list_lock_file}"
rm -f "${package_database_lock_file}"
}
trap clean_up_lock_file EXIT
-if [ "$5" == 'ERROR' ]; then
+if [ "$5" = 'ERROR' ]; then
# the build failed on the build slave
if [ ! -f "${work_dir}/package-states/$1.$2.$3.$4.locked" ]; then
@@ -47,7 +47,9 @@ if [ "$5" == 'ERROR' ]; then
exit 0
fi
- mv "${work_dir}/package-states/$1.$2.$3.$4."{locked,broken}
+ mv \
+ "${work_dir}/package-states/$1.$2.$3.$4.locked" \
+ "${work_dir}/package-states/$1.$2.$3.$4.broken"
# unlock every loop this package would have broken and which is not
# broken by another locked package
@@ -83,7 +85,7 @@ if ! grep -q "^${1//./\\.} $2 $3 $4\$" "${work_dir}/build-list" ||
exit 2
fi
-function clean_up_tmp_dir {
+clean_up_tmp_dir() {
popd > /dev/null
rm -rf --one-file-system "${tmp_dir}"
clean_up_lock_file
@@ -138,7 +140,10 @@ fi
destination="$(official_or_community "$1.$2.$3.$4")staging"
mkdir -p "${master_mirror_directory}/i686/${destination}/"
-mv *.pkg.tar.xz{,.sig} "${master_mirror_directory}/i686/${destination}/"
+mv \
+ *".pkg.tar.xz" \
+ *".pkg.tar.xz.sig" \
+ "${master_mirror_directory}/i686/${destination}/"
(
cd "${master_mirror_directory}/i686/${destination}"
diff --git a/bin/slave-build-connect b/bin/slave-build-connect
index c024386..930fdd9 100755
--- a/bin/slave-build-connect
+++ b/bin/slave-build-connect
@@ -2,8 +2,8 @@
. "${0%/*}/../conf/default.conf"
-if [ "${SSH_ORIGINAL_COMMAND%% *}" == "get-assignment" ] || \
- [ "${SSH_ORIGINAL_COMMAND%% *}" == "return-assignment" ]; then
+if [ "${SSH_ORIGINAL_COMMAND%% *}" = "get-assignment" ] || \
+ [ "${SSH_ORIGINAL_COMMAND%% *}" = "return-assignment" ]; then
slave="$1" /bin/bash -c "${base_dir}/bin/${SSH_ORIGINAL_COMMAND}"
else
>&2 echo "Invalid command: '${SSH_ORIGINAL_COMMAND%% *}'"
diff --git a/conf/default.conf b/conf/default.conf
index 947196f..1f75bd9 100755
--- a/conf/default.conf
+++ b/conf/default.conf
@@ -6,7 +6,7 @@ set -e
export LANG=C
# dirty hack to get this stuff debugable from a bash
-if [ "x$0" == "x-bash" ] || [ "x$0" == "xbash" ]; then
+if [ "x$0" = "x-bash" ] || [ "x$0" = "xbash" ]; then
base_dir="$(pwd)"
else
base_dir="$(dirname "$(readlink -f "$0")")/.."
@@ -56,7 +56,7 @@ for repo in "${!repo_paths[@]}"; do
mkdir -p "${repo_paths["${repo}"]%/*}"
if [ ! -d "${repo_paths["${repo}"]}/.git" ]; then
- if [ "${repo}" == "archlinux32" ]; then
+ if [ "${repo}" = "archlinux32" ]; then
repo_source='git@github.com:archlinux32/packages.git'
else
repo_source="git://git.archlinux.org/svntogit/${repo}.git"
@@ -66,7 +66,7 @@ for repo in "${!repo_paths[@]}"; do
done
-if [ "${master_build_server_identity}" == "${work_dir}/.ssh/id_rsa" ] && \
+if [ "${master_build_server_identity}" = "${work_dir}/.ssh/id_rsa" ] && \
[ ! -f "${master_build_server_identity}" ]; then
mkdir -p "${master_build_server_identity%/*}"
ssh-keygen -b4096 -f "${master_build_server_identity}"