summaryrefslogtreecommitdiffstats
path: root/makemod
diff options
context:
space:
mode:
author Eric Hameleers <alien@slackware.com>2016-05-13 22:39:37 +0200
committer Eric Hameleers <alien@slackware.com>2016-05-13 22:39:37 +0200
commit749cfdc7f9a98fd9728fc2e6d628c59368b436ad (patch)
treed0ab24df763c986dfc048802f6f96ae2a62d8ae9 /makemod
parent548f8bed627ae726d66cdbf755261d9ebe06623e (diff)
downloadliveslak-749cfdc7f9a98fd9728fc2e6d628c59368b436ad.tar.gz
liveslak-749cfdc7f9a98fd9728fc2e6d628c59368b436ad.tar.xz
makemod: add interactive mode (-i switch) to prevent overwriting module file.
Default behaviour of makemod is to overwrite the destination squashfs module without asking. When adding the '-i' switch to the 'makemod' command, the script will ask explicitly whether it is allowed to overwrite an existing file. Also added is a '-h' switch which shows help on using the script. Bugfix: add "-noappend" to the squashfs command in the script to avoid adding new data to an existing squashfs module.
Diffstat (limited to '')
-rwxr-xr-xmakemod58
1 files changed, 55 insertions, 3 deletions
diff --git a/makemod b/makemod
index 4cc9c26..27ba575 100755
--- a/makemod
+++ b/makemod
@@ -2,10 +2,62 @@
# Create squashfs module from a directory or a Slackware package.
# Module can then be added to liveslak/addons directory.
+# By default, overwrite destination module file without asking if it pre-exists.
+INTERACTIVE=NO
+
+function help() {
+ cat <<EOH
+
+-- Usage:
+ $(basename $0) [-i] <packagename|directory> modulename.sxz
+-- Option parameters:
+ h : This help.
+ i : Interactive mode will not overwrite destination file by default.
+-- Description:
+ The first parameter is either the full path to a Slackware package,
+ or else a directory.
+ If a packagename is supplied as first parameter, it will be installed
+ into a temporary directory using Slackware's "installpkg".
+ The content of the temporary directory will be squashed into a module
+ by the "squashfs" program.
+ If a directoryname is supplied, its content will be squashed into
+ a module by the "squashfs" program.
+ The second parameter is the full pathname of the output module
+ which will be created.
+
+EOH
+}
+
+# Option parsing:
+while getopts "hi" Option
+do
+ case $Option in
+ h ) help; exit
+ ;;
+ i ) INTERACTIVE="YES"
+ ;;
+ * ) help; exit
+ ;; # DEFAULT
+ esac
+done
+shift $(($OPTIND - 1))
+# End of option parsing.
+# $1 now references the first non option item supplied on the command line
+# ---------------------------------------------------------------------------
+
+# Input check:
if [ "x$1" = "x" ]; then
- echo "-- Usage:"
- echo " $(basename $0) <packagename|directory> modulename.sxz"
+ help
+ exit 1
+elif [ "x$2" = "x" ]; then
+ help
exit 1
+elif [ -f "$2" -a "$INTERACTIVE" = "YES" ]; then
+ read -p "-- Destination file '$2' already exists. Overwrite Y/N (y): " ANSWER
+ if [ "x$ANSWER" = "xN" -o "x$ANSWER" = "xn" ]; then
+ echo "-- Aborting now."
+ exit
+ fi
fi
# .sxz extension uses xz compression:
@@ -37,7 +89,7 @@ else
fi
fi
-mksquashfs "${PKGDIR}" "$2" -comp ${COMPR} -b 256K $3 $4 $5 $6 $7 $8 $9
+mksquashfs "${PKGDIR}" "$2" -noappend -comp ${COMPR} -b 256K $3 $4 $5 $6 $7 $8 $9
if [ $? -ne 0 ]; then
echo "-- Error creating squashfs compressed module"
exit 1