Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove code duplication for enabling DVD repositories #7241

Merged
merged 2 commits into from
Apr 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 16 additions & 8 deletions lib/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ our @EXPORT = qw(
unlock_if_encrypted
get_netboot_mirror
zypper_call
zypper_enable_install_dvd
zypper_ar
fully_patch_system
ssh_fully_patch_system
minimal_patch_system
Expand Down Expand Up @@ -71,7 +73,6 @@ our @EXPORT = qw(
shorten_url
reconnect_mgmt_console
set_hostname
zypper_ar
show_tasks_in_blocked_state
svirt_host_basedir
prepare_ssh_localhost_key_login
Expand Down Expand Up @@ -402,6 +403,20 @@ 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 is_sle('15+') and get_var('ISO_1', '') =~ /SLE-.*-Packages-.*\.iso/;
zypper_call 'ref';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take that "Enable dvd's" it's a step on it's own, and that includes the ref. Should we rename or repurpose the zypper_ref?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually you can skip AUTOYAST variable check, as it also has ISO_1 (all packages DVD mounted).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rwx788 dropped

}

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

zypper_call("ar $url $name", dumb_term => 1);
zypper_call("--gpg-auto-import-keys ref --repo $name", dumb_term => 1);
}

sub fully_patch_system {
# first run, possible update of packager -- exit code 103
zypper_call('patch --with-interactive -l', exitcode => [0, 102, 103], timeout => 3000);
Expand Down Expand Up @@ -973,13 +988,6 @@ sub reconnect_mgmt_console {
}
}

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

zypper_call("ar $url $name", dumb_term => 1);
zypper_call("--gpg-auto-import-keys ref --repo $name", dumb_term => 1);
}

sub show_tasks_in_blocked_state {
# sending sysrqs doesn't work for svirt
if (!check_var('BACKEND', 'svirt')) {
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