summaryrefslogtreecommitdiffstats
path: root/t/superuser--orphans-kernels.t
blob: f101f1f50fd06ef8af12c5223c63e546ca5ade26 (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
#!/usr/bin/perl

# kernel-desktop-latest request latest kernel-desktop-foobar
#
use strict;
use lib '.', 't';
use helper;
use urpm::orphans;
use Test::More 'no_plan';

need_root_and_prepare();

my $name = 'kernel';
urpmi_addmedia("$name-1 $::pwd/media/$name-1");
urpmi_addmedia("$name-2 $::pwd/media/$name-2");

# we want urpmi --auto-select to always check orphans (when not using --auto-orphans)
set_urpmi_cfg_global_options({ 'nb-of-new-unrequested-pkgs-between-auto-select-orphans-check' => 0 });

# old naming, each kernel NVR is N=kernel-desktop-5.6.2-1, V=1 R=1.mga8
test_unorphan_kernels("$name-1", 'kernel-desktop-latest');
# new naming, each kernel NVR is N=kernel-desktop, V=5.6.2 R=1.mga8
test_unorphan_kernels("$name-2", 'kernel-desktop-latest', 'kernel-desktop');

sub test_unorphan_kernels {
    my ($medium, $pkg, $o_pkg2) = @_;
    my $base_kversion = '5.15.4';
    $o_pkg2 ||= "kernel-desktop-${base_kversion}5-1.mga8";
    print "# test_unorphan_kernels($pkg) ($base_kversion)\n";
    urpmi("--media $medium --auto $pkg-${base_kversion}$_-1") foreach 1..4;
    urpmi("--media $medium --auto $pkg");
    urpme("--auto --auto-orphans");
    check_installed_and_remove($pkg, $o_pkg2);
}