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