annotate crvft/cd-backup.pl @ 26:14410daf5190 tip

get makefile.
author Robert McIntyre <rlm@mit.edu>
date Thu, 29 Jan 2015 20:51:17 -0800
parents e2bef5c2dc28
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 $C_spec = "1,$start_address";
rlm@8 42 @additional_args = ("-M", "/dev/cdrom", "-C", $C_spec);
rlm@8 43 @create_iso_command = (@create_iso_command, @additional_args);
rlm@8 44 }
rlm@8 45
rlm@8 46 @create_iso_command = (@create_iso_command, "-o", $tmp_iso, @graft_points);
rlm@8 47
rlm@8 48
rlm@8 49 @remove_previous_iso_command = ("rm", "-f", $tmp_iso);
rlm@8 50 print "@remove_previous_iso_command\n";
rlm@8 51 system(@remove_previous_iso_command);
rlm@8 52
rlm@8 53 print "@create_iso_command\n";
rlm@8 54 system(@create_iso_command);
rlm@8 55
rlm@8 56 print "Created $tmp_iso.\n";
rlm@8 57 print "Use burn-tmp-iso-image to write to CD.\n";
rlm@8 58 if ($multi_sessionP){
rlm@8 59 print "Note: this will be a multisession disk!.\n"
rlm@8 60 }
rlm@8 61
rlm@8 62 # #START=`cdrecord -msinfo`
rlm@8 63
rlm@8 64 # #echo "$START"
rlm@8 65
rlm@8 66 # GRAFT_POINTS=''
rlm@8 67
rlm@8 68 # for var in "$@"
rlm@8 69 # do
rlm@8 70 # GRAFT_POINTS="$GRAFT_POINTS \"`basename "$var"`\"=\"$var\""
rlm@8 71 # done
rlm@8 72
rlm@8 73
rlm@8 74 # #echo $GRAFT_POINTS
rlm@8 75
rlm@8 76 # #if [ "$START" == "0,0" ]; then
rlm@8 77 # COMMAND="mkisofs -iso-level 4 -rJT -o $TARGET -graft-points $GRAFT_POINTS"
rlm@8 78 # # echo $COMMAND
rlm@8 79 # # eval $COMMAND
rlm@8 80 # #else
rlm@8 81 # # COMMAND="mkisofs -iso-level 4 -rJT -M /dev/cdrom \
rlm@8 82 # # -C $START -o $TARGET -graft-points $GRAFT_POINTS"
rlm@8 83 # echo $COMMAND
rlm@8 84 # eval $COMMAND
rlm@8 85 # #fi
rlm@8 86
rlm@8 87
rlm@8 88 # echo "files copied to $TARGET. use 'burn-tmp-iso-image' to burn it."
rlm@8 89
rlm@8 90 # #cd-burn