Made adjustments in merge_debian_isos

master
Thomas Schmitt 5 months ago
parent bdc563a98b
commit 821628ae91
  1. 83
      test/merge_debian_isos
  2. BIN
      test/merge_debian_isos.sig

@ -24,7 +24,8 @@ usage() {
echo 'for which the user takes full and dangerous responsibility.' >&2
echo 'Special result_iso path "xorriso-dd-target-plug-test" determines' >&2
echo "on Linux the target USB stick by a dialog around plugging it in." >&2
echo "xorriso will be run under sudo, if xorriso-dd-target agrees." >&2
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 "All arguments must be single words without using quotation marks." >&2
@ -64,18 +65,22 @@ usage() {
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 " rmdir merge_mount" >&2
}
check_single_word() {
@ -113,6 +118,38 @@ check_single_word() {
return 0
}
XORRISO_DD_TARGET=xorriso-dd-target
XORRISO_STDIO_DEV=
XORRISO_SUDO=
XORRISO_BLANK_CMD=
XORRISO_STDIO_SYNC=off
confirm_xdt_device() {
# $1 : path of the device file in question
echo "$XORRISO_DD_TARGET agrees that this is a suitable device." >&2
echo >&2
echo \
"If you agree to xorriso running under sudo and overwriting the content" \
>&2
echo "of '${1}', then enter 'yes' :" >&2
answer=
read answer
if test "$answer" = yes
then
XORRISO_STDIO_DEV=stdio:
XORRISO_SUDO=sudo
XORRISO_BLANK_CMD="-blank as_needed"
XORRISO_STDIO_SYNC=16m
xorriso_rm_result_iso=0
echo "Will use sudo with xorriso and write to device." >&2
return 0
else
echo "--- Answer was not 'yes'. Will not write to device." >&2
fi
return 1
}
MOUNT_LIST=
UMOUNT_LIST=
RMDIR_LIST=
@ -317,7 +354,6 @@ then
exit 5
fi
XORRISO_DD_TARGET=
if test -z "$XORRISO_DD_TARGET_PATH"
then
XORRISO_DD_TARGET=xorriso-dd-target
@ -353,15 +389,10 @@ trap cleanup_for_exit EXIT
RESULT_ISO="$1"
check_single_word "$1" "result_iso" || cleanup_and_end 1
XORRISO_STDIO_DEV=
XORRISO_SUDO=
XORRISO_BLANK_CMD=
XORRISO_STDIO_SYNC=off
xorriso_rm_result_iso=1
if test "$RESULT_ISO" = xorriso-dd-target-plug-test
then
# Get device name from xorriso-dd-target
advice=NO
echo >&2
echo \
'Special result_iso path "xorriso-dd-target-plug-test" causes a run of' >&2
@ -370,7 +401,9 @@ then
echo "---------------------------------------------------------" >&2
plugged="$("$XORRISO_DD_TARGET" -with_sudo -plug_test)"
ret=$?
echo "$plugged" >&2
echo "---------------------------------------------------------" >&2
advice=NO
if test "$ret" = 0 && test -n "$plugged"
then
name="$(echo "$plugged" | awk '{print $1}')"
@ -378,13 +411,14 @@ then
fi
if test "$advice" = YES
then
RESULT_ISO=/dev/"$name"
XORRISO_STDIO_DEV=stdio:
XORRISO_SUDO=sudo
XORRISO_BLANK_CMD="-blank as_needed"
XORRISO_STDIO_SYNC=16m
xorriso_rm_result_iso=0
echo "Will use sudo with xorriso and write to ${RESULT_ISO}" >&2
if confirm_xdt_device /dev/"$name"
then
xorriso_rm_result_iso=0
RESULT_ISO=/dev/"$name"
echo "Actual target device path is '${RESULT_ISO}'" >&2
else
cleanup_and_end 1
fi
else
echo "--- No suitable device was determined." >&2
cleanup_and_end 1
@ -432,6 +466,7 @@ then
echo \
"Will try to overwrite the device content without sudo or pseudo-blanking." \
>&2
XORRISO_STDIO_SYNC=16m
else
echo "--- Answer was not 'yes'. Will not write to device." >&2
cleanup_and_end 1
@ -454,33 +489,23 @@ then
echo "---------------------------------------------------------" >&2
if test "$ret" = 0
then
echo "$XORRISO_DD_TARGET agrees that this is a suitable device." >&2
echo \
"If you agree to xorriso running under sudo and overwriting the content" \
>&2
echo "of '${RESULT_ISO}', then enter 'yes' :" >&2
answer=
read answer
if test "$answer" = yes
if confirm_xdt_device "$RESULT_ISO"
then
XORRISO_STDIO_DEV=stdio:
XORRISO_SUDO=sudo
XORRISO_BLANK_CMD="-blank as_needed"
XORRISO_STDIO_SYNC=16m
xorriso_rm_result_iso=0
echo "Will use sudo with xorriso and write to device." >&2
dummy=dummy
else
echo "--- Answer was not 'yes'. Will not write to device." >&2
cleanup_and_end 1
fi
else
echo \
"--- $XORRISO_DD_TARGET refuses to accept this device as result_iso" >&2
cleanup_and_end 1
fi
else
echo "--- Helper program $XORRISO_DD_TARGET is missing." >&2
echo \
"--- Cannot evaluate suitability of '${RESULT_ISO}' as result_iso path" \
>&2
cleanup_and_end 1
fi
fi
if test -z "$XORRISO_STDIO_DEV"

Binary file not shown.
Loading…
Cancel
Save