2 # supernested Makefile.am
4 # (C) Copyright 2014 Red Hat Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 # Written by Richard W.M. Jones <rjones@redhat.com>
27 guestfish="@GUESTFISH@"
30 if [ -z "$output" ]; then
31 echo "$0: do not run this script directly, use 'make'"
35 # Get the list of package names. This is distro-specific.
36 if [[ "$distro" =~ ^fedora- ]]; then
46 echo "$0: $distro not known. You need to edit this script to add support for this distro."
50 # Run the prepare step.
51 echo "Preparing the supermin appliance containing:" $packages
52 "$supermin" --prepare $packages -o tmp-supermin.d
54 # Add the init & run-supernested.sh scripts.
55 tar cf tmp-supermin.d/init.tar init run-supernested.sh
57 # Add the excludefiles.
58 cp excludefiles tmp-supermin.d/
61 echo "Building the full appliance ..."
62 echo "If you see 'Permission denied' errors here, you can probably ignore"
63 echo "them, but encourage your distro to stop using security-through-obscurity."
64 "$supermin" --build --format ext2 tmp-supermin.d -o tmp-appliance.d
66 # Add the kernel and initrd to the image.
67 # We have to do this here, AFTER the build step, because we don't
68 # have the kernel & initrd before this.
69 "$guestfish" --format=raw -a tmp-appliance.d/root -m /dev/sda <<'EOF'
70 echo "Adding kernel and initrd to the disk image ..."
71 upload tmp-appliance.d/kernel /kernel
72 upload tmp-appliance.d/initrd /initrd
74 echo "Adjusting configuration files in the image ..."
75 mkdir-p /etc/modprobe.d
76 write /etc/modprobe.d/kvm.conf "options kvm_intel nested=1"
79 # Copy out the kernel, initrd and disk image.
80 mv tmp-appliance.d/kernel .
81 mv tmp-appliance.d/initrd .
82 qemu-img convert -f raw tmp-appliance.d/root -O qcow2 "$output"
84 #rm -rf tmp-supermin.d tmp-appliance.d