Mercurial > hg > aboriginal
annotate system-image.sh @ 687:58f38b4049e4
Remove vestigial line.
author | Rob Landley <rob@landley.net> |
---|---|
date | Wed, 01 Apr 2009 04:49:42 -0500 |
parents | 4571f63c2298 |
children | 64cc63ad26ce |
rev | line source |
---|---|
177 | 1 #!/bin/bash |
109
d9dae1196ea7
Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
2 |
576
036dbe218036
Add BASE_ARCH support, so a hardware architecture can specify a base architecture and just provide a different kernel.
Rob Landley <rob@landley.net>
parents:
573
diff
changeset
|
3 # Create a bootable system image from mini-native |
109
d9dae1196ea7
Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
4 |
669 | 5 source sources/include.sh || exit 1 |
109
d9dae1196ea7
Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
6 |
485
b0438691e9e1
Move color selection into ./config. (The default colors don't look great on a white background.)
Rob Landley <rob@landley.net>
parents:
483
diff
changeset
|
7 echo -e "$PACKAGE_COLOR" |
b0438691e9e1
Move color selection into ./config. (The default colors don't look great on a white background.)
Rob Landley <rob@landley.net>
parents:
483
diff
changeset
|
8 echo "=== Packaging system image from mini-native" |
b0438691e9e1
Move color selection into ./config. (The default colors don't look great on a white background.)
Rob Landley <rob@landley.net>
parents:
483
diff
changeset
|
9 |
581
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
10 [ -z "$SYSIMAGE_TYPE" ] && SYSIMAGE_TYPE=ext2 |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
11 |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
12 SYSIMAGE="${BUILD}/system-image-${ARCH_NAME}" |
462
3f3283fb5e1e
Running ./package-mini-native.sh as root can just loopback mount itself, without User Mode Linux.
Rob Landley <rob@landley.net>
parents:
451
diff
changeset
|
13 |
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
|
14 TOOLSDIR=tools |
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
|
15 [ -z "$NATIVE_TOOLSDIR" ] && TOOLSDIR=usr |
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
|
16 |
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
|
17 # Flush old system-image directory |
468
3d2996abb6ea
Moving the temp dir broke non-root packaging: fix it.
Rob Landley <rob@landley.net>
parents:
467
diff
changeset
|
18 |
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
|
19 rm -rf "${SYSIMAGE}" |
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
|
20 mkdir -p "${SYSIMAGE}" || dienow |
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
|
21 |
581
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
22 # 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
|
23 # 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
|
24 # 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
|
25 # 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
|
26 # 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
|
27 # without repeating any. |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
28 |
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
|
29 # 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
|
30 |
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
|
31 setupfor linux |
586
c9c7420e952b
More tweaks to make hw- targets work.
Rob Landley <rob@landley.net>
parents:
581
diff
changeset
|
32 [ -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
|
33 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
|
34 [ "$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
|
35 (echo "CONFIG_BLK_DEV_INITRD=y" >> 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
|
36 make ARCH="${BOOT_KARCH}" KCONFIG_ALLCONFIG=mini.conf \ |
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
|
37 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
|
38 |
581
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
39 # 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
|
40 |
586
c9c7420e952b
More tweaks to make hw- targets work.
Rob Landley <rob@landley.net>
parents:
581
diff
changeset
|
41 ( make -j $CPUS ARCH="${BOOT_KARCH}" CROSS_COMPILE="${ARCH}-" $LINUX_FLAGS || |
c9c7420e952b
More tweaks to make hw- targets work.
Rob Landley <rob@landley.net>
parents:
581
diff
changeset
|
42 dienow ) & |
581
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
43 |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
44 # If we exit before removing this handler, kill everything in the current |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
45 # process group, which should take out backgrounded kernel make. |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
46 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
|
47 |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
48 # 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
|
49 |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
50 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
|
51 then |
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 echo "Generating initramfs (in background)" |
588
965923c576f3
More initramfs fixes. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
586
diff
changeset
|
53 $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
|
54 (./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
|
55 "$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
|
56 [ ! -e "$NATIVE_ROOT"/init ] && |
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
|
57 echo "slink /init /$TOOLSDIR/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
|
58 [ ! -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
|
59 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
|
60 ) || dienow |
965923c576f3
More initramfs fixes. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
586
diff
changeset
|
61 ) | 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
|
62 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
|
63 |
581
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
64 # 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
|
65 |
581
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
66 wait4background 0 |
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
|
67 |
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
|
68 # 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
|
69 # 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
|
70 # 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
|
71 # 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
|
72 |
573
de6725a2fdad
Fix an "it doesn't boot" bug dating back to commit 553. Sigh.
Rob Landley <rob@landley.net>
parents:
572
diff
changeset
|
73 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
|
74 [ -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
|
75 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
|
76 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
|
77 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
|
78 || dienow |
581
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
79 |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
80 # 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
|
81 |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
82 IMAGE= |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
83 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
|
84 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
|
85 # 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
|
86 # 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
|
87 # filesystem. |
581
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
88 |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
89 echo "Generating ext2 image (in background)" |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
90 |
616
a95cb8f13284
Add SYSIMAGE_HDA_MEGS config parameter (defaulting to 64).
Rob Landley <rob@landley.net>
parents:
597
diff
changeset
|
91 [ -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
|
92 |
581
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
93 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
|
94 DEVLIST="$WORK"/devlist |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
95 |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
96 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
|
97 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
|
98 |
671
fda459e9515a
Autodetect the amount of space in a mini-native directory for genext2fs.
Rob Landley <rob@landley.net>
parents:
669
diff
changeset
|
99 # 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
|
100 # 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
|
101 |
671
fda459e9515a
Autodetect the amount of space in a mini-native directory for genext2fs.
Rob Landley <rob@landley.net>
parents:
669
diff
changeset
|
102 genext2fs -z -D "$DEVLIST" -d "$NATIVE_ROOT" \ |
fda459e9515a
Autodetect the amount of space in a mini-native directory for genext2fs.
Rob Landley <rob@landley.net>
parents:
669
diff
changeset
|
103 -b $[1024*(($(du -m -s "$NATIVE_ROOT" | awk '{print $1}')*12)/10)] -i 1024 \ |
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
|
104 "$SYSIMAGE/$IMAGE" && |
581
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
105 rm "$DEVLIST" || dienow |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
106 |
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
|
107 # 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
|
108 # 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
|
109 # 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
|
110 |
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
|
111 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
|
112 then |
643
87ef47d783f5
Fix previous commit: actually download e2fsprogs and get image name right.
Rob Landley <rob@landley.net>
parents:
642
diff
changeset
|
113 dd if=/dev/zero of="$SYSIMAGE/$IMAGE" bs=1k count=1 seek=$[1024*1024-1] && |
87ef47d783f5
Fix previous commit: actually download e2fsprogs and get image name right.
Rob Landley <rob@landley.net>
parents:
642
diff
changeset
|
114 resize2fs "$SYSIMAGE/$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
|
115 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
|
116 |
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
|
117 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
|
118 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
|
119 echo "Creating squashfs image (in background)" |
581
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
120 |
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
|
121 IMAGE="image-${ARCH}.sqf" |
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
|
122 mksquashfs "${NATIVE_ROOT}" "$SYSIMAGE/$IMAGE" -noappend -all-root \ |
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
|
123 -no-progress || dienow |
586
c9c7420e952b
More tweaks to make hw- targets work.
Rob Landley <rob@landley.net>
parents:
581
diff
changeset
|
124 else |
c9c7420e952b
More tweaks to make hw- targets work.
Rob Landley <rob@landley.net>
parents:
581
diff
changeset
|
125 echo "Unknown image type." >&2 |
c9c7420e952b
More tweaks to make hw- targets work.
Rob Landley <rob@landley.net>
parents:
581
diff
changeset
|
126 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
|
127 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
|
128 |
581
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
129 # 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
|
130 |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
131 echo Image generation complete. |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
132 wait4background 0 |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
133 trap "" EXIT |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
134 |
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
|
135 # Install kernel |
109
d9dae1196ea7
Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
136 |
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
|
137 [ -d "${TOOLS}/src" ] && cp .config "${TOOLS}"/src/config-linux |
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
|
138 cp "${KERNEL_PATH}" "${SYSIMAGE}/zImage-${ARCH}" && |
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
|
139 cd .. |
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
|
140 |
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
|
141 cleanup linux |
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
|
142 |
330
f9ff71c71f9e
Tweak run-with-home.sh to have a chance of actually working.
Rob Landley <rob@landley.net>
parents:
325
diff
changeset
|
143 # Provide qemu's common command line options between architectures. The lack |
f9ff71c71f9e
Tweak run-with-home.sh to have a chance of actually working.
Rob Landley <rob@landley.net>
parents:
325
diff
changeset
|
144 # of ending quotes on -append is intentional, callers append more kernel |
f9ff71c71f9e
Tweak run-with-home.sh to have a chance of actually working.
Rob Landley <rob@landley.net>
parents:
325
diff
changeset
|
145 # command line arguments and provide their own ending quote. |
325
51bcd6de223d
Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents:
317
diff
changeset
|
146 function qemu_defaults() |
51bcd6de223d
Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents:
317
diff
changeset
|
147 { |
581
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
148 if [ "$SYSIMAGE_TYPE" != "initramfs" ] |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
149 then |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
150 HDA="-hda \"$1\" " |
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
|
151 APPEND="root=/dev/$ROOT rw init=/$TOOLSDIR/sbin/init.sh " |
581
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
152 fi |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
580
diff
changeset
|
153 |
640
b4ea140d2439
Add $QEMU_EXTRA for emulator command line arguments.
Rob Landley <rob@landley.net>
parents:
616
diff
changeset
|
154 echo "-nographic -no-reboot -kernel \"$2\" \$WITH_HDB ${HDA}" \ |
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
|
155 "-append \"${APPEND}panic=1 PATH=\$DISTCC_PATH_PREFIX/${TOOLSDIR}/bin" \ |
640
b4ea140d2439
Add $QEMU_EXTRA for emulator command line arguments.
Rob Landley <rob@landley.net>
parents:
616
diff
changeset
|
156 "console=$CONSOLE \$KERNEL_EXTRA\" \$QEMU_EXTRA" |
325
51bcd6de223d
Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents:
317
diff
changeset
|
157 } |
51bcd6de223d
Redo plumbing that constructs run-emulator.sh. Group common qemu command
Rob Landley <rob@landley.net>
parents:
317
diff
changeset
|
158 |
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
|
159 # 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
|
160 # 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
|
161 # 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
|
162 |
499
9d5fd8e1467b
Merge run-*.sh so run-emulator.sh takes command line arguments. Rename emulator-build.sh to be more clear what it does.
Rob Landley <rob@landley.net>
parents:
496
diff
changeset
|
163 cp "$SOURCES/toys/run-emulator.sh" "$SYSIMAGE/run-emulator.sh" && |
664
0743f9fe73cd
Image isn't always ext2 anymore, use $IMAGE for run-emulator.sh.
Rob Landley <rob@landley.net>
parents:
648
diff
changeset
|
164 emulator_command "$IMAGE" zImage-$ARCH >> "$SYSIMAGE/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
|
165 |
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
|
166 [ $? -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
|
167 |
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
|
168 if [ "$ARCH" == powerpc ] |
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
|
169 then |
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
|
170 cp "$SOURCES"/toys/ppc_rom.bin "$SYSIMAGE" || 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
|
171 fi |
109
d9dae1196ea7
Package ext2 filesystem image using UML.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
172 |
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
|
173 # 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
|
174 |
675
4571f63c2298
Add SKIP_STAGE_TARBALLS config option to skip creating tarballs after each stage.
Rob Landley <rob@landley.net>
parents:
671
diff
changeset
|
175 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
|
176 then |
4571f63c2298
Add SKIP_STAGE_TARBALLS config option to skip creating tarballs after each stage.
Rob Landley <rob@landley.net>
parents:
671
diff
changeset
|
177 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
|
178 -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
|
179 fi |
267
98c1a2136322
Update package-mini-native.sh to create qemu-image-$ARCH.tar.bz2
Rob Landley <rob@landley.net>
parents:
264
diff
changeset
|
180 |
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
|
181 echo -e "=== Packaging complete\e[0m" |