|
2
by Oliver Grawert
rename binary to rootstock |
1 |
#!/bin/sh
|
2 |
#
|
|
|
98
by Ricardo Salveti de Araujo
rootstock and rootstock.1: updating usage information to be possible to regenerate the man page with help2man |
3 |
# Copyright (c) 2009, 2010 Canonical
|
|
2
by Oliver Grawert
rename binary to rootstock |
4 |
#
|
5 |
# Author: Oliver Grawert <ogra@canonical.com>
|
|
|
120
by Ricardo Salveti de Araujo
rootstock: adding myself to the blame list :-) |
6 |
# Ricardo Salveti <ricardo.salveti@canonical.com>
|
|
2
by Oliver Grawert
rename binary to rootstock |
7 |
#
|
8 |
# This program is free software; you can redistribute it and/or
|
|
9 |
# modify it under the terms of the GNU General Public License as
|
|
10 |
# published by the Free Software Foundation; either version 2 of the
|
|
11 |
# License, or (at your option) any later version.
|
|
12 |
#
|
|
13 |
# This program is distributed in the hope that it will be useful,
|
|
14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 |
# GNU General Public License for more details.
|
|
17 |
#
|
|
18 |
# You should have received a copy of the GNU General Public License
|
|
19 |
# along with this program; if not, write to the Free Software
|
|
20 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
21 |
# USA
|
|
22 |
#
|
|
23 |
######################################################################
|
|
24 |
# This script creates a tgz file of an armel rootfs you can untar in #
|
|
25 |
# a partition for your target hardware (beagleboard, EVM or freescale#
|
|
26 |
# board were tested with this yet) #
|
|
27 |
# See https://wiki.ubuntu.com/ARM/RootfsFromScratch for more details #
|
|
28 |
######################################################################
|
|
29 |
#
|
|
30 |
# TODO: - install langpacks for selected locale
|
|
31 |
#
|
|
32 |
######################################################################
|
|
33 |
||
34 |
set -e
|
|
35 |
||
|
77
by Oliver Grawert
handle term signal in trap code in rootstock script |
36 |
trap cleanup 1 2 3 6 15
|
|
2
by Oliver Grawert
rename binary to rootstock |
37 |
|
|
98
by Ricardo Salveti de Araujo
rootstock and rootstock.1: updating usage information to be possible to regenerate the man page with help2man |
38 |
PROGRAM="$(basename $0)" |
|
122
by Ricardo Salveti de Araujo
Release 0.1.99.4 |
39 |
VERSION="0.1.99.4" |
|
98
by Ricardo Salveti de Araujo
rootstock and rootstock.1: updating usage information to be possible to regenerate the man page with help2man |
40 |
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
41 |
log()
|
42 |
{
|
|
43 |
[ $QUIET ] || echo "$*" |
|
44 |
echo "$*" >> $LOG |
|
45 |
}
|
|
46 |
||
47 |
error()
|
|
48 |
{
|
|
49 |
echo "$*" | tee -a $LOG |
|
50 |
}
|
|
51 |
||
|
2
by Oliver Grawert
rename binary to rootstock |
52 |
cleanup()
|
53 |
{
|
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
54 |
log "I: Cleaning up..."
|
|
99
by Ricardo Salveti de Araujo
rootstock: cosmetic changes, correctly indenting function cleanup |
55 |
|
56 |
# kill debootstrap if its running
|
|
57 |
if [ -e ${DBPID} ];then |
|
58 |
DPID=$(cat ${DBPID}) |
|
59 |
kill -9 $DPID >/dev/null 2>&1 |
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
60 |
log "I: Killed debootstrap... "
|
|
99
by Ricardo Salveti de Araujo
rootstock: cosmetic changes, correctly indenting function cleanup |
61 |
fi
|
62 |
||
63 |
# kill qemu if its running
|
|
64 |
if [ -e ${QEMUPID} ];then |
|
65 |
QPID=$(cat ${QEMUPID}) |
|
66 |
kill -9 $QPID >/dev/null 2>&1 |
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
67 |
log "I: Killed qemu... "
|
|
99
by Ricardo Salveti de Araujo
rootstock: cosmetic changes, correctly indenting function cleanup |
68 |
fi
|
69 |
||
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
70 |
# kill chroot environment if its running
|
71 |
if [ -e ${CHRPID} ];then |
|
72 |
CPID=$(cat ${CHRPID}) |
|
73 |
kill -9 $CPID >/dev/null 2>&1 |
|
74 |
log "I: Killed chroot... "
|
|
75 |
fi
|
|
76 |
||
|
99
by Ricardo Salveti de Araujo
rootstock: cosmetic changes, correctly indenting function cleanup |
77 |
for i in 1 2 3 4 5; do |
78 |
echo -n '.' |
|
79 |
sleep 1 |
|
80 |
done
|
|
81 |
echo |
|
82 |
||
83 |
# unmount qemu image
|
|
84 |
umount_image |
|
85 |
||
86 |
# unmount tmpfs for swap
|
|
87 |
umount_swap |
|
88 |
||
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
89 |
savelog |
90 |
||
|
99
by Ricardo Salveti de Araujo
rootstock: cosmetic changes, correctly indenting function cleanup |
91 |
# wipe builddir
|
92 |
rm -rf $BUILDDIR
|
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
93 |
echo "I: Done" |
|
99
by Ricardo Salveti de Araujo
rootstock: cosmetic changes, correctly indenting function cleanup |
94 |
exit 0
|
|
2
by Oliver Grawert
rename binary to rootstock |
95 |
}
|
96 |
||
97 |
usage()
|
|
98 |
{
|
|
|
30.1.3
by Loïc Minier
Fix default release output. |
99 |
cat <<EOF
|
|
98
by Ricardo Salveti de Araujo
rootstock and rootstock.1: updating usage information to be possible to regenerate the man page with help2man |
100 |
Usage: $PROGRAM -f <hostname> [OPTION]...
|
101 |
Generates Ubuntu armel rootfs tarballs and/or qemu image, to be
|
|
102 |
uncompressed onto a root device.
|
|
103 |
||
104 |
Note that it does not set up a kernel, modules or bootloader for you.
|
|
105 |
Kernel and bootloader need to be set up in a device specific manner,
|
|
106 |
modules should be copied to the filesystem after it was uncompressed
|
|
107 |
on the target device.
|
|
108 |
||
109 |
It also uses a virtual machine and can take long to build your
|
|
110 |
filesystem, please be patient and make sure to have enough CPU power
|
|
111 |
on the host machine.
|
|
112 |
||
113 |
Options:
|
|
114 |
||
115 |
Required:
|
|
116 |
||
|
2
by Oliver Grawert
rename binary to rootstock |
117 |
-f --fqdn <hostname>
|
118 |
Hostname to be used for the target system
|
|
|
42
by Oliver Grawert
install oem-config by default if username and password are not supplied |
119 |
|
|
98
by Ricardo Salveti de Araujo
rootstock and rootstock.1: updating usage information to be possible to regenerate the man page with help2man |
120 |
Additional:
|
121 |
||
|
2
by Oliver Grawert
rename binary to rootstock |
122 |
-l --login <login name>
|
123 |
Login ID of the admin user created during setup
|
|
124 |
-p --password <password>
|
|
125 |
Password of the admin user created during setup
|
|
126 |
-h --help
|
|
|
98
by Ricardo Salveti de Araujo
rootstock and rootstock.1: updating usage information to be possible to regenerate the man page with help2man |
127 |
Display this help
|
|
2
by Oliver Grawert
rename binary to rootstock |
128 |
-n --fullname <quoted string>
|
129 |
Full Name of the admin user created during setup
|
|
130 |
(default: "Ubuntu System User")
|
|
131 |
-s --seed <csv list>
|
|
132 |
List of packages to install (i.e. ubuntu-desktop)
|
|
133 |
-i --imagesize <size>M/G
|
|
134 |
Size of the target filesystem to be created (i.e. 500M)
|
|
135 |
(default: 1G)
|
|
|
33
by Oliver Grawert
add support for manifest (packagelist) file, thanks to tmiket@recipes4linux.com |
136 |
-g --manifest <path to file>
|
137 |
Manifest file with list of packages to install (one per line)
|
|
|
2
by Oliver Grawert
rename binary to rootstock |
138 |
-m --mirror <url>
|
139 |
apt mirror to use (i.e. http://ports.ubuntu.com/ubuntu-ports)
|
|
140 |
(default: http://ports.ubuntu.com/ubuntu-ports)
|
|
141 |
-c --components <csv list>
|
|
142 |
Archive components
|
|
143 |
(default: main,universe)
|
|
|
121
by Ricardo Salveti de Araujo
rootstock.1: updating manual |
144 |
-d --dist (jaunty, karmic, lucid or maverick)
|
|
8
by Oliver Grawert
add --dist option to script to support building for either jaunty or karmic release |
145 |
Specify Release to build
|
|
30.1.3
by Loïc Minier
Fix default release output. |
146 |
(default: `lsb_release -cs`)
|
|
2
by Oliver Grawert
rename binary to rootstock |
147 |
-t --timezone <timezone>
|
148 |
Timezone for the system (i.e. Europe/Berlin)
|
|
149 |
(default: buildsystem timezone)
|
|
150 |
-x --locale <locale.encoding>
|
|
151 |
Language used in the installed system (i.e. en_US.UTF-8)
|
|
152 |
(default: buildsystem locale)
|
|
|
30.2.1
by Loïc Minier
Add support for running a custom script at the end of the installation with |
153 |
--script <filename>
|
154 |
Run this script at the end of the installation process
|
|
|
19
by Oliver Grawert
update manpage and documentation for serial device support |
155 |
--serial <devicename>
|
156 |
Create a serial tty of <devicename> inside the rootfs for login (i.e. ttyS0)
|
|
|
82
by Oliver Grawert
rootstock: do not use swapfile by default (change --noswap to --doswap), adjust qemu cmdline options for new kernel and drop superfluous M from -m option, add mem=265M to kernel cmdline options. rootstock-gtk:still show an error even if no logfile was created (so wrong option arguments are catched), make progerssbar use the pkgcount variable that rootstock spits out for package install, adjust strings |
157 |
--doswap
|
158 |
Do create a swapfile in tmpfs for the virtual machine
|
|
|
16
by Oliver Grawert
rootstock: add support for swapfile in a tmpfs to be used by the VM, add --swapsize and --noswap arguments |
159 |
--swapsize <size in megabyte>
|
160 |
Use a different size for the swapfile used by the virtual machine
|
|
161 |
(default: 256M)
|
|
|
98
by Ricardo Salveti de Araujo
rootstock and rootstock.1: updating usage information to be possible to regenerate the man page with help2man |
162 |
--version
|
163 |
Print version number
|
|
164 |
||
165 |
Keyboard:
|
|
166 |
||
|
2
by Oliver Grawert
rename binary to rootstock |
167 |
--kblayout <layout>
|
168 |
Keyboard layout (i.e. us)
|
|
169 |
(default: buildsystem kblayout)
|
|
170 |
--kbmodel <model>
|
|
171 |
Keyboard model (i.e. pc105)
|
|
172 |
(default: buildsystem kbmodel)
|
|
173 |
--kbvariant <variant>
|
|
174 |
Keyboard variant (i.e. nodeadkeys)
|
|
175 |
(default: buildsystem kbvariant)
|
|
176 |
--kboptions <options>
|
|
177 |
Additional keyboard options
|
|
178 |
(default: buildsystem kboptions)
|
|
179 |
||
|
98
by Ricardo Salveti de Araujo
rootstock and rootstock.1: updating usage information to be possible to regenerate the man page with help2man |
180 |
Output:
|
181 |
||
|
2
by Oliver Grawert
rename binary to rootstock |
182 |
--keepimage
|
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
183 |
Keep the qemu image instead of deleting it (disabled for native)
|
|
2
by Oliver Grawert
rename binary to rootstock |
184 |
--notarball
|
185 |
Do not roll a tarball of the rootfs (autosets --keepimage)
|
|
186 |
||
|
98
by Ricardo Salveti de Araujo
rootstock and rootstock.1: updating usage information to be possible to regenerate the man page with help2man |
187 |
Extra parameters:
|
188 |
||
|
2
by Oliver Grawert
rename binary to rootstock |
189 |
-q --quiet
|
190 |
Quiet operation, only write to log
|
|
|
17.1.2
by Robert Nelson
inital kernle-iamge integration |
191 |
|
|
98
by Ricardo Salveti de Araujo
rootstock and rootstock.1: updating usage information to be possible to regenerate the man page with help2man |
192 |
Advanced:
|
193 |
||
|
87
by Oliver Grawert
revert the qcow2 usage, qemu-nbd is not really stable from scripts and converting teh image back and forth doesnt make the image auto grow, make sure --kernel-image has a proper description and checks for url |
194 |
--kernel-image <http url to kernel .deb>
|
195 |
install board specfic kernel package from http accessible deb package inside rootfs
|
|
|
45
by Oliver Grawert
switch --restore-package-cache to allow using no authentication in offline mode, add documentation of the caching switches |
196 |
--copy-package-cache
|
197 |
save a snapshot of all packages used for a build locally to re-use them
|
|
198 |
in a subsequent offline build with the --restore-package-cache option
|
|
199 |
--restore-package-cache
|
|
200 |
use precached packages from a former build run with --copy-package-cache
|
|
201 |
--clean-package-cache
|
|
202 |
empty the package cache of a former --copy-package-cache run
|
|
|
48
by Oliver Grawert
add --extra-mirror option to specify additional package mirror |
203 |
--extra-mirror
|
204 |
additional mirror to use
|
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
205 |
--no-root
|
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
206 |
run rootstock without requiring root access (slower as uses a full vm)
|
|
98
by Ricardo Salveti de Araujo
rootstock and rootstock.1: updating usage information to be possible to regenerate the man page with help2man |
207 |
|
208 |
Examples:
|
|
209 |
||
210 |
Xubuntu-Desktop (as root): rootstock -f host -l user -p temppwd -i 2G -s xubuntu-desktop
|
|
211 |
||
212 |
Minimal Ubuntu (as user): rootstock -f host -l user -p temppwd -i 512M --no-root -s ubuntu-minimal
|
|
213 |
||
214 |
Report bugs at https://launchpad.net/project-rootstock/+filebug
|
|
|
124
by Ricardo Salveti de Araujo
rootstock and rootstock.1: adding the link to the known issues wiki page (LP: #612504) |
215 |
|
216 |
For Known Issues, please read https://wiki.ubuntu.com/ARM/RootStock/KnownIssues.
|
|
|
30.1.3
by Loïc Minier
Fix default release output. |
217 |
EOF
|
|
2
by Oliver Grawert
rename binary to rootstock |
218 |
exit 0
|
219 |
}
|
|
220 |
||
|
98
by Ricardo Salveti de Araujo
rootstock and rootstock.1: updating usage information to be possible to regenerate the man page with help2man |
221 |
print_version()
|
222 |
{
|
|
223 |
cat <<EOF
|
|
224 |
$PROGRAM $VERSION
|
|
225 |
||
226 |
Copyright (C) 2009, 2010 Canonical
|
|
227 |
License: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
|
|
228 |
||
229 |
This is free software: you are free to change and redistribute it.
|
|
230 |
There is NO WARRANTY, to the extent permitted by law.
|
|
231 |
||
|
120
by Ricardo Salveti de Araujo
rootstock: adding myself to the blame list :-) |
232 |
Written by Oliver Grawert <ogra@canonical.com> and Ricardo Salveti <ricardo.salveti@canonical.com>.
|
|
98
by Ricardo Salveti de Araujo
rootstock and rootstock.1: updating usage information to be possible to regenerate the man page with help2man |
233 |
EOF
|
234 |
}
|
|
235 |
||
|
2
by Oliver Grawert
rename binary to rootstock |
236 |
savelog()
|
237 |
{
|
|
|
40
by Oliver Grawert
add a --clean-package-cache option to purge the cached files |
238 |
if [ -z "$NOSAVELOG" ];then |
239 |
mv $LOG $DIR/ |
|
|
98
by Ricardo Salveti de Araujo
rootstock and rootstock.1: updating usage information to be possible to regenerate the man page with help2man |
240 |
echo "I: A logfile was saved as $DIR/${PROGRAM}-$STAMP.log" |
|
40
by Oliver Grawert
add a --clean-package-cache option to purge the cached files |
241 |
fi
|
|
2
by Oliver Grawert
rename binary to rootstock |
242 |
}
|
243 |
||
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
244 |
create_qemu_image()
|
|
2
by Oliver Grawert
rename binary to rootstock |
245 |
{
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
246 |
log "I: Creating temporary qemu Image to be used as rootfs"
|
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
247 |
LANG=C qemu-img create $IMAGENAME ${IMAGESIZE}k >>$LOG 2>&1 |
|
75
by Oliver Grawert
use ext3 instead of ext2 as image filesystem |
248 |
LANG=C mkfs.ext3 -F $IMAGENAME >>$LOG 2>&1 |
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
249 |
}
|
250 |
||
251 |
create_rootfs_image()
|
|
252 |
{
|
|
253 |
# create the ext3 image to be used later with qemu
|
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
254 |
log "I: Creating ext3 Image from the rootfs"
|
|
106
by Ricardo Salveti de Araujo
rootstock: better error treatment for genext2fs |
255 |
if ! ERROR=$(genext2fs -b $IMAGESIZE -i $BYTEINODE -d $ROOTFS $IMAGENAME 2>&1);then |
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
256 |
error "E: $ERROR" |
|
106
by Ricardo Salveti de Araujo
rootstock: better error treatment for genext2fs |
257 |
cleanup |
258 |
fi
|
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
259 |
tune2fs -j $IMAGENAME >>$LOG 2>&1 |
260 |
# fsck is expected to return != 0
|
|
261 |
! fsck.ext3 -y -f $IMAGENAME >>$LOG 2>&1 |
|
|
2
by Oliver Grawert
rename binary to rootstock |
262 |
}
|
263 |
||
264 |
mount_image()
|
|
265 |
{
|
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
266 |
log "I: Mounting temporary Image"
|
|
2
by Oliver Grawert
rename binary to rootstock |
267 |
if [ ! -d $MOUNTPOINT ];then |
268 |
mkdir -p $MOUNTPOINT >>$LOG 2>&1 |
|
269 |
fi
|
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
270 |
if [ "$NOROOT" ];then |
|
119
by Ricardo Salveti de Araujo
rootstock: fuseext2 should mount as rw+ to be able to clean the cache |
271 |
fuseext2 -o rw+,direct_io -s $IMAGENAME $MOUNTPOINT >>$LOG 2>&1 |
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
272 |
elif [ ! "$IS_NATIVE" ];then |
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
273 |
mount -o loop $IMAGENAME $MOUNTPOINT >>$LOG 2>&1 |
274 |
fi
|
|
275 |
}
|
|
276 |
||
277 |
umount_image()
|
|
278 |
{
|
|
|
114
by Ricardo Salveti de Araujo
rootstock: at umount_image we should check /proc/mounts for mounting points |
279 |
if grep -q ${MOUNTPOINT} /proc/mounts; then |
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
280 |
log "I: Umounting temporary Image" |
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
281 |
if [ "$NOROOT" ];then |
282 |
fusermount -z -u $MOUNTPOINT >>$LOG 2>&1 |
|
283 |
else
|
|
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
284 |
# be sure we unmount everything
|
|
114
by Ricardo Salveti de Araujo
rootstock: at umount_image we should check /proc/mounts for mounting points |
285 |
if grep -q ${MOUNTPOINT}/dev/pts /proc/mounts; then |
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
286 |
umount -f ${MOUNTPOINT}/dev/pts |
287 |
fi
|
|
|
114
by Ricardo Salveti de Araujo
rootstock: at umount_image we should check /proc/mounts for mounting points |
288 |
if grep -q ${MOUNTPOINT}/proc /proc/mounts; then |
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
289 |
umount -f ${MOUNTPOINT}/proc |
290 |
fi
|
|
|
114
by Ricardo Salveti de Araujo
rootstock: at umount_image we should check /proc/mounts for mounting points |
291 |
if grep -q ${MOUNTPOINT}/sys /proc/mounts; then |
292 |
umount -f ${MOUNTPOINT}/sys |
|
293 |
fi
|
|
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
294 |
if [ ! "$IS_NATIVE" ]; then |
295 |
umount -l $MOUNTPOINT >>$LOG 2>&1 |
|
296 |
fi
|
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
297 |
fi
|
298 |
fi
|
|
299 |
}
|
|
300 |
||
301 |
umount_swap()
|
|
302 |
{
|
|
303 |
if [ -n "$TMPMOUNT" ];then |
|
304 |
if $(mount |grep -q $TMPMOUNT);then |
|
305 |
umount -l $TMPMOUNT |
|
306 |
fi
|
|
307 |
fi
|
|
|
2
by Oliver Grawert
rename binary to rootstock |
308 |
}
|
309 |
||
310 |
run_first_stage()
|
|
311 |
{
|
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
312 |
log "I: Running first stage"
|
|
2
by Oliver Grawert
rename binary to rootstock |
313 |
|
314 |
mkfifo $DBFIFO
|
|
315 |
||
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
316 |
EXTRAOPTS="" |
317 |
TARBALL=$CACHEDIR/debootstrap.tgz |
|
318 |
DMIRROR="$MIRROR" |
|
|
38
by Oliver Grawert
clean the caching code a bit |
319 |
DEFOPTS="--foreign --arch=armel" |
320 |
||
321 |
if [ "$RESTORE_PACKAGE_CACHE" ];then |
|
|
113
by Ricardo Salveti de Araujo
rootstock: with --restore-package-cache we should also check for a valid deboostrap tarball |
322 |
if [ ! -d $CACHEDIR ] || [ ! -f $TARBALL ];then |
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
323 |
error "E: Error, no pre-cached packages found !" |
324 |
error "E: please run rootstock with --copy-package-cache first"
|
|
|
41
by Oliver Grawert
do not explicitly write a log if no cache exists and we exit at the beginning |
325 |
NOSAVELOG=1 |
|
39
by Oliver Grawert
dont run --restore-package-cache if there are no cached packages |
326 |
cleanup |
327 |
fi
|
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
328 |
log "I: using pre-cached packages" |
|
38
by Oliver Grawert
clean the caching code a bit |
329 |
EXTRAOPTS="--unpack-tarball=$TARBALL" |
330 |
DMIRROR="file://$CACHEDIR" |
|
331 |
fi
|
|
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
332 |
|
333 |
if [ "$COPY_PACKAGE_CACHE" ];then |
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
334 |
log "I: pre-caching debootstrap packages" |
|
38
by Oliver Grawert
clean the caching code a bit |
335 |
EXTRAOPTS="--keep-debootstrap-dir --make-tarball=$TARBALL" |
336 |
mkdir -p $CACHEDIR
|
|
337 |
||
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
338 |
LANG=C fakeroot debootstrap $DEFOPTS $EXTRAOPTS $DIST $ROOTFS $DMIRROR >$DBFIFO 2>&1 & |
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
339 |
echo $! > $DBPID |
340 |
while read line; do |
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
341 |
log "${line}" |
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
342 |
done <$DBFIFO |
|
38
by Oliver Grawert
clean the caching code a bit |
343 |
|
344 |
EXTRAOPTS="--unpack-tarball=$TARBALL" |
|
345 |
fi
|
|
346 |
||
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
347 |
# recreate to avoid interrupted syscall
|
348 |
rm -f $DBFIFO
|
|
349 |
mkfifo $DBFIFO
|
|
350 |
||
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
351 |
# using fakeroot so we're able to create the base rootfs as user
|
352 |
LANG=C fakeroot debootstrap $DEFOPTS $EXTRAOPTS $DIST $ROOTFS $DMIRROR >$DBFIFO 2>&1 & |
|
|
38
by Oliver Grawert
clean the caching code a bit |
353 |
|
354 |
echo $! > $DBPID |
|
355 |
while read line; do |
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
356 |
log "${line}" |
|
38
by Oliver Grawert
clean the caching code a bit |
357 |
done <$DBFIFO |
358 |
||
359 |
if [ "$COPY_PACKAGE_CACHE" ];then |
|
360 |
mkdir -p $CACHEDIR/dists/$DIST |
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
361 |
cp $ROOTFS/var/lib/apt/lists/*Release $CACHEDIR/dists/$DIST/Release |
|
38
by Oliver Grawert
clean the caching code a bit |
362 |
fi
|
363 |
||
|
117
by Ricardo Salveti de Araujo
rootstock: removing extra whitespace that confuses if |
364 |
if [ ! "$(which qemu-arm-static)" -a ! "$IS_NATIVE" ] || [ "$NOROOT" ];then |
|
25
by Oliver Grawert
add support for qemu-arm-static if available |
365 |
SECOND_STAGE="/debootstrap/debootstrap --second-stage" |
366 |
else
|
|
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
367 |
if [ ! "$IS_NATIVE" ];then |
368 |
mkdir -p $ROOTFS/usr/bin/ |
|
369 |
cp $(which qemu-arm-static) $ROOTFS/usr/bin/ |
|
370 |
fi
|
|
|
128
by Ricardo Salveti de Araujo
rootstock: preserving TMPDIR with chroot (LP: #638190) |
371 |
$CHROOT $ROOTFS debootstrap/debootstrap --second-stage >$DBFIFO 2>&1 & |
|
25
by Oliver Grawert
add support for qemu-arm-static if available |
372 |
SECOND_STAGE="" |
|
93
by Oliver Grawert
merge patch from Sam Tyger <tygier@users.sourceforge.net> for LP: #556304 (build hangs at Extracting zlib1g in some environments) |
373 |
|
374 |
echo $! > $DBPID |
|
375 |
while read line; do |
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
376 |
log "${line}" |
|
93
by Oliver Grawert
merge patch from Sam Tyger <tygier@users.sourceforge.net> for LP: #556304 (build hangs at Extracting zlib1g in some environments) |
377 |
done <$DBFIFO |
|
25
by Oliver Grawert
add support for qemu-arm-static if available |
378 |
fi
|
|
2
by Oliver Grawert
rename binary to rootstock |
379 |
|
380 |
rm -f $DBFIFO |
|
381 |
rm -f $DBPID
|
|
382 |
||
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
383 |
log "I: First stage install done"
|
|
2
by Oliver Grawert
rename binary to rootstock |
384 |
}
|
385 |
||
386 |
run_vm()
|
|
387 |
{
|
|
388 |
# get kernel
|
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
389 |
log "I: Getting Virtual Machine kernel from the server"
|
|
35
by Oliver Grawert
add get_vm_kernel function to use the packaged versatile kernel from the ubuntu archive (temporarily disabled until kernel package is fixed) |
390 |
get_vm_kernel |
|
2
by Oliver Grawert
rename binary to rootstock |
391 |
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
392 |
log "I: Switching to Virtual Machine for second stage processing"
|
|
30.1.1
by Loïc Minier
Select cortex-a8 CPU for karmic and later. |
393 |
VMCPU="cortex-a8" |
|
16
by Oliver Grawert
rootstock: add support for swapfile in a tmpfs to be used by the VM, add --swapsize and --noswap arguments |
394 |
if [ -n "$SWAPFILE" ];then |
395 |
SWAPDEV="-hdb $SWAPFILE" |
|
396 |
fi
|
|
|
95
by Oliver Grawert
change qemu VM command to use no cache for the emulated harddisk, potentially improves the situation with Bug #532733 |
397 |
QEMUOPTS="-M versatilepb ${VMCPU:+-cpu $VMCPU} -kernel ${BUILDDIR}/qemu-vmlinuz -no-reboot -nographic -pidfile ${QEMUPID} -drive file=${IMAGENAME},aio=native,cache=none ${SWAPDEV} -m 256" |
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
398 |
APPEND="console=ttyAMA0,115200n8 root=/dev/sda rw mem=256M init=/bin/installer quiet" |
|
100
by Ricardo Salveti de Araujo
rootstock: when root, use devtmpfs.mount=0 to keep old behavior |
399 |
if [ ! "$NOROOT" ];then |
400 |
APPEND="${APPEND} devtmpfs.mount=0" |
|
401 |
fi
|
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
402 |
|
403 |
# XXX: run qemu at least 2 times, workaround for qemu bug LP #604872
|
|
404 |
QEMURUN=0 |
|
405 |
while [ "$QEMURUN" -lt 2 ] && [ ! "$QEMUDONE" ];do |
|
406 |
rm -f $QEMUFIFO |
|
407 |
mkfifo $QEMUFIFO
|
|
408 |
||
409 |
! qemu-system-arm $QEMUOPTS -append "${APPEND}" >$QEMUFIFO 2>&1 & |
|
410 |
if [ "$QEMURUN" -gt 0 ];then |
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
411 |
error "W: Bad Bad Qemu, trying second stage one more time (LP #604872)" |
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
412 |
fi
|
413 |
QEMURUN=$(($QEMURUN+1)) |
|
414 |
while read line; do |
|
415 |
if [ "$(echo $line|grep panic)" ];then |
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
416 |
log "${line}" |
417 |
error "E: Second stage build in Virtual Machine failed !"
|
|
418 |
error "E: Please see the log to see what went wrong."
|
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
419 |
cleanup |
420 |
fi
|
|
421 |
if [ "$line" ] && [ ! "$(echo $line|grep 'Uncompressing Linux')" ] && \ |
|
422 |
[ ! "$(echo $line|grep 'unknown LCD panel')" ] && \ |
|
423 |
[ ! "$(echo $line|grep 'Restarting system')" ];then |
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
424 |
log "${line}" |
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
425 |
fi
|
426 |
if [ "$(echo $line|grep 'Restarting system')" ];then |
|
427 |
QEMUDONE=1 |
|
428 |
fi
|
|
429 |
done <$QEMUFIFO |
|
430 |
done;
|
|
431 |
||
432 |
if [ ! "$QEMUDONE" ];then |
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
433 |
error "E: Failed to run the second stage in the Virtual Machine !" |
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
434 |
cleanup |
435 |
fi
|
|
|
2
by Oliver Grawert
rename binary to rootstock |
436 |
|
437 |
rm -f $QEMUPID |
|
438 |
||
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
439 |
log "I: Virtual Machine done"
|
|
2
by Oliver Grawert
rename binary to rootstock |
440 |
}
|
441 |
||
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
442 |
run_chroot()
|
443 |
{
|
|
444 |
log "I: Using Chroot for installer"
|
|
445 |
||
446 |
mkfifo $CHRFIFO
|
|
447 |
||
448 |
# mounting required mount points
|
|
449 |
mount -t proc none ${ROOTFS}/proc |
|
450 |
mkdir -p ${ROOTFS}/dev/pts |
|
451 |
mount -t devpts devpts ${ROOTFS}/dev/pts |
|
452 |
||
453 |
# do the work
|
|
|
128
by Ricardo Salveti de Araujo
rootstock: preserving TMPDIR with chroot (LP: #638190) |
454 |
$CHROOT $ROOTFS /bin/installer >$CHRFIFO 2>&1 || { |
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
455 |
error "E: Second stage build in chroot failed !"
|
456 |
error "E: Please see the log to see what went wrong."
|
|
457 |
rm -f $CHRPID
|
|
458 |
(cleanup) |
|
459 |
exit 1
|
|
460 |
} &
|
|
461 |
||
|
115
by Ricardo Salveti de Araujo
rootstock: removing a racing condition when dealing with an error inside chroot |
462 |
PID=$! |
463 |
echo $PID > $CHRPID |
|
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
464 |
while read line; do |
465 |
if [ ! "$(echo $line|grep 'qemu: Unsupported syscall')" ] && \ |
|
466 |
[ ! "$(echo $line|grep 'Unsupported ioctl:')" ];then |
|
467 |
log "${line}" |
|
468 |
else
|
|
469 |
echo "${line}" >> $LOG |
|
470 |
fi
|
|
471 |
done <$CHRFIFO |
|
472 |
||
|
115
by Ricardo Salveti de Araujo
rootstock: removing a racing condition when dealing with an error inside chroot |
473 |
wait $PID |
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
474 |
|
475 |
umount -f ${ROOTFS}/dev/pts |
|
476 |
umount -f ${ROOTFS}/proc |
|
477 |
||
478 |
rm -f $CHRFIFO
|
|
479 |
rm -f $CHRPID
|
|
480 |
||
481 |
log "I: Chroot done"
|
|
482 |
}
|
|
483 |
||
|
5
by Oliver Grawert
add --serial option to script to create a serial tty during build |
484 |
setup_serial()
|
485 |
{
|
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
486 |
log "I: Setting up serial tty in image"
|
|
5
by Oliver Grawert
add --serial option to script to create a serial tty during build |
487 |
|
488 |
if [ "$DIST" = "jaunty" ];then |
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
489 |
test -d $ROOTFS/etc/event.d/|| mkdir -p $ROOTFS/etc/event.d/ |
490 |
cat > $ROOTFS/etc/event.d/$SERIAL_TTYS <<EOF |
|
|
5
by Oliver Grawert
add --serial option to script to create a serial tty during build |
491 |
start on runlevel 2
|
492 |
start on runlevel 3
|
|
493 |
start on runlevel 4
|
|
494 |
start on runlevel 5
|
|
495 |
||
496 |
stop on runlevel 0
|
|
497 |
stop on runlevel 1
|
|
498 |
stop on runlevel 6
|
|
499 |
||
500 |
respawn
|
|
|
17.1.1
by Robert Nelson
allow users to specify serial port used --serial <ttySx> |
501 |
exec /sbin/getty 115200 $SERIAL_TTYS
|
|
5
by Oliver Grawert
add --serial option to script to create a serial tty during build |
502 |
EOF
|
503 |
else
|
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
504 |
test -d $ROOTFS/etc/init/|| mkdir -p $ROOTFS/etc/init/ |
505 |
cat > $ROOTFS/etc/init/$SERIAL_TTYS.conf <<EOF |
|
|
5
by Oliver Grawert
add --serial option to script to create a serial tty during build |
506 |
start on stopped rc RUNLEVEL=[2345]
|
507 |
stop on runlevel [!2345]
|
|
508 |
||
509 |
respawn
|
|
|
17.1.1
by Robert Nelson
allow users to specify serial port used --serial <ttySx> |
510 |
exec /sbin/getty 115200 $SERIAL_TTYS
|
|
5
by Oliver Grawert
add --serial option to script to create a serial tty during build |
511 |
EOF
|
512 |
fi
|
|
513 |
}
|
|
514 |
||
|
16
by Oliver Grawert
rootstock: add support for swapfile in a tmpfs to be used by the VM, add --swapsize and --noswap arguments |
515 |
use_swap()
|
516 |
{
|
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
517 |
# if normal user, use swap as a file
|
518 |
if [ "$NOROOT" ]; then |
|
519 |
SWAPFILE=$BUILDDIR/swapfile |
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
520 |
log "I: Creating a normal swapfile for VM (non-root)"
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
521 |
else
|
522 |
TMPMOUNT=$BUILDDIR/tmpfs |
|
523 |
SWAPFILE=$TMPMOUNT/swapfile |
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
524 |
log "I: Creating swapfile in tmpfs for VM"
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
525 |
mkdir -p $TMPMOUNT >>$LOG 2>&1 |
526 |
mount -t tmpfs -o size=$(($SWAPSIZE*1048576)) tmpfs $TMPMOUNT >>$LOG 2>&1 |
|
527 |
fi
|
|
528 |
||
|
17
by Oliver Grawert
make sure to leave 8k spare space in the tmpfs if creating the swapfile |
529 |
dd if=/dev/zero of=$SWAPFILE bs=1048576 count=$(($SWAPSIZE-8)) >>$LOG 2>&1 |
|
16
by Oliver Grawert
rootstock: add support for swapfile in a tmpfs to be used by the VM, add --swapsize and --noswap arguments |
530 |
mkswap -f $SWAPFILE >>$LOG 2>&1 |
531 |
SWAPCMD="swapon /dev/sdb" |
|
532 |
}
|
|
533 |
||
|
17.1.2
by Robert Nelson
inital kernle-iamge integration |
534 |
setup_kernel_image()
|
535 |
{
|
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
536 |
log "I: Downloading kernel image (deb) from external site"
|
|
17.1.2
by Robert Nelson
inital kernle-iamge integration |
537 |
|
|
125
by Ricardo Salveti de Araujo
rootstock: always tries to save vmlinuz and initrd.img |
538 |
KERNEL_IMG=${KERNEL_URL##*/} |
539 |
test -d $ROOTFS/tmp/ || mkdir -p $ROOTFS/tmp/ |
|
540 |
||
541 |
if [ "$RESTORE_PACKAGE_CACHE" ] && \ |
|
542 |
[ -f "$CACHEDIR/kernel/$KERNEL_IMG" ];then |
|
543 |
log "I: Found cached $KERNEL_IMG, skipping download" |
|
544 |
cp $CACHEDIR/kernel/$KERNEL_IMG $ROOTFS/tmp |
|
545 |
else
|
|
546 |
KERNELDIR=$(mktemp -d) |
|
547 |
wget --directory-prefix=$KERNELDIR --quiet $KERNEL_URL |
|
548 |
log "I: $KERNEL_IMG download complete"
|
|
549 |
cp $KERNELDIR/$KERNEL_IMG $ROOTFS/tmp |
|
550 |
||
551 |
if [ "$COPY_PACKAGE_CACHE" ];then |
|
552 |
mkdir -p $CACHEDIR/kernel |
|
553 |
cp $KERNELDIR/$KERNEL_IMG $CACHEDIR/kernel |
|
554 |
fi
|
|
555 |
rm -rfd $KERNELDIR |
|
556 |
fi
|
|
557 |
||
|
17.1.6
by Robert Nelson
image.deb workaround, extract *.deb via dpkg -x instead of installing *.deb, no dpkg install, and the modules correctly load on first boot |
558 |
#Hack dpkg -i fails, no postinstall script is run anyways, so lets just extract it.
|
559 |
KERNEL_IMAGE_CMD="dpkg -x /tmp/$KERNEL_IMG /" |
|
|
94
by Oliver Grawert
merge patch from Robert Nelson <robertcnelson@gmail.com> to generate initramfs from external deb |
560 |
|
561 |
KERNEL_IMG_REL=${KERNEL_IMG##*linux-image-} |
|
|
104
by Ricardo Salveti de Araujo
rootstock: merge patch from Robert Nelson <robertcnelson@gmail.com> to remove the bashism introduced in rev 94 |
562 |
KERNEL_IMG_REL=$(echo $KERNEL_IMG_REL | awk -F_ '{print $1}') |
|
94
by Oliver Grawert
merge patch from Robert Nelson <robertcnelson@gmail.com> to generate initramfs from external deb |
563 |
|
564 |
KERNEL_IMAGE_CREATE_INITRAMFS="update-initramfs -c -k $KERNEL_IMG_REL" |
|
|
17.1.2
by Robert Nelson
inital kernle-iamge integration |
565 |
}
|
566 |
||
|
35
by Oliver Grawert
add get_vm_kernel function to use the packaged versatile kernel from the ubuntu archive (temporarily disabled until kernel package is fixed) |
567 |
get_vm_kernel()
|
568 |
{
|
|
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
569 |
if [ "$RESTORE_PACKAGE_CACHE" ];then |
570 |
cp $CACHEDIR/vmkernel/qemu-vmlinuz $BUILDDIR/qemu-vmlinuz |
|
|
35
by Oliver Grawert
add get_vm_kernel function to use the packaged versatile kernel from the ubuntu archive (temporarily disabled until kernel package is fixed) |
571 |
else
|
|
83
by Oliver Grawert
rootstock script: use same kernel for all builds, fix useradd command quoting if -l and -p are set, keep the networking setup in oem-config plugins |
572 |
KERNEL="http://ports.ubuntu.com/ubuntu-ports/dists/lucid/main/installer-armel/current/images/versatile/netboot/vmlinuz" |
573 |
LANG=C wget -O $BUILDDIR/qemu-vmlinuz $KERNEL >>$LOG 2>&1 |
|
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
574 |
if [ "$COPY_PACKAGE_CACHE" ];then |
575 |
mkdir -p $CACHEDIR/vmkernel/ |
|
576 |
cp $BUILDDIR/qemu-vmlinuz $CACHEDIR/vmkernel/ |
|
577 |
fi
|
|
|
35
by Oliver Grawert
add get_vm_kernel function to use the packaged versatile kernel from the ubuntu archive (temporarily disabled until kernel package is fixed) |
578 |
fi
|
579 |
}
|
|
580 |
||
|
17.1.2
by Robert Nelson
inital kernle-iamge integration |
581 |
extract_kernel_image()
|
582 |
{
|
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
583 |
mount_image |
584 |
||
|
125
by Ricardo Salveti de Araujo
rootstock: always tries to save vmlinuz and initrd.img |
585 |
if ls $MOUNTPOINT/boot/vmlinuz-* >/dev/null 2>&1;then |
586 |
log "I: Found vmlinuz at the rootfs, copying it to $DIR"
|
|
587 |
cp $MOUNTPOINT/boot/vmlinuz-* $DIR |
|
588 |
fi
|
|
589 |
||
590 |
if ls $MOUNTPOINT/boot/initrd.img-* >/dev/null 2>&1;then |
|
591 |
log "I: Found initrd.img at the rootfs, copying it to $DIR"
|
|
592 |
cp $MOUNTPOINT/boot/initrd.img-* $DIR |
|
593 |
fi
|
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
594 |
|
595 |
umount_image
|
|
|
17.1.2
by Robert Nelson
inital kernle-iamge integration |
596 |
}
|
597 |
||
|
40
by Oliver Grawert
add a --clean-package-cache option to purge the cached files |
598 |
clean_package_cache()
|
599 |
{
|
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
600 |
log "I: Removing cached files"
|
|
108
by Ricardo Salveti de Araujo
rootstock: --clean-package-cache should exit just if the user doesn't request to generate a rootfs |
601 |
rm -rfv $CACHEDIR/* >> $LOG 2>&1 |
602 |
# just runs cleanup if we don't need to create a rootfs
|
|
603 |
if [ ! "${FQDN}" ];then |
|
604 |
NOSAVELOG=1 |
|
605 |
cleanup |
|
606 |
fi
|
|
|
40
by Oliver Grawert
add a --clean-package-cache option to purge the cached files |
607 |
}
|
608 |
||
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
609 |
save_package_cache()
|
610 |
{
|
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
611 |
log "I: caching packages for later use"
|
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
612 |
|
613 |
mount_image |
|
614 |
||
615 |
mkdir -p $CACHEDIR
|
|
616 |
cp -up $MOUNTPOINT/var/cache/apt/archives/*.deb $CACHEDIR/ || true |
|
617 |
||
618 |
mkdir -p $CACHEDIR/lists |
|
|
44
by Oliver Grawert
move PW generation above useradd command, do slight modifications to caching code |
619 |
cp -p $MOUNTPOINT/var/lib/apt/lists/* $CACHEDIR/lists/ || true |
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
620 |
|
|
101
by Ricardo Salveti de Araujo
rootstock: with user we're unable to chroot apt-get clean, but we should at least remove cached deb files |
621 |
if [ "$NOROOT" ];then |
622 |
rm -f $MOUNTPOINT/var/cache/apt/archives/*.deb |
|
623 |
else
|
|
|
128
by Ricardo Salveti de Araujo
rootstock: preserving TMPDIR with chroot (LP: #638190) |
624 |
$CHROOT $MOUNTPOINT apt-get clean |
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
625 |
fi
|
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
626 |
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
627 |
umount_image
|
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
628 |
}
|
629 |
||
630 |
restore_package_cache()
|
|
631 |
{
|
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
632 |
log "I: Restoring cached packages (may take a while)..."
|
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
633 |
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
634 |
mkdir -p $ROOTFS/var/cache/apt/archives
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
635 |
cp -vp $CACHEDIR/*.deb $ROOTFS/var/cache/apt/archives/ >> $LOG 2>&1 |
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
636 |
mkdir -p $ROOTFS/var/lib/apt/lists/
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
637 |
cp -vp $CACHEDIR/lists/* $ROOTFS/var/lib/apt/lists/ >> $LOG 2>&1 || true |
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
638 |
APT_UPDATE="" |
|
45
by Oliver Grawert
switch --restore-package-cache to allow using no authentication in offline mode, add documentation of the caching switches |
639 |
APT_FORCE="--allow-unauthenticated" |
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
640 |
}
|
641 |
||
|
48
by Oliver Grawert
add --extra-mirror option to specify additional package mirror |
642 |
add_extra_mirror()
|
643 |
{
|
|
644 |
EXRA_MIRROR_CMD="echo \"deb ${EXTRAMIRROR} ${DIST} ${COMPONENTS}\" >>/etc/apt/sources.list" |
|
645 |
}
|
|
646 |
||
|
2
by Oliver Grawert
rename binary to rootstock |
647 |
roll_tarball()
|
648 |
{
|
|
649 |
# create a rootfs tgz
|
|
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
650 |
log "I: Creating tarball from rootfs"
|
|
2
by Oliver Grawert
rename binary to rootstock |
651 |
|
652 |
mount_image |
|
653 |
||
654 |
cd $MOUNTPOINT >>$LOG 2>&1 |
|
655 |
LANG=C tar czvf ../armel-rootfs-$STAMP.tgz . >>$LOG 2>&1 |
|
656 |
mv ../armel-rootfs-$STAMP.tgz $DIR >>$LOG 2>&1 |
|
657 |
||
658 |
echo "I: ARM rootfs created as $DIR/armel-rootfs-$STAMP.tgz" |
|
659 |
||
660 |
cd - >/dev/null 2>&1
|
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
661 |
|
662 |
umount_image |
|
|
2
by Oliver Grawert
rename binary to rootstock |
663 |
}
|
664 |
||
665 |
save_qemu_img()
|
|
666 |
{
|
|
|
87
by Oliver Grawert
revert the qcow2 usage, qemu-nbd is not really stable from scripts and converting teh image back and forth doesnt make the image auto grow, make sure --kernel-image has a proper description and checks for url |
667 |
cp $IMAGENAME $DIR |
|
91
by Oliver Grawert
rootstock: change ownership of the .img file to $SUDO_USER instead of opening permissions LP: #540822 |
668 |
if [ "$SUDO_USER" ]; then |
669 |
chown $SUDO_USER $DIR/qemu-armel-$STAMP.img |
|
670 |
fi
|
|
|
2
by Oliver Grawert
rename binary to rootstock |
671 |
echo "I: Qemu image saved as $DIR/qemu-armel-$STAMP.img" |
672 |
}
|
|
673 |
||
674 |
# target system name
|
|
675 |
FQDN="" |
|
676 |
||
677 |
# target user
|
|
678 |
NEWUSER="" |
|
679 |
FULLNAME="Ubuntu System User" |
|
680 |
PASSWD="" |
|
681 |
||
682 |
# target package selection
|
|
|
22
by Oliver Grawert
dont enforce ubuntu-minimal as default so building debian images wont block on it |
683 |
SELECTION="" # change here to install ubuntu-desktop |
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
684 |
# kbytes
|
685 |
IMAGESIZE="1048576" # 1G, make this 3G for an ubuntu-desktop install |
|
686 |
BYTEINODE="4096" |
|
|
2
by Oliver Grawert
rename binary to rootstock |
687 |
|
688 |
# default to the build system locale
|
|
689 |
. /etc/environment |
|
|
51
by Oliver Grawert
fix locale handling |
690 |
. /etc/default/locale |
|
2
by Oliver Grawert
rename binary to rootstock |
691 |
NEWLOCALE=$LANG |
692 |
||
693 |
# default to the build system keyboard setup
|
|
694 |
KBDATA="/etc/default/console-setup" |
|
695 |
XKBL=$(grep XKBLAYOUT ${KBDATA}|tr -d '"'|cut -d '=' -f2) |
|
696 |
XKBM=$(grep XKBMODEL ${KBDATA}|tr -d '"'|cut -d '=' -f2) |
|
697 |
XKBV=$(grep XKBVARIANT ${KBDATA}|tr -d '"'|cut -d '=' -f2) |
|
698 |
XKBO=$(grep XKBOPTIONS ${KBDATA}|tr -d '"'|cut -d '=' -f2) |
|
699 |
||
700 |
# default to the build system timezone
|
|
701 |
TZONE=$(cat /etc/timezone) |
|
702 |
||
703 |
# target apt setup
|
|
|
24
by Oliver Grawert
default to host release for DIST |
704 |
DIST=$(lsb_release -cs) |
|
2
by Oliver Grawert
rename binary to rootstock |
705 |
MIRROR="http://ports.ubuntu.com/ubuntu-ports" |
706 |
COMPONENTS="main universe" |
|
707 |
||
|
30.2.1
by Loïc Minier
Add support for running a custom script at the end of the installation with |
708 |
# user-specified script
|
709 |
USER_SCRIPT="" |
|
710 |
||
|
2
by Oliver Grawert
rename binary to rootstock |
711 |
# builder defaults
|
712 |
DEFGROUPS="admin,adm,dialout,cdrom,floppy,audio,dip,video" |
|
713 |
STAMP=$(date +%Y%m%d%H%M) |
|
714 |
BUILDDIR=$(mktemp -d) |
|
715 |
MOUNTPOINT="${BUILDDIR}/tmpmount" |
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
716 |
ROOTFS="${BUILDDIR}/rootfs" |
|
2
by Oliver Grawert
rename binary to rootstock |
717 |
IMAGENAME="${BUILDDIR}/qemu-armel-$STAMP.img" |
718 |
QEMUPID="${BUILDDIR}/qemu.pid" |
|
719 |
QEMUFIFO="${BUILDDIR}/qemufifo" |
|
720 |
DBPID="${BUILDDIR}/debootstrap.pid" |
|
721 |
DBFIFO="${BUILDDIR}/dbfifo" |
|
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
722 |
CHRFIFO="${BUILDDIR}/chrootfifo" |
723 |
CHRPID="${BUILDDIR}/chroot.pid" |
|
|
2
by Oliver Grawert
rename binary to rootstock |
724 |
DIR="$(pwd)" |
|
82
by Oliver Grawert
rootstock: do not use swapfile by default (change --noswap to --doswap), adjust qemu cmdline options for new kernel and drop superfluous M from -m option, add mem=265M to kernel cmdline options. rootstock-gtk:still show an error even if no logfile was created (so wrong option arguments are catched), make progerssbar use the pkgcount variable that rootstock spits out for package install, adjust strings |
725 |
NOSWAP=1 |
|
16
by Oliver Grawert
rootstock: add support for swapfile in a tmpfs to be used by the VM, add --swapsize and --noswap arguments |
726 |
SWAPSIZE=256 |
|
2
by Oliver Grawert
rename binary to rootstock |
727 |
|
728 |
# general defaults
|
|
|
98
by Ricardo Salveti de Araujo
rootstock and rootstock.1: updating usage information to be possible to regenerate the man page with help2man |
729 |
LOG="$BUILDDIR/${PROGRAM}-$STAMP.log" |
|
2
by Oliver Grawert
rename binary to rootstock |
730 |
|
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
731 |
PACKAGE_CLEANUP="apt-get clean" |
|
46
by Oliver Grawert
move restore_package_cache call into right place so all variables are set, split apt-get clan calls into two variables for having different calls depending on the caching mode |
732 |
PACKAGE_CLEANUP_SUB="${PACKAGE_CLEANUP}" |
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
733 |
APT_UPDATE="apt-get update" |
|
44
by Oliver Grawert
move PW generation above useradd command, do slight modifications to caching code |
734 |
APT_FORCE="" |
|
48
by Oliver Grawert
add --extra-mirror option to specify additional package mirror |
735 |
EXRA_MIRROR_CMD="" |
|
128
by Ricardo Salveti de Araujo
rootstock: preserving TMPDIR with chroot (LP: #638190) |
736 |
CHROOT="eval TMPDIR=/tmp chroot" |
|
2
by Oliver Grawert
rename binary to rootstock |
737 |
|
738 |
# parse commandline options
|
|
|
129
by Ricardo Salveti de Araujo
rootstock: fixing -s (seed) argument usage (LP: #640420) |
739 |
GETOPT=`getopt -o hf:l:p:n:s:i:g:m:c:t:x:d:q --long help,fqdn:,login:,\ |
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
740 |
password:,fullname:,seed:,imagesize:,manifest:,mirror:,components:,timezone:,\
|
741 |
kblayout:,kbmodel:,kbvariant:,kboptions:,locale:,keepimage,notarball,script:,\
|
|
|
111
by Ricardo Salveti de Araujo
rootstock: --serial should always request an argument |
742 |
serial:,doswap,swapsize:,dist:,quiet,kernel-image:,copy-package-cache,\
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
743 |
restore-package-cache,clean-package-cache,extra-mirror:,no-root,version \
|
744 |
-n "$PROGRAM" -- "$@"` |
|
745 |
if [ $? != 0 ]; then usage; exit 1; fi |
|
746 |
eval set -- "$GETOPT" |
|
747 |
while true ; do |
|
|
2
by Oliver Grawert
rename binary to rootstock |
748 |
case $1 in |
749 |
-h|--help)
|
|
750 |
usage |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
751 |
shift
|
|
2
by Oliver Grawert
rename binary to rootstock |
752 |
;; |
753 |
-f|--fqdn)
|
|
754 |
FQDN="$2" |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
755 |
shift 2
|
|
2
by Oliver Grawert
rename binary to rootstock |
756 |
;; |
757 |
-l|--login)
|
|
758 |
NEWUSER="$2" |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
759 |
shift 2
|
|
2
by Oliver Grawert
rename binary to rootstock |
760 |
;; |
761 |
-p|--password)
|
|
762 |
PASSWD="$2" |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
763 |
shift 2
|
|
2
by Oliver Grawert
rename binary to rootstock |
764 |
;; |
765 |
-n|--fullname)
|
|
766 |
FULLNAME="$2" |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
767 |
shift 2
|
|
2
by Oliver Grawert
rename binary to rootstock |
768 |
;; |
769 |
-s|--seed)
|
|
770 |
SELECTION="$(echo $2|tr ',' ' ')" |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
771 |
shift 2
|
|
2
by Oliver Grawert
rename binary to rootstock |
772 |
;; |
773 |
-i|--imagesize)
|
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
774 |
if [ "$(echo $2|grep '^[0-9]*M$')" ];then |
775 |
IMAGESIZE="$((1024*${2%M}))" |
|
776 |
elif [ "$(echo $2|grep '^[0-9]*G$')" ];then |
|
777 |
IMAGESIZE="$((1024*1024*${2%G}))" |
|
778 |
else
|
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
779 |
echo "E: Size needs to be in gigabyte or megabyte (M|G)" |
780 |
exit 1
|
|
|
2
by Oliver Grawert
rename binary to rootstock |
781 |
fi
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
782 |
shift 2 |
|
2
by Oliver Grawert
rename binary to rootstock |
783 |
;; |
|
33
by Oliver Grawert
add support for manifest (packagelist) file, thanks to tmiket@recipes4linux.com |
784 |
-g|--manifest)
|
785 |
SELECTION="$(cat "${2}" | sed ':a;N;$!ba;s/\n/ /g')" |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
786 |
shift 2
|
|
33
by Oliver Grawert
add support for manifest (packagelist) file, thanks to tmiket@recipes4linux.com |
787 |
;; |
|
2
by Oliver Grawert
rename binary to rootstock |
788 |
-m|--mirror)
|
789 |
MIRROR="$2" |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
790 |
shift 2
|
|
2
by Oliver Grawert
rename binary to rootstock |
791 |
;; |
792 |
-c|--components)
|
|
793 |
COMPONENTS="$(echo $2|tr ',' ' ')" |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
794 |
shift 2
|
|
2
by Oliver Grawert
rename binary to rootstock |
795 |
;; |
796 |
-t|--timezone)
|
|
797 |
if [ ! "$(echo $2|grep '/')" ];then |
|
798 |
echo "E: Need a proper timezone" |
|
799 |
usage |
|
800 |
fi
|
|
801 |
TZONE="$2" |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
802 |
shift 2
|
|
2
by Oliver Grawert
rename binary to rootstock |
803 |
;; |
804 |
--kblayout)
|
|
805 |
XKBL="$2" |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
806 |
shift 2
|
|
2
by Oliver Grawert
rename binary to rootstock |
807 |
;; |
808 |
--kbmodel)
|
|
809 |
XKBM="$2" |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
810 |
shift 2
|
|
2
by Oliver Grawert
rename binary to rootstock |
811 |
;; |
812 |
--kbvariant)
|
|
813 |
XKBV="$2" |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
814 |
shift 2
|
|
2
by Oliver Grawert
rename binary to rootstock |
815 |
;; |
816 |
--kboptions)
|
|
817 |
XKBO="$2" |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
818 |
shift 2
|
|
2
by Oliver Grawert
rename binary to rootstock |
819 |
;; |
820 |
-x|--locale)
|
|
821 |
if [ ! "$(echo $2|grep '_')" ];then |
|
822 |
echo "E: Need a proper locale" |
|
823 |
usage |
|
824 |
fi
|
|
825 |
NEWLOCALE="$2" |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
826 |
shift 2
|
|
2
by Oliver Grawert
rename binary to rootstock |
827 |
;; |
828 |
--keepimage)
|
|
829 |
KEEPIMAGE=1 |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
830 |
shift
|
|
2
by Oliver Grawert
rename binary to rootstock |
831 |
;; |
832 |
--notarball)
|
|
833 |
NOTARBALL=1 |
|
834 |
KEEPIMAGE=1 |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
835 |
shift
|
|
2
by Oliver Grawert
rename binary to rootstock |
836 |
;; |
|
30.2.1
by Loïc Minier
Add support for running a custom script at the end of the installation with |
837 |
--script)
|
838 |
USER_SCRIPT="$2" |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
839 |
shift 2
|
|
30.2.1
by Loïc Minier
Add support for running a custom script at the end of the installation with |
840 |
;; |
|
5
by Oliver Grawert
add --serial option to script to create a serial tty during build |
841 |
--serial)
|
|
111
by Ricardo Salveti de Araujo
rootstock: --serial should always request an argument |
842 |
SERIAL_TTYS="$2" |
|
5
by Oliver Grawert
add --serial option to script to create a serial tty during build |
843 |
SERIAL=1 |
|
111
by Ricardo Salveti de Araujo
rootstock: --serial should always request an argument |
844 |
shift 2
|
|
5
by Oliver Grawert
add --serial option to script to create a serial tty during build |
845 |
;; |
|
82
by Oliver Grawert
rootstock: do not use swapfile by default (change --noswap to --doswap), adjust qemu cmdline options for new kernel and drop superfluous M from -m option, add mem=265M to kernel cmdline options. rootstock-gtk:still show an error even if no logfile was created (so wrong option arguments are catched), make progerssbar use the pkgcount variable that rootstock spits out for package install, adjust strings |
846 |
--doswap)
|
847 |
NOSWAP="" |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
848 |
shift
|
|
16
by Oliver Grawert
rootstock: add support for swapfile in a tmpfs to be used by the VM, add --swapsize and --noswap arguments |
849 |
;; |
850 |
--swapsize)
|
|
851 |
SWAPSIZE="$2" |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
852 |
shift 2
|
|
16
by Oliver Grawert
rootstock: add support for swapfile in a tmpfs to be used by the VM, add --swapsize and --noswap arguments |
853 |
;; |
|
8
by Oliver Grawert
add --dist option to script to support building for either jaunty or karmic release |
854 |
-d|--dist)
|
855 |
DIST="$2" |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
856 |
shift 2
|
|
8
by Oliver Grawert
add --dist option to script to support building for either jaunty or karmic release |
857 |
;; |
|
2
by Oliver Grawert
rename binary to rootstock |
858 |
-q|--quiet)
|
859 |
QUIET=1 |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
860 |
shift
|
|
2
by Oliver Grawert
rename binary to rootstock |
861 |
;; |
|
17.1.2
by Robert Nelson
inital kernle-iamge integration |
862 |
--kernel-image)
|
863 |
KERNEL_IMAGE=1 |
|
|
125
by Ricardo Salveti de Araujo
rootstock: always tries to save vmlinuz and initrd.img |
864 |
KERNEL_URL="$2" |
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
865 |
shift 2
|
|
17.1.2
by Robert Nelson
inital kernle-iamge integration |
866 |
;; |
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
867 |
--copy-package-cache)
|
868 |
COPY_PACKAGE_CACHE=1 |
|
869 |
PACKAGE_CLEANUP="" |
|
|
46
by Oliver Grawert
move restore_package_cache call into right place so all variables are set, split apt-get clan calls into two variables for having different calls depending on the caching mode |
870 |
PACKAGE_CLEANUP_SUB="" |
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
871 |
shift
|
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
872 |
;; |
873 |
--restore-package-cache)
|
|
874 |
RESTORE_PACKAGE_CACHE=1 |
|
875 |
APT_UPDATE="" |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
876 |
shift
|
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
877 |
;; |
|
40
by Oliver Grawert
add a --clean-package-cache option to purge the cached files |
878 |
--clean-package-cache)
|
879 |
CLEAN_PACKAGE_CACHE=1 |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
880 |
shift
|
|
40
by Oliver Grawert
add a --clean-package-cache option to purge the cached files |
881 |
;; |
|
48
by Oliver Grawert
add --extra-mirror option to specify additional package mirror |
882 |
--extra-mirror)
|
883 |
EXTRAMIRROR=$2 |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
884 |
shift 2
|
|
48
by Oliver Grawert
add --extra-mirror option to specify additional package mirror |
885 |
;; |
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
886 |
--no-root)
|
887 |
if [ "$(id -u)" -eq 0 ];then |
|
888 |
echo "You are root, why would you like to run with --no-root?" |
|
889 |
exit 2
|
|
890 |
fi
|
|
891 |
NOROOT=1 |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
892 |
shift
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
893 |
;; |
|
98
by Ricardo Salveti de Araujo
rootstock and rootstock.1: updating usage information to be possible to regenerate the man page with help2man |
894 |
--version)
|
895 |
print_version |
|
896 |
exit 0
|
|
897 |
;; |
|
|
105
by Ricardo Salveti de Araujo
rootstock: changing the way how we parse the arguments (getopt) |
898 |
--)
|
899 |
shift
|
|
900 |
break
|
|
901 |
;; |
|
902 |
*)
|
|
903 |
echo "Internal error!"; |
|
904 |
exit 1
|
|
905 |
;; |
|
|
2
by Oliver Grawert
rename binary to rootstock |
906 |
esac
|
907 |
done
|
|
908 |
||
|
96
by Ricardo Salveti de Araujo
rootstock: normal user should at least be able to check the command usage. |
909 |
# check if we have at least hostname
|
|
108
by Ricardo Salveti de Araujo
rootstock: --clean-package-cache should exit just if the user doesn't request to generate a rootfs |
910 |
if [ ! "${FQDN}" ] && [ ! "$CLEAN_PACKAGE_CACHE" ];then |
|
96
by Ricardo Salveti de Araujo
rootstock: normal user should at least be able to check the command usage. |
911 |
usage
|
912 |
fi
|
|
913 |
||
914 |
# we need root
|
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
915 |
if [ $(id -u) != 0 ] && [ ! "$NOROOT" ];then |
|
102
by Ricardo Salveti de Araujo
rootstock: fixing error message when running as user |
916 |
echo "You should run $PROGRAM as root unless you explicitly request it by giving --no-root" |
|
96
by Ricardo Salveti de Araujo
rootstock: normal user should at least be able to check the command usage. |
917 |
exit 2
|
918 |
fi
|
|
919 |
||
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
920 |
# check if we're doing native arm work
|
921 |
ARCH=$(uname -m) |
|
922 |
if echo $ARCH | grep -q "^armv[5-7].*"; then |
|
923 |
IS_NATIVE=1 |
|
924 |
KEEPIMAGE="" |
|
925 |
||
926 |
# check if we're able to run the desired arm code
|
|
927 |
if [ "$ARCH" = "armv5tel" ] && [ "$DIST" != "jaunty" ];then |
|
928 |
echo "Only jaunty is supported for armv5" |
|
929 |
exit 2
|
|
930 |
elif [ "$ARCH" = "armv6l" ] && [ "$DIST" != "jaunty" ] && \ |
|
931 |
[ "$DIST" != "karmic" ];then |
|
932 |
echo "Only jaunty and karmic are supported for armv6" |
|
933 |
exit 2
|
|
934 |
fi
|
|
935 |
fi
|
|
936 |
||
937 |
# in case the user request to skip tarball and we're native
|
|
938 |
if [ "$IS_NATIVE" ] && [ "$NOTARBALL" ];then |
|
939 |
echo "In a native run only a tarball is generated, so requesting --notarball makes rootstock create nothing" |
|
940 |
exit 2
|
|
941 |
fi
|
|
942 |
||
943 |
log "I: Running on a $ARCH machine"
|
|
944 |
||
|
108
by Ricardo Salveti de Araujo
rootstock: --clean-package-cache should exit just if the user doesn't request to generate a rootfs |
945 |
# set up the cache DIR and clean it if needed
|
946 |
if [ "$NOROOT" ];then |
|
947 |
CACHEDIR="${HOME}/.cache/rootstock/archives" |
|
948 |
else
|
|
949 |
CACHEDIR="/var/cache/rootstock/archives" |
|
950 |
fi
|
|
951 |
if [ "$CLEAN_PACKAGE_CACHE" ];then |
|
952 |
clean_package_cache
|
|
953 |
fi
|
|
954 |
||
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
955 |
# find if we should run full vm or just user emulation
|
|
126
by Ricardo Salveti de Araujo
rootstock: adding correct quotes at -a expression |
956 |
if [ "$NOROOT" ] || [ ! "$(which qemu-arm-static)" -a ! "$IS_NATIVE" ];then |
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
957 |
log "I: Second stage will run inside a full virtual machine" |
958 |
RUNVM=1 |
|
959 |
else
|
|
960 |
# when running in a chroot environment swap is useless
|
|
961 |
NOSWAP=1 |
|
962 |
fi
|
|
963 |
||
964 |
if [ "$RUNVM" ] && [ ! $(which qemu-system-arm) ];then |
|
|
96
by Ricardo Salveti de Araujo
rootstock: normal user should at least be able to check the command usage. |
965 |
echo "qemu not installed, please use:" |
966 |
echo "sudo apt-get install qemu" |
|
967 |
echo "(or on ubuntu > karmic sudo apt-get install qemu-kvm-extras)" |
|
968 |
echo "to install the qemu package !" |
|
969 |
exit 1
|
|
970 |
fi
|
|
971 |
||
972 |
if [ ! $(which debootstrap) ];then |
|
973 |
echo "debootstrap not installed, please use:" |
|
974 |
echo "sudo apt-get install debootstrap" |
|
975 |
echo "to install the debootstrap package !" |
|
976 |
exit 1
|
|
977 |
fi
|
|
978 |
||
|
23
by Oliver Grawert
add a check if debootstrap supports $DIST, thanks to Erik Corry <erik.corry@gmail.com> for the fix ! |
979 |
if [ ! -f /usr/share/debootstrap/scripts/$DIST ];then |
980 |
echo "Your debootstrap installation does not seem to have support for the $DIST distribution" |
|
981 |
exit 5
|
|
982 |
fi
|
|
983 |
||
|
2
by Oliver Grawert
rename binary to rootstock |
984 |
# process vars
|
985 |
AREA=${TZONE%%/*} |
|
986 |
ZONE=${TZONE#*/} |
|
987 |
||
|
109
by Ricardo Salveti de Araujo
rootstock: moving the user add/oem-config to the installer script, to be able to treat possible errors |
988 |
# generate the user password
|
|
44
by Oliver Grawert
move PW generation above useradd command, do slight modifications to caching code |
989 |
PW=$(perl -e 'print crypt($ARGV[0], "qemuonarm")', $PASSWD) |
990 |
||
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
991 |
# set up the rootfs
|
992 |
if [ ! "$NOROOT" ]; then |
|
993 |
ROOTFS=$MOUNTPOINT |
|
994 |
if [ ! "$IS_NATIVE" ];then |
|
995 |
# if we're root and not native, use qemu and mount the image as loop
|
|
996 |
create_qemu_image |
|
997 |
mount_image |
|
998 |
fi
|
|
999 |
fi
|
|
1000 |
if [ ! -d $ROOTFS ];then |
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
1001 |
mkdir -p $ROOTFS >>$LOG 2>&1 |
1002 |
fi
|
|
1003 |
||
|
2
by Oliver Grawert
rename binary to rootstock |
1004 |
run_first_stage |
1005 |
||
|
46
by Oliver Grawert
move restore_package_cache call into right place so all variables are set, split apt-get clan calls into two variables for having different calls depending on the caching mode |
1006 |
# restore cached packages from host machine
|
1007 |
if [ "$RESTORE_PACKAGE_CACHE" ];then |
|
1008 |
restore_package_cache
|
|
1009 |
fi
|
|
1010 |
||
|
48
by Oliver Grawert
add --extra-mirror option to specify additional package mirror |
1011 |
if [ "$EXTRAMIRROR" ];then |
1012 |
add_extra_mirror
|
|
1013 |
fi
|
|
1014 |
||
|
2
by Oliver Grawert
rename binary to rootstock |
1015 |
# basic fstab
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
1016 |
echo "proc /proc proc defaults 0 0" >$ROOTFS/etc/fstab |
|
80
by Oliver Grawert
determine UUID of image and write to fstab inside the rootfs if the --keepimage option is used |
1017 |
if [ "$KEEPIMAGE" ];then |
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
1018 |
echo "/dev/sda / auto errors=remount-ro 0 1" >>$ROOTFS/etc/fstab |
|
80
by Oliver Grawert
determine UUID of image and write to fstab inside the rootfs if the --keepimage option is used |
1019 |
fi
|
|
2
by Oliver Grawert
rename binary to rootstock |
1020 |
|
|
88
by Oliver Grawert
fix handling of http_proxy and apt proxy setting (LP: #455622) |
1021 |
if [ -e /etc/apt/apt.conf.d/proxy ];then |
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
1022 |
mkdir -p $ROOTFS/etc/apt/apt.conf.d |
1023 |
cp /etc/apt/apt.conf.d/proxy $ROOTFS/etc/apt/apt.conf.d/proxy
|
|
|
88
by Oliver Grawert
fix handling of http_proxy and apt proxy setting (LP: #455622) |
1024 |
fi
|
1025 |
||
1026 |
if [ "$http_proxy" ];then |
|
|
118
by Ricardo Salveti de Araujo
rootstock: keep the old proxy address in case we can't translate the name to ip |
1027 |
# try to translate name to IP so it can be used inside qemu (mDNS)
|
|
103
by Ricardo Salveti de Araujo
rootstock: resolving proxy addr before going inside qemu, to support mDNS proxies |
1028 |
PROXY_ADDR=$(echo $http_proxy | sed -e "s/\(.*\/\/\)\?\(.*@\)\?//" -e "s/:.*//") |
1029 |
PROXY_IP=$(getent hosts $PROXY_ADDR | head -n 1 | awk -F' ' '{print $1}') |
|
|
118
by Ricardo Salveti de Araujo
rootstock: keep the old proxy address in case we can't translate the name to ip |
1030 |
if [ "$PROXY_IP" ];then |
1031 |
PROXY=$(echo $http_proxy | sed -e "s/$PROXY_ADDR:/$PROXY_IP:/") |
|
1032 |
else
|
|
1033 |
# could not translate, using original content
|
|
1034 |
PROXY=$http_proxy |
|
1035 |
fi
|
|
|
88
by Oliver Grawert
fix handling of http_proxy and apt proxy setting (LP: #455622) |
1036 |
fi
|
1037 |
||
|
2
by Oliver Grawert
rename binary to rootstock |
1038 |
# set up basic networking
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
1039 |
NETWORKDIR="$ROOTFS/etc/network" |
|
27
by Oliver Grawert
add fix to create /etc/network/interfaces if it does not exist from LP Bug #431917, thanks to <sebjoub> |
1040 |
INTERFACES="$NETWORKDIR/interfaces" |
1041 |
mkdir -p $NETWORKDIR
|
|
1042 |
||
|
2
by Oliver Grawert
rename binary to rootstock |
1043 |
echo "auto lo" >$INTERFACES |
1044 |
echo "iface lo inet loopback" >>$INTERFACES |
|
1045 |
||
1046 |
# set up resolver
|
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
1047 |
HOSTS="$ROOTFS/etc/hosts" |
|
2
by Oliver Grawert
rename binary to rootstock |
1048 |
echo "127.0.0.1 localhost" >$HOSTS |
1049 |
echo "127.0.1.1 ${FQDN}" >>$HOSTS |
|
1050 |
||
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
1051 |
echo "${FQDN}" >$ROOTFS/etc/hostname |
|
2
by Oliver Grawert
rename binary to rootstock |
1052 |
|
|
17.1.2
by Robert Nelson
inital kernle-iamge integration |
1053 |
if [ "$KERNEL_IMAGE" ];then |
1054 |
setup_kernel_image
|
|
1055 |
fi
|
|
1056 |
||
|
2
by Oliver Grawert
rename binary to rootstock |
1057 |
# write installer script to image
|
1058 |
cat > $BUILDDIR/installer <<EOF |
|
1059 |
#!/bin/bash
|
|
1060 |
set -e
|
|
1061 |
||
|
73
by Oliver Grawert
add a temporary workaround for https://bugs.launchpad.net/ubuntu/+bug/520465 |
1062 |
export MALLOC_CHECK_=0 # workaround for LP: #520465
|
|
30
by Oliver Grawert
move debooststrap second stage run to an earlier point in the installer script so it doesnt break on systems that dont have qemu-arm-static where deboostrap runs completely before switching to VM |
1063 |
export PATH
|
1064 |
export LC_ALL=C
|
|
|
50
by Oliver Grawert
use DEBIAN_FRONTEND=noninteractive in teh installer script, fix for LP: #461668 |
1065 |
export DEBIAN_FRONTEND=noninteractive
|
|
88
by Oliver Grawert
fix handling of http_proxy and apt proxy setting (LP: #455622) |
1066 |
export http_proxy="${PROXY}"
|
|
30
by Oliver Grawert
move debooststrap second stage run to an earlier point in the installer script so it doesnt break on systems that dont have qemu-arm-static where deboostrap runs completely before switching to VM |
1067 |
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
1068 |
if [ -f "/debootstrap/debootstrap" ];then
|
1069 |
echo "I: Fixing root fs permission"
|
|
1070 |
chown -R 0:0 /
|
|
1071 |
||
1072 |
echo "I: Running second stage"
|
|
1073 |
${SECOND_STAGE}
|
|
1074 |
fi
|
|
|
30
by Oliver Grawert
move debooststrap second stage run to an earlier point in the installer script so it doesnt break on systems that dont have qemu-arm-static where deboostrap runs completely before switching to VM |
1075 |
|
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
1076 |
if [ "$RUNVM" ];then
|
1077 |
echo "I: Starting basic services in VM"
|
|
1078 |
||
1079 |
mount -t proc proc /proc
|
|
1080 |
mount -t sysfs sys /sys
|
|
1081 |
mkdir -p /dev/pts
|
|
1082 |
mount -t devpts devpts /dev/pts
|
|
1083 |
||
1084 |
udevd --daemon &
|
|
1085 |
hostname -F /etc/hostname
|
|
1086 |
fi
|
|
|
26
by Oliver Grawert
clean up installer script to behave more like a generic chroot and to work with new upstart |
1087 |
|
1088 |
dpkg-divert --add --local --divert /usr/sbin/invoke-rc.d.rootstock --rename /usr/sbin/invoke-rc.d
|
|
1089 |
cp /bin/true /usr/sbin/invoke-rc.d
|
|
1090 |
||
|
16
by Oliver Grawert
rootstock: add support for swapfile in a tmpfs to be used by the VM, add --swapsize and --noswap arguments |
1091 |
${SWAPCMD}
|
1092 |
||
|
8
by Oliver Grawert
add --dist option to script to support building for either jaunty or karmic release |
1093 |
echo "deb ${MIRROR} ${DIST} ${COMPONENTS}" >/etc/apt/sources.list
|
|
127
by Ricardo Salveti de Araujo
rootstock: also adding -updates mirror by default |
1094 |
echo "deb ${MIRROR} ${DIST}-updates ${COMPONENTS}" >>/etc/apt/sources.list
|
|
48
by Oliver Grawert
add --extra-mirror option to specify additional package mirror |
1095 |
${EXRA_MIRROR_CMD}
|
|
2
by Oliver Grawert
rename binary to rootstock |
1096 |
|
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
1097 |
if [ "$RUNVM" ];then
|
1098 |
ifconfig lo up
|
|
1099 |
ifconfig eth0 up
|
|
1100 |
dhclient eth0
|
|
1101 |
fi
|
|
|
2
by Oliver Grawert
rename binary to rootstock |
1102 |
|
|
14
by Oliver Grawert
only generate en_GB.UTF-8 as fallback locale, there is no need to genreate all of en |
1103 |
locale-gen --no-purge en_GB.UTF-8 || true
|
|
2
by Oliver Grawert
rename binary to rootstock |
1104 |
locale-gen --no-purge ${NEWLOCALE} || true
|
|
51
by Oliver Grawert
fix locale handling |
1105 |
echo LANG=${NEWLOCALE} >>/etc/default/locale
|
|
2
by Oliver Grawert
rename binary to rootstock |
1106 |
|
1107 |
sed -i -e 's/^XKBMODEL=.*\$/XKBMODEL="${XKBM}"/' /etc/default/console-setup || true
|
|
1108 |
sed -i -e 's/^XKBLAYOUT=.*\$/XKBLAYOUT="${XKBL}"/' /etc/default/console-setup || true
|
|
1109 |
sed -i -e 's/^XKBVARIANT=.*\$/XKBVARIANT="${XKBV}"/' /etc/default/console-setup || true
|
|
1110 |
sed -i -e 's/^XKBOPTIONS=.*\$/XKBOPTIONS="${XKBO}"/' /etc/default/console-setup || true
|
|
1111 |
||
1112 |
echo ${AREA}/${ZONE} > /etc/timezone
|
|
1113 |
cp -f /usr/share/zoneinfo/${AREA}/${ZONE} /etc/localtime || true
|
|
1114 |
||
|
26
by Oliver Grawert
clean up installer script to behave more like a generic chroot and to work with new upstart |
1115 |
groupadd fuse || true
|
1116 |
||
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
1117 |
${APT_UPDATE}
|
1118 |
||
1119 |
${PACKAGE_CLEANUP}
|
|
1120 |
||
|
79
by Oliver Grawert
add a packagecount output that can be used by teh gtk progressbar to rootstock script |
1121 |
PKGCOUNT=\$(LANG=C apt-get -s install ${SELECTION} |grep "newly installed"|cut -d ',' -f2|tr -d ' [a-z]')
|
1122 |
echo "packagecount=\${PKGCOUNT:-1}"
|
|
|
44
by Oliver Grawert
move PW generation above useradd command, do slight modifications to caching code |
1123 |
[ -z "${SELECTION}" ] || apt-get -y ${APT_FORCE} install ${SELECTION}
|
|
2
by Oliver Grawert
rename binary to rootstock |
1124 |
|
|
109
by Ricardo Salveti de Araujo
rootstock: moving the user add/oem-config to the installer script, to be able to treat possible errors |
1125 |
groupadd admin || true
|
1126 |
echo '%admin ALL=(ALL) ALL' >>/etc/sudoers
|
|
1127 |
||
1128 |
if [ "${NEWUSER}" ] && [ "${PASSWD}" ];then
|
|
1129 |
if ! ERROR=\$(useradd -G "${DEFGROUPS}" -s /bin/bash -m -p ${PW} -c "${FULLNAME}" ${NEWUSER} 2>&1);then
|
|
1130 |
echo "E: Failed to add user '${NEWUSER}'"
|
|
1131 |
echo "E: \$ERROR"
|
|
1132 |
echo "E: Besides possible user name conflicts, while adding the user" \
|
|
1133 |
"a new group is created with the same name as the user, so" \
|
|
1134 |
"avoid using existing group names"
|
|
1135 |
exit 1
|
|
1136 |
fi
|
|
1137 |
else
|
|
1138 |
echo "I: Enabling firstboot configuration (as no user/password" \
|
|
1139 |
"definition was found at the argument list)"
|
|
1140 |
PACKAGE="oem-config"
|
|
1141 |
if [ -n "\$(dpkg -l xserver-xorg 2>/dev/null|grep ^ii)" ];then
|
|
1142 |
if [ \$(which gdm) ];then
|
|
1143 |
PACKAGE="oem-config-gtk"
|
|
1144 |
elif [ \$(which kdm) ];then
|
|
1145 |
PACKAGE="oem-config-kde"
|
|
1146 |
fi
|
|
1147 |
fi
|
|
1148 |
apt-get install -y --no-install-recommends \$PACKAGE
|
|
1149 |
touch /var/lib/oem-config/run
|
|
1150 |
rm /usr/lib/ubiquity/plugins/ubi-tasks.py*
|
|
1151 |
fi
|
|
1152 |
||
|
17.1.6
by Robert Nelson
image.deb workaround, extract *.deb via dpkg -x instead of installing *.deb, no dpkg install, and the modules correctly load on first boot |
1153 |
${KERNEL_IMAGE_CMD}
|
|
94
by Oliver Grawert
merge patch from Robert Nelson <robertcnelson@gmail.com> to generate initramfs from external deb |
1154 |
${KERNEL_IMAGE_CREATE_INITRAMFS}
|
|
17.1.6
by Robert Nelson
image.deb workaround, extract *.deb via dpkg -x instead of installing *.deb, no dpkg install, and the modules correctly load on first boot |
1155 |
|
|
55
by Oliver Grawert
make sure we dont run unwanted debconf modules in oem-config, clean the package cache later so the ubiquity debs are gone too in the image |
1156 |
${PACKAGE_CLEANUP_SUB}
|
1157 |
||
|
2
by Oliver Grawert
rename binary to rootstock |
1158 |
passwd -l root || true
|
1159 |
||
|
26
by Oliver Grawert
clean up installer script to behave more like a generic chroot and to work with new upstart |
1160 |
rm -f /usr/sbin/invoke-rc.d
|
1161 |
dpkg-divert --remove --rename /usr/sbin/invoke-rc.d
|
|
1162 |
||
|
30.2.1
by Loïc Minier
Add support for running a custom script at the end of the installation with |
1163 |
if [ -x /rootstock-user-script ]; then
|
|
116
by Ricardo Salveti de Araujo
rootstock: showing a message when running user's own script |
1164 |
echo "I: Running user custom script"
|
|
30.2.1
by Loïc Minier
Add support for running a custom script at the end of the installation with |
1165 |
/rootstock-user-script
|
1166 |
rm -f /rootstock-user-script
|
|
1167 |
fi
|
|
1168 |
||
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
1169 |
if [ "$RUNVM" ];then
|
1170 |
mount -n -o remount,ro -t ext3 /dev/sda / || true
|
|
1171 |
rm /bin/installer && reboot -fp
|
|
1172 |
fi
|
|
|
2
by Oliver Grawert
rename binary to rootstock |
1173 |
|
1174 |
EOF
|
|
1175 |
||
|
30.2.1
by Loïc Minier
Add support for running a custom script at the end of the installation with |
1176 |
# copy over user script
|
|
30.2.2
by Loïc Minier
Fix typo and copy user-script to MOUNTPOINT not BUILDDIR |
1177 |
if [ "$USER_SCRIPT" ]; then |
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
1178 |
cp "$USER_SCRIPT" "$ROOTFS/rootstock-user-script" |
|
30.2.1
by Loïc Minier
Add support for running a custom script at the end of the installation with |
1179 |
fi
|
1180 |
||
|
5
by Oliver Grawert
add --serial option to script to create a serial tty during build |
1181 |
if [ "$SERIAL" ];then |
1182 |
setup_serial
|
|
1183 |
fi
|
|
1184 |
||
|
16
by Oliver Grawert
rootstock: add support for swapfile in a tmpfs to be used by the VM, add --swapsize and --noswap arguments |
1185 |
if [ ! "$NOSWAP" ];then |
1186 |
use_swap
|
|
1187 |
fi
|
|
1188 |
||
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
1189 |
mv $BUILDDIR/installer $ROOTFS/bin/ >>$LOG 2>&1 |
1190 |
chmod +x $ROOTFS/bin/installer >>$LOG 2>&1 |
|
|
2
by Oliver Grawert
rename binary to rootstock |
1191 |
|
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
1192 |
# runs the second stage
|
1193 |
if [ "$RUNVM" ];then |
|
1194 |
if [ "$NOROOT" ];then |
|
1195 |
# if user, creates the ext3 fs for qemu, based on the rootfs
|
|
1196 |
create_rootfs_image |
|
1197 |
else
|
|
1198 |
umount_image
|
|
1199 |
fi
|
|
1200 |
run_vm
|
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
1201 |
else
|
|
112
by Ricardo Salveti de Araujo
rootstock: adding native support and changing root path to use user mode emulation instead of a full vm (slower) |
1202 |
run_chroot
|
|
97
by Ricardo Salveti de Araujo
rootstock: adding first version that supports running rootstock as a user |
1203 |
umount_image |
1204 |
fi
|
|
|
2
by Oliver Grawert
rename binary to rootstock |
1205 |
|
|
37
by Oliver Grawert
add --copy-package-cache and --restore-package-cache options to enable caching all remotely downloaded data on one build and re-use the same data in an offline capable mode later |
1206 |
# cache packages on host machine
|
1207 |
if [ "$COPY_PACKAGE_CACHE" ];then |
|
1208 |
save_package_cache
|
|
1209 |
fi
|
|
1210 |
||
|
125
by Ricardo Salveti de Araujo
rootstock: always tries to save vmlinuz and initrd.img |
1211 |
# save vmlinuz and initrd.img for further usage
|
1212 |
extract_kernel_image |
|
1213 |
||
|
2
by Oliver Grawert
rename binary to rootstock |
1214 |
# build a rootfs tarball
|
1215 |
if [ ! "$NOTARBALL" ];then |
|
1216 |
roll_tarball
|
|
1217 |
fi
|
|
1218 |
||
1219 |
# save a qemu image
|
|
1220 |
if [ "$KEEPIMAGE" ];then |
|
1221 |
save_qemu_img
|
|
1222 |
fi
|
|
1223 |
||
|
107
by Ricardo Salveti de Araujo
rootstock: creating a log and error function, to unify the messages |
1224 |
# log, clean up and save a log
|
1225 |
log "I: Rootstock finished successfully"
|
|
|
2
by Oliver Grawert
rename binary to rootstock |
1226 |
cleanup |