[Pkg-libvirt-commits] [libguestfs] 160/179: p2v: Add usb-storage module and rebuild initrd (RHBZ#1157679).

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 31 19:08:51 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch experimental
in repository libguestfs.

commit b09b60c987ff113bc4520ab994142da912ffa3d6
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Mon Oct 27 15:42:02 2014 +0000

    p2v: Add usb-storage module and rebuild initrd (RHBZ#1157679).
    
    Include the usb-storage kernel module, to permit booting from USB
    keys.
    
    Rerun dracut to rebuild the initramfs.  This is complicated because by
    default dracut will try to build an initramfs for the running
    (ie. appliance) kernel, which is completely useless.  We need to find
    the latest installed kernel and rebuild the initramfs for that
    instead, which is hairy.
    
    This also does a small refactoring of the distro-specific code,
    removing the $selinux_relabel variable and replacing it with a generic
    $extra_args variable.
    
    I only added this to the virt-builder script, since one assumes that
    livecd-creator/whatever should make the kickstart ISO bootable by
    installing whatever drivers and modules are necessary.
---
 p2v/virt-p2v-make-disk.in | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/p2v/virt-p2v-make-disk.in b/p2v/virt-p2v-make-disk.in
index c29af2c..fb02856 100644
--- a/p2v/virt-p2v-make-disk.in
+++ b/p2v/virt-p2v-make-disk.in
@@ -74,6 +74,14 @@ fi
 
 osversion="$1"
 
+# Create a temporary directory and clean it up when we finish.
+tmpdir="$(mktemp -d)"
+cleanup ()
+{
+    rm -rf $tmpdir
+}
+trap cleanup INT QUIT TERM EXIT ERR
+
 # The dependencies are:
 #
 #   - pcre (library only)
@@ -92,7 +100,21 @@ osversion="$1"
 case "$osversion" in
     centos-*|fedora-*|rhel-*|scientificlinux-*)
         deps=pcre,libxml2,gtk2,/usr/bin/xinit,/usr/bin/ssh,/usr/bin/qemu-nbd,/usr/bin/Xorg,xorg-x11-drivers,xorg-x11-fonts-Type1,matchbox-window-manager, at hardware-support
-        selinux_relabel=--selinux-relabel
+        cat > $tmpdir/p2v.conf <<'EOF'
+add_drivers+=" usb-storage "
+EOF
+        cat > $tmpdir/post-install <<'EOF'
+#!/bin/bash
+# Rebuild the initramfs.
+version=` rpm -q kernel | sort -rV | head -1 | sed 's/kernel-//' `
+dracut -f --kver $version
+EOF
+        # Double quotes because we want $tmpdir to be expanded:
+        extra_args="
+          --selinux-relabel
+          --upload $tmpdir/p2v.conf:/etc/dracut.conf.d/
+          --run $tmpdir/post-install
+        "
         ;;
     debian-*|ubuntu-*)
         deps=libpcre3,libxml2,libgtk2.0-0,openssh-client,qemu-utils,xorg,xserver-xorg-video-all,matchbox-window-manager
@@ -123,7 +145,6 @@ fi
 
 # Run virt-builder.  Note we controversially assume systemd here.  We
 # could provide a sysvinit fallback if required.
-exec \
 virt-builder "$osversion"                                       \
     --output "$output"                                          \
     --update                                                    \
@@ -145,4 +166,7 @@ virt-builder "$osversion"                                       \
     --edit '/etc/systemd/logind.conf:
         s/^[Login]/[Login]\nReserveVT=1\n/
     '                                                           \
-    $selinux_relabel
+    $extra_args
+
+# We have to do this so the cleanup() handler runs.
+exit $?

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list