[Bio] / FigRelEngTools / assign_image_files Repository:
ViewVC logotype

View of /FigRelEngTools/assign_image_files

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (annotate)
Thu Oct 28 17:53:30 2004 UTC (14 years, 5 months ago) by olson
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +4 -3 lines
More releng stuff.

#!/usr/bin/perl

use FileHandle;
use File::Basename;

# 
# Assume we are in a release directory.
#
# Determine, based on a given disk size, what files in the release go on what disks.
# We do this by scanning the MANIFEST and checksum files.
#

#
# Destination is . unless passed on commandline
#

my $dest = ".";

if (@ARGV > 0)
{
    $dest = shift(@ARGV);
}

if (! -d $dest)
{
    die "Destination directory $dest does not exist\n";
}

my $pwd = `pwd`;
chop($pwd);
my $prefix = basename($pwd);


#
# Determine the list of files and their sizes.
#

our @files = ();

add_file("MANIFEST");

# checksums is already in the manifest.
# add_file("checksums");

scan_manifest("MANIFEST");
scan_manifest("checksums");

#
# Start assigning to disks.
#

my $first_disk_size = 4700000000;
#my $first_disk_size = 700000000;
my $other_disk_size = 4700000000;

#$first_disk_size = $other_disk_size;

my $disk_size = $first_disk_size;
    
my $disk_number = 1;
my $this_disk_size = 0;
my @this_disk;

while (@files > 0)
{
    my $item = shift(@files);

    my($file, $size) = @$item;

    # print "$file of size $size $this_disk_size $disk_size\n";

    if ($this_disk_size + $size > $disk_size)
    {
	complete_disk($disk_number, \@this_disk, $this_disk_size);
	@this_disk = ();
	$this_disk_size = 0;
	$disk_number++;
	$disk_size = $other_disk_size;
	unshift(@files, $item);
    }
    else
    {
	push(@this_disk, $file);
	$this_disk_size += $size;
    }
}
complete_disk($disk_number, \@this_disk, $this_disk_size);

for (my $disk  = 1; $disk <= $disk_number; $disk++)
{
    open(F, ">SEED.DISK.$disk");
    print F "SEED Disk $disk of $disk_number\n";
    close(F);
}
    

sub complete_disk
{
    my($number, $files, $size) = @_;

    $n = @$files;

    push(@$files, "SEED.DISK.$disk_number");

    print "# Disk $number: $n files, $size bytes\n";
    print "# @$files\n";

    print "/Users/fig/mkisofs -quiet -J -R -o $dest/$prefix.disk_$number.iso @$files\n";
}

sub add_file
{
    my($file) = @_;

    my $size = -s $file;

    push(@files, [$file, $size]);
}

sub scan_manifest
{
    my($manifest) = @_;

    my $fh= new FileHandle("<$manifest");

    while (<$fh>)
    {
	chop;
	my($chksum, $size, $file) = split(/\s+/);

	$file = basename($file);
	
	my $fsz;

	$fsz = -s $file;

	if ($fsz != $size)
	{
	    die "Incorrect size for $file: file is $fsz, manifest says $size\n";
	}
	add_file($file);
    }
    $fh->close();
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3