2 # Create guest root image
4 # Copyright (C) 2004 Eric Marchionni, Patrik Rayo
5 # Zuercher Hochschule Winterthur
7 # This program is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the
9 # Free Software Foundation; either version 2 of the License, or (at your
10 # option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 echo "Building root image"
19 . $PWD/scripts/function.sh
21 [ `id -u` -eq 0 ] || die "You must be root to run $0"
22 [ -f "$BASEIMG" ] || die "Base image $BASEIMG not found"
24 check_commands partprobe qemu-img qemu-nbd
29 mkdir -p $ROOTIMGCOMPILEDIR
31 log_action "Creating root image $ROOTIMG"
32 execute "qemu-img create -b $BASEIMG -f $IMGEXT $ROOTIMG"
34 log_action "Connecting root image to NBD device $NBDEV"
35 execute "qemu-nbd -c $NBDEV $ROOTIMG"
36 do_on_exit qemu-nbd -d $NBDEV
39 log_action "Mounting $NBDPARTITION to $LOOPDIR"
40 execute "mount $NBDPARTITION $LOOPDIR"
41 do_on_exit umount $LOOPDIR
43 log_action "Mounting proc filesystem to $LOOPDIR/proc"
44 execute "mount -t proc none $LOOPDIR/proc"
45 do_on_exit umount $LOOPDIR/proc
47 mkdir -p $LOOPDIR/root/compile
48 log_action "Mounting $ROOTIMGCOMPILEDIR as /root/compile"
49 execute "mount -o bind $ROOTIMGCOMPILEDIR $LOOPDIR/root/compile"
50 do_on_exit umount $LOOPDIR/root/compile
52 echo "Installing software from source"
53 RECPDIR=$TESTDIR/testing/scripts/recipes
54 RECIPES=`ls $RECPDIR/*.mk | xargs -n1 basename`
55 execute "cp -r $RECPDIR/patches $LOOPDIR/root/compile" 0
58 cp $RECPDIR/$r ${LOOPDIR}/root/compile
59 log_action "Installing from recipe $r"
60 execute_chroot "make SWANVERSION=$SWANVERSION -C /root/compile -f $r"
63 log_action "Removing /etc/resolv.conf"
64 execute "rm -f $LOOPDIR/etc/resolv.conf"