annotate system-image.sh @ 900:266dc7ea04c2

If there's enough memory (half a gig per processor), use 1.5x as many CPUs to try to keep 'em busy.
author Rob Landley <rob@landley.net>
date Tue, 24 Nov 2009 03:19:07 -0600
parents 9ae3c9520bec
children 890aa372ee30
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
888
626288dd5cf3 Lots of comments.
Rob Landley <rob@landley.net>
parents: 864
diff changeset
3 # Package a root filesystem directory into a filesystem image, with
626288dd5cf3 Lots of comments.
Rob Landley <rob@landley.net>
parents: 864
diff changeset
4 # associated bootable kernel binary and launch scripts.
109
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
5
669
1cf41855bb85 More error checking.
Rob Landley <rob@landley.net>
parents: 664
diff changeset
6 source sources/include.sh || exit 1
109
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
7
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 # Parse the sources/targets/$1 directory
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
9
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 read_arch_dir "$1"
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
11
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 # Do we have our prerequisites?
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
13
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 773
diff changeset
14 [ -z "$NATIVE_ROOT" ] && NATIVE_ROOT="$BUILD/root-filesystem-$ARCH"
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
15 if [ ! -d "$NATIVE_ROOT" ]
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
16 then
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
17 [ -z "$FAIL_QUIET" ] && echo No "$NATIVE_ROOT" >&2
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
18 exit 1
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
19 fi
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
20
813
e2fc10ede93f Consistently use STAGE_DIR as the output directory. (root-filesystem.sh already did, host-tools.sh was using $HOSTTOOLS, cross-compiler.sh was using $CROSS, and system-image.sh was using SYSIMAGE.)
Rob Landley <rob@landley.net>
parents: 783
diff changeset
21 # This little song and dance makes us run in our own session, to prevent the
e2fc10ede93f Consistently use STAGE_DIR as the output directory. (root-filesystem.sh already did, host-tools.sh was using $HOSTTOOLS, cross-compiler.sh was using $CROSS, and system-image.sh was using SYSIMAGE.)
Rob Landley <rob@landley.net>
parents: 783
diff changeset
22 # "kill 0" below from taking down the shell that called us when it cleans up
e2fc10ede93f Consistently use STAGE_DIR as the output directory. (root-filesystem.sh already did, host-tools.sh was using $HOSTTOOLS, cross-compiler.sh was using $CROSS, and system-image.sh was using SYSIMAGE.)
Rob Landley <rob@landley.net>
parents: 783
diff changeset
23 # our background tasks. (We run the kernel build and root filesystem image
e2fc10ede93f Consistently use STAGE_DIR as the output directory. (root-filesystem.sh already did, host-tools.sh was using $HOSTTOOLS, cross-compiler.sh was using $CROSS, and system-image.sh was using SYSIMAGE.)
Rob Landley <rob@landley.net>
parents: 783
diff changeset
24 # generation in parallel.)
719
428df726cf7f Have system-image.sh do its own setsid variant so when it does dienow() it can kill all its own backgrounded processes, but won't take down the parent shell that ran it.
Rob Landley <rob@landley.net>
parents: 712
diff changeset
25
428df726cf7f Have system-image.sh do its own setsid variant so when it does dienow() it can kill all its own backgrounded processes, but won't take down the parent shell that ran it.
Rob Landley <rob@landley.net>
parents: 712
diff changeset
26 if [ -z "$SYSTEM_IMAGE_SETSID" ]
428df726cf7f Have system-image.sh do its own setsid variant so when it does dienow() it can kill all its own backgrounded processes, but won't take down the parent shell that ran it.
Rob Landley <rob@landley.net>
parents: 712
diff changeset
27 then
428df726cf7f Have system-image.sh do its own setsid variant so when it does dienow() it can kill all its own backgrounded processes, but won't take down the parent shell that ran it.
Rob Landley <rob@landley.net>
parents: 712
diff changeset
28 export SYSTEM_IMAGE_SETSID=1
428df726cf7f Have system-image.sh do its own setsid variant so when it does dienow() it can kill all its own backgrounded processes, but won't take down the parent shell that ran it.
Rob Landley <rob@landley.net>
parents: 712
diff changeset
29
428df726cf7f Have system-image.sh do its own setsid variant so when it does dienow() it can kill all its own backgrounded processes, but won't take down the parent shell that ran it.
Rob Landley <rob@landley.net>
parents: 712
diff changeset
30 # Can't use setsid because it does setsid() but not setpgrp() or tcsetpgrp()
428df726cf7f Have system-image.sh do its own setsid variant so when it does dienow() it can kill all its own backgrounded processes, but won't take down the parent shell that ran it.
Rob Landley <rob@landley.net>
parents: 712
diff changeset
31 # so stdin's signal handling doesn't get moved to the new session id, so
428df726cf7f Have system-image.sh do its own setsid variant so when it does dienow() it can kill all its own backgrounded processes, but won't take down the parent shell that ran it.
Rob Landley <rob@landley.net>
parents: 712
diff changeset
32 # ctrl-c won't work. This little C program does it right.
428df726cf7f Have system-image.sh do its own setsid variant so when it does dienow() it can kill all its own backgrounded processes, but won't take down the parent shell that ran it.
Rob Landley <rob@landley.net>
parents: 712
diff changeset
33
428df726cf7f Have system-image.sh do its own setsid variant so when it does dienow() it can kill all its own backgrounded processes, but won't take down the parent shell that ran it.
Rob Landley <rob@landley.net>
parents: 712
diff changeset
34 $CC -s -Os "$SOURCES/toys/mysetsid.c" -o "$WORK/mysetsid" &&
428df726cf7f Have system-image.sh do its own setsid variant so when it does dienow() it can kill all its own backgrounded processes, but won't take down the parent shell that ran it.
Rob Landley <rob@landley.net>
parents: 712
diff changeset
35 exec "$WORK/mysetsid" "$0" "$@"
428df726cf7f Have system-image.sh do its own setsid variant so when it does dienow() it can kill all its own backgrounded processes, but won't take down the parent shell that ran it.
Rob Landley <rob@landley.net>
parents: 712
diff changeset
36 fi
428df726cf7f Have system-image.sh do its own setsid variant so when it does dienow() it can kill all its own backgrounded processes, but won't take down the parent shell that ran it.
Rob Landley <rob@landley.net>
parents: 712
diff changeset
37
813
e2fc10ede93f Consistently use STAGE_DIR as the output directory. (root-filesystem.sh already did, host-tools.sh was using $HOSTTOOLS, cross-compiler.sh was using $CROSS, and system-image.sh was using SYSIMAGE.)
Rob Landley <rob@landley.net>
parents: 783
diff changeset
38 # Announce start of stage. (Down here after the recursive call above so
e2fc10ede93f Consistently use STAGE_DIR as the output directory. (root-filesystem.sh already did, host-tools.sh was using $HOSTTOOLS, cross-compiler.sh was using $CROSS, and system-image.sh was using SYSIMAGE.)
Rob Landley <rob@landley.net>
parents: 783
diff changeset
39 # it doesn't get announced twice.)
764
dc34da83204d Cosmetic fix: don't announce system-image.sh stage twice.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
40
dc34da83204d Cosmetic fix: don't announce system-image.sh stage twice.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
41 echo -e "$PACKAGE_COLOR"
dc34da83204d Cosmetic fix: don't announce system-image.sh stage twice.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
42 echo "=== Packaging system image from root-filesystem"
dc34da83204d Cosmetic fix: don't announce system-image.sh stage twice.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
43
813
e2fc10ede93f Consistently use STAGE_DIR as the output directory. (root-filesystem.sh already did, host-tools.sh was using $HOSTTOOLS, cross-compiler.sh was using $CROSS, and system-image.sh was using SYSIMAGE.)
Rob Landley <rob@landley.net>
parents: 783
diff changeset
44 blank_tempdir "$STAGE_DIR"
815
8129df56091b Extended setupfor/cleanup to create binary package tarballs if the configure option BINARY_PACKAGE_TARBALLS is set. These tarballs extract into the current directory and add all the changed files installed by this package build, so you can pick and choose when assembling your own filesystem.
Rob Landley <rob@landley.net>
parents: 813
diff changeset
45 blank_tempdir "$WORK"
764
dc34da83204d Cosmetic fix: don't announce system-image.sh stage twice.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
46
dc34da83204d Cosmetic fix: don't announce system-image.sh stage twice.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
47
728
14b9373956a7 Teach squashfs to create /dev/console and change default image time to squashfs.
Rob Landley <rob@landley.net>
parents: 720
diff changeset
48 [ -z "$SYSIMAGE_TYPE" ] && SYSIMAGE_TYPE=squashfs
581
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
49
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 773
diff changeset
50 USRDIR=""
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 773
diff changeset
51 [ -z "$ROOT_NODIRS" ] && USRDIR=/usr
572
1277d5ae4507 Move bin/qemu-setup.sh to sbin/init.sh and do more work on initramfs packaging. (Doesn't work yet.)
Rob Landley <rob@landley.net>
parents: 553
diff changeset
52
581
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
53 # This next bit is a little complicated; we generate the root filesystem image
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
54 # in the middle of building a kernel. This is necessary to embed an
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
55 # initramfs in the kernel, and allows us to parallelize the kernel build with
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
56 # the image generation. Having the other image types in the same if/else
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
57 # staircase with initramfs lets us detect unknown image types (probably typos)
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
58 # without repeating any.
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
59
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
60 # Build a linux kernel for the target
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
61
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
62 setupfor linux
586
c9c7420e952b More tweaks to make hw- targets work.
Rob Landley <rob@landley.net>
parents: 581
diff changeset
63 [ -z "$BOOT_KARCH" ] && BOOT_KARCH="$KARCH"
591
4750bed36a72 The kernel changed so CONFIG_BLK_DEV_INITRD has to be enabled to use initramfs; yes even the built-in one.
Rob Landley <rob@landley.net>
parents: 590
diff changeset
64 cp "$(getconfig linux)" mini.conf || dienow
4750bed36a72 The kernel changed so CONFIG_BLK_DEV_INITRD has to be enabled to use initramfs; yes even the built-in one.
Rob Landley <rob@landley.net>
parents: 590
diff changeset
65 [ "$SYSIMAGE_TYPE" == "initramfs" ] &&
4750bed36a72 The kernel changed so CONFIG_BLK_DEV_INITRD has to be enabled to use initramfs; yes even the built-in one.
Rob Landley <rob@landley.net>
parents: 590
diff changeset
66 (echo "CONFIG_BLK_DEV_INITRD=y" >> mini.conf || dienow)
888
626288dd5cf3 Lots of comments.
Rob Landley <rob@landley.net>
parents: 864
diff changeset
67 make ARCH="${BOOT_KARCH}" KCONFIG_ALLCONFIG=mini.conf $LINUX_FLAGS \
591
4750bed36a72 The kernel changed so CONFIG_BLK_DEV_INITRD has to be enabled to use initramfs; yes even the built-in one.
Rob Landley <rob@landley.net>
parents: 590
diff changeset
68 allnoconfig >/dev/null || 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
69
581
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
70 # Build kernel in parallel with initramfs
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
71
888
626288dd5cf3 Lots of comments.
Rob Landley <rob@landley.net>
parents: 864
diff changeset
72 echo make -j $CPUS ARCH="${BOOT_KARCH}" CROSS_COMPILE="${ARCH}-" $LINUX_FLAGS \
626288dd5cf3 Lots of comments.
Rob Landley <rob@landley.net>
parents: 864
diff changeset
73 $VERBOSITY
626288dd5cf3 Lots of comments.
Rob Landley <rob@landley.net>
parents: 864
diff changeset
74
709
64cc63ad26ce Add BUILD_VERBOSE config option.
Rob Landley <rob@landley.net>
parents: 687
diff changeset
75 ( make -j $CPUS ARCH="${BOOT_KARCH}" CROSS_COMPILE="${ARCH}-" $LINUX_FLAGS \
64cc63ad26ce Add BUILD_VERBOSE config option.
Rob Landley <rob@landley.net>
parents: 687
diff changeset
76 $VERBOSITY || dienow ) &
581
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
77
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
78 # If we exit before removing this handler, kill everything in the current
719
428df726cf7f Have system-image.sh do its own setsid variant so when it does dienow() it can kill all its own backgrounded processes, but won't take down the parent shell that ran it.
Rob Landley <rob@landley.net>
parents: 712
diff changeset
79 # process group, which should take out backgrounded kernel make no matter
428df726cf7f Have system-image.sh do its own setsid variant so when it does dienow() it can kill all its own backgrounded processes, but won't take down the parent shell that ran it.
Rob Landley <rob@landley.net>
parents: 712
diff changeset
80 # how many child processes it's spawned.
581
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
81 trap "kill 0" EXIT
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
82
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
83 # Embed an initramfs image in the kernel?
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
84
719
428df726cf7f Have system-image.sh do its own setsid variant so when it does dienow() it can kill all its own backgrounded processes, but won't take down the parent shell that ran it.
Rob Landley <rob@landley.net>
parents: 712
diff changeset
85 echo "Generating root filesystem of type: $SYSIMAGE_TYPE"
428df726cf7f Have system-image.sh do its own setsid variant so when it does dienow() it can kill all its own backgrounded processes, but won't take down the parent shell that ran it.
Rob Landley <rob@landley.net>
parents: 712
diff changeset
86
581
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
87 if [ "$SYSIMAGE_TYPE" == "initramfs" ]
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
88 then
588
965923c576f3 More initramfs fixes. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 586
diff changeset
89 $CC usr/gen_init_cpio.c -o my_gen_init_cpio || dienow
965923c576f3 More initramfs fixes. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 586
diff changeset
90 (./my_gen_init_cpio <(
597
3d67228ceb1e Rename $NATIVE to $NATIVE_ROOT and allow it to be supplied externally so system-image.sh can package up an arbitrary native root filesystem source dir.
Rob Landley <rob@landley.net>
parents: 593
diff changeset
91 "$SOURCES"/toys/gen_initramfs_list.sh "$NATIVE_ROOT"
3d67228ceb1e Rename $NATIVE to $NATIVE_ROOT and allow it to be supplied externally so system-image.sh can package up an arbitrary native root filesystem source dir.
Rob Landley <rob@landley.net>
parents: 593
diff changeset
92 [ ! -e "$NATIVE_ROOT"/init ] &&
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 773
diff changeset
93 echo "slink /init $USRDIR/sbin/init.sh 755 0 0"
597
3d67228ceb1e Rename $NATIVE to $NATIVE_ROOT and allow it to be supplied externally so system-image.sh can package up an arbitrary native root filesystem source dir.
Rob Landley <rob@landley.net>
parents: 593
diff changeset
94 [ ! -d "$NATIVE_ROOT"/dev ] && echo "dir /dev 755 0 0"
590
8e7db79a3d75 Make initramfs work, add "--memory MEGS" option to ./run-emulator.sh and make run-from-build.sh use it.
Rob Landley <rob@landley.net>
parents: 588
diff changeset
95 echo "nod /dev/console 660 0 0 c 5 1"
588
965923c576f3 More initramfs fixes. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 586
diff changeset
96 ) || dienow
965923c576f3 More initramfs fixes. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 586
diff changeset
97 ) | gzip -9 > initramfs_data.cpio.gz || dienow
965923c576f3 More initramfs fixes. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 586
diff changeset
98 echo Initramfs generated.
354
d96741481221 User Mode Linux found a new way to break: now when it panics, it sends a kill
Rob Landley <rob@landley.net>
parents: 353
diff changeset
99
581
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
100 # Wait for initial kernel build to finish.
572
1277d5ae4507 Move bin/qemu-setup.sh to sbin/init.sh and do more work on initramfs packaging. (Doesn't work yet.)
Rob Landley <rob@landley.net>
parents: 553
diff changeset
101
773
2b9e8af90917 Remove wait4background, the shell has a builtin "wait" and we don't care about non-zero wait counts anymore.
Rob Landley <rob@landley.net>
parents: 764
diff changeset
102 wait
572
1277d5ae4507 Move bin/qemu-setup.sh to sbin/init.sh and do more work on initramfs packaging. (Doesn't work yet.)
Rob Landley <rob@landley.net>
parents: 553
diff changeset
103
1277d5ae4507 Move bin/qemu-setup.sh to sbin/init.sh and do more work on initramfs packaging. (Doesn't work yet.)
Rob Landley <rob@landley.net>
parents: 553
diff changeset
104 # This is a repeat of an earlier make invocation, but if we try to
1277d5ae4507 Move bin/qemu-setup.sh to sbin/init.sh and do more work on initramfs packaging. (Doesn't work yet.)
Rob Landley <rob@landley.net>
parents: 553
diff changeset
105 # consolidate them the dependencies build unnecessary prereqisites
1277d5ae4507 Move bin/qemu-setup.sh to sbin/init.sh and do more work on initramfs packaging. (Doesn't work yet.)
Rob Landley <rob@landley.net>
parents: 553
diff changeset
106 # and then decide that they're newer than the cpio.gz we supplied,
1277d5ae4507 Move bin/qemu-setup.sh to sbin/init.sh and do more work on initramfs packaging. (Doesn't work yet.)
Rob Landley <rob@landley.net>
parents: 553
diff changeset
107 # and thus overwrite it with a default (emptyish) one.
1277d5ae4507 Move bin/qemu-setup.sh to sbin/init.sh and do more work on initramfs packaging. (Doesn't work yet.)
Rob Landley <rob@landley.net>
parents: 553
diff changeset
108
573
de6725a2fdad Fix an "it doesn't boot" bug dating back to commit 553. Sigh.
Rob Landley <rob@landley.net>
parents: 572
diff changeset
109 echo "Building kernel with initramfs."
572
1277d5ae4507 Move bin/qemu-setup.sh to sbin/init.sh and do more work on initramfs packaging. (Doesn't work yet.)
Rob Landley <rob@landley.net>
parents: 553
diff changeset
110 [ -f initramfs_data.cpio.gz ] &&
1277d5ae4507 Move bin/qemu-setup.sh to sbin/init.sh and do more work on initramfs packaging. (Doesn't work yet.)
Rob Landley <rob@landley.net>
parents: 553
diff changeset
111 touch initramfs_data.cpio.gz &&
1277d5ae4507 Move bin/qemu-setup.sh to sbin/init.sh and do more work on initramfs packaging. (Doesn't work yet.)
Rob Landley <rob@landley.net>
parents: 553
diff changeset
112 mv initramfs_data.cpio.gz usr &&
593
67bc5a49cf1d Mark Miller pointed out that $LINUX_FLAGS is needed for the initramfs build.
Rob Landley <rob@landley.net>
parents: 591
diff changeset
113 make -j $CPUS ARCH="${BOOT_KARCH}" CROSS_COMPILE="${ARCH}-" $LINUX_FLAGS \
67bc5a49cf1d Mark Miller pointed out that $LINUX_FLAGS is needed for the initramfs build.
Rob Landley <rob@landley.net>
parents: 591
diff changeset
114 || dienow
581
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
115
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
116 # No need to supply an hda image to emulator.
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
117
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
118 IMAGE=
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
119 elif [ "$SYSIMAGE_TYPE" == "ext2" ]
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
120 then
597
3d67228ceb1e Rename $NATIVE to $NATIVE_ROOT and allow it to be supplied externally so system-image.sh can package up an arbitrary native root filesystem source dir.
Rob Landley <rob@landley.net>
parents: 593
diff changeset
121 # Generate a 64 megabyte ext2 filesystem image from the $NATIVE_ROOT
3d67228ceb1e Rename $NATIVE to $NATIVE_ROOT and allow it to be supplied externally so system-image.sh can package up an arbitrary native root filesystem source dir.
Rob Landley <rob@landley.net>
parents: 593
diff changeset
122 # directory, with a temporary file defining the /dev nodes for the new
3d67228ceb1e Rename $NATIVE to $NATIVE_ROOT and allow it to be supplied externally so system-image.sh can package up an arbitrary native root filesystem source dir.
Rob Landley <rob@landley.net>
parents: 593
diff changeset
123 # filesystem.
581
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
124
616
a95cb8f13284 Add SYSIMAGE_HDA_MEGS config parameter (defaulting to 64).
Rob Landley <rob@landley.net>
parents: 597
diff changeset
125 [ -z "$SYSIMAGE_HDA_MEGS" ] && SYSIMAGE_HDA_MEGS=64
a95cb8f13284 Add SYSIMAGE_HDA_MEGS config parameter (defaulting to 64).
Rob Landley <rob@landley.net>
parents: 597
diff changeset
126
581
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
127 IMAGE="image-${ARCH}.ext2"
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
128 DEVLIST="$WORK"/devlist
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
129
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
130 echo "/dev d 755 0 0 - - - - -" > "$DEVLIST" &&
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
131 echo "/dev/console c 640 0 0 5 1 0 0 -" >> "$DEVLIST" &&
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
132
671
fda459e9515a Autodetect the amount of space in a mini-native directory for genext2fs.
Rob Landley <rob@landley.net>
parents: 669
diff changeset
133 # Produce a filesystem with the currently used space plus 20% for filesystem
fda459e9515a Autodetect the amount of space in a mini-native directory for genext2fs.
Rob Landley <rob@landley.net>
parents: 669
diff changeset
134 # overhead, which should always be big enough.
642
c92dc77da038 Since gene2fs can't produce large images in a reasonable amount of time, make a 64 meg image and resize it if necessary. (This means the minimum image size is 64 megs, because gene2fs won't run unless you specify a size, but it knows right away if the size you gave it wasn't big enough. I don't understand this either.)
Rob Landley <rob@landley.net>
parents: 640
diff changeset
135
712
9d766670154a genext2fs needs a minimum amount of free space or it dies.
Rob Landley <rob@landley.net>
parents: 711
diff changeset
136 BLOCKS=$[1024*(($(du -m -s "$NATIVE_ROOT" | awk '{print $1}')*12)/10)]
9d766670154a genext2fs needs a minimum amount of free space or it dies.
Rob Landley <rob@landley.net>
parents: 711
diff changeset
137 [ $BLOCKS -lt 4096 ] && BLOCKS=4096
9d766670154a genext2fs needs a minimum amount of free space or it dies.
Rob Landley <rob@landley.net>
parents: 711
diff changeset
138
9d766670154a genext2fs needs a minimum amount of free space or it dies.
Rob Landley <rob@landley.net>
parents: 711
diff changeset
139 genext2fs -z -D "$DEVLIST" -d "$NATIVE_ROOT" -b $BLOCKS -i 1024 \
813
e2fc10ede93f Consistently use STAGE_DIR as the output directory. (root-filesystem.sh already did, host-tools.sh was using $HOSTTOOLS, cross-compiler.sh was using $CROSS, and system-image.sh was using SYSIMAGE.)
Rob Landley <rob@landley.net>
parents: 783
diff changeset
140 "$STAGE_DIR/$IMAGE" &&
581
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
141 rm "$DEVLIST" || dienow
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
142
642
c92dc77da038 Since gene2fs can't produce large images in a reasonable amount of time, make a 64 meg image and resize it if necessary. (This means the minimum image size is 64 megs, because gene2fs won't run unless you specify a size, but it knows right away if the size you gave it wasn't big enough. I don't understand this either.)
Rob Landley <rob@landley.net>
parents: 640
diff changeset
143 # Extend image size to HDA_MEGS if necessary, keeping it sparse. (Feeding
c92dc77da038 Since gene2fs can't produce large images in a reasonable amount of time, make a 64 meg image and resize it if necessary. (This means the minimum image size is 64 megs, because gene2fs won't run unless you specify a size, but it knows right away if the size you gave it wasn't big enough. I don't understand this either.)
Rob Landley <rob@landley.net>
parents: 640
diff changeset
144 # a larger -b size to genext2fs is insanely slow, and not particularly
c92dc77da038 Since gene2fs can't produce large images in a reasonable amount of time, make a 64 meg image and resize it if necessary. (This means the minimum image size is 64 megs, because gene2fs won't run unless you specify a size, but it knows right away if the size you gave it wasn't big enough. I don't understand this either.)
Rob Landley <rob@landley.net>
parents: 640
diff changeset
145 # sparse.)
c92dc77da038 Since gene2fs can't produce large images in a reasonable amount of time, make a 64 meg image and resize it if necessary. (This means the minimum image size is 64 megs, because gene2fs won't run unless you specify a size, but it knows right away if the size you gave it wasn't big enough. I don't understand this either.)
Rob Landley <rob@landley.net>
parents: 640
diff changeset
146
c92dc77da038 Since gene2fs can't produce large images in a reasonable amount of time, make a 64 meg image and resize it if necessary. (This means the minimum image size is 64 megs, because gene2fs won't run unless you specify a size, but it knows right away if the size you gave it wasn't big enough. I don't understand this either.)
Rob Landley <rob@landley.net>
parents: 640
diff changeset
147 if [ $[1024*$SYSIMAGE_HDA_MEGS] -gt 65536 ]
c92dc77da038 Since gene2fs can't produce large images in a reasonable amount of time, make a 64 meg image and resize it if necessary. (This means the minimum image size is 64 megs, because gene2fs won't run unless you specify a size, but it knows right away if the size you gave it wasn't big enough. I don't understand this either.)
Rob Landley <rob@landley.net>
parents: 640
diff changeset
148 then
813
e2fc10ede93f Consistently use STAGE_DIR as the output directory. (root-filesystem.sh already did, host-tools.sh was using $HOSTTOOLS, cross-compiler.sh was using $CROSS, and system-image.sh was using SYSIMAGE.)
Rob Landley <rob@landley.net>
parents: 783
diff changeset
149 dd if=/dev/zero of="$STAGE_DIR/$IMAGE" bs=1k count=1 seek=$[1024*1024-1] &&
e2fc10ede93f Consistently use STAGE_DIR as the output directory. (root-filesystem.sh already did, host-tools.sh was using $HOSTTOOLS, cross-compiler.sh was using $CROSS, and system-image.sh was using SYSIMAGE.)
Rob Landley <rob@landley.net>
parents: 783
diff changeset
150 resize2fs "$STAGE_DIR/$IMAGE" ${SYSIMAGE_HDA_MEGS}M || dienow
642
c92dc77da038 Since gene2fs can't produce large images in a reasonable amount of time, make a 64 meg image and resize it if necessary. (This means the minimum image size is 64 megs, because gene2fs won't run unless you specify a size, but it knows right away if the size you gave it wasn't big enough. I don't understand this either.)
Rob Landley <rob@landley.net>
parents: 640
diff changeset
151 fi
c92dc77da038 Since gene2fs can't produce large images in a reasonable amount of time, make a 64 meg image and resize it if necessary. (This means the minimum image size is 64 megs, because gene2fs won't run unless you specify a size, but it knows right away if the size you gave it wasn't big enough. I don't understand this either.)
Rob Landley <rob@landley.net>
parents: 640
diff changeset
152
648
a72f7f70c003 Now that the 2.6.29 kernel is out with squashfs, add squashfs to host-tools.sh and system-image.sh.
Rob Landley <rob@landley.net>
parents: 643
diff changeset
153 elif [ "$SYSIMAGE_TYPE" == "squashfs" ]
a72f7f70c003 Now that the 2.6.29 kernel is out with squashfs, add squashfs to host-tools.sh and system-image.sh.
Rob Landley <rob@landley.net>
parents: 643
diff changeset
154 then
a72f7f70c003 Now that the 2.6.29 kernel is out with squashfs, add squashfs to host-tools.sh and system-image.sh.
Rob Landley <rob@landley.net>
parents: 643
diff changeset
155 IMAGE="image-${ARCH}.sqf"
813
e2fc10ede93f Consistently use STAGE_DIR as the output directory. (root-filesystem.sh already did, host-tools.sh was using $HOSTTOOLS, cross-compiler.sh was using $CROSS, and system-image.sh was using SYSIMAGE.)
Rob Landley <rob@landley.net>
parents: 783
diff changeset
156 mksquashfs "${NATIVE_ROOT}" "$STAGE_DIR/$IMAGE" -noappend -all-root \
728
14b9373956a7 Teach squashfs to create /dev/console and change default image time to squashfs.
Rob Landley <rob@landley.net>
parents: 720
diff changeset
157 -no-progress -p "/dev d 755 0 0" -p "/dev/console c 666 0 0 5 1" || dienow
586
c9c7420e952b More tweaks to make hw- targets work.
Rob Landley <rob@landley.net>
parents: 581
diff changeset
158 else
c9c7420e952b More tweaks to make hw- targets work.
Rob Landley <rob@landley.net>
parents: 581
diff changeset
159 echo "Unknown image type." >&2
c9c7420e952b More tweaks to make hw- targets work.
Rob Landley <rob@landley.net>
parents: 581
diff changeset
160 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
161 fi
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
162
581
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
163 # Wait for kernel build to finish (may be a NOP)
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
164
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
165 echo Image generation complete.
773
2b9e8af90917 Remove wait4background, the shell has a builtin "wait" and we don't care about non-zero wait counts anymore.
Rob Landley <rob@landley.net>
parents: 764
diff changeset
166 wait
581
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
167 trap "" EXIT
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
168
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
169 # Install kernel
109
d9dae1196ea7 Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff changeset
170
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
171 [ -d "${TOOLS}/src" ] && cp .config "${TOOLS}"/src/config-linux
815
8129df56091b Extended setupfor/cleanup to create binary package tarballs if the configure option BINARY_PACKAGE_TARBALLS is set. These tarballs extract into the current directory and add all the changed files installed by this package build, so you can pick and choose when assembling your own filesystem.
Rob Landley <rob@landley.net>
parents: 813
diff changeset
172 cp "${KERNEL_PATH}" "${STAGE_DIR}/zImage-${ARCH}"
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
173
815
8129df56091b Extended setupfor/cleanup to create binary package tarballs if the configure option BINARY_PACKAGE_TARBALLS is set. These tarballs extract into the current directory and add all the changed files installed by this package build, so you can pick and choose when assembling your own filesystem.
Rob Landley <rob@landley.net>
parents: 813
diff changeset
174 cleanup
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
175
893
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
176 # 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
177
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
178 function kernel_cmdline()
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
179 {
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
180 [ "$SYSIMAGE_TYPE" != "initramfs" ] &&
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
181 echo -n "root=/dev/$ROOT rw init=$USRDIR/sbin/init.sh "
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
182
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
183 echo -n "panic=1 PATH=\$DISTCC_PATH_PREFIX${USRDIR}/bin console=$CONSOLE"
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
184 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
185 }
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
186
325
51bcd6de223d Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents: 317
diff changeset
187 function qemu_defaults()
51bcd6de223d Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents: 317
diff changeset
188 {
893
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
189 echo -n "-nographic -no-reboot -kernel \"$2\" \$WITH_HDC \$WITH_HDB"
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
190 [ "$SYSIMAGE_TYPE" != "initramfs" ] && echo -n " -hda \"$1\""
9ae3c9520bec Split out kernel_cmdline from qemu-defaults.
Rob Landley <rob@landley.net>
parents: 888
diff changeset
191 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
192 }
51bcd6de223d Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents: 317
diff changeset
193
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
194 # 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
195 # 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
196 # 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
197
864
5660a438421b Make system-image.sh write out dev-environment.sh from a here document.
Rob Landley <rob@landley.net>
parents: 863
diff changeset
198 cat > "$STAGE_DIR/dev-environment.sh" << EOF &&
5660a438421b Make system-image.sh write out dev-environment.sh from a here document.
Rob Landley <rob@landley.net>
parents: 863
diff changeset
199 #!/bin/sh
5660a438421b Make system-image.sh write out dev-environment.sh from a here document.
Rob Landley <rob@landley.net>
parents: 863
diff changeset
200
5660a438421b Make system-image.sh write out dev-environment.sh from a here document.
Rob Landley <rob@landley.net>
parents: 863
diff changeset
201 # Run the emulator with default values intended for a development environment.
5660a438421b Make system-image.sh write out dev-environment.sh from a here document.
Rob Landley <rob@landley.net>
parents: 863
diff changeset
202
5660a438421b Make system-image.sh write out dev-environment.sh from a here document.
Rob Landley <rob@landley.net>
parents: 863
diff changeset
203 QEMU_MEMORY=256 HDB=hdb.img HDBMEGS=2048 ./run-emulator.sh
5660a438421b Make system-image.sh write out dev-environment.sh from a here document.
Rob Landley <rob@landley.net>
parents: 863
diff changeset
204 EOF
5660a438421b Make system-image.sh write out dev-environment.sh from a here document.
Rob Landley <rob@landley.net>
parents: 863
diff changeset
205 chmod +x "$STAGE_DIR/dev-environment.sh" &&
863
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 846
diff changeset
206 sed -e 's/^ARCH=.*/ARCH='"$ARCH"/ "$SOURCES/toys/run-emulator.sh" > \
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 846
diff changeset
207 "$STAGE_DIR/run-emulator.sh" &&
4bfe2b34dd9f Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents: 846
diff changeset
208 chmod +x "$STAGE_DIR/run-emulator.sh" &&
813
e2fc10ede93f Consistently use STAGE_DIR as the output directory. (root-filesystem.sh already did, host-tools.sh was using $HOSTTOOLS, cross-compiler.sh was using $CROSS, and system-image.sh was using SYSIMAGE.)
Rob Landley <rob@landley.net>
parents: 783
diff changeset
209 emulator_command "$IMAGE" zImage-$ARCH >> "$STAGE_DIR/run-emulator.sh"
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
210
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
211 [ $? -ne 0 ] && dienow
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
212
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
213 # 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
214
675
4571f63c2298 Add SKIP_STAGE_TARBALLS config option to skip creating tarballs after each stage.
Rob Landley <rob@landley.net>
parents: 671
diff changeset
215 if [ -z "$SKIP_STAGE_TARBALLS" ]
4571f63c2298 Add SKIP_STAGE_TARBALLS config option to skip creating tarballs after each stage.
Rob Landley <rob@landley.net>
parents: 671
diff changeset
216 then
4571f63c2298 Add SKIP_STAGE_TARBALLS config option to skip creating tarballs after each stage.
Rob Landley <rob@landley.net>
parents: 671
diff changeset
217 tar -cvj -f "$BUILD"/system-image-$ARCH_NAME.tar.bz2 \
4571f63c2298 Add SKIP_STAGE_TARBALLS config option to skip creating tarballs after each stage.
Rob Landley <rob@landley.net>
parents: 671
diff changeset
218 -C "$BUILD" system-image-$ARCH_NAME || dienow
4571f63c2298 Add SKIP_STAGE_TARBALLS config option to skip creating tarballs after each stage.
Rob Landley <rob@landley.net>
parents: 671
diff changeset
219 fi
267
98c1a2136322 Update package-mini-native.sh to create qemu-image-$ARCH.tar.bz2
Rob Landley <rob@landley.net>
parents: 264
diff changeset
220
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
221 echo -e "=== Packaging complete\e[0m"