diff mbox series

[OSSTEST,1/2] TestSupport: Add support for installing from backport repo

Message ID 20220802102602.131992-2-anthony.perard@citrix.com (mailing list archive)
State New, archived
Headers show
Series osstest: Fix libvirt build | expand

Commit Message

Anthony PERARD Aug. 2, 2022, 10:26 a.m. UTC
We are going to need to install package from the debian backport
repository in order to do a build.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 Osstest/TestSupport.pm | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

Comments

Ian Jackson Aug. 2, 2022, 12:27 p.m. UTC | #1
Anthony PERARD writes ("[OSSTEST PATCH 1/2] TestSupport: Add support for installing from backport repo"):
> We are going to need to install package from the debian backport
> repository in order to do a build.

LGTM.  I was kind of surprised we didn't have this already, but now I
come to think of it, I think that was only for kernels ?  (I haven't
UTSL to check.)

> +sub target_install_packages_backport ($@) {
> +    my ($ho, @packages) = @_;
> +    my $had_backport_repo = 0;
> +    target_editfile_root($ho, '/etc/apt/sources.list', sub {
> +        my $suite = $ho->{Suite};
> +        my $bp_url = Osstest::Debian::debian_mirror_url($ho);
> +        while (<::EI>) {
> +            if (m/^# $suite backports/) {
> +                $had_backport_repo = 1;
> +            }
> +            print ::EO;
> +        }
> +        print ::EO <<EOF unless $had_backport_repo;
> +
> +# $suite backports
> +deb $bp_url $suite-backports main
> +EOF
> +        });

Nit: this last line looks misindented to me.

Regardless,

Acked-by: Ian Jackson <ijackson@chiark.greenend.org.uk>

Thanks,
Ian.
Anthony PERARD Aug. 2, 2022, 1:36 p.m. UTC | #2
On Tue, Aug 02, 2022 at 01:27:19PM +0100, Ian Jackson wrote:
> Anthony PERARD writes ("[OSSTEST PATCH 1/2] TestSupport: Add support for installing from backport repo"):
> > We are going to need to install package from the debian backport
> > repository in order to do a build.
> 
> LGTM.  I was kind of surprised we didn't have this already, but now I
> come to think of it, I think that was only for kernels ?  (I haven't
> UTSL to check.)

Yes, there's preseed_backports_packages() to install from backports repo
at host/guest installation. But nothing once the OS is already
installed. I thought it would not be a good idea to install meson on
every host.

> > +sub target_install_packages_backport ($@) {
> > +    my ($ho, @packages) = @_;
> > +    my $had_backport_repo = 0;
> > +    target_editfile_root($ho, '/etc/apt/sources.list', sub {
> > +        my $suite = $ho->{Suite};
> > +        my $bp_url = Osstest::Debian::debian_mirror_url($ho);
> > +        while (<::EI>) {
> > +            if (m/^# $suite backports/) {
> > +                $had_backport_repo = 1;
> > +            }
> > +            print ::EO;
> > +        }
> > +        print ::EO <<EOF unless $had_backport_repo;
> > +
> > +# $suite backports
> > +deb $bp_url $suite-backports main
> > +EOF
> > +        });
> 
> Nit: this last line looks misindented to me.

Would be nice to fix on commit, I guess.

> Acked-by: Ian Jackson <ijackson@chiark.greenend.org.uk>

Thanks,
diff mbox series

Patch

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 156cac799d58..91b0a7ab23a1 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -73,6 +73,7 @@  BEGIN {
                       target_run_pkgmanager_install
                       target_install_packages target_install_packages_norec
 		      target_install_packages_nonfree_nonconcurrent
+                      target_install_packages_backport
                       target_jobdir target_extract_jobdistpath_subdir
                       target_extract_jobdistpath target_extract_distpart
 		      target_tftp_prefix
@@ -650,8 +651,8 @@  sub target_putfile_root ($$$$;$) {
     tputfileex('root', @_);
 }
 
-sub target_run_pkgmanager_install ($$;$$) {
-    my ($ho, $packagelist, $norec, $force) = @_;
+sub target_run_pkgmanager_install ($$;$$$) {
+    my ($ho, $packagelist, $norec, $force, $backport) = @_;
     my @cmd;
     if ($ho->{OS} eq "freebsd") {
         push @cmd, qw(lockf /var/run/osstest-pkg-lock pkg-static install);
@@ -660,6 +661,7 @@  sub target_run_pkgmanager_install ($$;$$) {
                       with-lock-ex -w /var/lock/osstest-apt apt-get);
 	push @cmd, qw(-f) if $force;
 	push @cmd, qw(--no-install-recommends) if $norec;
+	push @cmd, "-t", "$ho->{Suite}-backports" if $backport;
 	push @cmd, qw(-y install);
     }
     push @cmd, @$packagelist;
@@ -688,6 +690,27 @@  END
     apt-get update
 END
 }
+sub target_install_packages_backport ($@) {
+    my ($ho, @packages) = @_;
+    my $had_backport_repo = 0;
+    target_editfile_root($ho, '/etc/apt/sources.list', sub {
+        my $suite = $ho->{Suite};
+        my $bp_url = Osstest::Debian::debian_mirror_url($ho);
+        while (<::EI>) {
+            if (m/^# $suite backports/) {
+                $had_backport_repo = 1;
+            }
+            print ::EO;
+        }
+        print ::EO <<EOF unless $had_backport_repo;
+
+# $suite backports
+deb $bp_url $suite-backports main
+EOF
+        });
+    target_cmd_root($ho, "apt-get update", 300) unless $had_backport_repo;
+    target_run_pkgmanager_install($ho,\@packages,0,0,1);
+}
 
 sub tpfcs_core {
     my ($tputfilef,$ho,$timeout,$filedata, $rdest,$lleaf) = @_;