]> git.ipfire.org Git - thirdparty/dracut.git/blob - git2spec.pl
ifcfg/write-ifcfg.sh: turn on IPV6INIT, if any inet6 address is found
[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";
24
25 while(<>) {
26 if (/^Version:/) {
27 print "Version: $tag\n";
28 }
29 elsif (/^Release:/) {
30 print "Release: $release%{?dist}\n";
31 }
32 elsif ((/^Source0:/) || (/^Source:/)) {
33 print $_;
34 $num=1;
35 for(@patches) {
36 s/.*\///g;
37 print "Patch$num: $_";
38 $num++;
39 }
40 print "\n";
41 }
42 else {
43 print $_;
44 }
45 }