[Bio] / FigRelEngTools / install-code Repository:
ViewVC logotype

View of /FigRelEngTools/install-code

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (annotate)
Thu Oct 28 17:53:30 2004 UTC (14 years, 10 months ago) by olson
Branch: MAIN
CVS Tags: HEAD
More releng stuff.

#!/usr/bin/perl

use strict;

use File::Copy;
use File::Basename;

#
# Assemble a new FIGdisk from a code distribution. This script is assumed
# to be found in the same directory as the three tarfiles that make up a distribution:
#
#  env-XX.tgz		Compiled-code environment
#  code-YY.tgz		Lightweight code
#  BLASTMAT.tgz		Blast inputs
#
# Each of these is a tarfile. env-file extracts to a directory called "env".
# code-file is named code-<version>.tgz. It extracts to a directory <version>.
# blastmat-file extracts to a directory BLASTMAT.
#
# This script takes a single argument: the name of a directory that does not yet
# exist that will hold the new installation.
#

if (@ARGV != 1)
{
    die "Usage: $0 destination-dir\n";
}

my($dest_dir) = @ARGV;

#
# Lstat in case the destination is a symlink that points nowhere.
#
if (my @s = lstat($dest_dir))
{
    die "Error: Destination directory $dest_dir already exists\n";
}

my($env_file, $code_file, $blastmat_file);

$env_file = find_by_pattern("env-*.tgz");
$code_file = find_by_pattern("code-*.tgz");
$blastmat_file = File::Spec->rel2abs("BLASTMAT.tgz");

if (! -f $env_file)
{
    die "Environment file $env_file not found\n";
}
if (! -f $code_file)
{
    die "Code file $code_file not found\n";
}
if (! -f $blastmat_file)
{
    die "Blastmat file $blastmat_file not found\n";
}

#
# Determine the code release name. 
#

my $code_version;
{
    my $base = basename($code_file);
    if ($base =~ /code-(.*).tgz/)
    {
	$code_version = $1;
    }
    else
    {
	die "Invalid code release filename $code_file\n";
    }
}

#
# We're okay. Create and chdir to the destination, and unpack.
#

mkdir($dest_dir) or die "Error: cannot mkdir $dest_dir: $!\n";

chdir($dest_dir) or die "Error: cannot chdir $dest_dir: $!\n";


print "Unpacking environment from $env_file\n";
(system("tar zxf $env_file") == 0) or die "Extract of environment from $env_file failed: $!\n";

print "Unpacking BLASTMAT from $blastmat_file\n";
(system("tar zxf $blastmat_file") == 0) or die "Extract of BLASTMAT from $blastmat_file failed: $!\n";

open(F, ">DEFAULT_RELEASE");
print F "$code_version\n";
close(F);

mkdir("FIG");
mkdir("FIG/Tmp");
chmod(0777, "FIG/Tmp");

mkdir("dist");
mkdir("dist/releases");

print "Unpacking code release $code_version\n";

(system("cd dist/releases; tar zxf $code_file") == 0) or die "Extract of code from $code_file failed: $!\n";

copy("dist/releases/$code_version/FigCommon/configure", "configure");
chmod(0755, "configure");

copy("dist/releases/$code_version/ReleaseTools/Makefile.top", "dist/releases/$code_version/Makefile");

#
# Find a file matching this pattern, and ensure that both it exists, and that
# it is unique.
#
sub find_by_pattern
{
    my($pat) = @_;

    my @r = glob($pat);

    if (@r == 1)
    {
	return File::Spec->rel2abs($r[0]);
    }
    elsif (@r == 0)
    {
	die "File matching pattern $pat not found.\n";
    }
    else
    {
	die "Multiple files found matching pattern $pat.\n";
    }
	
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3