Initial commit.
[virt-efivars.git] / build-appliance.sh.in
1 #!/bin/bash -
2 # virt-efivars build script
3 # @configure_input@
4 # (C) Copyright 2014-2015 Red Hat Inc.
5 #
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.
10 #
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.
15 #
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.
19 #
20 # Written by Richard W.M. Jones <rjones@redhat.com>
21
22 unset CDPATH
23 set -e
24
25 supermin="@SUPERMIN@"
26 distro="@DISTRO@"
27
28 output="$1"
29 if [ -z "$output" ]; then
30     echo "$0: do not run this script directly, use 'make'"
31     exit 1
32 fi
33
34 # Get the list of package names that are added to the appliance.
35 # Dependencies are resolved automatically by supermin.  This is
36 # distro-specific.
37 if [[ "$distro" =~ ^fedora- ]]; then
38     packages="
39         bash
40         coreutils
41         efivar-libs
42         systemd
43         util-linux
44     "
45 else
46     echo "$0: $distro not known."
47     echo "You need to edit '$0.in' to add support for this distro."
48     exit 1
49 fi
50
51 # Run the prepare step.
52 echo "Preparing the supermin appliance containing:" $packages
53 "$supermin" --prepare $packages -o tmp-supermin.d
54
55 # Add the init script and editor binary.
56 tar cf tmp-supermin.d/init.tar init editor
57
58 # Run the build step.
59 echo "Building the full appliance ..."
60 echo "If you see 'Permission denied' errors here, you can probably ignore"
61 echo "them, but encourage your distro to stop using security-through-obscurity."
62 "$supermin" --build --format ext2 tmp-supermin.d -o tmp-appliance.d
63
64 # Copy out the kernel, initrd and disk image.
65 mv tmp-appliance.d/kernel .
66 mv tmp-appliance.d/initrd .
67 qemu-img convert -f raw tmp-appliance.d/root -O qcow2 "$output"
68
69 rm -rf tmp-supermin.d tmp-appliance.d