annotate cd-backup-parse.pl @ 8:e736b9aaf5ad

various attempts to do multisession burning; giving up for now.
author Robert McIntyre <rlm@mit.edu>
date Mon, 25 Feb 2013 13:30:46 +0000
parents
children
rev   line source
rlm@8 1 #!/bin/perl
rlm@8 2
rlm@8 3 $tmp_iso="/home/r/tmp/image.iso";
rlm@8 4
rlm@8 5
rlm@8 6 use File::Basename;
rlm@8 7
rlm@8 8 $session_info = `cdrecord -minfo 2>/dev/null`;
rlm@8 9 $multi_sessionP = false;
rlm@8 10
rlm@8 11
rlm@8 12 # get the last 2 lines from $session_info, and use them to construct
rlm@8 13 # the proper flags for mkisofs.
rlm@8 14
rlm@8 15 @session_info_lines = split("\n", $session_info);
rlm@8 16
rlm@8 17 $session_number_line = $session_info_lines[-2];
rlm@8 18 $start_address_line = $session_info_lines[-1];
rlm@8 19
rlm@8 20 if ($session_number_line =~ m/^Last session start address:\s*(\d+)/){
rlm@8 21 $session_number = $1;
rlm@8 22 if ($start_address_line =~ m/^Last session leadout start address:\s*(\d+)/){
rlm@8 23 $start_address = $1;
rlm@8 24 $multi_sessionP = true;
rlm@8 25 }
rlm@8 26 }
rlm@8 27
rlm@8 28 #print "$multi_sessionP\n$session_number\n$start_address\n";
rlm@8 29
rlm@8 30 @graft_points = ("-graft-points");
rlm@8 31
rlm@8 32 for $graft_point(@ARGV){
rlm@8 33 push(@graft_points, basename($graft_point) . "=" . $graft_point);
rlm@8 34 }
rlm@8 35
rlm@8 36 @create_iso_command = ("mkisofs", "-iso-level", "4", "-r", "-J", "-T");
rlm@8 37
rlm@8 38
rlm@8 39 if ($multi_sessionP){
rlm@8 40 $C_spec = "$session_number,$start_address";
rlm@8 41 @additional_args = ("-M", "/dev/cdrom", "-C", $C_spec);
rlm@8 42 @create_iso_command = (@create_iso_command, @additional_args);
rlm@8 43 }
rlm@8 44
rlm@8 45 @create_iso_command = (@create_iso_command, "-o", $tmp_iso, @graft_points);
rlm@8 46
rlm@8 47
rlm@8 48 @remove_previous_iso_command = ("rm", "-f", $tmp_iso);
rlm@8 49 print "@remove_previous_iso_command\n";
rlm@8 50 system(@remove_previous_iso_command);
rlm@8 51
rlm@8 52 print "@create_iso_command\n";
rlm@8 53 system(@create_iso_command);
rlm@8 54
rlm@8 55 print "Created $tmp_iso.\n";
rlm@8 56 print "Use burn-tmp-iso-image to write to CD.\n";
rlm@8 57 if ($multi_sessionP){
rlm@8 58 print "Note: this will be a multisession disk!.\n"
rlm@8 59 }
rlm@8 60
rlm@8 61 # #START=`cdrecord -msinfo`
rlm@8 62
rlm@8 63 # #echo "$START"
rlm@8 64
rlm@8 65 # GRAFT_POINTS=''
rlm@8 66
rlm@8 67 # for var in "$@"
rlm@8 68 # do
rlm@8 69 # GRAFT_POINTS="$GRAFT_POINTS \"`basename "$var"`\"=\"$var\""
rlm@8 70 # done
rlm@8 71
rlm@8 72
rlm@8 73 # #echo $GRAFT_POINTS
rlm@8 74
rlm@8 75 # #if [ "$START" == "0,0" ]; then
rlm@8 76 # COMMAND="mkisofs -iso-level 4 -rJT -o $TARGET -graft-points $GRAFT_POINTS"
rlm@8 77 # # echo $COMMAND
rlm@8 78 # # eval $COMMAND
rlm@8 79 # #else
rlm@8 80 # # COMMAND="mkisofs -iso-level 4 -rJT -M /dev/cdrom \
rlm@8 81 # # -C $START -o $TARGET -graft-points $GRAFT_POINTS"
rlm@8 82 # echo $COMMAND
rlm@8 83 # eval $COMMAND
rlm@8 84 # #fi
rlm@8 85
rlm@8 86
rlm@8 87 # echo "files copied to $TARGET. use 'burn-tmp-iso-image' to burn it."
rlm@8 88
rlm@8 89 # #cd-burn