[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 01/11] Debian: Factor out di_special_kernel from ts-host-install



No functional change.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 Osstest/Debian.pm | 31 +++++++++++++++++++++++++++++++
 ts-host-install   | 29 +++++------------------------
 2 files changed, 36 insertions(+), 24 deletions(-)

diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm
index 845027a..ba39ad2 100644
--- a/Osstest/Debian.pm
+++ b/Osstest/Debian.pm
@@ -34,6 +34,7 @@ BEGIN {
     $VERSION     = 1.00;
     @ISA         = qw(Exporter);
     @EXPORT      = qw(debian_boot_setup
+                      di_special_kernel
                       setupboot_bootloader_edited_rune
                       debian_overlays
                       debian_guest_suite debian_guest_di_version
@@ -1043,6 +1044,36 @@ END
     return create_webfile($ho, "preseed$sfx", $preseed_file);
 }
 
+sub di_special_kernel ($$$) {
+    my ($ho, $d_i, $fn) = @_;
+    # calls $fn->($kernel, $cpio) # either or both may be undef
+    foreach my $kp (keys %{ $ho->{Flags} }) {
+        my $kernel;
+        # Backwards compatibility
+        $kp = "need-kernel-deb-wheezy-backports" if $kp eq 
"need-kernel-deb-armmp";
+        $kp =~ s/need-kernel-deb-$ho->{Suite}-// or next;
+        my $kern= "$ho->{Tftp}{Path}/$d_i/linux.$kp";
+        if (stat $kern) {
+            logm("using kernel from: $kern");
+            $kernel = "/$d_i/linux.$kp";
+        } elsif ($! == &ENOENT) {
+            logm("warning: no kernel found for $kp at $kern");
+        } else {
+            die "$kp $kern $!";
+        }
+        my $cpio= "$ho->{Tftp}{Path}/$d_i/$kp.cpio.gz";
+        if (stat $cpio) {
+            logm("using kernel modules from: $cpio");
+        } elsif ($! == &ENOENT) {
+            logm("warning: no kernel module cpio found for $kp at $cpio");
+            $cpio = undef;
+        } else {
+            die "$kp $cpio $!";
+        }
+        $fn->($kernel, $cpio);
+    }
+}
+
 sub preseed_create ($$;@) {
     my ($ho, $sfx, %xopts) = @_;
 
diff --git a/ts-host-install b/ts-host-install
index 11c14a7..2165436 100755
--- a/ts-host-install
+++ b/ts-host-install
@@ -181,30 +181,11 @@ sub setup_netboot_firstboot($) {
         }
     }
 
-    foreach my $kp (keys %{ $ho->{Flags} }) {
-        # Backwards compatibility
-        $kp = "need-kernel-deb-wheezy-backports" if $kp eq 
"need-kernel-deb-armmp";
-        $kp =~ s/need-kernel-deb-$ho->{Suite}-// or next;
-        my $kern= "$ho->{Tftp}{Path}/$d_i/linux.$kp";
-        if (stat $kern) {
-            logm("using kernel from: $kern");
-            $kernel = "/$d_i/linux.$kp";
-        } elsif ($! == &ENOENT) {
-            logm("warning: no kernel found for $kp at $kern");
-        } else {
-            die "$kp $kern $!";
-        }
-
-        my $cpio= "$ho->{Tftp}{Path}/$d_i/$kp.cpio.gz";
-        if (stat $cpio) {
-            logm("using kernel modules from: $cpio");
-            push @initrds, $cpio;
-        } elsif ($! == &ENOENT) {
-            logm("warning: no kernel module cpio found for $kp at $cpio");
-        } else {
-            die "$kp $cpio $!";
-        }
-    }
+    di_special_kernel($ho, $d_i, sub {
+        my ($k, $cpio) = @_;
+        $kernel = $k if defined $k;
+        push @initrds, $cpio if defined $cpio;
+    });
 
     $kernel = "/$d_i/linux" unless $kernel;
 
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.