summaryrefslogtreecommitdiffstats
path: root/files/reprepro/snapshots
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2016-05-23 11:17:28 +0000
committerintrigeri <intrigeri@boum.org>2016-05-23 11:17:28 +0000
commit34f2a13467a3db50bcba04eaf1111162066c4812 (patch)
tree953203c7e3df2d2fc945b7baaffe332eb60dc0bf /files/reprepro/snapshots
parentce026eaf2c39cd77bd096c1b1d3ea88df04a0d31 (diff)
Factorize echo + exit 1.
refs: #6299
Diffstat (limited to 'files/reprepro/snapshots')
-rwxr-xr-xfiles/reprepro/snapshots/time_based/tails-bump-apt-snapshot-valid-until17
1 files changed, 9 insertions, 8 deletions
diff --git a/files/reprepro/snapshots/time_based/tails-bump-apt-snapshot-valid-until b/files/reprepro/snapshots/time_based/tails-bump-apt-snapshot-valid-until
index 93145e8..6642886 100755
--- a/files/reprepro/snapshots/time_based/tails-bump-apt-snapshot-valid-until
+++ b/files/reprepro/snapshots/time_based/tails-bump-apt-snapshot-valid-until
@@ -2,9 +2,13 @@
set -e
set -u
+error() {
+ echo "$*" >&2
+ exit 1
+}
+
if [ $# -lt 3 ]; then
- echo "E: $0 archive serial days (not enough parameters)" >&2
- exit 1
+ error "E: $0 archive serial days (not enough parameters)"
fi
archive="$1"
@@ -12,8 +16,7 @@ serial="$2"
days="$3"
if [ ! -d "repositories/$archive" ]; then
- echo "E: archive $archive not found under repositories/" >&2
- exit 1
+ error "E: archive $archive not found under repositories/"
fi
# Make it valid for the specified amount of days:
@@ -22,14 +25,12 @@ validity=$(date --utc --rfc-2822 -d "now + $days days")
# Find snapshots for that serial for all suites (jessie, jessie/updates, etc.):
release_files=$(find "repositories/$archive/dists/" -wholename "*/snapshots/$serial/Release")
if [ -z "$release_files" ]; then
- echo "E: no Release files under snapshots/$serial, buggy serial?" >&2
- exit 1
+ error "E: no Release files under snapshots/$serial, buggy serial?"
fi
for release in $release_files; do
# Have a chance to detect we went too far (e.g. binary-amd64/Release):
if ! grep -qs ^Date: "$release"; then
- echo "Field 'Date' not found in Release file $release, aborting"
- exit 1
+ error "Field 'Date' not found in Release file $release, aborting"
fi
# Update field if present, add after Date otherwise: