annotate package-mini-native.sh @ 330:f9ff71c71f9e

Tweak run-with-home.sh to have a chance of actually working.
author Rob Landley <rob@landley.net>
date Tue, 20 May 2008 03:11:39 -0500
parents 51bcd6de223d
children df3855726ec7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
177
6b4844b708b9 dash->bash.
Rob Landley <rob@landley.net>
parents: 162
diff changeset
1 #!/bin/bash
109
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
2
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 # Create an ext2 root filesystem image
317
90c5fff61c7b Teach package script to recreate mini-native tarball if it changed.
Rob Landley <rob@landley.net>
parents: 314
diff changeset
4 # User User Mode Linux to package this, until toybox mke2fs is ready.
109
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
5
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
6 source include.sh
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
7
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
8 #echo -n "Creating tools.sqf"
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
9 #("${WORK}/mksquashfs" "${NATIVE}/tools" "${WORK}/tools.sqf" \
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
10 # -noappend -all-root -info || dienow) | dotprogress
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
11
306
358ef8a27085 Break up run-$ARCH.sh, move more temp files into temp dir, fix deletion logic.
Rob Landley <rob@landley.net>
parents: 300
diff changeset
12 IMAGE="${WORK}/image-${ARCH}.ext2"
358ef8a27085 Break up run-$ARCH.sh, move more temp files into temp dir, fix deletion logic.
Rob Landley <rob@landley.net>
parents: 300
diff changeset
13
300
86455766b85d Trim image sizes down to 64 megs (and show how much is left on each target).
Rob Landley <rob@landley.net>
parents: 274
diff changeset
14 # A 64 meg sparse image
109
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
15 rm -f "$IMAGE"
300
86455766b85d Trim image sizes down to 64 megs (and show how much is left on each target).
Rob Landley <rob@landley.net>
parents: 274
diff changeset
16 dd if=/dev/zero of="$IMAGE" bs=1024 seek=$[64*1024-1] count=1 &&
109
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
17 /sbin/mke2fs -b 1024 -F "$IMAGE" &&
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
18
317
90c5fff61c7b Teach package script to recreate mini-native tarball if it changed.
Rob Landley <rob@landley.net>
parents: 314
diff changeset
19 # Recreate tarball if changed. We need to use tarball produced outside of
90c5fff61c7b Teach package script to recreate mini-native tarball if it changed.
Rob Landley <rob@landley.net>
parents: 314
diff changeset
20 # UML because hostfs doesn't detect hard links, which wastes space in the
90c5fff61c7b Teach package script to recreate mini-native tarball if it changed.
Rob Landley <rob@landley.net>
parents: 314
diff changeset
21 # resulting filesystem.
90c5fff61c7b Teach package script to recreate mini-native tarball if it changed.
Rob Landley <rob@landley.net>
parents: 314
diff changeset
22
90c5fff61c7b Teach package script to recreate mini-native tarball if it changed.
Rob Landley <rob@landley.net>
parents: 314
diff changeset
23 cd "$BUILD" || dienow
90c5fff61c7b Teach package script to recreate mini-native tarball if it changed.
Rob Landley <rob@landley.net>
parents: 314
diff changeset
24 if [ ! -z "$(find "mini-native-${ARCH}" -newer "mini-native-${ARCH}.tar.bz2")" ]
90c5fff61c7b Teach package script to recreate mini-native tarball if it changed.
Rob Landley <rob@landley.net>
parents: 314
diff changeset
25 then
90c5fff61c7b Teach package script to recreate mini-native tarball if it changed.
Rob Landley <rob@landley.net>
parents: 314
diff changeset
26 echo -n updating mini-native-"${ARCH}".tar.bz2 &&
90c5fff61c7b Teach package script to recreate mini-native tarball if it changed.
Rob Landley <rob@landley.net>
parents: 314
diff changeset
27 { tar cjvf "mini-native-${ARCH}.tar.bz2" "mini-native-${ARCH}" || dienow
90c5fff61c7b Teach package script to recreate mini-native tarball if it changed.
Rob Landley <rob@landley.net>
parents: 314
diff changeset
28 } | dotprogress
90c5fff61c7b Teach package script to recreate mini-native tarball if it changed.
Rob Landley <rob@landley.net>
parents: 314
diff changeset
29 fi
109
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
30
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
31 # Write out a script to control user mode linux
314
a805d37b6c3f Alas, hostfs breaks hard links. Use the mini-native tarball created earlier
Rob Landley <rob@landley.net>
parents: 306
diff changeset
32 TARDEST="mini-native-$ARCH"
109
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
33 cat > "${WORK}/uml-package.sh" << EOF &&
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
34 #!/bin/sh
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
35 mount -n -t ramfs /dev /dev
205
827b76efba8e For some reason, ubuntu is only creating /dev/loop0 right now. I have
Rob Landley <rob@landley.net>
parents: 187
diff changeset
36 mknod /dev/loop0 b 7 1
109
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
37 # Jump to build dir
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
38 echo copying files...
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
39 cd "$BUILD"
205
827b76efba8e For some reason, ubuntu is only creating /dev/loop0 right now. I have
Rob Landley <rob@landley.net>
parents: 187
diff changeset
40 /sbin/losetup /dev/loop0 "$IMAGE"
314
a805d37b6c3f Alas, hostfs breaks hard links. Use the mini-native tarball created earlier
Rob Landley <rob@landley.net>
parents: 306
diff changeset
41 mount -n -t ext2 /dev/loop0 "$TARDEST"
a805d37b6c3f Alas, hostfs breaks hard links. Use the mini-native tarball created earlier
Rob Landley <rob@landley.net>
parents: 306
diff changeset
42 tar xf "$BUILD/mini-native-${ARCH}.tar.bz2"
a805d37b6c3f Alas, hostfs breaks hard links. Use the mini-native tarball created earlier
Rob Landley <rob@landley.net>
parents: 306
diff changeset
43 mkdir "$TARDEST"/dev
a805d37b6c3f Alas, hostfs breaks hard links. Use the mini-native tarball created earlier
Rob Landley <rob@landley.net>
parents: 306
diff changeset
44 mknod "$TARDEST"/dev/console c 5 1
a805d37b6c3f Alas, hostfs breaks hard links. Use the mini-native tarball created earlier
Rob Landley <rob@landley.net>
parents: 306
diff changeset
45 df "$TARDEST"
a805d37b6c3f Alas, hostfs breaks hard links. Use the mini-native tarball created earlier
Rob Landley <rob@landley.net>
parents: 306
diff changeset
46 umount "$TARDEST"
205
827b76efba8e For some reason, ubuntu is only creating /dev/loop0 right now. I have
Rob Landley <rob@landley.net>
parents: 187
diff changeset
47 /sbin/losetup -d /dev/loop0
109
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
48 umount /dev
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
49 sync
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
50 EOF
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
51 chmod +x ${WORK}/uml-package.sh &&
325
51bcd6de223d Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents: 317
diff changeset
52 linux rootfstype=hostfs rw quiet ARCH=${ARCH} PATH=/bin:/usr/bin:/sbin:/usr/sbin init="${HOSTTOOLS}/oneit -p ${WORK}/uml-package.sh" || dienow
109
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
53
330
f9ff71c71f9e Tweak run-with-home.sh to have a chance of actually working.
Rob Landley <rob@landley.net>
parents: 325
diff changeset
54 # Provide qemu's common command line options between architectures. The lack
f9ff71c71f9e Tweak run-with-home.sh to have a chance of actually working.
Rob Landley <rob@landley.net>
parents: 325
diff changeset
55 # of ending quotes on -append is intentional, callers append more kernel
f9ff71c71f9e Tweak run-with-home.sh to have a chance of actually working.
Rob Landley <rob@landley.net>
parents: 325
diff changeset
56 # command line arguments and provide their own ending quote.
325
51bcd6de223d Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents: 317
diff changeset
57 function qemu_defaults()
51bcd6de223d Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents: 317
diff changeset
58 {
330
f9ff71c71f9e Tweak run-with-home.sh to have a chance of actually working.
Rob Landley <rob@landley.net>
parents: 325
diff changeset
59 echo "-nographic -no-reboot \$WITH_HDB" \
f9ff71c71f9e Tweak run-with-home.sh to have a chance of actually working.
Rob Landley <rob@landley.net>
parents: 325
diff changeset
60 "-hda \"$1\" -kernel \"$2\" -append \"$3"
325
51bcd6de223d Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents: 317
diff changeset
61 }
51bcd6de223d Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents: 317
diff changeset
62
51bcd6de223d Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents: 317
diff changeset
63 # Call the appropriate emulator. We split out the filesystem, kernel, and
51bcd6de223d Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents: 317
diff changeset
64 # base kernel command line arguments in case you want to use an emulator
51bcd6de223d Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents: 317
diff changeset
65 # other than qemu, but put the default case in QEMU_BASE.
306
358ef8a27085 Break up run-$ARCH.sh, move more temp files into temp dir, fix deletion logic.
Rob Landley <rob@landley.net>
parents: 300
diff changeset
66
358ef8a27085 Break up run-$ARCH.sh, move more temp files into temp dir, fix deletion logic.
Rob Landley <rob@landley.net>
parents: 300
diff changeset
67 emulator_command image-$ARCH.ext2 zImage-$ARCH \
358ef8a27085 Break up run-$ARCH.sh, move more temp files into temp dir, fix deletion logic.
Rob Landley <rob@landley.net>
parents: 300
diff changeset
68 'rw init=/tools/bin/qemu-setup.sh panic=1 PATH=$DISTCC_PATH_PREFIX/tools/bin $DISTCC_VARS' \
358ef8a27085 Break up run-$ARCH.sh, move more temp files into temp dir, fix deletion logic.
Rob Landley <rob@landley.net>
parents: 300
diff changeset
69 > "$WORK/run-emulator.sh" &&
358ef8a27085 Break up run-$ARCH.sh, move more temp files into temp dir, fix deletion logic.
Rob Landley <rob@landley.net>
parents: 300
diff changeset
70
358ef8a27085 Break up run-$ARCH.sh, move more temp files into temp dir, fix deletion logic.
Rob Landley <rob@landley.net>
parents: 300
diff changeset
71 chmod +x "$WORK/run-emulator.sh"
358ef8a27085 Break up run-$ARCH.sh, move more temp files into temp dir, fix deletion logic.
Rob Landley <rob@landley.net>
parents: 300
diff changeset
72
358ef8a27085 Break up run-$ARCH.sh, move more temp files into temp dir, fix deletion logic.
Rob Landley <rob@landley.net>
parents: 300
diff changeset
73 # Create qemu-image-$ARCH.tar.bz2
358ef8a27085 Break up run-$ARCH.sh, move more temp files into temp dir, fix deletion logic.
Rob Landley <rob@landley.net>
parents: 300
diff changeset
74
267
98c1a2136322 Update package-mini-native.sh to create qemu-image-$ARCH.tar.bz2
Rob Landley <rob@landley.net>
parents: 264
diff changeset
75 function shipit()
98c1a2136322 Update package-mini-native.sh to create qemu-image-$ARCH.tar.bz2
Rob Landley <rob@landley.net>
parents: 264
diff changeset
76 {
325
51bcd6de223d Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents: 317
diff changeset
77 cd "$WORK" || dienow
51bcd6de223d Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents: 317
diff changeset
78 rm -rf qemu-image-$ARCH
267
98c1a2136322 Update package-mini-native.sh to create qemu-image-$ARCH.tar.bz2
Rob Landley <rob@landley.net>
parents: 264
diff changeset
79 mkdir qemu-image-$ARCH &&
306
358ef8a27085 Break up run-$ARCH.sh, move more temp files into temp dir, fix deletion logic.
Rob Landley <rob@landley.net>
parents: 300
diff changeset
80 ln {image-$ARCH.ext2,zImage-$ARCH,run-*.sh} \
358ef8a27085 Break up run-$ARCH.sh, move more temp files into temp dir, fix deletion logic.
Rob Landley <rob@landley.net>
parents: 300
diff changeset
81 "$SOURCES"/toys/run-with-{distcc,home}.sh \
325
51bcd6de223d Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents: 317
diff changeset
82 qemu-image-$ARCH
109
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
83
267
98c1a2136322 Update package-mini-native.sh to create qemu-image-$ARCH.tar.bz2
Rob Landley <rob@landley.net>
parents: 264
diff changeset
84 [ $? -ne 0 ] && dienow
98c1a2136322 Update package-mini-native.sh to create qemu-image-$ARCH.tar.bz2
Rob Landley <rob@landley.net>
parents: 264
diff changeset
85
274
3ca6f52688ac Fix typo when packaging powerpc image.
Rob Landley <rob@landley.net>
parents: 267
diff changeset
86 [ "$ARCH" == powerpc ] && ln "$SOURCES"/toys/ppc_rom.bin qemu-image-$ARCH
267
98c1a2136322 Update package-mini-native.sh to create qemu-image-$ARCH.tar.bz2
Rob Landley <rob@landley.net>
parents: 264
diff changeset
87 tar cvjf "$BUILD"/qemu-image-$ARCH.tar.bz2 qemu-image-$ARCH &&
98c1a2136322 Update package-mini-native.sh to create qemu-image-$ARCH.tar.bz2
Rob Landley <rob@landley.net>
parents: 264
diff changeset
88 rm -rf qemu-image-$ARCH
98c1a2136322 Update package-mini-native.sh to create qemu-image-$ARCH.tar.bz2
Rob Landley <rob@landley.net>
parents: 264
diff changeset
89 }
98c1a2136322 Update package-mini-native.sh to create qemu-image-$ARCH.tar.bz2
Rob Landley <rob@landley.net>
parents: 264
diff changeset
90
98c1a2136322 Update package-mini-native.sh to create qemu-image-$ARCH.tar.bz2
Rob Landley <rob@landley.net>
parents: 264
diff changeset
91 shipit