-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathnewvdr
executable file
·74 lines (62 loc) · 2.1 KB
/
newvdr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/perl
# newvdr - Helper script to spread the VDR version number to plugin PKGBUILD's
# Copyright (C) 2019 Manuel Reimer <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
use strict;
use warnings;
my $VDRPKGBUILD = 'vdr/PKGBUILD';
my $PLUGINSPATH = 'plugins';
{
# Read VDR's API version
my $vdrversion;
open(my $fh, '<', $VDRPKGBUILD) or die("Failed to read VDR PKGBUILD\n");
while (my $line = <$fh>) {
($vdrversion) = $line =~ /^_vdrapi=(\d+)/ and last;
}
close($fh);
die ("Can't read vdr-api from '$VDRPKGBUILD'\n") unless ($vdrversion);
# Loop over the plugins
open($fh, '<', 'repo-make.conf') or die($!);
my @plugindirs = grep(/^\Q$PLUGINSPATH\E\//, <$fh>);
close($fh);
chomp(@plugindirs);
my $counter = 0;
foreach my $plugindir (@plugindirs) {
next unless (-d $plugindir);
# Read full plugin PKGBUILD content
open($fh, '<', "$plugindir/PKGBUILD")
or die("Can't read PKGBUILD in $plugindir\n");
my $pkgbuildcontent = join('', <$fh>);
close($fh);
# Parse out variables
my ($vdrapi) = $pkgbuildcontent =~ /^_vdrapi=(.+)/m
or die("Can't read _vdrapi for $plugindir\n");
my ($pkgrel) = $pkgbuildcontent =~ /^pkgrel=(\d+)/m
or die("Can't read pkgrel for $plugindir\n");
# Anything to do for us?
next if ($vdrapi eq $vdrversion);
# Count up pkgrel
$pkgrel++;
# Edit PKGBUILD content
$pkgbuildcontent =~ s/^_vdrapi=.+$/_vdrapi=$vdrversion/m;
$pkgbuildcontent =~ s/^pkgrel=.+$/pkgrel=$pkgrel/m;
# Write out changes
open($fh, '>', "$plugindir/PKGBUILD")
or die("Can't write PKGBUILD in $plugindir\n");
print $fh $pkgbuildcontent;
close($fh);
# Count up
$counter++;
}
if ($counter > 1) {
print "Successfully edited $counter PKGBUILD's\n";
print "Don't forget to review the automatic changes via 'git diff'!\n";
}
else {
print "Nothing to do!\n";
}
}