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
|
#!/usr/bin/perl
use strict;
use warnings;
use Cwd qw(getcwd realpath);
use File::Temp qw();
use Test::More;
my $srcdir = getcwd;
ok(-x '/bin/sh', '/bin/sh must be executable');
ok(-x '/bin/dash', '/bin/dash must be executable');
ok(-x '/bin/bash', '/bin/bash must be executable');
ok(! -f '/bin/sh.distrib', '/bin/sh.distrib must not be present');
diag(qx(ls -l /bin/sh));
diag(qx(ls -l /bin/dash));
diag(qx(ls -l /bin/bash));
like(qx(dpkg -L dash),
qr{^/usr/bin/sh$}m,
'dash must contain a /usr/bin/sh symlink, for debootstrap');
is(qx(echo hello), "hello\n");
my $diverter = qx(dpkg-divert --listpackage /bin/sh);
ok($diverter eq "" or $diverter eq "LOCAL\n", '/bin/sh not diverted or local diversion');
ok($diverter ne "dash\n", '/bin/sh not diverted by dash');
ok($diverter ne "bash\n", '/bin/sh not diverted by bash');
ok(like(realpath('/bin/sh'), qr{^(?:/usr)?/bin/dash}));
my $diverter = qx(dpkg-divert --listpackage /usr/bin/sh);
ok($diverter eq "" or $diverter eq "LOCAL\n", '/usr/bin/sh not diverted or local diversion');
ok($diverter ne "dash\n", '/usr/bin/sh not diverted by dash');
ok($diverter ne "bash\n", '/usr/bin/sh not diverted by bash');
ok(like(realpath('/usr/bin/sh'), qr{^(?:/usr)?/bin/dash}));
my $tmpdir = File::Temp->newdir();
chdir $tmpdir;
is(system("apt-get download dash"), 0);
is(system("dpkg-deb -X *.deb ."), 0);
diag(qx(find . -ls));
chdir $srcdir;
like(readlink("$tmpdir/usr/bin/sh"), qr{^(?:/bin/)?[bd]ash$},
'dash_*.deb must contain a /usr/bin/sh symlink for debootstrap');
done_testing;
|