]> git.ipfire.org Git - thirdparty/dracut.git/blame - git2spec.pl
iscsi: always popd, even if there is no iscsi device
[thirdparty/dracut.git] / git2spec.pl
CommitLineData
0e6a94b3
HH
1#!/usr/bin/perl
2
0e6a94b3
HH
3sub create_patches {
4 my $tag=shift;
9af39cbe 5 my $pdir=shift;
2ceb910a
HH
6 my $n=1;
7 my @lines;
8c2aa616
HH
8 my $fname;
9 my $f=0;
2ceb910a
HH
10
11 mkdir $pdir, 0755;
12
13 open( GIT, 'git log -p --pretty=email --stat -m --first-parent --reverse '.$tag.'..HEAD |');
14
15 while (<GIT>) {
16 if (/^From [a-z0-9]{40} .*$/) {
8c2aa616 17 $fname = sprintf("%04d", $n++).".patch";
2ceb910a 18 open FH, ">".$pdir."/".$fname;
8c2aa616
HH
19 $f=1;
20 }
21 if (/^---$/ && $f == 1) {
22 push @lines, $fname;
23 $f=0;
2ceb910a
HH
24 }
25 print FH;
26 }
27
0e6a94b3
HH
28 return @lines;
29};
f2953927 30
0e6a94b3
HH
31use POSIX qw(strftime);
32my $datestr = strftime "%Y%m%d", gmtime;
33
34my $tag=shift;
9af39cbe 35my $pdir=shift;
5f8cd1a4
HH
36$tag=`git describe --abbrev=0 --tags` if not defined $tag;
37chomp($tag);
9af39cbe 38my @patches=&create_patches($tag, $pdir);
0e6a94b3
HH
39my $num=$#patches + 2;
40$tag=~s/[^0-9]+?([0-9]+)/$1/;
41my $release="$num.git$datestr";
42$release="1" if $num == 1;
43
44while(<>) {
45 if (/^Version:/) {
46 print "Version: $tag\n";
47 }
0344c2be
HH
48 elsif (/^%define dist_free_release/) {
49 print "%define dist_free_release $release\n";
0e6a94b3
HH
50 }
51 elsif ((/^Source0:/) || (/^Source:/)) {
52 print $_;
53 $num=1;
54 for(@patches) {
a9e8ca4a 55 s/.*\///g;
2ceb910a 56 print "Patch$num: $_\n";
0e6a94b3
HH
57 $num++;
58 }
59 print "\n";
60 }
0e6a94b3
HH
61 else {
62 print $_;
63 }
64}