2011-07-13 11:53:57 +01:00
|
|
|
#!/usr/bin/perl
|
2013-07-31 23:16:16 +01:00
|
|
|
use warnings;
|
|
|
|
use strict;
|
2011-07-13 11:53:57 +01:00
|
|
|
|
|
|
|
use Getopt::Long;
|
|
|
|
use Pod::Usage;
|
|
|
|
use File::Path;
|
|
|
|
use File::Temp;
|
2024-04-05 19:54:24 +01:00
|
|
|
use File::Basename;
|
|
|
|
use Cwd;
|
2011-07-13 11:53:57 +01:00
|
|
|
|
2013-07-31 23:16:16 +01:00
|
|
|
my $help;
|
|
|
|
my $man;
|
2011-07-13 11:53:57 +01:00
|
|
|
my $tagPoint;
|
|
|
|
my $last;
|
|
|
|
my $outDir = ".";
|
2024-04-05 19:54:24 +01:00
|
|
|
my $errorCount = 0;
|
|
|
|
|
|
|
|
# Find a command in the PATH.
|
|
|
|
sub which {
|
|
|
|
my $command = shift;
|
|
|
|
my @paths = split(/:/, $ENV{'PATH'});
|
|
|
|
my $path;
|
|
|
|
|
|
|
|
# Add some common locations for the commands we need.
|
|
|
|
push(@paths, qw(/sbin /usr/bin /usr/local/bin));
|
|
|
|
|
|
|
|
# Search for the command.
|
|
|
|
foreach $path (@paths) {
|
|
|
|
my $bin = File::Spec->catfile($path, $command);
|
|
|
|
if (-x $bin) {
|
|
|
|
return $bin; # Return the first one found.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return undef;
|
|
|
|
}
|
2011-07-13 11:53:57 +01:00
|
|
|
|
2020-04-16 12:37:39 +01:00
|
|
|
GetOptions(
|
|
|
|
"help|?" => \$help,
|
|
|
|
"man" => \$man,
|
|
|
|
"tagpoint=s" => \$tagPoint,
|
|
|
|
"last=s" => \$last,
|
|
|
|
"dir=s" => \$outDir,
|
|
|
|
) or pod2usage(2);
|
2011-07-13 11:53:57 +01:00
|
|
|
|
|
|
|
pod2usage(1) if $help;
|
|
|
|
pod2usage(-exitstatus => 0, -verbose => 2) if $man;
|
|
|
|
|
|
|
|
my $tagName = shift;
|
2020-04-16 12:21:51 +01:00
|
|
|
my $notused = shift; # Used to be "version".
|
2011-07-13 11:53:57 +01:00
|
|
|
|
|
|
|
pod2usage(2) if !defined($tagName);
|
2020-04-16 12:21:51 +01:00
|
|
|
if (defined $notused) {
|
|
|
|
warn "Warning: argument '$notused' is ignored.\n";
|
|
|
|
}
|
2011-07-13 11:53:57 +01:00
|
|
|
|
|
|
|
# Tag the repository
|
|
|
|
|
|
|
|
if ($tagPoint) {
|
|
|
|
system ("git tag -s $tagName $tagPoint") == 0
|
|
|
|
or die "git tag failed with : $!";
|
|
|
|
|
|
|
|
# Push the tag upstream
|
|
|
|
system ("git push ssh://gerrit.openafs.org:29418/openafs tag $tagName") == 0
|
2020-04-16 12:37:39 +01:00
|
|
|
or die "git push failed with : $!";
|
2011-07-13 11:53:57 +01:00
|
|
|
}
|
|
|
|
|
2020-04-16 12:21:51 +01:00
|
|
|
my $version = `git describe --abbrev=4 $tagName`;
|
2011-07-13 11:53:57 +01:00
|
|
|
chomp $version;
|
2020-04-16 14:41:41 +01:00
|
|
|
if (!$version) {
|
|
|
|
die "Failed to describe $tagName.\n";
|
|
|
|
}
|
|
|
|
my $suffix = $version;
|
|
|
|
$suffix =~ s/openafs-[^-]*-//;
|
|
|
|
$suffix =~ s/_/./g;
|
|
|
|
my $name = "openafs-$suffix";
|
2011-07-13 11:53:57 +01:00
|
|
|
|
|
|
|
# Grab the tagged code into a temporary directory
|
|
|
|
|
|
|
|
my $tempDir = File::Temp::tempdir();
|
|
|
|
system ("git archive --format=tar --prefix=$name/ $tagName ".
|
2020-04-16 12:37:39 +01:00
|
|
|
" | tar -C $tempDir -x") == 0
|
2011-07-13 11:53:57 +01:00
|
|
|
or die "Git archive failed with: $?";
|
|
|
|
|
2020-03-27 15:29:24 +00:00
|
|
|
# Make the output path, if not already present.
|
|
|
|
File::Path::mkpath($outDir);
|
|
|
|
|
2011-07-13 11:53:57 +01:00
|
|
|
# Construct the ChangeLog
|
|
|
|
if ($last) {
|
|
|
|
system("git log $last..$tagName > $outDir/ChangeLog");
|
|
|
|
} else {
|
|
|
|
system("git log $tagName > $outDir/ChangeLog");
|
|
|
|
}
|
|
|
|
|
|
|
|
# Describe the tree
|
2020-04-16 14:41:41 +01:00
|
|
|
open(my $fh, ">", "$tempDir/$name/.version") or
|
|
|
|
die "Failed to open $tempDir/$name/.version: $!\n";
|
|
|
|
print $fh "$version\n";
|
|
|
|
close($fh);
|
2011-07-13 11:53:57 +01:00
|
|
|
|
|
|
|
# Run regen.sh to create the rest of the tree
|
|
|
|
system ("cd $tempDir/$name && ./regen.sh") == 0
|
|
|
|
or die $!;
|
|
|
|
|
2013-07-31 23:16:16 +01:00
|
|
|
# A list of files to compress
|
|
|
|
my @toCompress;
|
|
|
|
|
2011-07-13 11:53:57 +01:00
|
|
|
# Create the documentation tarball
|
|
|
|
system("tar -cf $outDir/$name-doc.tar -C $tempDir $name/doc") == 0
|
|
|
|
or die "Unable to create documentation tarball : $!";
|
|
|
|
push @toCompress, "$outDir/$name-doc.tar";
|
|
|
|
|
|
|
|
# Remove the docs directory (we've already build a tarball for it)
|
|
|
|
File::Path::rmtree("$tempDir/$name/doc");
|
|
|
|
|
|
|
|
# Create the source tarball (both .gz and .bz2)
|
|
|
|
system("tar -cf $outDir/$name-src.tar -C $tempDir $name") == 0
|
2013-09-06 05:39:57 +01:00
|
|
|
or die "Unable to create source code tarball : $!";
|
2011-07-13 11:53:57 +01:00
|
|
|
push @toCompress, "$outDir/$name-src.tar";
|
|
|
|
|
|
|
|
# Construct the diffs, and zip them
|
|
|
|
if ($last) {
|
|
|
|
system("git diff $last..$tagName > $outDir/$name.diff") == 0
|
|
|
|
or die "Unable to create diff : $!";
|
|
|
|
push @toCompress, "$outDir/$name.diff";
|
|
|
|
}
|
|
|
|
|
2024-04-05 19:54:24 +01:00
|
|
|
my @toMD;
|
2011-07-13 11:53:57 +01:00
|
|
|
|
2013-07-31 23:00:24 +01:00
|
|
|
# Compress everything that needs squashing,
|
2024-04-05 19:54:24 +01:00
|
|
|
# and also set up a list for checksumming.
|
2011-07-13 11:53:57 +01:00
|
|
|
foreach my $file (@toCompress) {
|
|
|
|
system("gzip < $file > $file.gz") == 0
|
2020-04-16 12:37:39 +01:00
|
|
|
or die "Unable to create gzip file of '$file' : $!";
|
2024-04-05 19:54:24 +01:00
|
|
|
push @toMD, "$file.gz";
|
2011-07-13 11:53:57 +01:00
|
|
|
|
|
|
|
system("bzip2 < $file > $file.bz2") == 0
|
2020-04-16 12:37:39 +01:00
|
|
|
or die "Unable to create bzip file of '$file' : $!";
|
2024-04-05 19:54:24 +01:00
|
|
|
push @toMD, "$file.bz2";
|
2013-07-31 23:00:24 +01:00
|
|
|
|
|
|
|
# Delete the uncompressed tar files.
|
|
|
|
if ($file =~ /\.tar$/) {
|
|
|
|
unlink($file);
|
|
|
|
} else {
|
2024-04-05 19:54:24 +01:00
|
|
|
# Otherwise, queue this file for checksumming.
|
|
|
|
push @toMD, $file;
|
2013-07-31 23:00:24 +01:00
|
|
|
}
|
2011-07-13 11:53:57 +01:00
|
|
|
}
|
|
|
|
|
2024-04-05 19:54:24 +01:00
|
|
|
# Generate message digest files.
|
|
|
|
|
|
|
|
my $cwd = getcwd() or die "Failed getcwd(): $!";
|
|
|
|
my $md5 = which('md5');
|
|
|
|
my $md5sum = which('md5sum');
|
|
|
|
my $shasum = which("shasum");
|
|
|
|
my $sha256sum = which("sha256sum");
|
|
|
|
|
|
|
|
foreach my $pathname (@toMD) {
|
|
|
|
my $directory = dirname($pathname);
|
|
|
|
my $file = basename($pathname);
|
|
|
|
my $rc;
|
|
|
|
|
|
|
|
chdir($directory) or die "Failed cd $directory: $!";
|
|
|
|
|
|
|
|
if ($md5) {
|
|
|
|
$rc = system("$md5 -q $file > $file.md5");
|
|
|
|
if ($rc != 0) {
|
|
|
|
warn "Command failed: $md5 -q $file, code=$rc";
|
|
|
|
$errorCount += 1;
|
|
|
|
}
|
|
|
|
} elsif ($md5sum) {
|
|
|
|
$rc = system("$md5sum $file > $file.md5");
|
|
|
|
if ($rc != 0) {
|
|
|
|
warn "Command failed: md5sum $file, code=$rc";
|
|
|
|
$errorCount += 1;
|
|
|
|
}
|
2011-07-13 11:53:57 +01:00
|
|
|
} else {
|
2024-04-05 19:54:24 +01:00
|
|
|
warn "MD5 utility not found. Not producing $file.md5";
|
|
|
|
$errorCount += 1;
|
2011-07-13 11:53:57 +01:00
|
|
|
}
|
2024-04-05 19:54:24 +01:00
|
|
|
|
|
|
|
if ($shasum) {
|
|
|
|
$rc = system("$shasum -a 256 $file > $file.sha256");
|
|
|
|
if ($rc != 0) {
|
|
|
|
warn "Command failed: $shasum -a 256 $file, code=$rc";
|
|
|
|
$errorCount += 1;
|
|
|
|
}
|
|
|
|
} elsif ($sha256sum) {
|
|
|
|
$rc = system("$sha256sum $file > $file.sha256");
|
|
|
|
if ($rc != 0) {
|
|
|
|
warn "Command failed: $sha256sum $file, code=$rc";
|
|
|
|
$errorCount += 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
warn "SHA256 utility program not found. Not producing $file.sha256";
|
|
|
|
$errorCount += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
chdir($cwd) or die "Failed cd $cwd: $!";
|
2011-07-13 11:53:57 +01:00
|
|
|
}
|
2020-04-16 12:37:39 +01:00
|
|
|
|
2024-04-05 19:54:24 +01:00
|
|
|
if ($errorCount != 0) {
|
|
|
|
die "Failed to create all files; $errorCount errors encountered.";
|
|
|
|
}
|
2011-07-13 11:53:57 +01:00
|
|
|
|
|
|
|
__END__
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
2020-04-16 12:37:39 +01:00
|
|
|
make-release - Make an OpenAFS release from git
|
2011-07-13 11:53:57 +01:00
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
2020-04-16 12:21:51 +01:00
|
|
|
make-release [options] <tag>
|
2011-07-13 11:53:57 +01:00
|
|
|
|
|
|
|
Options:
|
2020-04-16 12:37:39 +01:00
|
|
|
--help brief help message
|
|
|
|
--man full documentation
|
2011-07-13 11:53:57 +01:00
|
|
|
--tagpoint <object> create new tag
|
|
|
|
--last <object> generate changelog and diffs from this point
|
|
|
|
--dir <dir> output results into this directory
|
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
2020-04-16 12:37:39 +01:00
|
|
|
make-release constructs an OpenAFS release from a local git clone. If run
|
2011-07-13 11:53:57 +01:00
|
|
|
with just the standard arguments, it will extract the contents of the
|
|
|
|
specified tag into the current directory, creating src and doc tarballs,
|
2024-04-05 19:54:24 +01:00
|
|
|
gzipping and bzipping them, and generating digest files. It will also create a
|
2011-07-13 11:53:57 +01:00
|
|
|
ChangeLog file, listing all of the changes in that release.
|
|
|
|
|
|
|
|
This standard behaviour may be modified by the following options
|
|
|
|
|
|
|
|
=head1 OPTIONS
|
|
|
|
|
|
|
|
=over 8
|
|
|
|
|
|
|
|
=item B<--last> I<object>
|
|
|
|
|
2020-04-16 12:37:39 +01:00
|
|
|
Generate the ChangeLog starting from I<object>. Also generate a
|
2011-07-13 11:53:57 +01:00
|
|
|
openafs-$version.diff file in the output directory containing all of the
|
|
|
|
changes between I<object> and the current tag
|
|
|
|
|
|
|
|
=item B<--dir> I<directory>
|
|
|
|
|
|
|
|
Instead of generating all of the output in the current directory, place it
|
2020-03-27 15:29:24 +00:00
|
|
|
in <directory>, which is created if it does not already exist.
|
2011-07-13 11:53:57 +01:00
|
|
|
|
|
|
|
=item B<--tagpoint> I<commit|branch>
|
|
|
|
|
|
|
|
Rather than using an existing tag, create a new one on the specified commit,
|
|
|
|
or on the tip of the specified branch. This will GPG sign the new tag, and
|
|
|
|
push it into gerrit.
|
|
|
|
|
2020-04-16 12:37:39 +01:00
|
|
|
=back
|
|
|
|
|
2011-07-13 11:53:57 +01:00
|
|
|
=cut
|