Current location

narf Source control manager Git

aboutsummaryrefslogtreecommitdiff
blob: 2c6892049849627514c9409adcc79ac753757719 (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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/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
export ARCHITECTURE
export DESTINATION
export MACHINE
export SOURCE
export SUITE
export ENABLE_NONFREE

# 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 on the beaglebone
beaglebone_pkgs="linux-image-armmp u-boot-tools u-boot"

# Packages needed on the cubietruck
cubietruck_pkgs="linux-image-armmp-lpae 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"

echo Building $MACHINE FreedomBox for $ARCHITECTURE.

case "$MACHINE" in
    raspberry)
	extra_opts="\
 --variant minbase \
 --bootsize 128M \
 --boottype vfat \
 --no-kernel \
 --no-extlinux \
 --foreign /usr/bin/qemu-arm-static \
 --roottype ext4 \
"
	;;
    dreamplug)
	extra_pkgs="$dreamplug_pkgs"
	extra_opts="\
 --variant minbase \
 --bootsize 128M \
 --boottype vfat \
 --no-kernel \
 --no-extlinux \
 --foreign /usr/bin/qemu-arm-static \
 --roottype btrfs \
"
	;;
    beaglebone)
	extra_pkgs="$beaglebone_pkgs"
	extra_opts="\
 --variant minbase \
 --bootoffset=2mib \
 --bootsize 128M \
 --boottype ext2 \
 --no-kernel \
 --no-extlinux \
 --foreign /usr/bin/qemu-arm-static \
 --roottype btrfs \
"
	;;
    cubietruck)
       extra_pkgs="$cubietruck_pkgs"
       extra_opts="\
 --variant minbase \
 --bootoffset=1mib \
 --bootsize 128M \
 --boottype vfat \
 --no-kernel \
 --no-extlinux \
 --foreign /usr/bin/qemu-arm-static \
 --roottype btrfs \
"
       ;;
    virtualbox)
	extra_opts="\
 --grub \
 --roottype btrfs \
"	;;
    all)
	extra_opts="\
 --grub \
 --roottype btrfs \
"	;;
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

if [ -x vendor/vmdebootstrap/vmdebootstrap ] ; then
    VMDEBOOTSTRAP=vendor/vmdebootstrap/vmdebootstrap
else
    VMDEBOOTSTRAP=vmdebootstrap
fi

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