1998-01-30 00:31:24 +08:00
|
|
|
#! /usr/local/bin/perl -w
|
|
|
|
require 5.003;
|
1998-01-30 05:56:06 +08:00
|
|
|
use Cwd;
|
1998-01-30 00:31:24 +08:00
|
|
|
|
|
|
|
# Builds a release. Arguments are zero or more of the words.
|
|
|
|
#
|
|
|
|
# tar -- build a tar file *.tar
|
|
|
|
# compress -- build a compressed tar file *.tar.Z
|
|
|
|
# gzip -- build a compressed tar file *.tar.gz
|
|
|
|
# bzip2 -- build a compressed tar file *.tar.bz2
|
|
|
|
#
|
|
|
|
# If no arguments are given then `gzip' is assumed. If the only argument
|
|
|
|
# is the word `all' then all forms are used.
|
|
|
|
|
|
|
|
$releases = "./releases"; # Directory for release tarballs
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Read version info, return an array (MAJOR,MINOR,RELEASE,PATCHLEVEL) or
|
|
|
|
# a string "MAJOR.MINOR.RELEASE PATCHLEVEL"
|
|
|
|
#
|
|
|
|
sub getver () {
|
|
|
|
my @ver;
|
|
|
|
|
|
|
|
open SRC, "./src/H5private.h" or die "cannot read HDF5 version";
|
|
|
|
while (<SRC>) {
|
|
|
|
$ver[0] = $1 if /define\s+HDF5_MAJOR_VERSION\s+(\d+)/;
|
|
|
|
$ver[1] = $1 if /define\s+HDF5_MINOR_VERSION\s+(\d+)/;
|
|
|
|
$ver[2] = $1 if /define\s+HDF5_RELEASE_VERSION\s+(\d+)/;
|
|
|
|
$ver[3] = $1 if /define\s+HDF5_PATCH_VERSION\s+(\d+)/;
|
|
|
|
}
|
|
|
|
close SRC;
|
|
|
|
wantarray ? @ver : "$ver[0].$ver[1].$ver[2]".chr(ord('a')+$ver[3]);
|
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Set version information. Input is a string or an array.
|
|
|
|
#
|
|
|
|
sub setver ($;$$$) {
|
|
|
|
my @ver = @_;
|
|
|
|
local $_;
|
|
|
|
|
|
|
|
if ($ver[0]=~/\D/) {
|
|
|
|
@ver = $ver[0] =~ /^(\d+)\.(\d+)\.(\d+)([a-z])$/ or return "";
|
|
|
|
$ver[3] = ord($ver[3])-ord('a');
|
|
|
|
}
|
|
|
|
|
|
|
|
$_ = `cat ./src/H5private.h`;
|
|
|
|
s/(define\s+HDF5_MAJOR_VERSION\s+)(\d+)/$1$ver[0]/;
|
|
|
|
s/(define\s+HDF5_MINOR_VERSION\s+)(\d+)/$1$ver[1]/;
|
|
|
|
s/(define\s+HDF5_RELEASE_VERSION\s+)(\d+)/$1$ver[2]/;
|
|
|
|
s/(define\s+HDF5_PATCH_VERSION\s+)(\d+)/$1$ver[3]/;
|
|
|
|
open SRC, "> ./src/H5private.h" or return "";
|
|
|
|
print SRC $_;
|
|
|
|
close SRC;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1998-02-11 00:39:47 +08:00
|
|
|
##############################################################################
|
|
|
|
# Make sure MANIFEST contains all the necessary files. If we are running
|
|
|
|
# under CVS then look at the CVS/Entries files to get the names that should
|
|
|
|
# be in the manifest. Otherwise we really can't do anything.
|
|
|
|
#
|
|
|
|
sub manifest () {
|
|
|
|
my ($fname, %manifest);
|
|
|
|
my $nprobs=0;
|
|
|
|
|
|
|
|
# We can't do anything if we're not running under cvs.
|
|
|
|
return "" unless -d "CVS";
|
|
|
|
|
|
|
|
# Read the files from the manifest.
|
|
|
|
open MANIFEST, "MANIFEST" or die "unable to read manifest";
|
|
|
|
while (<MANIFEST>) {
|
|
|
|
chomp;
|
|
|
|
$manifest{$_} = 1;
|
|
|
|
}
|
|
|
|
close MANIFEST;
|
|
|
|
|
|
|
|
# Read files from CVS/Entries
|
|
|
|
open FIND, "find . -name Entries -print | sort |" or
|
|
|
|
die "unable to find CVS entries";
|
1998-02-20 02:19:48 +08:00
|
|
|
while (defined($fname=<FIND>)) {
|
1998-02-11 00:39:47 +08:00
|
|
|
chomp $fname;
|
|
|
|
my ($dir) = $fname =~ m%(.*)/CVS/Entries%;
|
|
|
|
open ENTRIES, $fname or die "unable to open $fname";
|
|
|
|
while (<ENTRIES>) {
|
1998-03-31 03:24:08 +08:00
|
|
|
my ($ename);
|
|
|
|
next unless ($ename) = m%^/([^/]+)/[^-]%;
|
1998-02-11 00:39:47 +08:00
|
|
|
$ename = "$dir/" . $ename;
|
|
|
|
if (exists $manifest{$ename}) {
|
|
|
|
delete $manifest{$ename};
|
|
|
|
} else {
|
|
|
|
print "NEW: $ename\n";
|
|
|
|
$nprobs++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close ENTRIES;
|
|
|
|
}
|
|
|
|
close FIND;
|
|
|
|
|
|
|
|
for (sort keys %manifest) {
|
|
|
|
print "OLD: $_\n";
|
|
|
|
$nprobs++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($nprobs) {
|
|
|
|
print "Please add the new files to MANIFEST and remove the old\n";
|
|
|
|
print "files and try again. The MANIFEST should contain all files\n";
|
|
|
|
print "that are to be distributed for a release.\n";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-01-30 00:31:24 +08:00
|
|
|
##############################################################################
|
|
|
|
# Build a release
|
|
|
|
#
|
|
|
|
sub release (@) {
|
|
|
|
my @types = @_;
|
1998-01-30 05:56:06 +08:00
|
|
|
my ($ver, $status, $created_symlink);
|
1998-01-30 00:31:24 +08:00
|
|
|
local $_;
|
|
|
|
|
1998-02-11 00:39:47 +08:00
|
|
|
# Make sure no one forgot to update MANIFEST
|
|
|
|
manifest;
|
|
|
|
|
1998-01-30 00:31:24 +08:00
|
|
|
# Make sure the version number is correct.
|
|
|
|
print "Building an HDF release...\n";
|
|
|
|
print "HDF version to release [", ($ver=getver), "] ";
|
|
|
|
return "" unless defined ($_=<STDIN>);
|
|
|
|
chomp;
|
|
|
|
(setver ($ver=$_) or die "cannot set version") if /\S/;
|
|
|
|
|
|
|
|
# Clean the source tree, showing only errors.
|
|
|
|
print "Cleaning source tree...\n";
|
|
|
|
$status = system "make distclean >/dev/null";
|
|
|
|
die "cannot make distclean" if $status >> 8;
|
|
|
|
|
|
|
|
# Move default top-level makefile into place.
|
|
|
|
$status = system "cp Makefile.dist Makefile";
|
|
|
|
die "cannot install default Makefile" if $status >> 8;
|
|
|
|
|
1998-01-30 05:56:06 +08:00
|
|
|
# Make sure release directory exists
|
1998-01-30 00:31:24 +08:00
|
|
|
(mkdir $releases, 0777 or die "cannot create $releases")
|
|
|
|
unless -d $releases;
|
|
|
|
die "no manifest" unless -r "MANIFEST";
|
|
|
|
|
1998-01-30 05:56:06 +08:00
|
|
|
# We build the release from above the root of the source tree so the
|
|
|
|
# hdf5 directory appears as part of the name in the tar file. We create
|
1998-02-18 04:19:13 +08:00
|
|
|
# a temporary symlink called something like `hdf5-1.0.0a' that points to
|
1998-01-30 05:56:06 +08:00
|
|
|
# our current working directory.
|
|
|
|
$_ = cwd;
|
|
|
|
my ($parent,$root) = m%(.*)/(.*)$% or die "cannot split directory";
|
1998-02-18 04:23:52 +08:00
|
|
|
if ($root ne "hdf5-$ver" && ! -e "../hdf5-$ver") {
|
|
|
|
symlink $root, "../hdf5-$ver" or die "cannot create link";
|
1998-01-30 05:56:06 +08:00
|
|
|
$created_symlink = 1;
|
|
|
|
}
|
1998-02-18 04:23:52 +08:00
|
|
|
my $name = "$root/$releases/hdf5-$ver";
|
1998-01-30 05:56:06 +08:00
|
|
|
|
|
|
|
# Build the releases.
|
1998-01-30 00:31:24 +08:00
|
|
|
@types = ("gzip") unless @types;
|
|
|
|
@types = qw/tar gzip compress bzip2/ if 1==@types && "all" eq $types[0];
|
1998-01-30 05:56:06 +08:00
|
|
|
$_ = `cat MANIFEST`;
|
|
|
|
s/^\.\///mg;
|
|
|
|
@filelist = ("Makefile", split /\s*\n/, $_);
|
1998-02-18 04:23:52 +08:00
|
|
|
$filelist = join " ", map {"hdf5-$ver/$_"} @filelist;
|
1998-01-30 05:56:06 +08:00
|
|
|
|
|
|
|
chdir ".." or die;
|
1998-01-30 00:31:24 +08:00
|
|
|
for (@types) {
|
|
|
|
print "Compressing with $_...\n";
|
|
|
|
|
|
|
|
/^tar$/ && do {
|
|
|
|
$status = system "tar cf $name.tar $filelist";
|
|
|
|
next;
|
|
|
|
};
|
|
|
|
|
|
|
|
/^gzip$/ && do {
|
|
|
|
$status = system "tar cf - $filelist |gzip -9 >$name.tar.gz";
|
|
|
|
next;
|
|
|
|
};
|
|
|
|
|
|
|
|
/^compress$/ && do {
|
|
|
|
$status = system "tar cf - $filelist |compress -c >$name.tar.Z";
|
|
|
|
next;
|
|
|
|
};
|
|
|
|
|
|
|
|
/^bzip2$/ && do {
|
|
|
|
$status = system "tar cf - $filelist |bzip2 -9 >$name.tar.bz2";
|
|
|
|
next;
|
|
|
|
};
|
|
|
|
} continue {
|
|
|
|
print STDERR "$_ failed\n" if $status >> 8;
|
|
|
|
}
|
1998-01-30 05:56:06 +08:00
|
|
|
chdir $root or die;
|
|
|
|
|
|
|
|
# Remove the temporary symlink we created above.
|
1998-02-18 04:23:52 +08:00
|
|
|
unlink "../hdf5-$ver" if $created_symlink;
|
1998-01-30 05:56:06 +08:00
|
|
|
|
1998-01-30 00:31:24 +08:00
|
|
|
|
|
|
|
# Update version info
|
|
|
|
print <<EOF;
|
|
|
|
|
|
|
|
If this is a real release then the version number for continued development
|
|
|
|
should be incremented. Otherwise just press return.
|
|
|
|
|
|
|
|
EOF
|
|
|
|
print "Set development version to [", ($ver=getver), "] ";
|
|
|
|
return "" unless defined ($_ = <STDIN>);
|
|
|
|
chomp;
|
|
|
|
(setver ($ver=$_) or die "cannot set version") if /\S/;
|
|
|
|
|
|
|
|
if (-d "CVS") {
|
1998-02-20 02:19:48 +08:00
|
|
|
my $tag = $ver;
|
|
|
|
$tag =~ s/\./-/g;
|
1998-02-28 04:07:37 +08:00
|
|
|
print "Tag CVS sources with \"$tag\"? [n] ";
|
1998-02-20 02:19:48 +08:00
|
|
|
chomp ($_ = <STDIN>);
|
1998-02-28 04:07:37 +08:00
|
|
|
if ($_ eq 'y') {
|
1998-02-20 02:19:48 +08:00
|
|
|
print "Tagging CVS sources...\n";
|
|
|
|
my $status = system "cvs tag -R $tag";
|
|
|
|
die "cvs tag failed" if $status >> 8;
|
|
|
|
}
|
1998-01-30 00:31:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
release @ARGV;
|