| 1 |
#!/bin/sh
|
| 2 |
|
| 3 |
####################
|
| 4 |
# Copyright (C) 2009 by Raphael Geissert <atomo64@gmail.com>
|
| 5 |
#
|
| 6 |
#
|
| 7 |
# This file is free software: you can redistribute it and/or modify
|
| 8 |
# it under the terms of the GNU General Public License as published by
|
| 9 |
# the Free Software Foundation, either version 3 of the License, or
|
| 10 |
# (at your option) any later version.
|
| 11 |
#
|
| 12 |
# This file is distributed in the hope that it will be useful,
|
| 13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
# GNU General Public License for more details.
|
| 16 |
#
|
| 17 |
# You should have received a copy of the GNU General Public License
|
| 18 |
# along with this file. If not, see <http://www.gnu.org/licenses/>.
|
| 19 |
####################
|
| 20 |
|
| 21 |
set -e
|
| 22 |
|
| 23 |
case "$1" in
|
| 24 |
-h|--help)
|
| 25 |
cat <<FOO
|
| 26 |
Usage: $(basename "$0") [--help]
|
| 27 |
--help: this information.
|
| 28 |
|
| 29 |
This script obtains the list of all source packages in the archive and
|
| 30 |
checks that the list of packages in embedded-code-copies is correct.
|
| 31 |
Results are written to stderr, everything else in stdout is just informational
|
| 32 |
and can safely be ignored or redirected to /dev/null.
|
| 33 |
FOO
|
| 34 |
exit
|
| 35 |
;;
|
| 36 |
esac
|
| 37 |
|
| 38 |
[ -f data/embedded-code-copies ] || {
|
| 39 |
echo "Please run under the top-level directory of the repository" >&2
|
| 40 |
exit 1
|
| 41 |
}
|
| 42 |
|
| 43 |
PKGSLIST=$(mktemp)
|
| 44 |
|
| 45 |
echo "Querying UDD via alioth (you may need to enter a password):"
|
| 46 |
ssh -oBatchMode=yes alioth.debian.org "psql -Atx -c \"SELECT DISTINCT source,release from sources where distribution='debian';\" 'service=udd'" > "$PKGSLIST"
|
| 47 |
|
| 48 |
export PKGSLIST
|
| 49 |
|
| 50 |
perl -w <<'PSCRIPT'
|
| 51 |
|
| 52 |
use strict;
|
| 53 |
|
| 54 |
# translate pseudo-names into a package name that exists
|
| 55 |
my %translate = qw(
|
| 56 |
python* python2.5
|
| 57 |
drupal drupal6
|
| 58 |
typo3 typo3-src
|
| 59 |
linux-kernel linux-2.6
|
| 60 |
zope zope3
|
| 61 |
);
|
| 62 |
$translate{'linux kernels'} = 'linux-2.6';
|
| 63 |
|
| 64 |
# archived stable releases
|
| 65 |
my @oldstables = qw(
|
| 66 |
woody
|
| 67 |
sarge
|
| 68 |
etch
|
| 69 |
);
|
| 70 |
|
| 71 |
my %pkgs;
|
| 72 |
|
| 73 |
open(PKGS, '<', $ENV{'PKGSLIST'});
|
| 74 |
{
|
| 75 |
my ($pkg, $release, %ref);
|
| 76 |
my $entry = 0;
|
| 77 |
$ref{'source'} = \$pkg;
|
| 78 |
$ref{'release'} = \$release;
|
| 79 |
while(<PKGS>) {
|
| 80 |
chomp;
|
| 81 |
if (m/^$/ && defined($pkg)) {
|
| 82 |
next unless $entry;
|
| 83 |
$pkgs{$pkg} = {}
|
| 84 |
unless (exists $pkgs{$pkg});
|
| 85 |
$pkgs{$pkg}{$release} = 1;
|
| 86 |
$entry = 0;
|
| 87 |
$release = $pkg = '';
|
| 88 |
next;
|
| 89 |
}
|
| 90 |
if($_ eq '') {
|
| 91 |
print STDERR "Skipping empty line $., \$pkg not defined\n";
|
| 92 |
next;
|
| 93 |
}
|
| 94 |
my ($k, $v) = split(/\|/);
|
| 95 |
${$ref{$k}} = $v;
|
| 96 |
$entry = 1;
|
| 97 |
}
|
| 98 |
}
|
| 99 |
close(PKGS);
|
| 100 |
|
| 101 |
my (@errors, @warnings);
|
| 102 |
|
| 103 |
open(DATA, '<', 'data/embedded-code-copies');
|
| 104 |
my ($seen_flag, $embedded_package, %embedding_packages) = (0, '');
|
| 105 |
while(<DATA>) {
|
| 106 |
if (m/^---BEGIN/) {
|
| 107 |
$seen_flag = 1;
|
| 108 |
next;
|
| 109 |
}
|
| 110 |
next unless $seen_flag;
|
| 111 |
next if /(?:NOTE|TODO):/;
|
| 112 |
s/\(.*?\)//;
|
| 113 |
s/(?:^\s+|\s+$)//g;
|
| 114 |
next if ($_ eq '');
|
| 115 |
$_ = lc;
|
| 116 |
|
| 117 |
if (m/^\w/) {
|
| 118 |
s,/.+$,,;
|
| 119 |
while (my ($pkg, $count) = each %embedding_packages) {
|
| 120 |
push @errors, "Duplicated entry for $pkg (for $embedded_package)"
|
| 121 |
if ($count gt 1);
|
| 122 |
}
|
| 123 |
undef %embedding_packages;
|
| 124 |
if (exists($translate{$_})) {
|
| 125 |
$embedded_package = $translate{$_};
|
| 126 |
} else {
|
| 127 |
$embedded_package = $_;
|
| 128 |
}
|
| 129 |
unless (exists($pkgs{$embedded_package})) {
|
| 130 |
# disabled for now, need to check how bin/check-new-issues uses it:
|
| 131 |
# push @warnings, "'$embedded_package' does not exist, line:$.";
|
| 132 |
}
|
| 133 |
next;
|
| 134 |
}
|
| 135 |
|
| 136 |
if (m/^(?:\[(\w+)\]\s+)?-\s+(.+?)\s(?:<(.+?)>|\d)/) {
|
| 137 |
my ($release, $embedding_package, $status) = ($1 || '', $2, $3 || '');
|
| 138 |
my $reported = 0;
|
| 139 |
|
| 140 |
$embedding_package = $translate{$embedding_package}
|
| 141 |
if (exists($translate{$embedding_package}));
|
| 142 |
|
| 143 |
unless (exists($pkgs{$embedding_package})
|
| 144 |
|| $reported || $status eq 'removed' || $status eq 'itp') {
|
| 145 |
push @errors, "Non-existing package '$embedding_package', line:$.";
|
| 146 |
$reported = 1;
|
| 147 |
}
|
| 148 |
|
| 149 |
if (exists($pkgs{$embedding_package}{'sid'}) && !$reported
|
| 150 |
&& ($status eq 'removed' || $status eq 'itp')) {
|
| 151 |
push @errors, "Package '$embedding_package' does exist, line:$.";
|
| 152 |
$reported = 1;
|
| 153 |
}
|
| 154 |
|
| 155 |
if ($release) {
|
| 156 |
unless ($reported || exists ($pkgs{$embedding_package}{$release})
|
| 157 |
|| grep {$_ eq $release} @oldstables) {
|
| 158 |
push @errors, "'$embedding_package' does not exist in '$release', line:$.";
|
| 159 |
$reported = 1;
|
| 160 |
}
|
| 161 |
$embedding_package .= '-' . $release;
|
| 162 |
}
|
| 163 |
$embedding_packages{$embedding_package}++;
|
| 164 |
} else {
|
| 165 |
push @errors, "Malformed line ($.) detected: '$_'";
|
| 166 |
}
|
| 167 |
}
|
| 168 |
close(DATA);
|
| 169 |
|
| 170 |
print STDERR join("\n", @errors);
|
| 171 |
print STDERR "\nWarnings\n" if @warnings;
|
| 172 |
print STDERR join("\n", @warnings);
|
| 173 |
print STDERR "\n" if @errors or @warnings;
|
| 174 |
|
| 175 |
PSCRIPT
|
| 176 |
|
| 177 |
unlink "$PKGSLIST"
|