]> mj.ucw.cz Git - pciutils.git/blobdiff - maint/release.pm
lib/configure: drop usage of which
[pciutils.git] / maint / release.pm
index bf8afc0706bf86b5923c33bbfd8c4036aaa04726..33f64d7e6886365db4830e26d5bb4b21601a7947 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 # A simple system for making software releases
-# (c) 2003 Martin Mares <mj@ucw.cz>
+# (c) 2003--2011 Martin Mares <mj@ucw.cz>
 
 package UCW::Release;
 use strict;
@@ -15,24 +15,28 @@ sub new($$) {
                "PACKAGE" => $basename,
                "rules" => [
                        # p=preprocess, s=subst, -=discard
-                       '(^|/)(CVS|\.arch-ids|{arch}|tmp)/' => '-',
+                       '(^|/)(CVS|\.arch-ids|{arch}|\.git|tmp)/' => '-',
+                       '\.sw[a-z]$' => '-',
                        '\.(lsm|spec)$' => 'ps',
                        '(^|/)README$' => 's'
                        ],
+               "directories" => [
+                       ],
                "conditions" => {
                        },
                "DATE" => `date '+%Y-%m-%d' | tr -d '\n'`,
                "LSMDATE" => `date '+%y%m%d' | tr -d '\n'`,
                "distfiles" => [
                        ],
-               "archivedir" => "/home/mj/tmp/archives/$basename",
+               "archivedir" => $ENV{HOME} . "/archives/sw/$basename",
                "uploads" => [
                        ],
                # Options
                "do_test" => 1,
                "do_patch" => 1,
                "diff_against" => "",
-               "do_upload" => 1
+               "do_upload" => 1,
+               "do_sign" => 1,
        };
        bless $s;
        return $s;
@@ -145,14 +149,14 @@ sub CopyFile($$$$) {
                                        $empty && next;
                                        $empty = 1;
                                } else { $empty = 0; }
-                       }               
+                       }
                        print O;
                }
                close O;
                close I;
                ! -x $f or chmod(0755, "$dir/$f") or die "chmod($dir/$f): $!";
        } else {
-               `cp -a $f $dir/$f`; die if $?;
+               `cp -a "$f" "$dir/$f"`; die if $?;
        }
 }
 
@@ -182,6 +186,10 @@ sub GenPackage($) {
                $s->CopyFile($f, $dir, $action);
        }
 
+       foreach my $d (@{$s->{"directories"}}) {
+               `mkdir -p $dir/$d`; die if $?;
+       }
+
        if (-f "$dir/Makefile") {
                print "Cleaning up\n";
                `cd $dir && make distclean >&2`; die if $?;
@@ -192,6 +200,14 @@ sub GenPackage($) {
        `cd $dd && tar cz${tarvv}f $pkg.tar.gz $pkg >&2`; die if $?;
        push @{$s->{"distfiles"}}, "$dd/$pkg.tar.gz";
 
+       if ($s->{'do_sign'}) {
+               print "Signing package\n";
+               system "gpg", "--armor", "--detach-sig", "$dd/$pkg.tar.gz";
+               die if $?;
+               rename "$dd/$pkg.tar.gz.asc", "$dd/$pkg.tar.gz.sign" or die "No signature produced!?\n";
+               push @{$s->{"distfiles"}}, "$dd/$pkg.tar.gz.sign";
+       }
+
        my $adir = $s->{"archivedir"};
        my $afile = "$adir/$pkg.tar.gz";
        print "Archiving to $afile\n";
@@ -217,8 +233,9 @@ sub ParseOptions($) {
                "test!" => \$s->{"do_test"},
                "patch!" => \$s->{"do_patch"},
                "diff-against=s" => \$s->{"diff_against"},
-               "upload!" => \$s->{"do_upload"}
-       ) || die "Syntax: release [--verbose] [--test] [--nopatch] [--diff-against=<version>] [--noupload]";
+               "upload!" => \$s->{"do_upload"},
+               "sign!" => \$s->{"do_sign"},
+       ) || die "Syntax: release [--verbose] [--test] [--nopatch] [--diff-against=<version>] [--noupload] [--nosign]";
 }
 
 sub Test($) {
@@ -245,7 +262,8 @@ sub MakePatch($) {
        } elsif (defined $s->{"OLDVERSION"}) {
                $oldver = $s->{"OLDVERSION"};
        } else {
-               die "MakePatch: Don't know which is the previous version";
+               print "WARNING: No previous version known. No patch generated.\n";
+               return;
        }
        my $pkg0 = $s->{"PACKAGE"} . "-" . $oldver;