Updated version 1.6.21 from 'upstream/1.6.21'
[pkg-k5-afs_openafs.git] / build-tools / make-release
blobd35a27107fbe092f78971a97e550cc19f508fe16
1 #!/usr/bin/perl
3 use Getopt::Long;
4 use Pod::Usage;
5 use File::Path;
6 use File::Temp;
8 my $tag;
9 my $last;
10 my $tagPoint;
11 my $last;
12 my $outDir = ".";
14 GetOptions("help|?" => \$help,
15 "man" => \$man,
16 "tagpoint=s" => \$tagPoint,
17 "last=s" => \$last,
18 "dir=s" => \$outDir) or pod2usage(2);
20 pod2usage(1) if $help;
21 pod2usage(-exitstatus => 0, -verbose => 2) if $man;
23 my $tagName = shift;
24 my $version = shift;
26 pod2usage(2) if !defined($tagName);
28 # Tag the repository
30 if ($tagPoint) {
31 system ("git tag -s $tagName $tagPoint") == 0
32 or die "git tag failed with : $!";
34 # Push the tag upstream
35 system ("git push ssh://gerrit.openafs.org:29418/openafs tag $tagName") == 0
36 or die "git push failed with : $!";
39 $version = `git describe --abbrev=4 $tagName`;
40 chomp $version;
41 $version=~s/openafs-[^-]*-//;
42 $version=~s/_/./g;
44 # Grab the tagged code into a temporary directory
46 my $name = "openafs-".$version;
48 my $tempDir = File::Temp::tempdir();
49 system ("git archive --format=tar --prefix=$name/ $tagName ".
50 " | tar -C $tempDir -x") == 0
51 or die "Git archive failed with: $?";
53 # Construct the ChangeLog
54 if ($last) {
55 system("git log $last..$tagName > $outDir/ChangeLog");
56 } else {
57 system("git log $tagName > $outDir/ChangeLog");
60 # Describe the tree
61 system("git describe --abbrev=4 $tagName > $tempDir/$name/.version");
63 # Run regen.sh to create the rest of the tree
64 system ("cd $tempDir/$name && ./regen.sh") == 0
65 or die $!;
67 # Create the documentation tarball
68 system("tar -cf $outDir/$name-doc.tar -C $tempDir $name/doc") == 0
69 or die "Unable to create documentation tarball : $!";
70 push @toCompress, "$outDir/$name-doc.tar";
72 # Remove the docs directory (we've already build a tarball for it)
73 File::Path::rmtree("$tempDir/$name/doc");
75 # Create the source tarball (both .gz and .bz2)
76 system("tar -cf $outDir/$name-src.tar -C $tempDir $name") == 0
77 or die "Unable to create documentation tarball : $!";
78 push @toCompress, "$outDir/$name-src.tar";
80 # Construct the diffs, and zip them
81 if ($last) {
82 system("git diff $last..$tagName > $outDir/$name.diff") == 0
83 or die "Unable to create diff : $!";
84 push @toCompress, "$outDir/$name.diff";
87 my @toMD5;
89 # Compress everything that needs squashing,
90 # and also set up a list for md5 checksumming.
91 foreach my $file (@toCompress) {
92 system("gzip < $file > $file.gz") == 0
93 or die "Unable to create gzip file of '$file' : $!";
94 push @toMD5, "$file.gz";
96 system("bzip2 < $file > $file.bz2") == 0
97 or die "Unable to create bzip file of '$file' : $!";
98 push @toMD5, "$file.bz2";
100 # Delete the uncompressed tar files.
101 if ($file =~ /\.tar$/) {
102 unlink($file);
103 } else {
104 # Otherwise, queue this file for md5 checksumming.
105 push @toMD5, $file;
109 foreach my $file (@toMD5) {
110 if (-x "/sbin/md5") {
111 system("/sbin/md5 -q $file > $file.md5");
112 } elsif (-x "/usr/bin/md5sum") {
113 system("/usr/bin/md5sum $file > $file.md5");
114 } else {
115 print STDERR "No md5 utiltiy found. Not producing checksums\n";
120 __END__
122 =head1 NAME
124 make_release - Make an OpenAFS release from git
126 =head1 SYNOPSIS
128 make_release [options] <tag> [<version>]
130 Options:
131 --help brief help message
132 --man full documentation
133 --tagpoint <object> create new tag
134 --last <object> generate changelog and diffs from this point
135 --dir <dir> output results into this directory
137 =head1 DESCRIPTION
139 make_release constructs an OpenAFS release from a local git clone. If run
140 with just the standard arguments, it will extract the contents of the
141 specified tag into the current directory, creating src and doc tarballs,
142 gziping and bziping them, and generating md5 hashes. It will also create a
143 ChangeLog file, listing all of the changes in that release.
145 This standard behaviour may be modified by the following options
147 =head1 OPTIONS
149 =over 8
151 =item B<--last> I<object>
153 Generate the ChangeLog starting from I<object>. Also generate a
154 openafs-$version.diff file in the output directory containing all of the
155 changes between I<object> and the current tag
157 =item B<--dir> I<directory>
159 Instead of generating all of the output in the current directory, place it
160 in <directory>, which must already exist.
162 =item B<--tagpoint> I<commit|branch>
164 Rather than using an existing tag, create a new one on the specified commit,
165 or on the tip of the specified branch. This will GPG sign the new tag, and
166 push it into gerrit.
168 =cut