2011-07-11 09:24:57 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2011-07-11 09:40:23 +00:00
|
|
|
# Copyright 2011 George Danchev <danchev@spnet.net>
|
2011-07-15 06:08:29 +00:00
|
|
|
# Copyright 2011 Thomas Schmitt <scdbackup@gmx.net>
|
|
|
|
# Licensed under GNU GPL version 2 or later
|
2011-07-11 09:40:23 +00:00
|
|
|
|
2011-07-11 09:24:57 +00:00
|
|
|
# set -e
|
|
|
|
|
2011-07-15 06:08:29 +00:00
|
|
|
print_specific_help() {
|
2011-07-20 12:23:40 +00:00
|
|
|
cat << HLP
|
|
|
|
Specific options:
|
|
|
|
--dev path Suppress dialog and use path as drive address.
|
2011-08-11 16:47:51 +00:00
|
|
|
--priv_cmd 'command [arg [arg ...]]'
|
|
|
|
With drive operations execute xorriso as argument
|
|
|
|
of the given command (e.g. pfexec, sudo) with the
|
|
|
|
optionally given arguments: command arg arg xorriso ...
|
|
|
|
Command and arguments must be single words.
|
2011-07-20 12:23:40 +00:00
|
|
|
Overview:
|
|
|
|
Test device scanning and list of speeds.
|
|
|
|
HLP
|
2011-07-13 11:24:32 +00:00
|
|
|
}
|
|
|
|
|
2011-07-15 06:08:29 +00:00
|
|
|
# Include common bits and interpret general options
|
2011-07-15 10:26:26 +00:00
|
|
|
getopts_inc=inc/releng_getopts.inc
|
2011-07-15 06:08:29 +00:00
|
|
|
if test -e "$getopts_inc"
|
|
|
|
then
|
|
|
|
. "$getopts_inc"
|
|
|
|
|
2011-07-18 17:22:59 +00:00
|
|
|
if test "$SPECIFIC_HELP" = 1
|
2011-07-15 06:08:29 +00:00
|
|
|
then
|
|
|
|
print_specific_help
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo >&2
|
|
|
|
echo "File not found: $getopts_inc" >&2
|
|
|
|
echo "Are we in the ./releng directory of a libisoburn SVN checkout ?" >&2
|
|
|
|
echo "(Please execute the tests from that ./releng directory.)" >&2
|
|
|
|
echo >&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Interpret private options, they begin after the first --.
|
|
|
|
dev=
|
2011-08-11 16:47:51 +00:00
|
|
|
priv_cmd=
|
2011-07-15 06:08:29 +00:00
|
|
|
next_is=ignore
|
|
|
|
for i in "$@"
|
|
|
|
do
|
|
|
|
if test "$next_is" = "ignore"
|
|
|
|
then
|
|
|
|
if test "$i" = "--"
|
|
|
|
then
|
|
|
|
next_is=""
|
|
|
|
fi
|
|
|
|
elif test "$next_is" = "dev"
|
|
|
|
then
|
|
|
|
dev="$i"
|
|
|
|
next_is=""
|
2011-08-11 16:47:51 +00:00
|
|
|
elif test "$next_is" = "priv_cmd"
|
|
|
|
then
|
|
|
|
priv_cmd="$i"
|
|
|
|
next_is=""
|
2011-07-15 06:08:29 +00:00
|
|
|
elif test "$i" = "--dev"
|
|
|
|
then
|
|
|
|
next_is="dev"
|
2011-08-11 16:47:51 +00:00
|
|
|
elif test "$i" = "--priv_cmd"
|
|
|
|
then
|
|
|
|
next_is="priv_cmd"
|
2011-07-15 06:08:29 +00:00
|
|
|
else
|
|
|
|
echo >&2
|
|
|
|
echo "Unknown test specific option: $i" >&2
|
|
|
|
print_help
|
|
|
|
print_specific_help
|
|
|
|
exit 31
|
|
|
|
fi
|
|
|
|
done
|
2011-07-11 09:24:57 +00:00
|
|
|
|
2011-07-15 06:08:29 +00:00
|
|
|
# Insist in having a xorriso
|
2011-07-15 11:30:30 +00:00
|
|
|
check_for_xorriso -x
|
2011-07-11 09:24:57 +00:00
|
|
|
|
2011-07-27 21:43:24 +00:00
|
|
|
has_device_links=$("$RELENG_XORRISO" -help 2>/dev/null | fgrep ' -device_links')
|
|
|
|
if test -n "$has_device_links"
|
|
|
|
then
|
|
|
|
devices_opt="-device_links"
|
|
|
|
else
|
|
|
|
devices_opt="-devices"
|
|
|
|
fi
|
|
|
|
|
2011-07-11 09:24:57 +00:00
|
|
|
#
|
|
|
|
get_speeds() {
|
2011-08-11 16:47:51 +00:00
|
|
|
echo -e "\n${SELF}: Running: ${priv_cmd} ${RELENG_XORRISO} -report_about WARNING -outdev ${1} -toc -list_formats -list_profiles out -list_speeds"
|
|
|
|
${priv_cmd} "$RELENG_XORRISO" -report_about WARNING -outdev "$1" \
|
2011-07-15 06:08:29 +00:00
|
|
|
-print '---toc :' -toc \
|
|
|
|
-print '---list_formats :' -list_formats \
|
|
|
|
-print '---list_profiles :' -list_profiles out \
|
|
|
|
-print '---list_speeds :' -list_speeds
|
2011-07-11 09:24:57 +00:00
|
|
|
}
|
|
|
|
|
2011-07-15 06:08:29 +00:00
|
|
|
cat_var() {
|
|
|
|
# $1 = variable to put out with line feeds
|
|
|
|
cat <<+
|
|
|
|
$1
|
2011-07-13 11:41:39 +00:00
|
|
|
+
|
2011-07-15 06:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get_devices() {
|
2011-07-27 21:43:24 +00:00
|
|
|
# $1 = if not empty: device lines from xorriso -devices or -device_links
|
2011-07-15 06:08:29 +00:00
|
|
|
# $2 = if not empty: suppress dialog and use $2 as input
|
2011-07-11 09:24:57 +00:00
|
|
|
|
2011-07-15 06:08:29 +00:00
|
|
|
if test -n "$1"
|
|
|
|
then
|
|
|
|
DEVICES="$1"
|
|
|
|
else
|
2011-08-11 16:47:51 +00:00
|
|
|
DEVICES=$( ${priv_cmd} "$RELENG_XORRISO" $devices_opt 2>/dev/null | grep "\-dev")
|
2011-07-15 06:08:29 +00:00
|
|
|
fi
|
|
|
|
NUM_DEV=$(cat_var "$DEVICES" | wc -l)
|
2011-07-11 09:24:57 +00:00
|
|
|
case "${NUM_DEV}" in
|
|
|
|
0)
|
2011-07-15 06:08:29 +00:00
|
|
|
echo -e "\n${SELF}: No drives found."
|
2011-07-11 09:24:57 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
1)
|
2011-07-15 06:08:29 +00:00
|
|
|
echo -e "\n${SELF}: 1 drive found:\n"
|
2011-07-11 09:24:57 +00:00
|
|
|
;;
|
|
|
|
*)
|
2011-07-15 06:08:29 +00:00
|
|
|
echo -e "\n${SELF}: ${NUM_DEV} drives found:\n"
|
2011-07-11 09:24:57 +00:00
|
|
|
;;
|
|
|
|
esac
|
2011-07-15 06:08:29 +00:00
|
|
|
echo =================================================================
|
|
|
|
echo "$DEVICES"
|
|
|
|
echo =================================================================
|
|
|
|
|
|
|
|
OUTDEV=$( cat_var "$DEVICES" | head -1 | \
|
|
|
|
sed -e "s/[0-9] *-dev '\//\//" -e "s/'.*$//" )
|
|
|
|
if test -n "$2"
|
|
|
|
then
|
|
|
|
x="$2"
|
|
|
|
else
|
|
|
|
echo >&2
|
|
|
|
echo "WARNING: The following tests might pull in the drive tray." >&2
|
|
|
|
echo " Best is if you now put in a suitable media and" >&2
|
|
|
|
echo " load it manually, so nobody gets surprised. :))" >&2
|
|
|
|
echo >&2
|
|
|
|
echo "Which drive to examine ? (Empty input = ${OUTDEV})" >&2
|
|
|
|
read x
|
|
|
|
fi
|
|
|
|
if test -n "$x"
|
|
|
|
then
|
|
|
|
OUTDEV="$x"
|
|
|
|
fi
|
|
|
|
|
|
|
|
get_speeds "$OUTDEV"
|
2011-07-11 09:24:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# main
|
2011-07-15 06:08:29 +00:00
|
|
|
"$RELENG_XORRISO" -version
|
2011-07-27 21:43:24 +00:00
|
|
|
echo -e "\n${SELF}: Running: $RELENG_XORRISO $devices_opt ..."
|
2011-08-11 16:47:51 +00:00
|
|
|
devices=$( ${priv_cmd} "$RELENG_XORRISO" -report_about WARNING $devices_opt | grep "\-dev")
|
2011-07-15 06:08:29 +00:00
|
|
|
RET="$?"
|
|
|
|
if test "$SIMULATE_FAILURE" = 1
|
|
|
|
then
|
|
|
|
echo "===" >&2
|
|
|
|
echo "=== SIMULATING FAILURE BY OVERRIDING EXIT VALUE OF XORRISO" >&2
|
|
|
|
echo "===" >&2
|
|
|
|
echo "FAIL : ${SELF} : Simulated failure caused by option -f"
|
|
|
|
RET=1
|
|
|
|
fi
|
|
|
|
case ${RET} in
|
2011-07-11 09:24:57 +00:00
|
|
|
0)
|
2011-07-15 06:08:29 +00:00
|
|
|
get_devices "$devices" "$dev"
|
|
|
|
RET="$?"
|
|
|
|
if test "$RET" = 0
|
2011-07-16 13:41:18 +00:00
|
|
|
then :
|
2011-07-15 06:08:29 +00:00
|
|
|
else
|
|
|
|
echo "FAIL : ${SELF} : Device scan or single drive listing failed"
|
|
|
|
exit "$RET"
|
|
|
|
fi
|
|
|
|
;;
|
2011-07-11 09:24:57 +00:00
|
|
|
*)
|
2011-07-15 06:08:29 +00:00
|
|
|
boldify
|
2011-08-11 16:47:51 +00:00
|
|
|
echo -ne "\n${SELF}: ${priv_cmd} ${RELENG_XORRISO} $devices_opt returned ${RET}."
|
2011-07-15 06:08:29 +00:00
|
|
|
unboldify
|
|
|
|
echo -e "\n${SELF}: Already mounted?"
|
|
|
|
df -kh
|
2011-08-11 16:47:51 +00:00
|
|
|
exit 1
|
2011-07-11 09:24:57 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|