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 echo "Adding kernel and initrd to the disk image ..."
70 "$guestfish" --format=raw -a tmp-appliance.d/root -m /dev/sda <<EOF
71 upload tmp-appliance.d/kernel /kernel
72 upload tmp-appliance.d/initrd /initrd
75 # Copy out the kernel, initrd and disk image.
76 mv tmp-appliance.d/kernel .
77 mv tmp-appliance.d/initrd .
78 qemu-img convert -f raw tmp-appliance.d/root -O qcow2 "$output"
80 #rm -rf tmp-supermin.d tmp-appliance.d