Mercurial > hg > aboriginal
annotate package-mini-native.sh @ 328:6a0788146ccb
Because sysfs doesn't have a stable API, the old mdev doesn't work with 2.6.25.
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 12 May 2008 00:55:23 -0500 |
parents | 51bcd6de223d |
children | f9ff71c71f9e |
rev | line source |
---|---|
177 | 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 |
325
51bcd6de223d
Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents:
317
diff
changeset
|
54 function qemu_defaults() |
51bcd6de223d
Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents:
317
diff
changeset
|
55 { |
51bcd6de223d
Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents:
317
diff
changeset
|
56 echo "-nographic -no-reboot -hda \"$1\" -kernel \"$2\" -append \"$3" |
51bcd6de223d
Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents:
317
diff
changeset
|
57 } |
51bcd6de223d
Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents:
317
diff
changeset
|
58 |
51bcd6de223d
Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents:
317
diff
changeset
|
59 # 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
|
60 # 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
|
61 # 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
|
62 |
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
|
63 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
|
64 '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
|
65 > "$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
|
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 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
|
68 |
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 # 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
|
70 |
267
98c1a2136322
Update package-mini-native.sh to create qemu-image-$ARCH.tar.bz2
Rob Landley <rob@landley.net>
parents:
264
diff
changeset
|
71 function shipit() |
98c1a2136322
Update package-mini-native.sh to create qemu-image-$ARCH.tar.bz2
Rob Landley <rob@landley.net>
parents:
264
diff
changeset
|
72 { |
325
51bcd6de223d
Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents:
317
diff
changeset
|
73 cd "$WORK" || dienow |
51bcd6de223d
Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents:
317
diff
changeset
|
74 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
|
75 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
|
76 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
|
77 "$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
|
78 qemu-image-$ARCH |
109
d9dae1196ea7
Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
79 |
267
98c1a2136322
Update package-mini-native.sh to create qemu-image-$ARCH.tar.bz2
Rob Landley <rob@landley.net>
parents:
264
diff
changeset
|
80 [ $? -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
|
81 |
274
3ca6f52688ac
Fix typo when packaging powerpc image.
Rob Landley <rob@landley.net>
parents:
267
diff
changeset
|
82 [ "$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
|
83 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
|
84 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
|
85 } |
98c1a2136322
Update package-mini-native.sh to create qemu-image-$ARCH.tar.bz2
Rob Landley <rob@landley.net>
parents:
264
diff
changeset
|
86 |
98c1a2136322
Update package-mini-native.sh to create qemu-image-$ARCH.tar.bz2
Rob Landley <rob@landley.net>
parents:
264
diff
changeset
|
87 shipit |