Current location

narf Source control manager Git

aboutsummaryrefslogtreecommitdiff
blob: 0c34bc76abc74e3273cb79adc325818dc639c3c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/sh
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

set -e # Exit on first error

#set -x # Enable debugging

IMAGE=$1

# Locate vmdebootstrap program fetched in Makefile
basedir=`pwd`
vendor_dir="${basedir}/vendor"
vmdebootstrap_dir="${vendor_dir}/vmdebootstrap"

if [ -z "$MIRROR" ] || [ -z "$SUITE" ] ; then
    echo error: Missing MIRROR and SUITE settings inherited from Makefile.
    exit 1
fi

# Packages to install in all FreedomBox environments
base_pkgs="apt base-files ifupdown initramfs-tools \
logrotate module-init-tools netbase rsyslog udev debian-archive-keyring"

# Packages needed on the dreamplug
dreamplug_pkgs="linux-image-kirkwood u-boot-tools u-boot"

# Packages needed for gui-based self-hosted development
dev_pkgs="task-xfce-desktop emacs org-mode git mercurial iceweasel ca-certificates"

if [ -z "$ARCHITECTURE" ] ; then
    ARCHITECTURE=i386
fi

echo building $MACHINE for $ARCHITECTURE

case "$MACHINE" in
    raspberry)
	extra_opts="\
 --variant minbase \
 --bootsize 128M \
 --boottype vfat \
 --no-kernel \
 --no-extlinux \
 --foreign /usr/bin/qemu-arm-static \
"
	;;
    dreamplug)
	extra_pkgs="$dreamplug_pkgs"
	extra_opts="\
 --variant minbase \
 --bootsize 128M \
 --boottype vfat \
 --no-kernel \
 --no-extlinux \
 --foreign /usr/bin/qemu-arm-static \
"
	;;
    virtualbox)
	extra_opts="\
 --enable-dhcp \
"	;;
esac

# allow for lots of extra fun customization options.
for customization in "$CUSTOMIZATIONS"
do
    case "$customization" in
        development)
            extra_pkgs="$extra_pkgs $dev_pkgs"
            ;;
    esac
done

for p in $base_pkgs $extra_pkgs; do
    pkgopts="$pkgopts --package $p"
done

# Make sure file is owned by current user, not root
touch $(dirname $IMAGE)/freedombox.log

# Run vmdebootstrap script to create image
sudo -H \
    SUITE="$SUITE" \
    MIRROR="$MIRROR" \
    DESTINATION="$DESTINATION" \
    MACHINE="$MACHINE" \
    ARCHITECTURE="$ARCHITECTURE" \
    vmdebootstrap \
    --log $(dirname $IMAGE)/freedombox.log \
    --log-level debug \
    --size 3G \
    --image $IMAGE.img \
    --hostname freedombox \
    --verbose \
    --mirror $MIRROR \
    --customize "$basedir/bin/freedombox-customize" \
    --lock-root-password \
    --arch $ARCHITECTURE \
    --distribution $SUITE \
    $extra_opts \
    $pkgopts