]> xenbits.xensource.com Git - people/royger/osstest.git/commitdiff
Debian: Factor out di_special_kernel from ts-host-install
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 14 Dec 2017 12:09:53 +0000 (12:09 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 14 Dec 2017 15:34:41 +0000 (15:34 +0000)
No functional change.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Osstest/Debian.pm
ts-host-install

index 845027a3afdbfa80b6e84373f7f6a7b4b7545441..ba39ad2ae9e1d0ca7e64d82b458e759bc95393fd 100644 (file)
@@ -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) = @_;
 
index 11c14a74c2ba77205a8033f337f4d4b603d5184a..21654369ec4dec573685841eb26275afa314b606 100755 (executable)
@@ -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;