view 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
line wrap: on
line source
1 #!/bin/perl
3 $tmp_iso="/home/r/tmp/image.iso";
6 use File::Basename;
8 $session_info = `cdrecord -minfo 2>/dev/null`;
9 $multi_sessionP = false;
12 # get the last 2 lines from $session_info, and use them to construct
13 # the proper flags for mkisofs.
15 @session_info_lines = split("\n", $session_info);
17 $session_number_line = $session_info_lines[-2];
18 $start_address_line = $session_info_lines[-1];
20 if ($session_number_line =~ m/^Last session start address:\s*(\d+)/){
21 $session_number = $1;
22 if ($start_address_line =~ m/^Last session leadout start address:\s*(\d+)/){
23 $start_address = $1;
24 $multi_sessionP = true;
25 }
26 }
28 #print "$multi_sessionP\n$session_number\n$start_address\n";
30 @graft_points = ("-graft-points");
32 for $graft_point(@ARGV){
33 push(@graft_points, basename($graft_point) . "=" . $graft_point);
34 }
36 @create_iso_command = ("mkisofs", "-iso-level", "4", "-r", "-J", "-T");
39 if ($multi_sessionP){
40 # $C_spec = "$session_number,$start_address";
41 $C_spec = "1,$start_address";
42 @additional_args = ("-M", "/dev/cdrom", "-C", $C_spec);
43 @create_iso_command = (@create_iso_command, @additional_args);
44 }
46 @create_iso_command = (@create_iso_command, "-o", $tmp_iso, @graft_points);
49 @remove_previous_iso_command = ("rm", "-f", $tmp_iso);
50 print "@remove_previous_iso_command\n";
51 system(@remove_previous_iso_command);
53 print "@create_iso_command\n";
54 system(@create_iso_command);
56 print "Created $tmp_iso.\n";
57 print "Use burn-tmp-iso-image to write to CD.\n";
58 if ($multi_sessionP){
59 print "Note: this will be a multisession disk!.\n"
60 }
62 # #START=`cdrecord -msinfo`
64 # #echo "$START"
66 # GRAFT_POINTS=''
68 # for var in "$@"
69 # do
70 # GRAFT_POINTS="$GRAFT_POINTS \"`basename "$var"`\"=\"$var\""
71 # done
74 # #echo $GRAFT_POINTS
76 # #if [ "$START" == "0,0" ]; then
77 # COMMAND="mkisofs -iso-level 4 -rJT -o $TARGET -graft-points $GRAFT_POINTS"
78 # # echo $COMMAND
79 # # eval $COMMAND
80 # #else
81 # # COMMAND="mkisofs -iso-level 4 -rJT -M /dev/cdrom \
82 # # -C $START -o $TARGET -graft-points $GRAFT_POINTS"
83 # echo $COMMAND
84 # eval $COMMAND
85 # #fi
88 # echo "files copied to $TARGET. use 'burn-tmp-iso-image' to burn it."
90 # #cd-burn