dvd-sector-copy.c: Include file-relative information in bad-blocks file.
[dvdrip] / dvdrip
diff --git a/dvdrip b/dvdrip
index b09abe8..5c1e72b 100755 (executable)
--- a/dvdrip
+++ b/dvdrip
@@ -4,9 +4,8 @@ prog=${0##*/}
 dev=${DVDRIP_DEVICE-/dev/dvd}
 tmp=${DVDRIP_TMPDIR-${HOME?}/tmp/dvdrip}
 archive=${DVDRIP_ARCHIVE-jem.distorted.org.uk:/mnt/dvd/archive}
-here=$(realpath "$0"); here=${here%/*}
-: ${DVD_SECTOR_COPY=$here/dvd-sector-copy.$(uname -m)}
-: ${DVDRIP_UPLOAD=$here/dvdrip-upload}
+: ${DVD_SECTOR_COPY=dvd-sector-copy}
+: ${DVDRIP_UPLOAD=dvdrip-upload}
 backup=nil eject=nil force=nil verbose=nil bogus=nil; unset dir sub n label
 usage () {
   cat <<EOF
@@ -118,6 +117,16 @@ case $rc,$force in
   0,t) warn "output file already exists; will overwrite" ;;
 esac
 
+accumulate_badblocks () {
+  if [ -f "$tmp/$tag/badblocks.new" ]; then
+    if [ ! -f "$tmp/$tag/badblocks" ]; then
+      { echo "## bad-blocks region map"; echo; } >"$tmp/$tag/badblocks"
+    fi
+    sed -n "/^[^#]/p" "$tmp/$tag/badblocks.new" >>"$tmp/$tag/badblocks"
+    rm "$tmp/$tag/badblocks.new"
+  fi
+}
+
 mkdir -p "$tmp/$tag"
 case $backup in
   t)
@@ -134,7 +143,10 @@ case $backup in
     ;;
   nil)
     if [ ! -f "$tmp/$tag/iso" ]; then
-      run_setrc "$DVD_SECTOR_COPY" -D"$dev" -c -b"$tmp/$tag/badblocks" -o"$tmp/$tag/iso.new"
+      accumulate_badblocks
+      run_setrc "$DVD_SECTOR_COPY" -c -b"$tmp/$tag/badblocks.new" \
+               "$dev" "$tmp/$tag/iso.new"
+      accumulate_badblocks
       case $rc in
        0)
          run mv "$tmp/$tag/iso.new" "$tmp/$tag/iso"