annotate system-image.sh @ 1633:a4823c561e28

Patrick Lauer suggested making the smoketest timeout configurable, and default to 3 minutes when FORK=1.
author Rob Landley <rob@landley.net>
date Tue, 15 Oct 2013 22:25:55 -0500
parents 29109240fd6d
children b89324905ca2
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
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
669
1cf41855bb85 More error checking.
Rob Landley <rob@landley.net>
parents: 664
diff changeset
5 source sources/include.sh || exit 1
109
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
6
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
7 # 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
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 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
10
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
11 cd "$BUILD/linux-kernel-$ARCH_NAME" &&
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
12 KERNEL="$(ls)" &&
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
13 ln "$KERNEL" "$STAGE_DIR" &&
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
14 cd "$BUILD/root-image-$ARCH" &&
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
15 IMAGE="$(ls)" &&
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
16 ln "$IMAGE" "$STAGE_DIR" || dienow
553
80f3356577fc Move kernel building from mini-native to package-mini-native in preparation for initramfs packaging option.
Rob Landley <rob@landley.net>
parents: 537
diff changeset
17
893
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
18 # 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
19
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1074
diff changeset
20 kernel_cmdline()
893
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
21 {
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
22 [ "$SYSIMAGE_TYPE" != "initramfs" ] &&
1163
2b05860c6cf1 Update initramfs generation to deal with kernel changes, and rip out unnecessary complexity (backgrounding the kernel build, partial rebuild) that other stages don't do.
Rob Landley <rob@landley.net>
parents: 1152
diff changeset
23 echo -n "root=/dev/$ROOT rw init=/sbin/init.sh "
893
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
24
1307
6ea4204209d0 Add /sbin to the $PATH in the system image. (Oops.)
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
25 echo -n "panic=1 PATH=\$DISTCC_PATH_PREFIX/bin:/sbin console=$CONSOLE"
893
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
26 echo -n " HOST=$ARCH ${KERNEL_EXTRA}\$KERNEL_EXTRA"
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
27 }
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
28
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1074
diff changeset
29 qemu_defaults()
325
51bcd6de223d Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents: 317
diff changeset
30 {
1437
5a0ca606858b Get rid of of two old and now unused variables
Alessio Igor Bogani <alessioigorbogani@gmail.com>
parents: 1398
diff changeset
31 echo -n "-nographic -no-reboot -kernel $KERNEL"
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
32 [ "$SYSIMAGE_TYPE" != "initramfs" ] && echo -n " -hda $IMAGE"
893
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
33 echo -n " -append \"$(kernel_cmdline)\" \$QEMU_EXTRA"
325
51bcd6de223d Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents: 317
diff changeset
34 }
51bcd6de223d Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents: 317
diff changeset
35
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
36 # 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
37 # 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
38 # 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
39
1005
ed8e33b81032 Make run-emulator.sh executable.
Rob Landley <rob@landley.net>
parents: 1000
diff changeset
40 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
41 #!/bin/bash
29109240fd6d Comment tweaks, and make run-emulator.sh use bash.
Rob Landley <rob@landley.net>
parents: 1437
diff changeset
42
29109240fd6d Comment tweaks, and make run-emulator.sh use bash.
Rob Landley <rob@landley.net>
parents: 1437
diff changeset
43 # 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
44
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
45 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
46 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
47 {
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
48 [ ! -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
49 $(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
50 }
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
51
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
52 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
53 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
54 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
55 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
56 EOF
1005
ed8e33b81032 Make run-emulator.sh executable.
Rob Landley <rob@landley.net>
parents: 1000
diff changeset
57 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
58
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
59 # 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
60
1169
d13ddec32cee Only include the dev-environment.sh and native-build.sh scripts when the system image contains native development tools.
Rob Landley <rob@landley.net>
parents: 1163
diff changeset
61 [ -z "$NO_NATIVE_COMPILER" ] && 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
62 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
63 (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
64 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
65 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
66 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
67 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
68 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
69 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
70 # 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
71 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
72 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
73 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
74 ) > "$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
75
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
76 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
77 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
78
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
79 # 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
80
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
81 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
82
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
83 announce "Packaging complete"