"Fossies" - the Fresh Open Source Software Archive

Member "xorriso-1.5.4/releng/manual_burn" (25 Oct 2012, 5916 Bytes) of package /linux/misc/xorriso-1.5.4.pl02.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/bash
    2 
    3 # Copyright 2011 George Danchev <danchev@spnet.net>
    4 # Copyright 2011 Thomas Schmitt <scdbackup@gmx.net>
    5 #
    6 # Licensed under GNU GPL version 2 or later
    7 
    8 set -e
    9 # set -x
   10 
   11 print_specific_help() {
   12 cat << HLP
   13 Specific options: 
   14        --dev path  use path as drive address. Default: /dev/cdrw
   15        --what path use path as address of the directory which shall
   16                    be copied into an ISO 9660 filesystem on media.
   17        --any_media allow non re-usable MMC media, like CD-R or DVD+R.
   18                    Allow paths to non-existing files, but disallow paths
   19                    to existing regular files.
   20        --priv_cmd 'command [arg [arg ...]]'
   21                    With drive operations execute xorriso as argument
   22                    of the given command (e.g. pfexec, sudo) with the
   23                    optionally given arguments: command arg arg xorriso ...
   24                    Command and arguments must be single words.
   25 Overview:
   26        Test burning to re-usable media CD-RW, DVD-RW, DVD-RAM, DVD+RW, BD-RE.
   27        By default, one-time usable media will be rejected deliberately.
   28 HLP
   29 }
   30 
   31 wait_for_dev () {
   32 # $1 = device address
   33   timeout=30
   34   counter=0
   35 
   36   while test "$counter" -lt "$timeout"
   37   do
   38     if test -e "$1"
   39     then
   40       echo
   41       return 0
   42     fi
   43     if test "$counter" = 0
   44     then
   45       echo
   46       echo "Not existing: $dev"
   47       echo "Will wait up to $timeout seconds for it to appear."
   48     fi
   49     counter=$(expr $counter + 1)
   50     echo -n "$counter " 
   51     sleep 1
   52   done
   53   echo
   54   return 1
   55 }
   56 
   57 getopts_inc=inc/releng_getopts.inc
   58 if test -e "$getopts_inc"
   59 then
   60   . "$getopts_inc"
   61   if test "$SPECIFIC_HELP" = 1
   62   then
   63        print_specific_help
   64        exit 0
   65   fi
   66 else
   67   echo >&2
   68   echo "File not found: $getopts_inc" >&2
   69   echo "Are we in the ./releng directory of a libisoburn SVN checkout ?" >&2
   70   echo "(Please execute the tests from that ./releng directory.)" >&2
   71   echo >&2
   72   exit 29  
   73 fi
   74 
   75 # Set default values for specific option variables.
   76 dev=/dev/cdrw
   77 what=../xorriso
   78 any_media=0
   79 priv_cmd=
   80 # Interpret specific options, they begin after the first --.
   81 next_is=ignore
   82 for i in "$@"
   83 do
   84   if test "$next_is" = "ignore"
   85   then
   86        if test "$i" = "--"
   87        then
   88             next_is=""
   89        fi
   90   elif test "$next_is" = "dev"
   91   then
   92        dev="$i"
   93        next_is=""
   94   elif test "$next_is" = "what"
   95   then
   96        what="$i"
   97        next_is=""
   98   elif test "$next_is" = "priv_cmd"
   99   then
  100        priv_cmd="$i"
  101        next_is=""
  102   elif test "$i" = "--dev"
  103   then
  104        next_is="dev"
  105   elif test "$i" = "--what"
  106   then
  107        next_is="what"
  108   elif test "$i" = "--any_media"
  109   then
  110        any_media=1
  111   elif test "$i" = "--priv_cmd"
  112   then
  113        next_is="priv_cmd"
  114   else
  115        echo >&2
  116        echo "Unknown test specific option: $i" >&2
  117        print_help
  118        print_specific_help
  119        exit 31
  120   fi
  121 done
  122 
  123 
  124 check_for_xorriso -x
  125 
  126 
  127 # check data dir, if any and after checking -x xorriso
  128 if [ -d "${GEN_DATA_DIR}" ]; then
  129  printf "\n${SELF}: directory %s exists!" ${GEN_DATA_DIR}
  130  printf "\n${SELF}: use '${SELF} -c' to remove.\n"
  131  exit 30
  132 else
  133  mkdir "${GEN_DATA_DIR}"
  134 fi
  135 
  136 
  137 #####################################################################
  138 
  139 # Inspect drive address
  140 if test -e "$dev"
  141 then
  142   if test "$any_media" = 1 -a -f "$dev"
  143   then
  144     echo "FAIL : ${SELF} : --dev $dev leads to an existing regular file"
  145     echo
  146     cleanup
  147     exit 31
  148   fi
  149 else
  150   if test "$any_media" = "0"
  151   then
  152     echo "FAIL : ${SELF} : --dev $dev does not lead to an existing file"
  153     echo
  154     cleanup
  155     exit 31
  156   fi
  157 fi
  158 
  159 # Inspect media
  160 set +e
  161 wait_for_dev "$dev"
  162 res=$(${priv_cmd} "$RELENG_XORRISO" -outdev "$dev" 2>&1)
  163 ret=$?
  164 set -e
  165 if test "$ret" -ne 0
  166 then
  167   echo "$res" >&2
  168   echo "FAIL : ${SELF} : Non-zero exit value $ret with: ${priv_cmd} $RELENG_XORRISO -outdev $dev"
  169   echo
  170   cleanup
  171   exit 1
  172 elif echo "$res" | grep '^Media current:' >/dev/null 2>&1
  173 then
  174   media=$(echo "$res" | grep '^Media current:' | \
  175           sed -e 's/^Media current: //')
  176   echo "Detected media: '$media'"
  177   if test "$media" = "CD-RW" -o "$media" = "DVD-RW sequential recording" -o \
  178           "$media" = "DVD-RW restricted overwrite" -o "$media" = "DVD-RAM" -o \
  179           "$media" = "DVD+RW" -o "$media" = "BD-RE"
  180   then
  181     echo "Recognized as re-usable."
  182   elif test "$media" = "is not recognizable"
  183   then
  184     echo "FAIL : ${SELF} : No recognizable media detected in: '$dev'"
  185     echo
  186     cleanup
  187     exit 2
  188   elif test "$any_media" = 1
  189   then
  190     echo "Accepted media only because of option --any_media : '$media'"
  191   else
  192     echo "FAIL : ${SELF} : No re-usable media detected, but: '$media'"
  193     echo
  194     cleanup
  195     exit 2
  196   fi
  197 fi
  198 
  199 # Perform burn run
  200 echo ${priv_cmd} "$RELENG_XORRISO" -for_backup -outdev "$dev" -blank as_needed -map "$what" /test
  201 set +e
  202 wait_for_dev "$dev"
  203 ${priv_cmd} "$RELENG_XORRISO" \
  204     -for_backup \
  205     -outdev "$dev" \
  206     -blank as_needed \
  207     -map "$what" /test
  208 ret=$?
  209 set -e
  210 if test "$ret" -ne 0
  211 then
  212   echo "FAIL : ${SELF} : Non-zero exit value with burn run: $ret"
  213   echo
  214   cleanup
  215   exit 1
  216 fi
  217 
  218 if test "$SIMULATE_FAILURE" = 1
  219 then
  220   echo "FAIL : ${SELF} : Simulated failure caused by option -f" 
  221   if test -f "$dev"
  222   then
  223     # Alter image 
  224     dd if=/dev/urandom bs=2K count=1 \
  225        of="$dev" conv=notrunc seek=400
  226   else
  227     cleanup
  228     exit 1
  229   fi
  230 fi
  231 
  232 # Check read
  233 echo ${priv_cmd} "$RELENG_XORRISO" -for_backup -indev "$dev" \
  234      -check_media event=FATAL -- \ -check_md5_r FATAL / --
  235 set +e
  236 wait_for_dev "$dev"
  237 ${priv_cmd} "$RELENG_XORRISO" \
  238     -for_backup \
  239     -indev "$dev" \
  240     -print '---check_media:'  -check_media event=FATAL -- \
  241     -print '---check_md5_r:'  -check_md5_r FATAL / -- \
  242     -print '---compare_r:'    -md5 off -compare_r "$what" /test
  243 ret=$?
  244 set -e
  245 if test "$ret" -ne 0
  246 then
  247   echo "FAIL : ${SELF} : Non-zero exit value with checkread run: $ret"
  248   echo
  249   cleanup
  250   exit 1
  251 fi
  252 
  253 echo "Ok. Burn test passed."
  254 echo
  255 cleanup
  256 exit 0