File: update-id

package info (click to toggle)
cfengine2 2.1.14-1sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,688 kB
  • ctags: 12
  • sloc: sh: 290; makefile: 113; perl: 29
file content (28 lines) | stat: -rw-r--r-- 483 bytes parent folder | download | duplicates (3)
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
#! /usr/bin/perl -i~
#
# Edit the patch version specified in either source code or patch

use strict;
use warnings;
use Getopt::Std;

my %opts;
getopts('v:', \%opts);

sub get_version {
    open(DP, "dpkg-parsechangelog |");
    while (<DP>) {
	return 'Debian ' . $1 if /^Version: (.*)$/;
    }
    return 0;
}

my $ver = $opts{'v'} || get_version() || die("Unable to get version");
my $rex = qr/(?<=\$PatchVersion: ).*(?= \$)/;

while (<>) {
    s/$rex/$ver/;
    print;
}

exit 0;