]> git.ipfire.org Git - thirdparty/dracut.git/blob - git2spec.pl
rename sosreport to rdsosreport
[thirdparty/dracut.git] / git2spec.pl
1 #!/usr/bin/perl
2
3 sub create_patches {
4 my $tag=shift;
5 my $pdir=shift;
6 my $num=0;
7 open( GIT, 'git format-patch -M -N --no-signature -o "'.$pdir.'" '.$tag.' |');
8 @lines=<GIT>;
9 close GIT; # be done
10 return @lines;
11 };
12
13 use POSIX qw(strftime);
14 my $datestr = strftime "%Y%m%d", gmtime;
15
16 my $tag=shift;
17 my $pdir=shift;
18 $tag=`git describe --abbrev=0 --tags` if not defined $tag;
19 chomp($tag);
20 my @patches=&create_patches($tag, $pdir);
21 my $num=$#patches + 2;
22 $tag=~s/[^0-9]+?([0-9]+)/$1/;
23 my $release="$num.git$datestr";
24 $release="1" if $num == 1;
25
26 while(<>) {
27 if (/^Version:/) {
28 print "Version: $tag\n";
29 }
30 elsif (/^Release:/) {
31 print "Release: $release%{?dist}\n";
32 }
33 elsif ((/^Source0:/) || (/^Source:/)) {
34 print $_;
35 $num=1;
36 for(@patches) {
37 s/.*\///g;
38 print "Patch$num: $_";
39 $num++;
40 }
41 print "\n";
42 }
43 else {
44 print $_;
45 }
46 }