summaryrefslogtreecommitdiff
path: root/archrelease.in
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2019-07-30 20:05:49 -0400
committerLevente Polyak <anthraxx@archlinux.org>2019-08-09 19:41:53 +0200
commit93dbb14ab9f99e0ac6077637e444e1662ff09bd5 (patch)
tree2a33405fc6aab162119a6c712544ecd039c2ea5e /archrelease.in
parent10c6efc440c732b70c1f11302777987cdf7e31de (diff)
downloaddevtools32-93dbb14ab9f99e0ac6077637e444e1662ff09bd5.tar.xz
archrelease: actually fail in failure conditions
When svn ls fails due to network timeouts, this currently results in archrelease deleting all files, then committing this as the changeset. This causes data loss... With bash 4.4 and using wait $! we can get return the return code of the last backgrounded command -- which process substitution qualifies as. Key off of this to make sure that `svn ls` actually succeeded. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
Diffstat (limited to 'archrelease.in')
-rw-r--r--archrelease.in15
1 files changed, 8 insertions, 7 deletions
diff --git a/archrelease.in b/archrelease.in
index 25379a7..491e68f 100644
--- a/archrelease.in
+++ b/archrelease.in
@@ -48,7 +48,8 @@ if [[ $(svn status -q) ]]; then
fi
pushd .. >/dev/null
-IFS=$'\n' read -r -d '' -a known_files < <(svn ls -r HEAD "$trunk")
+mapfile -t known_files < <(svn ls -r HEAD "$trunk")
+wait $! || die "failed to discover committed files"
for file in "${known_files[@]}"; do
if [[ ${file:(-1)} = '/' ]]; then
die "archrelease: subdirectories are not supported in package directories!"
@@ -65,12 +66,12 @@ for tag in "$@"; do
stat_busy "Copying %s to %s" "${trunk}" "${tag}"
if [[ -d repos/$tag ]]; then
- declare -a trash
- trash=()
- while read -r file; do
- trash+=("repos/$tag/$file")
- done < <(svn ls "repos/$tag")
- [[ ${#trash[@]} == 0 ]] || svn rm -q "${trash[@]/%/@}"
+ mapfile -t trash < <(svn ls "repos/$tag")
+ wait $! || die "failed to discover existing files"
+ if (( ${#trash[@]} )); then
+ trash=("${trash[@]/#/repos/$tag/}")
+ svn rm -q "${trash[@]/%/@}"
+ fi
else
mkdir -p "repos/$tag"
svn add --parents -q "repos/$tag"