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

View of /FigKernelScripts/install-data.pl

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.1 - (download) (as text) (annotate)
Thu Oct 14 15:05:27 2004 UTC (15 years, 5 months ago) by olson
Branch: MAIN
new installer stuff

use FIG;

# Install the contents of a data disk.

if (@ARGV != 1)
    die "Usage: install-data <data-disk-directory>\n";

my($data_dir) = @ARGV;

# First check that the data directory is valid.

if (! -d $data_dir or
    ! -f "$data_dir/RELEASE" or
    ! -f "$data_dir/MANIFEST")
    die "Data directory $data_dir is not a valid data release disk.\n";

# Read the release information.

open(R, "<$data_dir/RELEASE") or die "Cannot open data release file $data_dir/RELEASE: $!\n";

my @r = <R>;
map { s/\r//g; } @r;

if (@r < 5)
    die "Invalid data release file $data_dir/RELEASE: Not enough lines.\n";

my($d_name, $d_id, $d_institution, $d_contact, $d_superset_id, @d_info) = @r;

opendir(D, $data_dir) or die "Cannot open data directory $data_dir: $!\n";

my @disk_tags = grep { /^DISK_\d+_OF_\d$/ } readdir(D);

@disk_tags == 0 and die "Disk tag file DISK_X_OF_Y not found in $data_dir\n";
@disk_tags > 1 and die "Multiple disk tag file files @disk_tags found in $data_dir\n";

my($this_disk, $num_disks) = $disk_tags[0] =~ /DISK_(\d+)_OF_(\d+)/;

print "Installing data release $d_name. Disk $this_disk of $num_disks\n";

# We untar into FIG/DataTmp$$.

$target_dir = "$FIG_Config::fig/Tmp$$";

chdir $target_dir or die "Could not chdir $target_dir: $!\n";

open(M, "<$data_dir/MANIFEST") or die "Cannot open manifest $data_dir/MANIFEST: $!\n";

while (<M>)

    my($cksum, $size, $file) = split;

    my $path = "$data_dir/$file";

    -f $path or die "File $path missing from disk.\n";

    my $psize = -s $path;
    $psize == $size or die "File $path is of the wrong size (is $psize, should be $size\n";

    # Skip checksum check for now.

    # Untar file.

    system("tar -x -v -f $path");

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3