Mercurial > hg > aboriginal
annotate more/chroot-splice.sh @ 1529:90da269bc09c
Minor cleanup and remove hardlinking for chroot-splice: it's slower and uses more disk space but doesn't damage external copy if something goes wrong.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 10 Jun 2012 20:34:04 -0500 |
parents | bb26de4dfe47 |
children | 866adfa9c63c |
rev | line source |
---|---|
1284
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
1 #!/bin/bash |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
2 |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
3 # Combine a root filesystem directory and a control image into an $ARCH-specific |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
4 # chroot containing native build control files, suitable for chrooting into. |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
5 |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
6 if [ $# -ne 2 ] |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
7 then |
1448
bb26de4dfe47
Make chroot-splice.sh more useful for testing new control images in a chroot instead of qemu.
Rob Landley <rob@landley.net>
parents:
1417
diff
changeset
|
8 echo "usage: $0 "'$ARCH $CONTROL_IMAGE' >&2 |
1284
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
9 exit 1 |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
10 fi |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
11 |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
12 # Make sure prerequisites exist |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
13 |
1417
aabc07905de3
Now that the control-images have their own repository, remove them from this one.
Rob Landley <rob@landley.net>
parents:
1284
diff
changeset
|
14 for i in "build/root-filesystem-$1" "$2" |
1284
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
15 do |
1448
bb26de4dfe47
Make chroot-splice.sh more useful for testing new control images in a chroot instead of qemu.
Rob Landley <rob@landley.net>
parents:
1417
diff
changeset
|
16 if [ ! -e "$i" ] |
1284
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
17 then |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
18 echo "No $i" >&2 |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
19 exit 1 |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
20 fi |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
21 done |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
22 |
1448
bb26de4dfe47
Make chroot-splice.sh more useful for testing new control images in a chroot instead of qemu.
Rob Landley <rob@landley.net>
parents:
1417
diff
changeset
|
23 if [ `id -u` -ne 0 ] |
bb26de4dfe47
Make chroot-splice.sh more useful for testing new control images in a chroot instead of qemu.
Rob Landley <rob@landley.net>
parents:
1417
diff
changeset
|
24 then |
bb26de4dfe47
Make chroot-splice.sh more useful for testing new control images in a chroot instead of qemu.
Rob Landley <rob@landley.net>
parents:
1417
diff
changeset
|
25 echo "Not root">&2 |
bb26de4dfe47
Make chroot-splice.sh more useful for testing new control images in a chroot instead of qemu.
Rob Landley <rob@landley.net>
parents:
1417
diff
changeset
|
26 exit 1 |
bb26de4dfe47
Make chroot-splice.sh more useful for testing new control images in a chroot instead of qemu.
Rob Landley <rob@landley.net>
parents:
1417
diff
changeset
|
27 fi |
bb26de4dfe47
Make chroot-splice.sh more useful for testing new control images in a chroot instead of qemu.
Rob Landley <rob@landley.net>
parents:
1417
diff
changeset
|
28 |
1284
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
29 # Zap old stuff (if any) |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
30 |
1529
90da269bc09c
Minor cleanup and remove hardlinking for chroot-splice: it's slower and uses more disk space but doesn't damage external copy if something goes wrong.
Rob Landley <rob@landley.net>
parents:
1448
diff
changeset
|
31 [ -z "$CHROOT" ] && CHROOT="build/chroot-$1" |
1448
bb26de4dfe47
Make chroot-splice.sh more useful for testing new control images in a chroot instead of qemu.
Rob Landley <rob@landley.net>
parents:
1417
diff
changeset
|
32 trap 'more/zapchroot.sh "$CHROOT"' EXIT |
bb26de4dfe47
Make chroot-splice.sh more useful for testing new control images in a chroot instead of qemu.
Rob Landley <rob@landley.net>
parents:
1417
diff
changeset
|
33 if [ -e "$CHROOT" ] |
1284
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
34 then |
1448
bb26de4dfe47
Make chroot-splice.sh more useful for testing new control images in a chroot instead of qemu.
Rob Landley <rob@landley.net>
parents:
1417
diff
changeset
|
35 more/zapchroot.sh "$CHROOT" || exit 1 |
1284
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
36 fi |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
37 |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
38 # Copy root filesystem and splice in control image |
1529
90da269bc09c
Minor cleanup and remove hardlinking for chroot-splice: it's slower and uses more disk space but doesn't damage external copy if something goes wrong.
Rob Landley <rob@landley.net>
parents:
1448
diff
changeset
|
39 cp -a "build/root-filesystem-$1" "$CHROOT" || exit 1 |
1448
bb26de4dfe47
Make chroot-splice.sh more useful for testing new control images in a chroot instead of qemu.
Rob Landley <rob@landley.net>
parents:
1417
diff
changeset
|
40 |
bb26de4dfe47
Make chroot-splice.sh more useful for testing new control images in a chroot instead of qemu.
Rob Landley <rob@landley.net>
parents:
1417
diff
changeset
|
41 if [ -d "$2" ] |
bb26de4dfe47
Make chroot-splice.sh more useful for testing new control images in a chroot instead of qemu.
Rob Landley <rob@landley.net>
parents:
1417
diff
changeset
|
42 then |
1529
90da269bc09c
Minor cleanup and remove hardlinking for chroot-splice: it's slower and uses more disk space but doesn't damage external copy if something goes wrong.
Rob Landley <rob@landley.net>
parents:
1448
diff
changeset
|
43 rm -rf "$CHROOT/mnt" && cp -a "$2" "$CHROOT/mnt" || exit 1 |
1448
bb26de4dfe47
Make chroot-splice.sh more useful for testing new control images in a chroot instead of qemu.
Rob Landley <rob@landley.net>
parents:
1417
diff
changeset
|
44 else |
bb26de4dfe47
Make chroot-splice.sh more useful for testing new control images in a chroot instead of qemu.
Rob Landley <rob@landley.net>
parents:
1417
diff
changeset
|
45 mount -o loop "$2" "$CHROOT/mnt" || exit 1 |
bb26de4dfe47
Make chroot-splice.sh more useful for testing new control images in a chroot instead of qemu.
Rob Landley <rob@landley.net>
parents:
1417
diff
changeset
|
46 fi |
1284
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
47 |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
48 # Output some usage hints |
095c9652525e
Second try at a chroot-splice script, combining a root-filesystem and a control image into a chroot directory. (Useful for working out new control images.)
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
49 |
1448
bb26de4dfe47
Make chroot-splice.sh more useful for testing new control images in a chroot instead of qemu.
Rob Landley <rob@landley.net>
parents:
1417
diff
changeset
|
50 CPUS=1 HOST="$1" chroot "$CHROOT" /sbin/init.sh |