Mercurial > hg > aboriginal
annotate root-filesystem.sh @ 1839:c8293b3ab81f draft default tip
Teach chroot-splice to accept one or two arguments. (Control image now optional.)
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 17 Jan 2016 21:18:52 -0600 |
parents | 297a5d07c73b |
children |
rev | line source |
---|---|
177 | 1 #!/bin/bash |
43
6d16887ec084
Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
2 |
1116
2b68517f5b62
Break out simple-root-filesystem.sh and root-filesystem.sh (adding native-compiler.sh output), and use NO_NATIVE_COMPILER to determine which to use. Rename STATIC_CC_HOST to CROSS_HOST_ARCH.
Rob Landley <rob@landley.net>
parents:
1108
diff
changeset
|
3 # Build a basic busybox+uClibc root filesystem for a given target. |
888 | 4 |
1128
e5f9681a8b3c
Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents:
1116
diff
changeset
|
5 # Requires a cross-compiler (or simple-cross-compiler) in the $PATH or in |
e5f9681a8b3c
Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents:
1116
diff
changeset
|
6 # the build directory. In theory you can supply your own as long as the |
e5f9681a8b3c
Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents:
1116
diff
changeset
|
7 # prefix- name is correct. |
e5f9681a8b3c
Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents:
1116
diff
changeset
|
8 |
669 | 9 source sources/include.sh || exit 1 |
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
|
10 load_target "$1" |
783
db06a8c1bfed
Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents:
782
diff
changeset
|
11 check_for_base_arch || exit 0 |
1812
acaa88463c0c
Add CROSS_COMPILER_PATH and CC_PREFIX knobs.
Rob Landley <rob@landley.net>
parents:
1811
diff
changeset
|
12 check_prerequisite "${CC_PREFIX}cc" |
685
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
675
diff
changeset
|
13 |
1811
f326dbd73bee
Rename SIMPLE_ROOT_OVERLAY to ROOT_OVERLAY since simple-root-filesystem became root-filesystem.
Rob Landley <rob@landley.net>
parents:
1730
diff
changeset
|
14 # Source control isn't good at storing empty directories, so create |
f326dbd73bee
Rename SIMPLE_ROOT_OVERLAY to ROOT_OVERLAY since simple-root-filesystem became root-filesystem.
Rob Landley <rob@landley.net>
parents:
1730
diff
changeset
|
15 # directory layout and apply permissions changes. |
658
dc5512d734f0
Actually put MANIFEST into mini-native.
Rob Landley <rob@landley.net>
parents:
633
diff
changeset
|
16 |
1727
45c936d93711
Drop ROOT_NODIRS, it's not worth the complexity to support both layouts.
Rob Landley <rob@landley.net>
parents:
1708
diff
changeset
|
17 mkdir -p "$STAGE_DIR"/{tmp,proc,sys,dev,home,mnt,root} && |
45c936d93711
Drop ROOT_NODIRS, it's not worth the complexity to support both layouts.
Rob Landley <rob@landley.net>
parents:
1708
diff
changeset
|
18 chmod a+rwxt "$STAGE_DIR/tmp" || dienow |
1139
2c6d799f0451
Fix a dangling symlink that confuses root-filesystem.sh, and add some comments.
Rob Landley <rob@landley.net>
parents:
1133
diff
changeset
|
19 |
1727
45c936d93711
Drop ROOT_NODIRS, it's not worth the complexity to support both layouts.
Rob Landley <rob@landley.net>
parents:
1708
diff
changeset
|
20 STAGE_USR="$STAGE_DIR/usr" |
1511
e59de35d8437
Leave STAGE_DIR alone and add STAGE_USR instead.
Rob Landley <rob@landley.net>
parents:
1482
diff
changeset
|
21 |
1727
45c936d93711
Drop ROOT_NODIRS, it's not worth the complexity to support both layouts.
Rob Landley <rob@landley.net>
parents:
1708
diff
changeset
|
22 # Having lots of repeated locations at / and also under /usr is silly, so |
45c936d93711
Drop ROOT_NODIRS, it's not worth the complexity to support both layouts.
Rob Landley <rob@landley.net>
parents:
1708
diff
changeset
|
23 # symlink them together. (The duplication happened back in the 1970's |
45c936d93711
Drop ROOT_NODIRS, it's not worth the complexity to support both layouts.
Rob Landley <rob@landley.net>
parents:
1708
diff
changeset
|
24 # when Ken and Dennis ran out of space on their PDP-11's root disk and |
45c936d93711
Drop ROOT_NODIRS, it's not worth the complexity to support both layouts.
Rob Landley <rob@landley.net>
parents:
1708
diff
changeset
|
25 # leaked the OS into the disk containing the user home directories. It's |
45c936d93711
Drop ROOT_NODIRS, it's not worth the complexity to support both layouts.
Rob Landley <rob@landley.net>
parents:
1708
diff
changeset
|
26 # been mindlessly duplicated ever since.) |
45c936d93711
Drop ROOT_NODIRS, it's not worth the complexity to support both layouts.
Rob Landley <rob@landley.net>
parents:
1708
diff
changeset
|
27 for i in bin sbin lib etc |
45c936d93711
Drop ROOT_NODIRS, it's not worth the complexity to support both layouts.
Rob Landley <rob@landley.net>
parents:
1708
diff
changeset
|
28 do |
45c936d93711
Drop ROOT_NODIRS, it's not worth the complexity to support both layouts.
Rob Landley <rob@landley.net>
parents:
1708
diff
changeset
|
29 mkdir -p "$STAGE_USR/$i" && ln -s "usr/$i" "$STAGE_DIR/$i" || dienow |
45c936d93711
Drop ROOT_NODIRS, it's not worth the complexity to support both layouts.
Rob Landley <rob@landley.net>
parents:
1708
diff
changeset
|
30 done |
395
c2b290c1df40
Upgrade BUILD_SHORT to make a small busybox+uClibc system in /usr, with top level symlinks (/bin, /lib, etc) and adjustments to boot script and run-emulator.
Rob Landley <rob@landley.net>
parents:
390
diff
changeset
|
31 |
713
9282f84b31a1
Add NATIVE_TOOLCHAIN=only, to build _just_ the native toolchain (sae set of packages as the cross compiler, only --enable-shared and with uClibc++).
Rob Landley <rob@landley.net>
parents:
711
diff
changeset
|
32 # Copy qemu setup script and so on. |
9282f84b31a1
Add NATIVE_TOOLCHAIN=only, to build _just_ the native toolchain (sae set of packages as the cross compiler, only --enable-shared and with uClibc++).
Rob Landley <rob@landley.net>
parents:
711
diff
changeset
|
33 |
1511
e59de35d8437
Leave STAGE_DIR alone and add STAGE_USR instead.
Rob Landley <rob@landley.net>
parents:
1482
diff
changeset
|
34 cp -r "$SOURCES/root-filesystem/." "$STAGE_USR/" && |
1221
6a4968ae5ac8
Add new "/src/host-info" file to target, with CROSS_TARGET and KARCH values.
Rob Landley <rob@landley.net>
parents:
1206
diff
changeset
|
35 echo -e "CROSS_TARGET=$CROSS_TARGET\nKARCH=$KARCH" > \ |
1511
e59de35d8437
Leave STAGE_DIR alone and add STAGE_USR instead.
Rob Landley <rob@landley.net>
parents:
1482
diff
changeset
|
36 "$STAGE_USR/src/host-info" && |
e59de35d8437
Leave STAGE_DIR alone and add STAGE_USR instead.
Rob Landley <rob@landley.net>
parents:
1482
diff
changeset
|
37 cp "$SRCDIR"/MANIFEST "$STAGE_USR/src" || dienow |
52
6d6551a37687
Add make to mini-native (required one more option switched on in uClibc), add
Rob Landley <rob@landley.net>
parents:
51
diff
changeset
|
38 |
1151 | 39 # If user specified different files to put in the root filesystem, add them. |
40 # (This overwrites existing files.) | |
41 | |
1816
fb05f99ffcce
Collate site-local variables under "MY_XXX" prefix: MY_PATCH_DIR,
Rob Landley <rob@landley.net>
parents:
1812
diff
changeset
|
42 if [ ! -z "$MY_ROOT_OVERLAY" ] |
1151 | 43 then |
44 cd "$TOP" | |
1816
fb05f99ffcce
Collate site-local variables under "MY_XXX" prefix: MY_PATCH_DIR,
Rob Landley <rob@landley.net>
parents:
1812
diff
changeset
|
45 tar -c -C "$MY_ROOT_OVERLAY" . | tar -x -C "$STAGE_DIR" || dienow |
1151 | 46 fi |
47 | |
1708
b871f0e7b837
Build the compiler wrapper static if possible, and only copy libraries into the simple-root-filesystem if we need them.
Rob Landley <rob@landley.net>
parents:
1676
diff
changeset
|
48 # Build toybox |
52
6d6551a37687
Add make to mini-native (required one more option switched on in uClibc), add
Rob Landley <rob@landley.net>
parents:
51
diff
changeset
|
49 |
1511
e59de35d8437
Leave STAGE_DIR alone and add STAGE_USR instead.
Rob Landley <rob@landley.net>
parents:
1482
diff
changeset
|
50 STAGE_DIR="$STAGE_USR" build_section busybox |
e59de35d8437
Leave STAGE_DIR alone and add STAGE_USR instead.
Rob Landley <rob@landley.net>
parents:
1482
diff
changeset
|
51 cp "$WORK"/config-busybox "$STAGE_USR"/src || dienow |
1544
e2f722cc97a6
Make busybox build by default, switch override knob to BUSYBOX=1 to use defconfig busybox, always use toybox for oneit, cleanup/fix record-commands logic.
Rob Landley <rob@landley.net>
parents:
1511
diff
changeset
|
52 build_section toybox |
1133
1ad777637d2d
Migrate oneit out of toybox into sources/toys as a standalone program, and fix it so pid 1 has / as its working directory so we can umount /home if necessary.
Rob Landley <rob@landley.net>
parents:
1128
diff
changeset
|
53 |
83
8fb80545fe84
Move the "hello world" source into sources/toys. Build (in mini-native)
Rob Landley <rob@landley.net>
parents:
81
diff
changeset
|
54 # Put statically and dynamically linked hello world programs on there for |
315
7fe514d773b9
Install setup script even for BUILD_SHORT.
Rob Landley <rob@landley.net>
parents:
311
diff
changeset
|
55 # test purposes. |
83
8fb80545fe84
Move the "hello world" source into sources/toys. Build (in mini-native)
Rob Landley <rob@landley.net>
parents:
81
diff
changeset
|
56 |
1828
297a5d07c73b
There are some uses of ${ARCH}-cc and ${ARCH}-strip remaining in
Geoff Salmon <geoff@se-instruments.com>
parents:
1816
diff
changeset
|
57 "${CC_PREFIX}cc" "${SOURCES}/root-filesystem/src/hello.c" -Os $CFLAGS \ |
1511
e59de35d8437
Leave STAGE_DIR alone and add STAGE_USR instead.
Rob Landley <rob@landley.net>
parents:
1482
diff
changeset
|
58 -o "$STAGE_USR/bin/hello-dynamic" || dienow |
1036
e021bba5e22e
Yank ugly STAGE_DIR adjustment and instead teach busybox/toybox bilds to auto-detect "bin" directory on install. (And while we're at it, don't build hello-dynamic on static-only system.)
Rob Landley <rob@landley.net>
parents:
1034
diff
changeset
|
59 |
1083
cb4dbdb7f2cd
Make BUILD_STATIC take comma separated list of packages, or "all" or "none". Default behavior should remain the same.
Rob Landley <rob@landley.net>
parents:
1062
diff
changeset
|
60 if [ "$BUILD_STATIC" != none ] |
1036
e021bba5e22e
Yank ugly STAGE_DIR adjustment and instead teach busybox/toybox bilds to auto-detect "bin" directory on install. (And while we're at it, don't build hello-dynamic on static-only system.)
Rob Landley <rob@landley.net>
parents:
1034
diff
changeset
|
61 then |
1828
297a5d07c73b
There are some uses of ${ARCH}-cc and ${ARCH}-strip remaining in
Geoff Salmon <geoff@se-instruments.com>
parents:
1816
diff
changeset
|
62 "${CC_PREFIX}cc" "${SOURCES}/root-filesystem/src/hello.c" -Os $CFLAGS -static \ |
1511
e59de35d8437
Leave STAGE_DIR alone and add STAGE_USR instead.
Rob Landley <rob@landley.net>
parents:
1482
diff
changeset
|
63 -o "$STAGE_USR/bin/hello-static" || dienow |
1708
b871f0e7b837
Build the compiler wrapper static if possible, and only copy libraries into the simple-root-filesystem if we need them.
Rob Landley <rob@landley.net>
parents:
1676
diff
changeset
|
64 STATIC=--static |
b871f0e7b837
Build the compiler wrapper static if possible, and only copy libraries into the simple-root-filesystem if we need them.
Rob Landley <rob@landley.net>
parents:
1676
diff
changeset
|
65 else |
b871f0e7b837
Build the compiler wrapper static if possible, and only copy libraries into the simple-root-filesystem if we need them.
Rob Landley <rob@landley.net>
parents:
1676
diff
changeset
|
66 STATIC= |
1036
e021bba5e22e
Yank ugly STAGE_DIR adjustment and instead teach busybox/toybox bilds to auto-detect "bin" directory on install. (And while we're at it, don't build hello-dynamic on static-only system.)
Rob Landley <rob@landley.net>
parents:
1034
diff
changeset
|
67 fi |
944
fc134a13357e
Largeish refactoring and cleanup of compiler build:
Rob Landley <rob@landley.net>
parents:
941
diff
changeset
|
68 |
1472
a4673f17b7c0
Add record-commands wrapper and plumbing to target image, so you can record-commands /mnt/init in a native build.
Rob Landley <rob@landley.net>
parents:
1398
diff
changeset
|
69 # Debug wrapper for use with /usr/src/record-commands.sh |
a4673f17b7c0
Add record-commands wrapper and plumbing to target image, so you can record-commands /mnt/init in a native build.
Rob Landley <rob@landley.net>
parents:
1398
diff
changeset
|
70 |
1828
297a5d07c73b
There are some uses of ${ARCH}-cc and ${ARCH}-strip remaining in
Geoff Salmon <geoff@se-instruments.com>
parents:
1816
diff
changeset
|
71 "${CC_PREFIX}cc" "$SOURCES/toys/wrappy.c" -Os $CFLAGS $STATIC \ |
1708
b871f0e7b837
Build the compiler wrapper static if possible, and only copy libraries into the simple-root-filesystem if we need them.
Rob Landley <rob@landley.net>
parents:
1676
diff
changeset
|
72 -o "$STAGE_USR/bin/record-commands-wrapper" || dienow |
1472
a4673f17b7c0
Add record-commands wrapper and plumbing to target image, so you can record-commands /mnt/init in a native build.
Rob Landley <rob@landley.net>
parents:
1398
diff
changeset
|
73 |
1062
abc8ddd4d9f0
Don't have root-filesystem.sh suck in the native-compiler.sh output, have build.sh collate those instead before calling system-image.sh. (That way the root-filesystem.sh tarball does't include the native compiler output.)
Rob Landley <rob@landley.net>
parents:
1036
diff
changeset
|
74 # Do we need shared libraries? |
944
fc134a13357e
Largeish refactoring and cleanup of compiler build:
Rob Landley <rob@landley.net>
parents:
941
diff
changeset
|
75 |
1708
b871f0e7b837
Build the compiler wrapper static if possible, and only copy libraries into the simple-root-filesystem if we need them.
Rob Landley <rob@landley.net>
parents:
1676
diff
changeset
|
76 if ! is_in_list toybox $BUILD_STATIC || ! is_in_list busybox $BUILD_STATIC |
1062
abc8ddd4d9f0
Don't have root-filesystem.sh suck in the native-compiler.sh output, have build.sh collate those instead before calling system-image.sh. (That way the root-filesystem.sh tarball does't include the native compiler output.)
Rob Landley <rob@landley.net>
parents:
1036
diff
changeset
|
77 then |
abc8ddd4d9f0
Don't have root-filesystem.sh suck in the native-compiler.sh output, have build.sh collate those instead before calling system-image.sh. (That way the root-filesystem.sh tarball does't include the native compiler output.)
Rob Landley <rob@landley.net>
parents:
1036
diff
changeset
|
78 echo Copying compiler libraries... |
1511
e59de35d8437
Leave STAGE_DIR alone and add STAGE_USR instead.
Rob Landley <rob@landley.net>
parents:
1482
diff
changeset
|
79 mkdir -p "$STAGE_USR/lib" || dienow |
1062
abc8ddd4d9f0
Don't have root-filesystem.sh suck in the native-compiler.sh output, have build.sh collate those instead before calling system-image.sh. (That way the root-filesystem.sh tarball does't include the native compiler output.)
Rob Landley <rob@landley.net>
parents:
1036
diff
changeset
|
80 (path_search \ |
1828
297a5d07c73b
There are some uses of ${ARCH}-cc and ${ARCH}-strip remaining in
Geoff Salmon <geoff@se-instruments.com>
parents:
1816
diff
changeset
|
81 "$("${CC_PREFIX}cc" --print-search-dirs | sed -n 's/^libraries: =*//p')" \ |
1511
e59de35d8437
Leave STAGE_DIR alone and add STAGE_USR instead.
Rob Landley <rob@landley.net>
parents:
1482
diff
changeset
|
82 "*.so*" 'cp -H "$DIR/$FILE" "$STAGE_USR/lib/$FILE"' \ |
1062
abc8ddd4d9f0
Don't have root-filesystem.sh suck in the native-compiler.sh output, have build.sh collate those instead before calling system-image.sh. (That way the root-filesystem.sh tarball does't include the native compiler output.)
Rob Landley <rob@landley.net>
parents:
1036
diff
changeset
|
83 || dienow) | dotprogress |
1198
78e786334c5b
Polish the strip logic a bit.
Rob Landley <rob@landley.net>
parents:
1178
diff
changeset
|
84 |
78e786334c5b
Polish the strip logic a bit.
Rob Landley <rob@landley.net>
parents:
1178
diff
changeset
|
85 [ -z "$SKIP_STRIP" ] && |
1828
297a5d07c73b
There are some uses of ${ARCH}-cc and ${ARCH}-strip remaining in
Geoff Salmon <geoff@se-instruments.com>
parents:
1816
diff
changeset
|
86 "${CC_PREFIX}strip" --strip-unneeded "$STAGE_USR"/lib/*.so |
1034
27c38c82401d
Move make, bash, and distcc builds into native-compiler.sh. (Break 'em out into sources/sections/*.build.)
Rob Landley <rob@landley.net>
parents:
1008
diff
changeset
|
87 fi |
944
fc134a13357e
Largeish refactoring and cleanup of compiler build:
Rob Landley <rob@landley.net>
parents:
941
diff
changeset
|
88 |
fc134a13357e
Largeish refactoring and cleanup of compiler build:
Rob Landley <rob@landley.net>
parents:
941
diff
changeset
|
89 # Clean up and package the result |
713
9282f84b31a1
Add NATIVE_TOOLCHAIN=only, to build _just_ the native toolchain (sae set of packages as the cross compiler, only --enable-shared and with uClibc++).
Rob Landley <rob@landley.net>
parents:
711
diff
changeset
|
90 |
1198
78e786334c5b
Polish the strip logic a bit.
Rob Landley <rob@landley.net>
parents:
1178
diff
changeset
|
91 [ -z "$SKIP_STRIP" ] && |
1828
297a5d07c73b
There are some uses of ${ARCH}-cc and ${ARCH}-strip remaining in
Geoff Salmon <geoff@se-instruments.com>
parents:
1816
diff
changeset
|
92 "${CC_PREFIX}strip" "$STAGE_USR"/{bin/*,sbin/*} |
53
3fd961e31444
Build a gcc wrapper for _target_, and add a "strip" command to halve the
Rob Landley <rob@landley.net>
parents:
52
diff
changeset
|
93 |
783
db06a8c1bfed
Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents:
782
diff
changeset
|
94 create_stage_tarball |
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:
572
diff
changeset
|
95 |
50
5aeba79b8f5f
Remove qemu build (it's in cross-compiler.sh now), move uClibc build right
Rob Landley <rob@landley.net>
parents:
46
diff
changeset
|
96 # Color back to normal |
52
6d6551a37687
Add make to mini-native (required one more option switched on in uClibc), add
Rob Landley <rob@landley.net>
parents:
51
diff
changeset
|
97 echo -e "\e[0mBuild complete" |