dracut-systemd/dracut-initqueue: only start service if really needed
[dracut.git] / git2spec.pl
blob0d8adb4a161149440cb05444712c9dcc07816e32
1 #!/usr/bin/perl
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;
13 use POSIX qw(strftime);
14 my $datestr = strftime "%Y%m%d", gmtime;
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;
26 while(<>) {
27 if (/^Version:/) {
28 print "Version: $tag\n";
30 elsif (/^Release:/) {
31 print "Release: $release%{?dist}\n";
33 elsif ((/^Source0:/) || (/^Source:/)) {
34 print $_;
35 $num=1;
36 for(@patches) {
37 s/.*\///g;
38 print "Patch$num: $_";
39 $num++;
41 print "\n";
43 else {
44 print $_;