Skip to content

Commit

Permalink
TO SQUASH: Use package qam instead wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
dzedro committed Nov 29, 2023
1 parent a3e6c8e commit d926ace
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 64 deletions.
39 changes: 38 additions & 1 deletion lib/qam.pm
Expand Up @@ -16,10 +16,12 @@ use utils qw(zypper_call handle_screen zypper_repos);
use JSON;
use List::Util qw(max);
use version_utils qw(is_sle is_transactional);
use transactional qw(trup_call check_reboot_changes);

our @EXPORT
= qw(capture_state check_automounter is_patch_needed add_test_repositories disable_test_repositories enable_test_repositories
add_extra_customer_repositories ssh_add_test_repositories remove_test_repositories advance_installer_window get_patches check_patch_variables);
add_extra_customer_repositories ssh_add_test_repositories remove_test_repositories advance_installer_window get_patches
check_patch_variables install_package);
use constant ZYPPER_PACKAGE_COL => 1;
use constant OLD_ZYPPER_STATUS_COL => 4;
use constant ZYPPER_STATUS_COL => 5;
Expand Down Expand Up @@ -245,4 +247,39 @@ sub check_patch_variables {
}
}

=head2 install_package
install_package('kernel-devel' [, trup_packages => 'kernel-default-base] [, zypper_packages => 'kernel-devel']);
C<packages> defines packages to install for both zypper and trup call,
Parameters C<trup_extra> and C<zypper_extra> define transactional
or zypper specific packages.
C<skip_trup> or C<skip_zypper> will return from fucntion,
record_info is used if sentence is argument value.
C<trup_reboot> parameter will run check_reboot_changes after trup_call,
reboot if diff between the current FS and the new snapshot.
=cut

sub install_package {
my $ret;
my ($packages, %args) = @_;
die 'Paramater packages is required' unless defined($packages);
my $timeout = $args{timeout} // 500;

if (is_transactional) {
record_info('install_package', $args{skip_trup}) if $args{skip_trup} =~ /\w+/;
return if $args{skip_trup};
$packages .= ' ' . $args{trup_extra} // '';
$ret = trup_call('pkg in -l ' . $packages, timeout => $args{timeout});
check_reboot_changes if $args{trup_reboot};
}
else {
record_info('install_package', $args{skip_zypper}) if $args{skip_zypper} =~ /\w+/;
return if $args{skip_zypper};
$packages .= ' ' . $args{zypper_extra} // '';
$ret = zypper_call('in -l ' . $packages, timeout => $args{timeout});
}
return $ret;
}

1;
56 changes: 0 additions & 56 deletions lib/wrapper.pm

This file was deleted.

8 changes: 2 additions & 6 deletions tests/console/year_2038_detection.pm
Expand Up @@ -25,17 +25,13 @@ use version_utils qw(is_transactional is_sle is_sle_micro is_leap is_leap_micro)
use Utils::Systemd 'disable_and_stop_service';
use power_action_utils 'power_action';
use Utils::Backends 'is_pvm';
use wrapper;

sub install_pkg {
install_package('chrony', trup_reboot => 1);
}
use qam;

sub run {
my $self = shift;
select_serial_terminal;

install_pkg if (script_run('rpm -qi chrony') != 0);
install_package('chrony', trup_reboot => 1) if script_run('rpm -qi chrony') != 0;
systemctl("start chronyd"); # Ensure chrony is started
assert_script_run('chronyc makestep');
record_info('Show current date and time', script_output('date +"%Y-%m-%d"'));
Expand Down
1 change: 0 additions & 1 deletion tests/kernel/update_kernel.pm
Expand Up @@ -23,7 +23,6 @@ use repo_tools 'add_qa_head_repo';
use Utils::Backends;
use LTP::utils;
use transactional;
use wrapper;

sub check_kernel_package {
my $kernel_name = shift;
Expand Down

0 comments on commit d926ace

Please sign in to comment.