File: what-to-build

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 (59 lines) | stat: -rwxr-xr-x 1,375 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
#!/usr/bin/perl

use strict;
use warnings;

use DHT;

usage <<__END__;
what-to-build - Find packages to be built

Usage: dht what-to-build [directory..]

For all given directories (defaults to p/*/), check if they are to be built.
This means, in particular:

 * The latest entry in debian/changelog is not UNRELEASED, and
 * there is no corresponding tag in the git repository.
__END__

manpage <<__END__;

Usage: dht what-to-build [directory..]

For all given directories (defaults to `p/*/`), check if they are to be built.
This means, in particular:

 * The latest entry in `debian/changelog` is *not* `UNRELEASED`, and
 * there is no corresponding tag in the git repository.
__END__


my @dirs = @ARGV;

unless (@dirs) {
	@dirs = glob 'p/*/';
}

my %tags;
open TAGS, '-|', 'git tag -l' or die @!;
while (<TAGS>) { chomp; $tags{$_}++ };
close TAGS or die @!;

for my $dir (@dirs) {
	my $changelog = "$dir/debian/changelog";
	next unless -r $changelog;
	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/:~/_/;
		next if ($suite eq "UNRELEASED");
		next if ($tags{$tag});
		printf "%s\n", $dir;
	} else {
		printf STDERR "Cannot parse %s:\n%s", $changelog, $firstline;
		next
	}
}