File: update-debver

package info (click to toggle)
derivations 0.53.20120414-1.2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,208 kB
  • ctags: 486
  • sloc: cpp: 1,634; perl: 600; makefile: 153; sh: 116
file content (61 lines) | stat: -rw-r--r-- 1,229 bytes parent folder | download | duplicates (6)
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
#! /usr/bin/perl
use warnings;
use strict;
use integer;
use FindBin;
use lib $FindBin::RealBin;
use Def;

# This script adds or updates the Debian package version number at the
# head of debian/changelog.

our $usage = <<END;
usage: $0 [-h] [debian-version]
    -h print this usage message
If no debian-version is given, then the package version number
is removed from the changelog.
END

our $changelog_deb = "${FindBin::RealBin}/../debian/changelog";

# Read command-line arguments and options.
my @arg;
my %opt;
for ( @ARGV ) {
  if ( my($o) = /^-(\S+)/ ) {
    $opt{$_} = 1 for split //, $o;
  }
  else { push @arg, $_ }
}
if ( $opt{h} || $opt{'?'} ) {
  print $usage;
  exit 0;
}
my( $debver, $vdstr );
if    ( @arg == 0 ) {
  die $usage;
  $debver = '';
  $vdstr  = '';
}
elsif ( @arg == 1 ) {
  $debver = shift @arg;
  $vdstr  = "-$debver";
}
else { die $usage }

# Read the changelog in.
my @cld;
open CL, '<', $changelog_deb;
  @cld = <CL>;
close CL;

# Update the changelog's first line.
$cld[0] =~
  s/^(${Def::out} \(${Def::basever}\.\d+)((?:-\d+)?)(\))/$1$vdstr$3/
  or die "$0: can't parse the first line of debian/changelog\n";

# Write the changelog out.
open CL, '>', $changelog_deb;
  print CL @cld;
close CL;