]> git.ipfire.org Git - thirdparty/dracut.git/blobdiff - git2spec.pl
dracut.modules.7.asc: correct filename parse-instmodpost.sh in documentation
[thirdparty/dracut.git] / git2spec.pl
index 8525ad26a719b749d39cbfdba17e37cb0b8fca5c..0d8adb4a161149440cb05444712c9dcc07816e32 100755 (executable)
@@ -1,35 +1,23 @@
 #!/usr/bin/perl
 
-sub last_tag {
-    open( GIT, 'git log  --pretty=format:%H |');
-  LINE: while( <GIT> ) {
-      open( GIT2, "git tag --contains $_ |");
-      while( <GIT2> ) {
-         chomp;
-         last LINE if /..*/;
-      }
-      close GIT2;
-  }
-    $tag=$_;
-    close GIT2;
-    close GIT;         # be done
-    return $tag;
-};
-
 sub create_patches {
     my $tag=shift;
+    my $pdir=shift;
     my $num=0;
-    open( GIT, 'git format-patch --no-renames -N --no-signature '.$tag.' |');
+    open( GIT, 'git format-patch -M -N --no-signature -o "'.$pdir.'" '.$tag.' |');
     @lines=<GIT>;
     close GIT;         # be done
     return @lines;
 };
+
 use POSIX qw(strftime);
 my $datestr = strftime "%Y%m%d", gmtime;
 
 my $tag=shift;
-$tag=&last_tag if not defined $tag;
-my @patches=&create_patches($tag);
+my $pdir=shift;
+$tag=`git describe --abbrev=0 --tags` if not defined $tag;
+chomp($tag);
+my @patches=&create_patches($tag, $pdir);
 my $num=$#patches + 2;
 $tag=~s/[^0-9]+?([0-9]+)/$1/;
 my $release="$num.git$datestr";
@@ -40,26 +28,18 @@ while(<>) {
        print "Version: $tag\n";
     }
     elsif (/^Release:/) {
-       print "Release: $release\n";
+       print "Release: $release%{?dist}\n";
     }
     elsif ((/^Source0:/) || (/^Source:/)) {
        print $_;
        $num=1;
        for(@patches) {
+           s/.*\///g;
            print "Patch$num: $_";
            $num++;
        }
        print "\n";
     }
-    elsif (/^%setup/) {
-       print $_;
-       $num=1;
-       for(@patches) {
-           print "%patch$num -p1\n";
-           $num++;
-       }
-       print "\n";
-    }
     else {
        print $_;
     }