From: Denys Vlasenko <dvlasenk(a)redhat.com>
redhat/scripts/expand_srpm.sh: add missing function, robustify
"die" (presumably a shell function) is not defined. Add it.
Delete the empty line at the end of the script,
git complained when I added a copy of this file to another tree.
This part will happily execute if someone just accidentally runs
the script from the command line with no arguments:
cd "$cloned/$PACKAGE_NAME"
rm -r -- *
...and might delete most of your files!
Add a safeguard against this.
While at it, remove superfluous stray semicolons.
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
diff --git a/redhat/scripts/expand_srpm.sh b/redhat/scripts/expand_srpm.sh
index blahblah..blahblah 100755
--- a/redhat/scripts/expand_srpm.sh
+++ b/redhat/scripts/expand_srpm.sh
@@ -1,9 +1,18 @@
#!/bin/sh
+die() {
+ echo "Error: $1" >&2
+ exit 1
+}
+
# $1: cloned tree
-cloned="$1";
+cloned="$1"
+
+# Avoid accidental "rm *" in the root directory
+test "$cloned" || die '$1 is not given'
+test "$SPECPACKAGE_NAME" || die '$SPECPACKAGE_NAME is not set'
-cd "$cloned/$SPECPACKAGE_NAME" || die "\"$cloned\" doesn't
seem to have a dist-git clone";
+cd "$cloned/$SPECPACKAGE_NAME" || die "\"$cloned\" doesn't
seem to have a dist-git clone"
# delete everything in the cloned tree to avoid having stale files
rm -r -- *
@@ -17,4 +26,3 @@ echo "*.bz2" >> .gitignore
rpm2cpio "$SRPM" | cpio -idmv
git add -A
-
--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2619