blob: 2deab7f697d0336e6f6fc16b2fb96ebb5502b7a5 (
plain)
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
# Validate if packages are using the expected component
# Tested: postgresql-NN and libpq*
# Input: Packages file or "dpkg-deb -I" output (which has everything
# indented by one space, hence the " ?" in the regexps)
use strict;
use warnings;
my $mainversion;
# read pgapt config
foreach my $dir (qw(. .. /srv/apt)) {
next unless (-f "$dir/pgapt.conf");
open F, "$dir/pgapt.conf";
while (<F>) {
$mainversion = $1 if /^PG_MAIN_VERSION=(.+)/;
}
close F;
last;
}
die "Could not determine PG_MAIN_VERSION" unless ($mainversion);
$/ = ''; # slurp paragraphs
my $exit = 0;
while (<>) {
my ($pkg) = (/^ ?Package: (.*)/m) or die "Paragraph without Package: $_";
next unless $pkg =~ /^(postgresql-[\d.]+$|libpq5)/;
my ($component) = (m!^ ?Section: (.*)/!m);
$component ||= 'main';
my ($ver, $major) = (/^ ?Version: (([\d.]{1,3})[.~].*)/m)
or die "Paragraph without Version: $_"; # major is 9.x or 1x, followed by . or ~
my ($arch) = (m!^ ?Architecture: (.+)!m);
die "Paragraph without Architecture: $_" unless ($arch);
my $expected_component;
if ($major eq $mainversion) { # most recent stable branch -> main
$expected_component = 'main';
} else {
if ($pkg =~ /^lib/) { # all other lib packages go to N.N/NN
$expected_component = $major;
} else { # postgresql
if ($major > $mainversion) { # devel/beta/rc server packages
$expected_component = $major;
} else { # $major < $mainversion # older stable server packages
$expected_component = 'main';
}
}
}
if ($component ne $expected_component and "$pkg:$arch ($ver)" ne "libpq5:ppc64el (11.2-2.pgdg80+1)") { # whitelist old libpq5 on jessie/ppc64el
warn "$pkg:$arch ($ver) is in $component but should be in $expected_component\n";
$exit = 1;
} else {
print "$pkg:$arch ($ver) $component: OK\n";
}
}
exit $exit;
|