Mercurial > hg > aboriginal
annotate system-image.sh @ 1753:3ffb288cc713 draft
I really, really, really need to finish switching to musl.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 12 Apr 2015 02:24:26 -0500 |
parents | 10b64f52ad20 |
children | 74d6173e3390 |
rev | line source |
---|---|
177 | 1 #!/bin/bash |
109
d9dae1196ea7
Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
2 |
1350
7eabfa815c90
Split up system-image.sh into root-image.sh, linux-kernel.sh, and system-image.sh. Rename CROSS_HOST_ARCH to CROSS_COMPILER_HOST.
Rob Landley <rob@landley.net>
parents:
1307
diff
changeset
|
3 # Combine a filesystem image and kernel with emulator launch scripts. |
109
d9dae1196ea7
Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
4 |
1728
b89324905ca2
Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents:
1538
diff
changeset
|
5 # Package a root filesystem directory into a filesystem image file |
b89324905ca2
Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents:
1538
diff
changeset
|
6 |
669 | 7 source sources/include.sh || exit 1 |
109
d9dae1196ea7
Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
8 |
1398
b74d36876c0a
Replace read_arch_dir with load_target, which understands that sources/targets/$TARGET can be a file or a directory.
Rob Landley <rob@landley.net>
parents:
1358
diff
changeset
|
9 # Parse sources/targets/$1 |
744
759adf5a0fe9
Refactor so include.sh mostly just sets environment variables. Move read_arch_dir to function and call it explicitly (no more need for $NO_ARCH). Make blank_tempdir a function, called explicitly by stages when needed, with some sanity checks. Insert prerequisite tests to later stages so they can detect failure early and provide an explicit erro rmessage, and have those tests happen before blanking $WORK dir, to preserve debugging info. Make buildall.sh depend on prerequisite tests rather than trying to avoid calling later stages (and thus do flow control from asynchronous context). Add FAIL_QUIET option so buildall.sh doesn't spam the log with the new prerequisite error messages.
Rob Landley <rob@landley.net>
parents:
728
diff
changeset
|
10 |
1398
b74d36876c0a
Replace read_arch_dir with load_target, which understands that sources/targets/$TARGET can be a file or a directory.
Rob Landley <rob@landley.net>
parents:
1358
diff
changeset
|
11 load_target "$1" |
744
759adf5a0fe9
Refactor so include.sh mostly just sets environment variables. Move read_arch_dir to function and call it explicitly (no more need for $NO_ARCH). Make blank_tempdir a function, called explicitly by stages when needed, with some sanity checks. Insert prerequisite tests to later stages so they can detect failure early and provide an explicit erro rmessage, and have those tests happen before blanking $WORK dir, to preserve debugging info. Make buildall.sh depend on prerequisite tests rather than trying to avoid calling later stages (and thus do flow control from asynchronous context). Add FAIL_QUIET option so buildall.sh doesn't spam the log with the new prerequisite error messages.
Rob Landley <rob@landley.net>
parents:
728
diff
changeset
|
12 |
893
9ae3c9520bec
Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents:
888
diff
changeset
|
13 # Provide qemu's common command line options between architectures. |
9ae3c9520bec
Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents:
888
diff
changeset
|
14 |
1081
e992bc65b048
Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
15 qemu_defaults() |
325
51bcd6de223d
Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents:
317
diff
changeset
|
16 { |
1728
b89324905ca2
Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents:
1538
diff
changeset
|
17 echo -n "-nographic -no-reboot -kernel linux" |
b89324905ca2
Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents:
1538
diff
changeset
|
18 [ "$SYSIMAGE_TYPE" != "rootfs" ] && echo -n " -initrd rootfs.cpio.gz" |
1735 | 19 echo -n " -append \"panic=1 console=$CONSOLE HOST=$ARCH \$KERNEL_EXTRA\"" |
1728
b89324905ca2
Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents:
1538
diff
changeset
|
20 echo -n " \$QEMU_EXTRA" |
325
51bcd6de223d
Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents:
317
diff
changeset
|
21 } |
51bcd6de223d
Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents:
317
diff
changeset
|
22 |
490
004f9509349b
Rip out User Mode Linux, switch to genext2fs instead. (Based on an old patch from James Davidson.)
Rob Landley <rob@landley.net>
parents:
486
diff
changeset
|
23 # Write out a script to call the appropriate emulator. We split out the |
004f9509349b
Rip out User Mode Linux, switch to genext2fs instead. (Based on an old patch from James Davidson.)
Rob Landley <rob@landley.net>
parents:
486
diff
changeset
|
24 # filesystem, kernel, and base kernel command line arguments in case you want |
004f9509349b
Rip out User Mode Linux, switch to genext2fs instead. (Based on an old patch from James Davidson.)
Rob Landley <rob@landley.net>
parents:
486
diff
changeset
|
25 # to use an emulator other than qemu, but put the default case in qemu_defaults |
004f9509349b
Rip out User Mode Linux, switch to genext2fs instead. (Based on an old patch from James Davidson.)
Rob Landley <rob@landley.net>
parents:
486
diff
changeset
|
26 |
1005
ed8e33b81032
Make run-emulator.sh executable.
Rob Landley <rob@landley.net>
parents:
1000
diff
changeset
|
27 cat > "$STAGE_DIR/run-emulator.sh" << EOF && |
1538
29109240fd6d
Comment tweaks, and make run-emulator.sh use bash.
Rob Landley <rob@landley.net>
parents:
1437
diff
changeset
|
28 #!/bin/bash |
29109240fd6d
Comment tweaks, and make run-emulator.sh use bash.
Rob Landley <rob@landley.net>
parents:
1437
diff
changeset
|
29 |
29109240fd6d
Comment tweaks, and make run-emulator.sh use bash.
Rob Landley <rob@landley.net>
parents:
1437
diff
changeset
|
30 # Boot the emulated system to a shell prompt. |
29109240fd6d
Comment tweaks, and make run-emulator.sh use bash.
Rob Landley <rob@landley.net>
parents:
1437
diff
changeset
|
31 |
1000
6a6a9e8de6ef
Finish previous commit: fix HDB and HDC and make run_emulator() a function. (And finally, if you say DEBUG=1 you get the emulator command output! Yay!)
Rob Landley <rob@landley.net>
parents:
999
diff
changeset
|
32 ARCH=$ARCH |
6a6a9e8de6ef
Finish previous commit: fix HDB and HDC and make run_emulator() a function. (And finally, if you say DEBUG=1 you get the emulator command output! Yay!)
Rob Landley <rob@landley.net>
parents:
999
diff
changeset
|
33 run_emulator() |
6a6a9e8de6ef
Finish previous commit: fix HDB and HDC and make run_emulator() a function. (And finally, if you say DEBUG=1 you get the emulator command output! Yay!)
Rob Landley <rob@landley.net>
parents:
999
diff
changeset
|
34 { |
6a6a9e8de6ef
Finish previous commit: fix HDB and HDC and make run_emulator() a function. (And finally, if you say DEBUG=1 you get the emulator command output! Yay!)
Rob Landley <rob@landley.net>
parents:
999
diff
changeset
|
35 [ ! -z "\$DEBUG" ] && set -x |
1350
7eabfa815c90
Split up system-image.sh into root-image.sh, linux-kernel.sh, and system-image.sh. Rename CROSS_HOST_ARCH to CROSS_COMPILER_HOST.
Rob Landley <rob@landley.net>
parents:
1307
diff
changeset
|
36 $(emulator_command) |
1000
6a6a9e8de6ef
Finish previous commit: fix HDB and HDC and make run_emulator() a function. (And finally, if you say DEBUG=1 you get the emulator command output! Yay!)
Rob Landley <rob@landley.net>
parents:
999
diff
changeset
|
37 } |
6a6a9e8de6ef
Finish previous commit: fix HDB and HDC and make run_emulator() a function. (And finally, if you say DEBUG=1 you get the emulator command output! Yay!)
Rob Landley <rob@landley.net>
parents:
999
diff
changeset
|
38 |
6a6a9e8de6ef
Finish previous commit: fix HDB and HDC and make run_emulator() a function. (And finally, if you say DEBUG=1 you get the emulator command output! Yay!)
Rob Landley <rob@landley.net>
parents:
999
diff
changeset
|
39 if [ "\$1" != "--norun" ] |
6a6a9e8de6ef
Finish previous commit: fix HDB and HDC and make run_emulator() a function. (And finally, if you say DEBUG=1 you get the emulator command output! Yay!)
Rob Landley <rob@landley.net>
parents:
999
diff
changeset
|
40 then |
6a6a9e8de6ef
Finish previous commit: fix HDB and HDC and make run_emulator() a function. (And finally, if you say DEBUG=1 you get the emulator command output! Yay!)
Rob Landley <rob@landley.net>
parents:
999
diff
changeset
|
41 run_emulator |
6a6a9e8de6ef
Finish previous commit: fix HDB and HDC and make run_emulator() a function. (And finally, if you say DEBUG=1 you get the emulator command output! Yay!)
Rob Landley <rob@landley.net>
parents:
999
diff
changeset
|
42 fi |
6a6a9e8de6ef
Finish previous commit: fix HDB and HDC and make run_emulator() a function. (And finally, if you say DEBUG=1 you get the emulator command output! Yay!)
Rob Landley <rob@landley.net>
parents:
999
diff
changeset
|
43 EOF |
1005
ed8e33b81032
Make run-emulator.sh executable.
Rob Landley <rob@landley.net>
parents:
1000
diff
changeset
|
44 chmod +x "$STAGE_DIR/run-emulator.sh" && |
864
5660a438421b
Make system-image.sh write out dev-environment.sh from a here document.
Rob Landley <rob@landley.net>
parents:
863
diff
changeset
|
45 |
1072
94b0b4ef1157
Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents:
1071
diff
changeset
|
46 # Write out development wrapper scripts, substituting INCLUDE lines. |
94b0b4ef1157
Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents:
1071
diff
changeset
|
47 |
1728
b89324905ca2
Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents:
1538
diff
changeset
|
48 for FILE in dev-environment.sh native-build.sh |
1072
94b0b4ef1157
Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents:
1071
diff
changeset
|
49 do |
94b0b4ef1157
Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents:
1071
diff
changeset
|
50 (export IFS="$(echo -e "\n")" |
94b0b4ef1157
Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents:
1071
diff
changeset
|
51 cat "$SOURCES/toys/$FILE" | while read -r i |
94b0b4ef1157
Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents:
1071
diff
changeset
|
52 do |
94b0b4ef1157
Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents:
1071
diff
changeset
|
53 if [ "${i:0:8}" == "INCLUDE " ] |
94b0b4ef1157
Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents:
1071
diff
changeset
|
54 then |
94b0b4ef1157
Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents:
1071
diff
changeset
|
55 cat "$SOURCES/toys/${i:8}" || dienow |
94b0b4ef1157
Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents:
1071
diff
changeset
|
56 else |
94b0b4ef1157
Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents:
1071
diff
changeset
|
57 # because echo doesn't support --, that's why. |
94b0b4ef1157
Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents:
1071
diff
changeset
|
58 echo "$i" || dienow |
94b0b4ef1157
Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents:
1071
diff
changeset
|
59 fi |
94b0b4ef1157
Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents:
1071
diff
changeset
|
60 done |
94b0b4ef1157
Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents:
1071
diff
changeset
|
61 ) > "$STAGE_DIR/$FILE" |
94b0b4ef1157
Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents:
1071
diff
changeset
|
62 |
94b0b4ef1157
Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents:
1071
diff
changeset
|
63 chmod +x "$STAGE_DIR/$FILE" || dienow |
94b0b4ef1157
Add native-build.sh to system-image (it takes only one argument now, the build control system image file). Make system-image.sh script processing understand an INCLUDE syntax to insert unique-port, and trim the unique-port comment to something less distracting.
Rob Landley <rob@landley.net>
parents:
1071
diff
changeset
|
64 done |
490
004f9509349b
Rip out User Mode Linux, switch to genext2fs instead. (Based on an old patch from James Davidson.)
Rob Landley <rob@landley.net>
parents:
486
diff
changeset
|
65 |
1730
7f1b9fb1099e
Move simple-root-filesystem.sh to root-filesystem.sh
Rob Landley <rob@landley.net>
parents:
1728
diff
changeset
|
66 # Package root-filesystem into cpio file for initramfs |
1728
b89324905ca2
Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents:
1538
diff
changeset
|
67 |
1730
7f1b9fb1099e
Move simple-root-filesystem.sh to root-filesystem.sh
Rob Landley <rob@landley.net>
parents:
1728
diff
changeset
|
68 SYSIMAGE_TYPE=cpio image_filesystem "$BUILD/root-filesystem-$ARCH" \ |
1728
b89324905ca2
Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents:
1538
diff
changeset
|
69 "$STAGE_DIR/rootfs" && |
b89324905ca2
Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents:
1538
diff
changeset
|
70 SYSIMAGE_TYPE=squashfs image_filesystem "$BUILD/native-compiler-$ARCH" \ |
b89324905ca2
Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents:
1538
diff
changeset
|
71 "$STAGE_DIR/toolchain" || dienow |
b89324905ca2
Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents:
1538
diff
changeset
|
72 |
b89324905ca2
Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents:
1538
diff
changeset
|
73 # Build linux kernel for the target |
b89324905ca2
Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents:
1538
diff
changeset
|
74 |
1743
10b64f52ad20
Make tweak.sh actually work, and do less unnecessary rebuilding.
Rob Landley <rob@landley.net>
parents:
1735
diff
changeset
|
75 if [ -z "$NO_CLEANUP" ] || [ ! -e "$STAGE_DIR/linux" ] |
10b64f52ad20
Make tweak.sh actually work, and do less unnecessary rebuilding.
Rob Landley <rob@landley.net>
parents:
1735
diff
changeset
|
76 then |
10b64f52ad20
Make tweak.sh actually work, and do less unnecessary rebuilding.
Rob Landley <rob@landley.net>
parents:
1735
diff
changeset
|
77 setupfor linux |
10b64f52ad20
Make tweak.sh actually work, and do less unnecessary rebuilding.
Rob Landley <rob@landley.net>
parents:
1735
diff
changeset
|
78 getconfig linux > mini.conf |
10b64f52ad20
Make tweak.sh actually work, and do less unnecessary rebuilding.
Rob Landley <rob@landley.net>
parents:
1735
diff
changeset
|
79 [ "$SYSIMAGE_TYPE" == rootfs ] && |
10b64f52ad20
Make tweak.sh actually work, and do less unnecessary rebuilding.
Rob Landley <rob@landley.net>
parents:
1735
diff
changeset
|
80 echo -e "CONFIG_INITRAMFS_SOURCE=\"$BUILD/root-filesystem-$ARCH/rootfs.cpio.gz\"\n" \ |
10b64f52ad20
Make tweak.sh actually work, and do less unnecessary rebuilding.
Rob Landley <rob@landley.net>
parents:
1735
diff
changeset
|
81 >> mini.conf |
10b64f52ad20
Make tweak.sh actually work, and do less unnecessary rebuilding.
Rob Landley <rob@landley.net>
parents:
1735
diff
changeset
|
82 make ARCH=${BOOT_KARCH:-$KARCH} $LINUX_FLAGS KCONFIG_ALLCONFIG=mini.conf \ |
10b64f52ad20
Make tweak.sh actually work, and do less unnecessary rebuilding.
Rob Landley <rob@landley.net>
parents:
1735
diff
changeset
|
83 allnoconfig >/dev/null && |
10b64f52ad20
Make tweak.sh actually work, and do less unnecessary rebuilding.
Rob Landley <rob@landley.net>
parents:
1735
diff
changeset
|
84 make -j $CPUS ARCH=${BOOT_KARCH:-$KARCH} $DO_CROSS $LINUX_FLAGS $VERBOSITY && |
10b64f52ad20
Make tweak.sh actually work, and do less unnecessary rebuilding.
Rob Landley <rob@landley.net>
parents:
1735
diff
changeset
|
85 cp "$KERNEL_PATH" "$STAGE_DIR/linux" |
10b64f52ad20
Make tweak.sh actually work, and do less unnecessary rebuilding.
Rob Landley <rob@landley.net>
parents:
1735
diff
changeset
|
86 cleanup |
10b64f52ad20
Make tweak.sh actually work, and do less unnecessary rebuilding.
Rob Landley <rob@landley.net>
parents:
1735
diff
changeset
|
87 fi |
490
004f9509349b
Rip out User Mode Linux, switch to genext2fs instead. (Based on an old patch from James Davidson.)
Rob Landley <rob@landley.net>
parents:
486
diff
changeset
|
88 # Tar it up. |
004f9509349b
Rip out User Mode Linux, switch to genext2fs instead. (Based on an old patch from James Davidson.)
Rob Landley <rob@landley.net>
parents:
486
diff
changeset
|
89 |
988
30e4bab11f9e
Rename SKIP_STAGE_TARBALLS to NO_STAGE_TARBALLS (for consistency), and make system-image.sh use it instead of doing it by hand.
Rob Landley <rob@landley.net>
parents:
972
diff
changeset
|
90 ARCH="$ARCH_NAME" create_stage_tarball |
267
98c1a2136322
Update package-mini-native.sh to create qemu-image-$ARCH.tar.bz2
Rob Landley <rob@landley.net>
parents:
264
diff
changeset
|
91 |
1358
9252453c40d0
Combine set_titlebar and "echo ===" stuff into announce() function. Consistently output target/stage info, and yank redundant instances.
Rob Landley <rob@landley.net>
parents:
1350
diff
changeset
|
92 announce "Packaging complete" |