]> git.ipfire.org Git - thirdparty/dracut.git/blame - git2spec.pl
99fs-lib/module-setup.sh: only include fsck helper needed for hostonly
[thirdparty/dracut.git] / git2spec.pl
CommitLineData
0e6a94b3
HH
1#!/usr/bin/perl
2
3sub last_tag {
4 open( GIT, 'git log --pretty=format:%H |');
5 LINE: while( <GIT> ) {
6 open( GIT2, "git tag --contains $_ |");
7 while( <GIT2> ) {
8 chomp;
9 last LINE if /..*/;
10 }
11 close GIT2;
12 }
13 $tag=$_;
14 close GIT2;
15 close GIT; # be done
16 return $tag;
17};
18
19sub create_patches {
20 my $tag=shift;
21 my $num=0;
85cda6ae 22 open( GIT, 'git format-patch -N --no-signature '.$tag.' |');
0e6a94b3
HH
23 @lines=<GIT>;
24 close GIT; # be done
25 return @lines;
26};
f2953927 27
0e6a94b3
HH
28use POSIX qw(strftime);
29my $datestr = strftime "%Y%m%d", gmtime;
30
31my $tag=shift;
32$tag=&last_tag if not defined $tag;
33my @patches=&create_patches($tag);
34my $num=$#patches + 2;
35$tag=~s/[^0-9]+?([0-9]+)/$1/;
36my $release="$num.git$datestr";
37$release="1" if $num == 1;
38
39while(<>) {
40 if (/^Version:/) {
41 print "Version: $tag\n";
42 }
43 elsif (/^Release:/) {
f2953927 44 print "Release: $release%{?dist}\n";
0e6a94b3
HH
45 }
46 elsif ((/^Source0:/) || (/^Source:/)) {
47 print $_;
48 $num=1;
49 for(@patches) {
50 print "Patch$num: $_";
51 $num++;
52 }
53 print "\n";
54 }
0e6a94b3
HH
55 else {
56 print $_;
57 }
58}