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

Annotation of /FigKernelScripts/install-data.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3