File: what-to-upgrade

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 (83 lines) | stat: -rwxr-xr-x 2,091 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
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
76
77
78
79
80
81
82
83
#!/usr/bin/perl

use strict;
use warnings;

use File::Slurp;

use DHT;

usage <<__END__;
what-to-upgrade - Find packages to be upgraded

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

For all given directories (defaults to p/*/), check if they are to be upgraded,
i.e. that the package plan lists a newer version than the changelog.
__END__

manpage <<__END__;

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

For all given directories (defaults to `p/*/`), check if they are to be upgraded,
i.e. that the package plan lists a newer version than the changelog.
__END__

my @dirs = @ARGV;

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

my %plan;
open PLAN, '<', '../package-plan/packages.txt' or die "Failure to open ../package-plan/packages.txt: ".@!;
while (<PLAN>) {
        chomp;
        next if /^#/;
        next if /^\s*$/;
        unless (m/^(.*?) (.*?)(?: ([^#]*))?(?:#.*)?$/) {
                print "Ignoring unparseable line $.: $_\n";
        }
        my ($pkg,$version,$attribs) = ($1,$2,$3);
	next if $attribs and $attribs =~ /obsolete/;
	$plan{$pkg} = $version;
}
close PLAN or die @!;

for my $dir (@dirs) {
	my $changelog = "$dir/debian/changelog";
	my $watchfile = "$dir/debian/watch";
	next unless -r $changelog;
	next unless -r $watchfile;

	open CHANGELOG, '<', $changelog or die @!;
	my $firstline = <CHANGELOG>;
	if ($firstline =~ m/([\w-]+) \(([\w:~.+-]+)\) (\w+);/) {
		my ($source, $version, $suite) = ($1, $2, $3);
		my ($cabal_version) = ($version =~ m/^(?:.*:)?(.*?)(?:\+(?:dfsg|ds)\d*)?-.*?$/);

		my $watch = read_file($watchfile) or die @!;
		unless ($watch =~ m!https?://hackage.haskell.org/package/(.*)/distro-monitor!) {
			#printf STDERR "Cannot parse watchfile %s\n", $watchfile;
			# ignore packages with non-standard watch files
			next
		}
		my $cabal_package = $1;

		unless (exists $plan{$cabal_package}) {
			printf STDERR "W: package %s not in the package plan\n", $cabal_package;
			next
		}

		if ($cabal_version ne $plan{$cabal_package}) {
			printf "%s\n", $dir;
		}
	} else {
		printf STDERR "Cannot parse %s:\n%s", $changelog, $firstline;
		next
	}
}