]>
Commit | Line | Data |
---|---|---|
997358a6 | 1 | #!/bin/bash |
8ed98c13 | 2 | # Create guest root image |
997358a6 MW |
3 | # |
4 | # Copyright (C) 2004 Eric Marchionni, Patrik Rayo | |
5 | # Zuercher Hochschule Winterthur | |
6 | # | |
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>. | |
11 | # | |
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 | |
15 | # for more details. | |
997358a6 | 16 | |
bf3ff0e5 | 17 | echo "Building root image" |
997358a6 | 18 | |
aafc0a17 RB |
19 | DIR=$(dirname `readlink -f $0`) |
20 | . $DIR/../testing.conf | |
21 | . $DIR/function.sh | |
997358a6 | 22 | |
bf3ff0e5 | 23 | [ `id -u` -eq 0 ] || die "You must be root to run $0" |
258cbd40 | 24 | [ -f "$BASEIMG" ] || die "Base image $BASEIMG not found" |
83efded3 | 25 | running_any $STRONGSWANHOSTS && die "Please stop test environment before running $0" |
997358a6 | 26 | |
cbe031d7 | 27 | check_commands partprobe qemu-img qemu-nbd |
b24d3ed5 | 28 | |
8ed98c13 RB |
29 | load_qemu_nbd |
30 | ||
bf3ff0e5 | 31 | mkdir -p $LOOPDIR |
2c4954ad | 32 | mkdir -p $SHAREDDIR/compile |
48ea1d8b | 33 | mkdir -p $IMGDIR |
997358a6 | 34 | |
258cbd40 | 35 | log_action "Creating root image $ROOTIMG" |
cbe031d7 | 36 | execute "qemu-img create -b $BASEIMG -f $IMGEXT $ROOTIMG" |
bf3ff0e5 | 37 | |
258cbd40 RB |
38 | log_action "Connecting root image to NBD device $NBDEV" |
39 | execute "qemu-nbd -c $NBDEV $ROOTIMG" | |
74c0839a | 40 | do_on_exit qemu-nbd -d $NBDEV |
97265aba | 41 | partprobe $NBDEV |
8ed98c13 RB |
42 | |
43 | log_action "Mounting $NBDPARTITION to $LOOPDIR" | |
44 | execute "mount $NBDPARTITION $LOOPDIR" | |
74c0839a | 45 | do_on_exit umount $LOOPDIR |
8ed98c13 | 46 | |
bf3ff0e5 RB |
47 | log_action "Mounting proc filesystem to $LOOPDIR/proc" |
48 | execute "mount -t proc none $LOOPDIR/proc" | |
74c0839a | 49 | do_on_exit umount $LOOPDIR/proc |
997358a6 | 50 | |
2c4954ad RB |
51 | mkdir -p $LOOPDIR/root/shared |
52 | log_action "Mounting $SHAREDDIR as /root/shared" | |
53 | execute "mount -o bind $SHAREDDIR $LOOPDIR/root/shared" | |
54 | do_on_exit umount $LOOPDIR/root/shared | |
0cc40637 | 55 | |
bf3ff0e5 | 56 | echo "Installing software from source" |
aafc0a17 | 57 | RECPDIR=$DIR/recipes |
99f6457e TB |
58 | if [ -d "$RECPDIR/patches" ] |
59 | then | |
60 | execute "cp -r $RECPDIR/patches $LOOPDIR/root/shared/compile" 0 | |
61 | fi | |
e61ce6ee RB |
62 | RECIPES=`ls $RECPDIR/*.mk | xargs -n1 basename` |
63 | for r in $RECIPES | |
64 | do | |
2c4954ad | 65 | cp $RECPDIR/$r ${LOOPDIR}/root/shared/compile |
bf3ff0e5 | 66 | log_action "Installing from recipe $r" |
2c4954ad | 67 | execute_chroot "make SWANVERSION=$SWANVERSION -C /root/shared/compile -f $r" |
e61ce6ee | 68 | done |
997358a6 | 69 | |
bf3ff0e5 RB |
70 | log_action "Removing /etc/resolv.conf" |
71 | execute "rm -f $LOOPDIR/etc/resolv.conf" |