chore: bump rpm spec version, adjust script to make this automatic

This commit is contained in:
Stéphane Lesimple
2021-03-30 07:56:15 +00:00
committed by Stéphane Lesimple
parent a258f760fd
commit 4cea07a209
2 changed files with 16 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
Summary: Extended (but compatible) fork of ttyrec
Name: ovh-ttyrec
Version: 1.1.6.6
Version: 1.1.6.7
Release: 1
License: BSD
Group: Applications/System

View File

@@ -4,25 +4,27 @@ use warnings;
use File::Copy;
my $ver;
my $latestver;
my @changes;
my $changelog_fd;
my $oldspec_fd;
my $newspec_fd;
my $first = 1;
open($changelog_fd, '<', 'debian/changelog') or die $!;
open($oldspec_fd, '<', 'ovh-ttyrec.spec') or die $!;
open($newspec_fd, '>', 'ovh-ttyrec.spec.tmp') or die $!;
open($oldspec_fd, '<', 'ovh-ttyrec.spec') or die $!;
# first, copy all the old spec contents up to %changelog
my @contents;
while (<$oldspec_fd>) {
print $newspec_fd $_;
push @contents, $_;
if (/^%changelog/) { last; }
}
close($oldspec_fd);
open($changelog_fd, '<', 'debian/changelog') or die $!;
while (<$changelog_fd>) {
if (m{^ovh-ttyrec \(([^)]+)\)}) {
$ver = $1;
$latestver = $ver if not defined $latestver;
}
elsif (m{^ -- (.+)\s+(...), (..) (...) (....)}) {
my ($author,$wday,$day,$month,$year) = ($1,$2,$3,$4,$5);
@@ -30,11 +32,11 @@ while (<$changelog_fd>) {
# to: Wed Nov 04 2020
my $date = "$wday $month $day $year";
if (@changes) { s/^\*/-/ for @changes; }
print $newspec_fd "\n" if $first == 0;
push @contents, "\n" if $first == 0;
$first = 0;
print $newspec_fd "* $date $author $ver\n";
print $newspec_fd join("\n", @changes);
print $newspec_fd "\n";
push @contents, "* $date $author $ver\n";
push @contents, join("\n", @changes);
push @contents, "\n";
undef $ver;
@changes = ();
}
@@ -46,5 +48,10 @@ while (<$changelog_fd>) {
}
}
close($changelog_fd);
s/^Version: .*/Version: $latestver/ for @contents;
open($newspec_fd, '>', 'ovh-ttyrec.spec.tmp') or die $!;
print $newspec_fd join("", @contents);
close($newspec_fd);
move("ovh-ttyrec.spec.tmp", "ovh-ttyrec.spec");