publiccloud::zypper - Zypper / transactional-update plumbing for public cloud tests
use publiccloud::zypper qw(pc_pkg_call pc_refresh pc_add_repo);
pc_refresh($instance);
pc_add_repo($instance, 'my-repo', 'http://example.com/repo');
pc_pkg_call($instance, 'in some-package');
Centralises all package-management interactions with remote public cloud instances (and a small helper for local installations). On transactional systems, package-changing operations are transparently routed through transactional-update; refresh and repository management always go through plain zypper.
sudo zypper -n ...sudo transactional-update -n ...is_transactional()zypper ref (always plain; poo#195920)See the per-function sections below for full signatures and options.
pc_zypper_call($instance, $cmd, %opts);
pc_zypper_call($instance, cmd => $cmd, %opts);
Runs sudo zypper -n $cmd on a remote instance. Never wraps the command in transactional-update; use this for repo/refresh/info operations even on transactional systems.
Options (all optional):
pc_transactional_call($instance, $cmd, %opts);
Runs sudo transactional-update -n $cmd on a remote instance and triggers a soft reboot on success (unless no_reboot = 1> is passed). The default accepted exit codes are 0, 102, 103.
pc_pkg_call($instance, $cmd, %opts);
Smart dispatch: on transactional systems, translates $cmd into the equivalent transactional-update invocation when possible (for install / remove / update / dup / patch). Anything that transactional-update does not support (refresh, repo management, queries, ...) falls through to plain pc_zypper_call. On non-transactional systems this is identical to pc_zypper_call.
pc_refresh($instance, %opts);
Refreshes repositories on the remote instance. Always uses plain zypper, even on transactional systems, because transactional-update does not support repo refresh actions (poo#195920).
pc_add_repo($instance, $name, $url, [timeout => 600]);
Adds a GPG-checked repository to the remote instance. Uses ssh_assert_script_run directly (i.e. dies on non-zero exit) rather than the full pc_zypper_call retry pipeline, since adding a single repository is a one-shot operation.
pc_wait_quit($instance, [timeout => 20], [delay => 10], [retry => 120]);
Waits until no zypper / packagekit / purge-kernels / rpm processes are running on the remote instance. Defaults give a ~20 minute ceiling.
pc_installed_packages($instance, \@pkgs);
Returns an arrayref of those packages from \@pkgs that are installed on the remote instance, preserving the order from the input list.
pc_available_packages($instance, \@pkgs);
Returns an arrayref of packages from \@pkgs that are not yet installed but are available for installation. Uses zypper -x info to query availability.
pc_install_packages_local(\@pkgs, [timeout => $seconds]);
Installs packages on the local SUT. On transactional systems uses trup_call("pkg install ...") followed by reboot_on_changes; otherwise uses the standard utils::zypper_call("in ...").