[Bio] / FigKernelScripts / install-data.pl Repository:
ViewVC logotype

Annotation of /FigKernelScripts/install-data.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (view) (download) (as text)

1 : olson 1.1 use FIG;
2 :    
3 :    
4 :     #
5 :     # Install the contents of a data disk.
6 :     #
7 :    
8 :     if (@ARGV != 1)
9 :     {
10 :     die "Usage: install-data <data-disk-directory>\n";
11 :     }
12 :    
13 :     my($data_dir) = @ARGV;
14 :    
15 :     #
16 :     # First check that the data directory is valid.
17 :     #
18 :    
19 :     if (! -d $data_dir or
20 :     ! -f "$data_dir/RELEASE" or
21 :     ! -f "$data_dir/MANIFEST")
22 :     {
23 :     die "Data directory $data_dir is not a valid data release disk.\n";
24 :     }
25 :    
26 :     #
27 :     # Read the release information.
28 :     #
29 :    
30 :     open(R, "<$data_dir/RELEASE") or die "Cannot open data release file $data_dir/RELEASE: $!\n";
31 :    
32 :     my @r = <R>;
33 :     chomp(@r);
34 :     map { s/\r//g; } @r;
35 :    
36 :     if (@r < 5)
37 :     {
38 :     die "Invalid data release file $data_dir/RELEASE: Not enough lines.\n";
39 :     }
40 :    
41 :     my($d_name, $d_id, $d_institution, $d_contact, $d_superset_id, @d_info) = @r;
42 :    
43 :     opendir(D, $data_dir) or die "Cannot open data directory $data_dir: $!\n";
44 :    
45 :     my @disk_tags = grep { /^DISK_\d+_OF_\d$/ } readdir(D);
46 :    
47 :     @disk_tags == 0 and die "Disk tag file DISK_X_OF_Y not found in $data_dir\n";
48 :     @disk_tags > 1 and die "Multiple disk tag file files @disk_tags found in $data_dir\n";
49 :    
50 :     my($this_disk, $num_disks) = $disk_tags[0] =~ /DISK_(\d+)_OF_(\d+)/;
51 :    
52 : olson 1.2 print "Installing data release \"$d_name\". Disk $this_disk of $num_disks\n";
53 : olson 1.1
54 :     #
55 :     # We untar into FIG/DataTmp$$.
56 :     #
57 :    
58 :     $target_dir = "$FIG_Config::fig/Tmp$$";
59 :     &FIG::verify_dir($target_dir);
60 :    
61 :     chdir $target_dir or die "Could not chdir $target_dir: $!\n";
62 :    
63 :     open(M, "<$data_dir/MANIFEST") or die "Cannot open manifest $data_dir/MANIFEST: $!\n";
64 :    
65 :     while (<M>)
66 :     {
67 :     chomp;
68 :    
69 : olson 1.2 my($cksum, $size, $file) = split(/\s+/);
70 :     print "cksum=$cksum size=$size file=$file\n";
71 : olson 1.1
72 :     my $path = "$data_dir/$file";
73 :    
74 :     -f $path or die "File $path missing from disk.\n";
75 :    
76 :     my $psize = -s $path;
77 :     $psize == $size or die "File $path is of the wrong size (is $psize, should be $size\n";
78 :    
79 :     #
80 :     # Skip checksum check for now.
81 :     #
82 :    
83 :     #
84 :     # Untar file.
85 :     #
86 :    
87 : olson 1.3 if (system("tar -x -v -f $path") != 0)
88 :     {
89 :     die "Untar of $f failed\n";
90 :     }
91 :    
92 : olson 1.1 }
93 :    
94 :    
95 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3