File: dch

package info (click to toggle)
pkg-haskell-tools 0.12.5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 160 kB
  • sloc: haskell: 691; sh: 591; perl: 308; makefile: 10
file content (75 lines) | stat: -rwxr-xr-x 2,777 bytes parent folder | download | duplicates (5)
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
75
#!/usr/bin/perl

use strict;
use warnings;

use DHT;

usage <<__END__;
dch - Append the changelog

Usage: dht dch [debchange option]

This is a wrapper for debchange(1), which will implement our custom heuristics
of whether a new changelog entry should be created, or the current one be
amended: If the current version is tagged, create a new changelog entry, else
append to the current one.

It passes either --append or --increment to debchange, so you should not.
The --newversion option may be used in order to specify the version number.
__END__

manpage <<__END__;

Usage: dht dch [debchange option]

This is a wrapper for debchange(1), which will implement our custom heuristics
of whether a new changelog entry should be created, or the current one be
amended: If the current version is tagged, create a new changelog entry, else
append to the current one.

It passes either --append or --increment to debchange, so you should not.
The --newversion option may be used in order to specify the version number.
__END__

my $changelog = "debian/changelog";
unless (-r $changelog) {
	print "ERROR: Could not find $changelog\n";
	next;
}
open CHANGELOG, '<', $changelog or die @!;
my $firstline = <CHANGELOG>;
if ($firstline =~ m/([\w-]+) \(([\w:~.+-]+)\) ([\w-]+);/) {
	my ($source, $version, $suite) = ($1, $2, $3);
	my $tag = sprintf "%s_v%s", $source, $version;
	$tag =~ tr/:~/_/;

	my @options = ("--release-heuristic", "changelog", "--no-auto-nmu");
	if (system(qw/git show-ref --quiet/, "refs/tags/$tag") == 0) {
        if ($suite eq "UNRELEASED") {
            printf STDERR "Tag %s exists, but version is marked UNRELEASED\n", $tag;
            next;
        }
        # A new changelog entry should be created.
        # If user passes '--newversion' then this version will be used,
        # else debchange will behave as if '--increment' has been given.
        system("debchange", @options, @ARGV);
	} else {
        if ($suite ne "UNRELEASED") {
            # We want to append to this version, but debchange's heuristics
            # consider this version to be released. Change distribution to
            # UNRELEASED, and revert but to the current one later.
            system("debchange", "-D", "UNRELEASED", "--append", "");
        }
        # Append to the current changelog entry.
        # Since distribution is UNRELEASED, debchange's heuristics will
        # append to the current entry, if '--newversion' is being used,
        # or fallback to the '--append' option otherwise.
        # Also, revert to the previous distribution. Users can always
        # override this by passing the '-D' option.
        system("debchange", @options, "-D", $suite, @ARGV);
	}
} else {
	printf STDERR "Cannot parse %s:\n%s", $changelog, $firstline;
	next;
}