Skip to content

Commit

Permalink
Remove code duplication for enabling DVD repos
Browse files Browse the repository at this point in the history
  • Loading branch information
foursixnine committed Apr 10, 2019
1 parent 2d30786 commit b668d6c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
9 changes: 9 additions & 0 deletions lib/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ our @EXPORT = qw(
unlock_if_encrypted
get_netboot_mirror
zypper_call
zypper_enable_install_dvd
zypper_ar
fully_patch_system
ssh_fully_patch_system
Expand Down Expand Up @@ -402,6 +403,14 @@ sub zypper_call {
return $ret;
}

sub zypper_enable_install_dvd {
# If DVD Packages is used we need to (re-)enable the local repos
# see FATE#325541
zypper_call 'mr -e -l' if get_var('AUTOYAST')
|| is_sle('15+') and get_var('ISO_1', '') =~ /SLE-.*-Packages-.*\.iso/;
zypper_call 'ref';
}

sub zypper_ar {
my ($url, $name) = @_;

Expand Down
4 changes: 1 addition & 3 deletions tests/autoyast/repos.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ sub run {
# sles12_minimal.xml profile does not install "ip"
assert_script_run 'ip a || ifstatus all';
pkcon_quit;
# Enable local repositories if needed
zypper_call 'mr -el'; # Returns 0 even if repos are already enabled
zypper_call 'ref';
zypper_enable_install_dvd;
# make sure that save_y2logs from yast2 package, tar and bzip2 are installed
# even on minimal system
zypper_call 'in yast2 tar bzip2';
Expand Down
9 changes: 2 additions & 7 deletions tests/console/zypper_ref.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,12 @@ use base "consoletest";
use strict;
use warnings;
use testapi;
use utils 'zypper_call';
use utils qw(zypper_call zypper_enable_install_dvd);
use version_utils 'is_sle';

sub run {
select_console 'root-console';

# see FATE#325541
zypper_call 'mr -e -l'
if is_sle('15+')
and get_var('ISO_1', '') =~ /SLE-.*-Packages-.*\.iso/;

zypper_enable_install_dvd;
zypper_call '--gpg-auto-import-keys ref';
}

Expand Down
6 changes: 1 addition & 5 deletions tests/sles4sap/patterns.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ sub run {

my $base_pattern = is_sle('>=15') ? 'patterns-server-enterprise-sap_server' : 'patterns-sles-sap_server';

# If DVD Packages is used we need to (re-)enable the local repos
zypper_call 'mr -e -l'
if is_sle('15+')
and get_var('ISO_1', '') =~ /SLE-.*-Packages-.*\.iso/;

zypper_enable_install_dvd;
# First check pattern sap_server which is installed by default in SLES4SAP
# when 'SLES for SAP Applications' system role is selected
$output = script_output("zypper info -t pattern sap_server");
Expand Down

0 comments on commit b668d6c

Please sign in to comment.