Automatically creating mount parent directory in merge_debian_isos
This commit is contained in:
parent
f205e4294a
commit
9e79f64cae
@ -27,7 +27,9 @@ usage() {
|
||||
echo "xorriso will be run under sudo, if xorriso-dd-target agrees and" >&2
|
||||
echo 'the user confirms by input "yes".' >&2
|
||||
echo >&2
|
||||
echo "At least the parent directory of mount_template must already exist." >&2
|
||||
echo "At least the parent directory of mount_template must already exist" >&2
|
||||
echo 'or has to be given by a plain name without "/" so that it can be' >&2
|
||||
echo 'created in the current directory. (I.e. without even "./".)' >&2
|
||||
echo "All arguments must be single words without using quotation marks." >&2
|
||||
echo "None of the isoN must be equal to another isoM." >&2
|
||||
echo >&2
|
||||
@ -36,11 +38,16 @@ usage() {
|
||||
echo " ./merged_dists , ./merged_md5sum.txt , ./merged_REAMDE.txt" >&2
|
||||
echo " ./temp_file" >&2
|
||||
echo "Further it creates and finally removes directories mount_template*" >&2
|
||||
echo "if they are needed and do not exist when the script starts." >&2
|
||||
echo "It depends on the following programs:" >&2
|
||||
echo "if they are needed and do not exist when the script starts. If the" >&2
|
||||
echo "parent directory in the mount_template path does not exist and" >&2
|
||||
echo 'its path contains no "/" then it gets created and finally removed.' >&2
|
||||
echo "The script depends on the following programs:" >&2
|
||||
echo " awk, basename, cat, chmod, cp, date, dirname, expr, fgrep, grep," >&2
|
||||
echo " gunzip, gzip, head, ls, md5sum, mkdir, mount, mv, rm, rmdir," >&2
|
||||
echo " sed, sh, sha256sum, sort, stat, sudo, umount, uniq, xorriso" >&2
|
||||
echo "With device writing involving helper script xorriso-dd-target:" >&2
|
||||
echo " dd, Linux kernel, lsblk, sleep, tr, uname, wc, whoami," >&2
|
||||
echo " xorriso-dd-target" >&2
|
||||
echo "Recommended are: sha1sum, sha512sum" >&2
|
||||
echo >&2
|
||||
echo "Exported non-empty variable MERGE_DATE enforces a particular" >&2
|
||||
@ -59,29 +66,23 @@ usage() {
|
||||
echo >&2
|
||||
echo "Example using GNU xorriso-1.5.4 instead of /usr/bin/xorriso:" >&2
|
||||
echo " export XORRISO="'"$HOME"'"/xorriso-1.5.4/xorriso/xorriso" >&2
|
||||
echo " mkdir merge_mount" >&2
|
||||
echo " $(basename "$0") merged.iso merge_mount/iso "'\' >&2
|
||||
echo " debian-11.2.0-amd64-DVD-[12345].iso" >&2
|
||||
echo " rmdir merge_mount" >&2
|
||||
echo >&2
|
||||
echo "Example writing to optical drive /dev/sr0 :" >&2
|
||||
echo " mkdir merge_mount" >&2
|
||||
echo " $(basename "$0") mmc:/dev/sr0 merge_mount/iso "'\' >&2
|
||||
echo " debian-11.2.0-amd64-DVD-[12345].iso" >&2
|
||||
echo " rmdir merge_mount" >&2
|
||||
echo >&2
|
||||
echo \
|
||||
"Example on Linux writing to USB stick with xorriso-dd-target-plug-test:" >&2
|
||||
echo " wget https://dev.lovelyhq.com/libburnia/libisoburn/raw/master/xorriso-dd-target/xorriso-dd-target" >&2
|
||||
echo " chmod u+x xorriso-dd-target" >&2
|
||||
echo ' export XORRISO_DD_TARGET_PATH="$(pwd)"' >&2
|
||||
echo " mkdir merge_mount" >&2
|
||||
echo " $(basename "$0") xorriso-dd-target-plug-test merge_mount/iso "'\' >&2
|
||||
echo " debian-11.2.0-amd64-DVD-[12345].iso" >&2
|
||||
echo "This leads to the first two steps of the xorriso-dd-target device" >&2
|
||||
echo "plug dialog. See: https://wiki.debian.org/XorrisoDdTarget" >&2
|
||||
echo 'Finally input "yes" is required to authorize xorriso under sudo.' >&2
|
||||
echo " rmdir merge_mount" >&2
|
||||
}
|
||||
|
||||
check_single_word() {
|
||||
@ -520,12 +521,21 @@ fi
|
||||
MOUNT_TEMPLATE="$2"
|
||||
check_single_word "$2" "mount_template" || cleanup_and_end 1
|
||||
x=$(dirname "$MOUNT_TEMPLATE")
|
||||
mount_parent_to_make=
|
||||
mount_parent_made=
|
||||
if test -d "$x"
|
||||
then
|
||||
dummy=dummy
|
||||
else
|
||||
echo "--- The parent directory of '${MOUNT_TEMPLATE}' does not exist." >&2
|
||||
cleanup_and_end 1
|
||||
# The parent will be temporarily created only if it is a plain leaf name
|
||||
if echo " $x" | fgrep / >/dev/null
|
||||
then
|
||||
echo "--- The parent directory '${x}' of mount_template does not exist" \
|
||||
>&2
|
||||
echo "--- and contains a '/' character. Will not create it." >&2
|
||||
cleanup_and_end 1
|
||||
fi
|
||||
mount_parent_to_make="$x"
|
||||
fi
|
||||
|
||||
shift 2
|
||||
@ -575,6 +585,17 @@ echo "Arguments look acceptable." >&2
|
||||
echo >&2
|
||||
echo "Mounting ISO images if not yet mounted ..." >&2
|
||||
|
||||
if test -n "$mount_parent_to_make"
|
||||
then
|
||||
if mkdir "$mount_parent_to_make"
|
||||
then
|
||||
mount_parent_made="$mount_parent_to_make"
|
||||
else
|
||||
echo "--- Cannot create the parent directory of '${MOUNT_TEMPLATE}'." >&2
|
||||
cleanup_and_end 1
|
||||
fi
|
||||
fi
|
||||
|
||||
mount_count=0
|
||||
for i in $ISO_LIST
|
||||
do
|
||||
@ -630,6 +651,12 @@ do
|
||||
|
||||
MOUNT_LIST="$MOUNT_LIST $mount_point"
|
||||
done
|
||||
|
||||
if test -n "$mount_parent_made"
|
||||
then
|
||||
RMDIR_LIST="$RMDIR_LIST $mount_parent_made "
|
||||
fi
|
||||
|
||||
echo "Done." >&2
|
||||
|
||||
echo >&2
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user