1
0
mirror of synced 2026-02-09 17:21:11 +00:00

Use regexp to check for $dist/updates vs $dist-security

If the security repo will be  enabled or not currently depends on the
host's sources.list. So the resulting files differ depending on the
host where the test is run. Add a TODO item to break with that
"feature".

Also mention in the TODO list that a repo on archive.debian.org should
be used instead security.debian.org if the release is EoL. Currently
the security mirror is hardcoded into the hook.
This commit is contained in:
Axel Beckert
2020-12-20 08:32:12 +01:00
parent ed497ab39c
commit 285d2c80b9
6 changed files with 43 additions and 126 deletions

View File

@@ -1,16 +0,0 @@
#
# /etc/apt/sources.list
#
#
# bookworm
#
deb http://deb.debian.org/debian bookworm main contrib non-free
deb-src http://deb.debian.org/debian bookworm main contrib non-free
#
# Security updates
#
deb http://security.debian.org/ bookworm-security main contrib non-free
deb-src http://security.debian.org/ bookworm-security main contrib non-free

View File

@@ -1,16 +0,0 @@
#
# /etc/apt/sources.list
#
#
# bullseye
#
deb http://deb.debian.org/debian bullseye main contrib non-free
deb-src http://deb.debian.org/debian bullseye main contrib non-free
#
# Security updates
#
deb http://security.debian.org/ bullseye-security main contrib non-free
deb-src http://security.debian.org/ bullseye-security main contrib non-free

View File

@@ -1,16 +0,0 @@
#
# /etc/apt/sources.list
#
#
# buster
#
deb http://deb.debian.org/debian buster main contrib non-free
deb-src http://deb.debian.org/debian buster main contrib non-free
#
# Security updates
#
deb http://security.debian.org/ buster/updates main contrib non-free
deb-src http://security.debian.org/ buster/updates main contrib non-free

View File

@@ -1,16 +0,0 @@
#
# /etc/apt/sources.list
#
#
# sid
#
deb http://deb.debian.org/debian sid main contrib non-free
deb-src http://deb.debian.org/debian sid main contrib non-free
#
# Security updates - Uncomment to enable.
#
# deb http://security.debian.org/ sid-security main contrib non-free
# deb-src http://security.debian.org/ sid-security main contrib non-free

View File

@@ -1,16 +0,0 @@
#
# /etc/apt/sources.list
#
#
# stretch
#
deb http://deb.debian.org/debian stretch main contrib non-free
deb-src http://deb.debian.org/debian stretch main contrib non-free
#
# Security updates
#
deb http://security.debian.org/ stretch/updates main contrib non-free
deb-src http://security.debian.org/ stretch/updates main contrib non-free

View File

@@ -13,7 +13,6 @@ use File::Temp;
use File::Copy;
use File::Path qw(make_path);
my $asl = 't/data/sources.list';
my $hook_dir = $ENV{AS_INSTALLED_TESTING} ? '/usr/share/xen-tools' : 'hooks';
foreach my $dist (qw(stretch buster bullseye bookworm sid)) {
@@ -25,7 +24,6 @@ done_testing();
sub testHook
{
my ( $dist ) = ( @_ );
my $dasl = "$asl.$dist";
my $ea = 'etc/apt';
my $easl = "$ea/sources.list";
my $hook = "$hook_dir/" .
@@ -36,57 +34,56 @@ sub testHook
) . '/20-setup-apt';
#
# Check that the according sample sources.list exists.
# Create a temporary directory to use as prefix
#
if (-e $dasl) {
my $dir = File::Temp::tempdir( CLEANUP => 1 );
make_path( "$dir/$ea/apt.conf.d", { chmod => 0755 });
make_path( "$dir/bin", { chmod => 0755 });
my $tmphook = "$dir/bin/20-setup-apt";
#
# Create a temporary directory to use as prefix
#
my $dir = File::Temp::tempdir( CLEANUP => 1 );
make_path( "$dir/$ea/apt.conf.d", { chmod => 0755 });
make_path( "$dir/bin", { chmod => 0755 });
my $tmphook = "$dir/bin/20-setup-apt";
#
# Make sure that worked.
#
ok( -d $dir, "temporary directory created OK [$dist]" );
ok( -d "$dir/bin",
"bin inside temporary directory created OK [$dist]" );
ok( -d "$dir/$ea",
"$ea inside temporary directory created OK [$dist]" );
#
# Make sure that worked.
#
ok( -d $dir, "temporary directory created OK [$dist]" );
ok( -d "$dir/bin",
"bin inside temporary directory created OK [$dist]" );
ok( -d "$dir/$ea",
"$ea inside temporary directory created OK [$dist]" );
# Create a copy of the 20-setup-apt hook to be able to comment out
# the chroot + apt-get update call.
File::Copy::cp( $hook, $tmphook );
# Create a copy of the 20-setup-apt hook to be able to comment
# out the chroot + apt-get update call.
File::Copy::cp( $hook, $tmphook );
ok( -e "$tmphook", "hook exists in temporary directory [$dist]" );
ok( -x "$tmphook", "hook is executable in temporary directory [$dist]" );
ok( -e "$tmphook", "hook exists in temporary directory [$dist]" );
ok( -x "$tmphook",
"hook is executable in temporary directory [$dist]" );
no warnings qw(qw);
is(system(qw(sed -e s/chroot/#chroot/ -i), $tmphook) >> 8, 0,
"chroot call in hook could be deactivated [$dist]");
use warnings qw(qw);
no warnings qw(qw);
is(system(qw(sed -e s/chroot/#chroot/ -i), $tmphook) >> 8, 0,
"chroot call in hook could be deactivated [$dist]");
use warnings qw(qw);
#
# Set up some variables expected by the hook
#
$ENV{dist} = $dist;
$ENV{mirror} = 'http://deb.debian.org/debian';
#
# Set up some variables expected by the hook
#
$ENV{dist} = $dist;
$ENV{mirror} = 'http://deb.debian.org/debian';
#
# Call the hook
#
is(system($tmphook, $dir) >> 8, 0,
"hook for $dist exited with zero return code");
#
# Call the hook
#
is(system($tmphook, $dir) >> 8, 0,
"hook for $dist exited with zero return code");
ok( -e "$dir/$easl", "A sources.list file has been created. [$dist]" );
files_eq_or_diff($dasl, "$dir/$easl",
"sources.list for $dist has the expected contents")
}
else {
BAIL_OUT("$dasl not found, source distribution seems incomplete");
ok( -e "$dir/$easl", "A sources.list file has been created. [$dist]" );
if ($dist =~ /stretch|buster/) {
file_contents_like( "$dir/$easl", qr(\b${dist}/updates\b),
"sources.list contains $dist/updates");
file_contents_unlike( "$dir/$easl", qr(\b${dist}-security\b),
"sources.list doesn't contain $dist-security");
} else {
file_contents_like( "$dir/$easl", qr(\b${dist}-security\b),
"sources.list contains $dist-security");
file_contents_unlike( "$dir/$easl", qr(\b${dist}/updates\b),
"sources.list doesn't contain $dist/updates");
}
}