aboutsummaryrefslogtreecommitdiff
path: root/brep/handler/submit/submit-pub.in
diff options
context:
space:
mode:
Diffstat (limited to 'brep/handler/submit/submit-pub.in')
-rw-r--r--brep/handler/submit/submit-pub.in29
1 files changed, 24 insertions, 5 deletions
diff --git a/brep/handler/submit/submit-pub.in b/brep/handler/submit/submit-pub.in
index ccb701d..42d478d 100644
--- a/brep/handler/submit/submit-pub.in
+++ b/brep/handler/submit/submit-pub.in
@@ -12,7 +12,7 @@
#
# Specifically, the handler performs the following steps:
#
-# - Lock the repository directory for the duraton of the package submission.
+# - Lock the repository directory for the duration of the package submission.
#
# - Check for the package duplicate.
#
@@ -85,7 +85,10 @@ verbose= #true
rep_lock_timeout=60
trap "{ exit 1; }" ERR
-set -o errtrace # Trap ERR in functions.
+set -o errtrace # Trap in functions and subshells.
+set -o pipefail # Fail if any pipeline command fails.
+shopt -s lastpipe # Execute last pipeline command in the current shell.
+shopt -s nullglob # Expand no-match globs to nothing rather than themselves.
@import brep/handler/handler@
@import brep/handler/submit/submit@
@@ -254,6 +257,8 @@ else
message_suffix=": $name/$version"
fi
+revision="$(version_revision "$version")"
+
# Open the reading file descriptor and lock the repository. Fail if unable to
# lock before timeout.
#
@@ -297,7 +302,7 @@ trap exit_trap EXIT
# Use <name>-<version>.* without .tar.gz in case we want to support more
# archive types later.
#
-IFS=$'\n' eval 'p=($(run pkg_find_archive "$name-$version.*" "$repo_old/1"))'
+run pkg_find_archive "$name-$version.*" "$repo_old/1" | readarray -t p
if [ "${#p[@]}" -ne 0 ]; then
n="${p[1]}"
@@ -327,8 +332,22 @@ run rsync -rtO --exclude 'packages.manifest' --link-dest="$repo_old" \
# Remove the package version revision archives that may exist in the
# repository.
#
-IFS=$'\n' eval \
-'arcs=($(run pkg_find_archives "$name" "$version*" "$repo_new/1"))'
+# But first check if the repository contains newer revision of this package
+# version. Respond with the 'newer revision is present' result manifest and
+# exit if that's the case.
+#
+run pkg_find_archives "$name" "$version*" "$repo_new/1" | readarray -t arcs
+
+for f in "${arcs[@]}"; do
+ pkg_verify_archive "$f" | readarray -t p
+
+ v="${p[1]}"
+ rv="$(version_revision "$v")"
+
+ if [ "$rv" -gt "$revision" ]; then
+ exit_with_manifest 422 "newer revision $name/$v is present"
+ fi
+done
for f in "${arcs[@]}"; do
run rm "$f"