diff mbox

[v7,12/20] osstest: add support for the FreeBSD package manager

Message ID 20170725150032.9225-3-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Roger Pau Monné July 25, 2017, 3 p.m. UTC
FreeBSD support is added to target_install_packages and
target_install_packages_norec, although there's no equivalent to the
--no-install-recommends in the FreeBSD package manager.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
Changes since v6:
 - Use $ho->{Os} in order to detect the target OS.

Changes since v5:
 - Add prototype for package_install_cmd.
 - Use $ho->{Ident} instead of hardcoding "host" in get_hostflags.

Changes since v4:
 - Unify more code between FreeBSD and Debian: introduce an
   OS-agnostic package_install_cmd to generate the install cmd.

Changes since v3:
 - New in this version.
---
 Osstest/TestSupport.pm | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 7642a95b..4cb939e7 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -68,7 +68,6 @@  BEGIN {
                       http_proxy_envsettings
                       target_editfile_root target_file_exists
                       target_editfile_kvp_replace
-                      target_run_apt
                       target_install_packages target_install_packages_norec
                       target_jobdir target_extract_jobdistpath_subdir
                       target_extract_jobdistpath target_tftp_prefix
@@ -523,19 +522,33 @@  sub target_putfile ($$$$;$) {
 sub target_putfile_root ($$$$;$) {
     tputfileex('root', @_);
 }
-sub target_run_apt {
-    my ($ho, @aptopts) = @_;
-    target_cmd_root($ho,
-        "DEBIAN_PRIORITY=critical UCF_FORCE_CONFFOLD=y \\
-            with-lock-ex -w /var/lock/osstest-apt apt-get @aptopts", 3000);
+
+sub package_install_cmd ($;$) {
+    my ($ho, $norec) = @_;
+    my @cmd;
+
+    if ($ho->{Os} eq "freebsd") {
+        push @cmd, qw(lockf /var/run/osstest-pkg-lock pkg-static install);
+    } else {
+        push @cmd, qw(DEBIAN_PRIORITY=critical UCF_FORCE_CONFFOLD=y
+                      with-lock-ex -w /var/lock/osstest-apt apt-get);
+        push @cmd, qw(--no-install-recommends) if $norec;
+        push @cmd, qw(-y install);
+    }
+
+    return @cmd;
 }
 sub target_install_packages ($@) {
     my ($ho, @packages) = @_;
-    target_run_apt($ho, qw(-y install), @packages);
+    my @cmd = package_install_cmd($ho);
+
+    target_cmd_root($ho,"@cmd @packages", 3000);
 }
 sub target_install_packages_norec ($@) {
     my ($ho, @packages) = @_;
-    target_run_apt($ho, qw(--no-install-recommends -y install), @packages);
+    my @cmd = package_install_cmd($ho, 1);
+
+    target_cmd_root($ho,"@cmd @packages", 3000);
 }
 
 sub target_somefile_getleaf ($$$) {