summaryrefslogtreecommitdiffstats
path: root/t/superuser--media_info_dir.t
blob: 7ba9f0c947c17fe1615277e6832042faf79b774f (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
62
#!/usr/bin/perl

use strict;
use lib '.', 't';
use helper;
use Test::More 'no_plan';


need_root_and_prepare();
various();
rpm_v3();

sub various {
    my $name = 'various';
    foreach my $medium_name ('various', 'various_nohdlist', 'various nohdlist', 'various_no_subdir') {
	urpmi_addmedia("'$medium_name' '$::pwd/media/$medium_name'");
	urpmi($name);
	is(`rpm -qa --root $::pwd/root`, "$name-1-1\n");
	urpme($name);
	urpmi_removemedia("'$medium_name'");
    }
}

sub rpm_v3 {
    my @names = qw(libtermcap nls p2c);

    system_("rpm --root $::pwd/root -i --noscripts media/rpm-v3/*.i386.rpm");
    check_installed_names(@names);
    rebuilddb(); # why here? well, why not
    check_installed_names(@names);   

    system_("rpm --root $::pwd/root -e --noscripts " . join(' ', @names));
    is(`rpm -qa --root $::pwd/root`, '');    

    foreach my $medium_name ('rpm-v3', 'rpm-v3_nohdlist', 'rpm-v3_no_subdir') {
	urpmi_addmedia("$medium_name $::pwd/media/$medium_name");
	urpmi('--no-verify-rpm --noscripts ' . join(' ', @names));
	check_installed_names(@names);
	urpme('-a --auto --noscripts');
	is(`rpm -qa --root $::pwd/root`, '');    
	urpmi_removemedia($medium_name);
    }

    foreach my $src_rpm (glob('media/rpm-v3/*.rpm')) {
	my ($wanted_arch) = $src_rpm =~ /(\w+)\.rpm$/;
	my $cmd = urpm_cmd('urpmq') . " -f $src_rpm";
	warn "# $cmd\n";
	chomp(my $fullname = `$cmd`);
	my ($arch) = $fullname =~ /(\w+)$/;

	$wanted_arch = 'i386' if $src_rpm =~ /KBackup/; # WARNING: package has a Sourcerpm empty tag (#29809), but this package is broken anyway

	is($arch, $wanted_arch, "$fullname should have arch $wanted_arch (found $arch)");
    }
}

sub rebuilddb {
    # testing rebuilddb (could be done elsewhere, but here is 
    system_("rpm --root $::pwd/root --rebuilddb");
    my ($dir) = glob("$::pwd/root/var/lib/rpmrebuilddb*");
    is($dir, undef, "$dir should not be there");
}