annotate sources/functions.sh @ 1816:fb05f99ffcce draft

Collate site-local variables under "MY_XXX" prefix: MY_PATCH_DIR, MY_ROOT_OVERLAY, MY_CROSS_PATH and MY_CROSS_PREFIX.
author Rob Landley <rob@landley.net>
date Sat, 21 Nov 2015 16:44:39 -0600
parents acaa88463c0c
children 92d542aa6ceb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
840
96b276eda7f1 Comment tweaks.
Rob Landley <rob@landley.net>
parents: 835
diff changeset
1 #!/bin/echo "This file is sourced, not run"
96b276eda7f1 Comment tweaks.
Rob Landley <rob@landley.net>
parents: 835
diff changeset
2
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 # Lots of reusable functions. This file is sourced, not run.
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
4
1090
affef1edbdba Cleanup "FROM_ARCH" mess. Rename FROM_ARCH->HOST_ARCH, make stage script responsible for setting HOST_ARCH (not includes.sh). Also, remove HOST_UTILS variable, only build uClibc utils for non-simple compilers and bypass uClibc's (weird) makefile for the utils directory.
Rob Landley <rob@landley.net>
parents: 1084
diff changeset
5 # Output path to cross compiler.
915
a541c5a96ff3 Don't actually replace cross-compiler with cross-static, when you build both use $PATH to select which one to use.
Rob Landley <rob@landley.net>
parents: 904
diff changeset
6
a541c5a96ff3 Don't actually replace cross-compiler with cross-static, when you build both use $PATH to select which one to use.
Rob Landley <rob@landley.net>
parents: 904
diff changeset
7 cc_path()
a541c5a96ff3 Don't actually replace cross-compiler with cross-static, when you build both use $PATH to select which one to use.
Rob Landley <rob@landley.net>
parents: 904
diff changeset
8 {
a541c5a96ff3 Don't actually replace cross-compiler with cross-static, when you build both use $PATH to select which one to use.
Rob Landley <rob@landley.net>
parents: 904
diff changeset
9 local i
a541c5a96ff3 Don't actually replace cross-compiler with cross-static, when you build both use $PATH to select which one to use.
Rob Landley <rob@landley.net>
parents: 904
diff changeset
10
1816
fb05f99ffcce Collate site-local variables under "MY_XXX" prefix: MY_PATCH_DIR,
Rob Landley <rob@landley.net>
parents: 1812
diff changeset
11 if [ ! -z "$MY_CROSS_PATH" ]
1812
acaa88463c0c Add CROSS_COMPILER_PATH and CC_PREFIX knobs.
Rob Landley <rob@landley.net>
parents: 1784
diff changeset
12 then
1816
fb05f99ffcce Collate site-local variables under "MY_XXX" prefix: MY_PATCH_DIR,
Rob Landley <rob@landley.net>
parents: 1812
diff changeset
13 CC_PREFIX="$MY_CC_PREFIX"
1812
acaa88463c0c Add CROSS_COMPILER_PATH and CC_PREFIX knobs.
Rob Landley <rob@landley.net>
parents: 1784
diff changeset
14 [ -z "$CC_PREFIX" ] &&
1816
fb05f99ffcce Collate site-local variables under "MY_XXX" prefix: MY_PATCH_DIR,
Rob Landley <rob@landley.net>
parents: 1812
diff changeset
15 echo "MY_CROSS_PATH without MY_CC_PREFIX" >&2 &&
1812
acaa88463c0c Add CROSS_COMPILER_PATH and CC_PREFIX knobs.
Rob Landley <rob@landley.net>
parents: 1784
diff changeset
16 dienow
1816
fb05f99ffcce Collate site-local variables under "MY_XXX" prefix: MY_PATCH_DIR,
Rob Landley <rob@landley.net>
parents: 1812
diff changeset
17 echo -n "$MY_CROSS_PATH:"
1812
acaa88463c0c Add CROSS_COMPILER_PATH and CC_PREFIX knobs.
Rob Landley <rob@landley.net>
parents: 1784
diff changeset
18 return
acaa88463c0c Add CROSS_COMPILER_PATH and CC_PREFIX knobs.
Rob Landley <rob@landley.net>
parents: 1784
diff changeset
19 fi
acaa88463c0c Add CROSS_COMPILER_PATH and CC_PREFIX knobs.
Rob Landley <rob@landley.net>
parents: 1784
diff changeset
20
1090
affef1edbdba Cleanup "FROM_ARCH" mess. Rename FROM_ARCH->HOST_ARCH, make stage script responsible for setting HOST_ARCH (not includes.sh). Also, remove HOST_UTILS variable, only build uClibc utils for non-simple compilers and bypass uClibc's (weird) makefile for the utils directory.
Rob Landley <rob@landley.net>
parents: 1084
diff changeset
21 # Output cross it if exists, else simple. If neither exists, output simple.
affef1edbdba Cleanup "FROM_ARCH" mess. Rename FROM_ARCH->HOST_ARCH, make stage script responsible for setting HOST_ARCH (not includes.sh). Also, remove HOST_UTILS variable, only build uClibc utils for non-simple compilers and bypass uClibc's (weird) makefile for the utils directory.
Rob Landley <rob@landley.net>
parents: 1084
diff changeset
22
944
fc134a13357e Largeish refactoring and cleanup of compiler build:
Rob Landley <rob@landley.net>
parents: 942
diff changeset
23 for i in "$BUILD"/{,simple-}cross-compiler-"$1/bin"
915
a541c5a96ff3 Don't actually replace cross-compiler with cross-static, when you build both use $PATH to select which one to use.
Rob Landley <rob@landley.net>
parents: 904
diff changeset
24 do
a541c5a96ff3 Don't actually replace cross-compiler with cross-static, when you build both use $PATH to select which one to use.
Rob Landley <rob@landley.net>
parents: 904
diff changeset
25 [ -e "$i/$1-cc" ] && break
a541c5a96ff3 Don't actually replace cross-compiler with cross-static, when you build both use $PATH to select which one to use.
Rob Landley <rob@landley.net>
parents: 904
diff changeset
26 done
a541c5a96ff3 Don't actually replace cross-compiler with cross-static, when you build both use $PATH to select which one to use.
Rob Landley <rob@landley.net>
parents: 904
diff changeset
27 echo -n "$i:"
a541c5a96ff3 Don't actually replace cross-compiler with cross-static, when you build both use $PATH to select which one to use.
Rob Landley <rob@landley.net>
parents: 904
diff changeset
28 }
a541c5a96ff3 Don't actually replace cross-compiler with cross-static, when you build both use $PATH to select which one to use.
Rob Landley <rob@landley.net>
parents: 904
diff changeset
29
1401
f1d2afdf2034 Add base_architecture, make base architectures and extra targets work, and move i586 virtio stuff to new i686-kvm target.
Rob Landley <rob@landley.net>
parents: 1400
diff changeset
30 base_architecture()
f1d2afdf2034 Add base_architecture, make base architectures and extra targets work, and move i586 virtio stuff to new i686-kvm target.
Rob Landley <rob@landley.net>
parents: 1400
diff changeset
31 {
f1d2afdf2034 Add base_architecture, make base architectures and extra targets work, and move i586 virtio stuff to new i686-kvm target.
Rob Landley <rob@landley.net>
parents: 1400
diff changeset
32 ARCH="$1"
f1d2afdf2034 Add base_architecture, make base architectures and extra targets work, and move i586 virtio stuff to new i686-kvm target.
Rob Landley <rob@landley.net>
parents: 1400
diff changeset
33 source "$CONFIG_DIR/$1"
f1d2afdf2034 Add base_architecture, make base architectures and extra targets work, and move i586 virtio stuff to new i686-kvm target.
Rob Landley <rob@landley.net>
parents: 1400
diff changeset
34 }
f1d2afdf2034 Add base_architecture, make base architectures and extra targets work, and move i586 virtio stuff to new i686-kvm target.
Rob Landley <rob@landley.net>
parents: 1400
diff changeset
35
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: 1391
diff changeset
36 load_target()
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: 727
diff changeset
37 {
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: 727
diff changeset
38 # Get target platform from first command line argument.
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: 727
diff changeset
39
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: 727
diff changeset
40 ARCH_NAME="$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: 1391
diff changeset
41 CONFIG_DIR="$SOURCES/targets"
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: 1391
diff changeset
42
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: 1391
diff changeset
43 # Read the relevant config file.
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: 1391
diff changeset
44
1401
f1d2afdf2034 Add base_architecture, make base architectures and extra targets work, and move i586 virtio stuff to new i686-kvm target.
Rob Landley <rob@landley.net>
parents: 1400
diff changeset
45 if [ -f "$CONFIG_DIR/$1" ]
744
759adf5a0fe9 Refactor so include.sh mostly just sets environment variables. Move read_arch_dir to function and call it explicitly (no more need for $NO_ARCH). Make blank_tempdir a function, called explicitly by stages when needed, with some sanity checks. Insert prerequisite tests to later stages so they can detect failure early and provide an explicit erro rmessage, and have those tests happen before blanking $WORK dir, to preserve debugging info. Make buildall.sh depend on prerequisite tests rather than trying to avoid calling later stages (and thus do flow control from asynchronous context). Add FAIL_QUIET option so buildall.sh doesn't spam the log with the new prerequisite error messages.
Rob Landley <rob@landley.net>
parents: 727
diff changeset
46 then
1401
f1d2afdf2034 Add base_architecture, make base architectures and extra targets work, and move i586 virtio stuff to new i686-kvm target.
Rob Landley <rob@landley.net>
parents: 1400
diff changeset
47 base_architecture "$ARCH_NAME"
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: 1391
diff changeset
48 CONFIG_DIR=
1401
f1d2afdf2034 Add base_architecture, make base architectures and extra targets work, and move i586 virtio stuff to new i686-kvm target.
Rob Landley <rob@landley.net>
parents: 1400
diff changeset
49 elif [ -f "$CONFIG_DIR/$1/settings" ]
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: 1391
diff changeset
50 then
1401
f1d2afdf2034 Add base_architecture, make base architectures and extra targets work, and move i586 virtio stuff to new i686-kvm target.
Rob Landley <rob@landley.net>
parents: 1400
diff changeset
51 source "$CONFIG_DIR/$1/settings"
f1d2afdf2034 Add base_architecture, make base architectures and extra targets work, and move i586 virtio stuff to new i686-kvm target.
Rob Landley <rob@landley.net>
parents: 1400
diff changeset
52 [ -z "$ARCH" ] && dienow "No base_architecture"
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: 1391
diff changeset
53 else
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: 727
diff changeset
54 echo "Supported architectures: "
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: 1391
diff changeset
55 ls "$CONFIG_DIR"
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: 727
diff changeset
56
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: 727
diff changeset
57 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: 727
diff changeset
58 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: 727
diff changeset
59
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: 727
diff changeset
60 # Which platform are we building for?
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: 727
diff changeset
61
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: 727
diff changeset
62 export WORK="${BUILD}/temp-$ARCH_NAME"
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: 727
diff changeset
63
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: 727
diff changeset
64 # Say "unknown" in two different ways so it doesn't assume we're NOT
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: 727
diff changeset
65 # cross compiling when the host and target are the same processor. (If host
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: 727
diff changeset
66 # and target match, the binutils/gcc/make builds won't use the cross compiler
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: 727
diff changeset
67 # during root-filesystem.sh, and the host compiler links binaries against the
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: 727
diff changeset
68 # wrong libc.)
984
9840847885e8 Add export_if_blank and make lots of build paths overrideable.
Rob Landley <rob@landley.net>
parents: 973
diff changeset
69 export_if_blank CROSS_HOST=`uname -m`-walrus-linux
1090
affef1edbdba Cleanup "FROM_ARCH" mess. Rename FROM_ARCH->HOST_ARCH, make stage script responsible for setting HOST_ARCH (not includes.sh). Also, remove HOST_UTILS variable, only build uClibc utils for non-simple compilers and bypass uClibc's (weird) makefile for the utils directory.
Rob Landley <rob@landley.net>
parents: 1084
diff changeset
70 export_if_blank CROSS_TARGET=${ARCH}-unknown-linux
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: 727
diff changeset
71
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: 727
diff changeset
72 # Setup directories and add the cross compiler to the start of the path.
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: 727
diff changeset
73
844
ea9af6c73dbf Use the ARCH_NAME rather than ARCH when making stage directories. The only place we don't run check_for_base_arch is system-image, and here we want this to differ because of the kernels.
Mark Miller <mark@mirell.org>
parents: 840
diff changeset
74 STAGE_DIR="$BUILD/${STAGE_NAME}-${ARCH_NAME}"
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 778
diff changeset
75
1099
3c6263354ca9 Blank $STAGE_DIR before adjusting $PATH so building the cross-compiler stage doesn't get confused if it dies during the uClibc++ build and gets re-run (adjusting the path to point to the cross compiler we're about to delete and rebuild). Make NO_CLEANUP explicit in system-image.sh so it can rebuild zImage and squashfs independently by default.
Rob Landley <rob@landley.net>
parents: 1098
diff changeset
76 blank_tempdir "$STAGE_DIR"
1741
189a1748c8bf add NO_CLEANUP=temp to delete build/temp-$ARCH but not output directory.
Rob Landley <rob@landley.net>
parents: 1738
diff changeset
77 NO_CLEANUP=${NO_CLEANUP/temp//} blank_tempdir "$WORK"
1099
3c6263354ca9 Blank $STAGE_DIR before adjusting $PATH so building the cross-compiler stage doesn't get confused if it dies during the uClibc++ build and gets re-run (adjusting the path to point to the cross compiler we're about to delete and rebuild). Make NO_CLEANUP explicit in system-image.sh so it can rebuild zImage and squashfs independently by default.
Rob Landley <rob@landley.net>
parents: 1098
diff changeset
78
915
a541c5a96ff3 Don't actually replace cross-compiler with cross-static, when you build both use $PATH to select which one to use.
Rob Landley <rob@landley.net>
parents: 904
diff changeset
79 export PATH="$(cc_path "$ARCH")$PATH"
1090
affef1edbdba Cleanup "FROM_ARCH" mess. Rename FROM_ARCH->HOST_ARCH, make stage script responsible for setting HOST_ARCH (not includes.sh). Also, remove HOST_UTILS variable, only build uClibc utils for non-simple compilers and bypass uClibc's (weird) makefile for the utils directory.
Rob Landley <rob@landley.net>
parents: 1084
diff changeset
80 [ ! -z "$HOST_ARCH" ] && [ "$HOST_ARCH" != "$ARCH" ] &&
affef1edbdba Cleanup "FROM_ARCH" mess. Rename FROM_ARCH->HOST_ARCH, make stage script responsible for setting HOST_ARCH (not includes.sh). Also, remove HOST_UTILS variable, only build uClibc utils for non-simple compilers and bypass uClibc's (weird) makefile for the utils directory.
Rob Landley <rob@landley.net>
parents: 1084
diff changeset
81 PATH="$(cc_path "$HOST_ARCH")$PATH"
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: 727
diff changeset
82
1812
acaa88463c0c Add CROSS_COMPILER_PATH and CC_PREFIX knobs.
Rob Landley <rob@landley.net>
parents: 1784
diff changeset
83 export_if_blank CC_PREFIX="${ARCH}-"
acaa88463c0c Add CROSS_COMPILER_PATH and CC_PREFIX knobs.
Rob Landley <rob@landley.net>
parents: 1784
diff changeset
84 DO_CROSS="CROSS_COMPILE=$CC_PREFIX"
798
2c9f22daa8fe Allow target settings to specify BUILD_STATIC.
Rob Landley <rob@landley.net>
parents: 796
diff changeset
85
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: 727
diff changeset
86 return 0
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: 727
diff changeset
87 }
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: 727
diff changeset
88
820
d1a88d878e18 Factor out and unify binutils, gcc, and ccwrap builds.
Rob Landley <rob@landley.net>
parents: 818
diff changeset
89 # Note that this sources the file, rather than calling it as a separate
d1a88d878e18 Factor out and unify binutils, gcc, and ccwrap builds.
Rob Landley <rob@landley.net>
parents: 818
diff changeset
90 # process. That way it can set environment variables if it wants to.
d1a88d878e18 Factor out and unify binutils, gcc, and ccwrap builds.
Rob Landley <rob@landley.net>
parents: 818
diff changeset
91
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
92 build_section()
820
d1a88d878e18 Factor out and unify binutils, gcc, and ccwrap builds.
Rob Landley <rob@landley.net>
parents: 818
diff changeset
93 {
1084
b52ba5df878d Don't build anything statically in host-tools.sh, glibc is broken.
Rob Landley <rob@landley.net>
parents: 1083
diff changeset
94 # Don't build anything statically in host-tools, glibc is broken.
b52ba5df878d Don't build anything statically in host-tools.sh, glibc is broken.
Rob Landley <rob@landley.net>
parents: 1083
diff changeset
95 # See http://people.redhat.com/drepper/no_static_linking.html for
b52ba5df878d Don't build anything statically in host-tools.sh, glibc is broken.
Rob Landley <rob@landley.net>
parents: 1083
diff changeset
96 # insane rant from the glibc maintainer about why he doesn't care.
b52ba5df878d Don't build anything statically in host-tools.sh, glibc is broken.
Rob Landley <rob@landley.net>
parents: 1083
diff changeset
97 is_in_list $1 $BUILD_STATIC && [ ! -z "$ARCH" ] && STATIC_FLAGS="--static"
b52ba5df878d Don't build anything statically in host-tools.sh, glibc is broken.
Rob Landley <rob@landley.net>
parents: 1083
diff changeset
98
1200
8651437b2b44 Add DEBUG_PACKAGE config variable to build just one package with CPUS=1.
Rob Landley <rob@landley.net>
parents: 1184
diff changeset
99 OLDCPUS=$CPUS
1517
a246e0b13639 Bug fix: DEBUG_PACKAGE shouldn't pollute NO_CLEANUP.
Rob Landley <rob@landley.net>
parents: 1461
diff changeset
100 OLDNOCLEAN=$NO_CLEANUP
a246e0b13639 Bug fix: DEBUG_PACKAGE shouldn't pollute NO_CLEANUP.
Rob Landley <rob@landley.net>
parents: 1461
diff changeset
101 is_in_list $1 $DEBUG_PACKAGE && CPUS=1 && NO_CLEANUP=1
1200
8651437b2b44 Add DEBUG_PACKAGE config variable to build just one package with CPUS=1.
Rob Landley <rob@landley.net>
parents: 1184
diff changeset
102
938
609bc05b0d6a Teach build_section to run "*.build" sections (with setupfor/cleanup called for them) as well as "*.sh" sections which do their own setup/cleanup.
Rob Landley <rob@landley.net>
parents: 936
diff changeset
103 if [ -e "$SOURCES/sections/$1".build ]
609bc05b0d6a Teach build_section to run "*.build" sections (with setupfor/cleanup called for them) as well as "*.sh" sections which do their own setup/cleanup.
Rob Landley <rob@landley.net>
parents: 936
diff changeset
104 then
609bc05b0d6a Teach build_section to run "*.build" sections (with setupfor/cleanup called for them) as well as "*.sh" sections which do their own setup/cleanup.
Rob Landley <rob@landley.net>
parents: 936
diff changeset
105 setupfor "$1"
609bc05b0d6a Teach build_section to run "*.build" sections (with setupfor/cleanup called for them) as well as "*.sh" sections which do their own setup/cleanup.
Rob Landley <rob@landley.net>
parents: 936
diff changeset
106 . "$SOURCES/sections/$1".build
609bc05b0d6a Teach build_section to run "*.build" sections (with setupfor/cleanup called for them) as well as "*.sh" sections which do their own setup/cleanup.
Rob Landley <rob@landley.net>
parents: 936
diff changeset
107 cleanup
609bc05b0d6a Teach build_section to run "*.build" sections (with setupfor/cleanup called for them) as well as "*.sh" sections which do their own setup/cleanup.
Rob Landley <rob@landley.net>
parents: 936
diff changeset
108 else
1358
9252453c40d0 Combine set_titlebar and "echo ===" stuff into announce() function. Consistently output target/stage info, and yank redundant instances.
Rob Landley <rob@landley.net>
parents: 1253
diff changeset
109 announce "$1"
938
609bc05b0d6a Teach build_section to run "*.build" sections (with setupfor/cleanup called for them) as well as "*.sh" sections which do their own setup/cleanup.
Rob Landley <rob@landley.net>
parents: 936
diff changeset
110 . "$SOURCES"/sections/"$1".sh
609bc05b0d6a Teach build_section to run "*.build" sections (with setupfor/cleanup called for them) as well as "*.sh" sections which do their own setup/cleanup.
Rob Landley <rob@landley.net>
parents: 936
diff changeset
111 fi
1200
8651437b2b44 Add DEBUG_PACKAGE config variable to build just one package with CPUS=1.
Rob Landley <rob@landley.net>
parents: 1184
diff changeset
112 CPUS=$OLDCPUS
1517
a246e0b13639 Bug fix: DEBUG_PACKAGE shouldn't pollute NO_CLEANUP.
Rob Landley <rob@landley.net>
parents: 1461
diff changeset
113 NO_CLEANUP=$OLDNOCLEAN
820
d1a88d878e18 Factor out and unify binutils, gcc, and ccwrap builds.
Rob Landley <rob@landley.net>
parents: 818
diff changeset
114 }
d1a88d878e18 Factor out and unify binutils, gcc, and ccwrap builds.
Rob Landley <rob@landley.net>
parents: 818
diff changeset
115
530
ea7a010e5c47 Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents: 494
diff changeset
116 # Find appropriate miniconfig file
ea7a010e5c47 Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents: 494
diff changeset
117
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
118 getconfig()
530
ea7a010e5c47 Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents: 494
diff changeset
119 {
1552
c3b91b70cc42 Remove USE_ALT option, I have a better idea (upcoming patch).
Rob Landley <rob@landley.net>
parents: 1517
diff changeset
120 for i in {$ARCH_NAME,$ARCH}/miniconfig-$1
581
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 567
diff changeset
121 do
1152
2f39d1bfb2fd Add baseconfig-linux, the infrastructure to use it, and move over the arm targets. (You can override with a miniconfig-linux or miniconfig-uClibc in the appropriate target directory.)
Rob Landley <rob@landley.net>
parents: 1107
diff changeset
122 [ -f "$CONFIG_DIR/$i" ] && cat "$CONFIG_DIR/$i" && return
581
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 567
diff changeset
123 done
530
ea7a010e5c47 Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents: 494
diff changeset
124
1152
2f39d1bfb2fd Add baseconfig-linux, the infrastructure to use it, and move over the arm targets. (You can override with a miniconfig-linux or miniconfig-uClibc in the appropriate target directory.)
Rob Landley <rob@landley.net>
parents: 1107
diff changeset
125 # Output baseconfig, then append $1_CONFIG (converting $1 to uppercase)
2f39d1bfb2fd Add baseconfig-linux, the infrastructure to use it, and move over the arm targets. (You can override with a miniconfig-linux or miniconfig-uClibc in the appropriate target directory.)
Rob Landley <rob@landley.net>
parents: 1107
diff changeset
126 cat "$SOURCES/baseconfig-$1"
2f39d1bfb2fd Add baseconfig-linux, the infrastructure to use it, and move over the arm targets. (You can override with a miniconfig-linux or miniconfig-uClibc in the appropriate target directory.)
Rob Landley <rob@landley.net>
parents: 1107
diff changeset
127 eval "echo \"\${$(echo $1 | tr a-z A-Z)_CONFIG}\""
530
ea7a010e5c47 Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents: 494
diff changeset
128 }
ea7a010e5c47 Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents: 494
diff changeset
129
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: 798
diff changeset
130 # Find all files in $STAGE_DIR newer than $CURSRC.
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: 798
diff changeset
131
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
132 recent_binary_files()
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: 798
diff changeset
133 {
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: 798
diff changeset
134 PREVIOUS=
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: 798
diff changeset
135 (cd "$STAGE_DIR" || dienow
1390
ac60cab45463 Remove FWL debris and rename do_rename to do_manifest while we're at it. (Based on prompting from Alessio Bogani).
Rob Landley <rob@landley.net>
parents: 1389
diff changeset
136 find . -depth -newer "$CURSRC/BUILD-TIMESTAMP" \
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: 798
diff changeset
137 | sed -e 's/^.//' -e 's/^.//' -e '/^$/d'
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: 798
diff changeset
138 ) | while read i
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: 798
diff changeset
139 do
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: 798
diff changeset
140 TEMP="${PREVIOUS##"$i"/}"
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: 798
diff changeset
141
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: 798
diff changeset
142 if [ $[${#PREVIOUS}-${#TEMP}] -ne $[${#i}+1] ]
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: 798
diff changeset
143 then
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: 798
diff changeset
144 # Because the expanded $i might have \ chars in it, that's why.
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: 798
diff changeset
145 echo -n "$i"
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: 798
diff changeset
146 echo -ne '\0'
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: 798
diff changeset
147 fi
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: 798
diff changeset
148 PREVIOUS="$i"
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: 798
diff changeset
149 done
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: 798
diff changeset
150 }
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: 798
diff changeset
151
1253
d4b251e78fc0 Break out download_functions.sh into their own file.
Rob Landley <rob@landley.net>
parents: 1229
diff changeset
152 # Delete a working copy of source code once the build's done.
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
153
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
154 cleanup()
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
155 {
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: 798
diff changeset
156 # If package build exited with an error, do not continue.
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
157
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
158 [ $? -ne 0 ] && dienow
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
159
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: 798
diff changeset
160 if [ ! -z "$BINARY_PACKAGE_TARBALLS" ]
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: 798
diff changeset
161 then
1737
1acbe7e78d9d Switch from bz2 to gz tarball output.
Rob Landley <rob@landley.net>
parents: 1728
diff changeset
162 TARNAME="$PACKAGE-$STAGE_NAME-${ARCH_NAME}".tar.gz
1391
42ec661e3916 Fix BINARY_PACKAGE_TARBALLS generation: some packages produce no output (zlib used to build dropbear for example), and thus check for an empty list before trying to make a tarball.
Rob Landley <rob@landley.net>
parents: 1390
diff changeset
163 [ ! -z "$(recent_binary_files)" ] &&
42ec661e3916 Fix BINARY_PACKAGE_TARBALLS generation: some packages produce no output (zlib used to build dropbear for example), and thus check for an empty list before trying to make a tarball.
Rob Landley <rob@landley.net>
parents: 1390
diff changeset
164 echo -n Creating "$TARNAME" &&
1737
1acbe7e78d9d Switch from bz2 to gz tarball output.
Rob Landley <rob@landley.net>
parents: 1728
diff changeset
165 { recent_binary_files | xargs -0 tar -czvf \
1391
42ec661e3916 Fix BINARY_PACKAGE_TARBALLS generation: some packages produce no output (zlib used to build dropbear for example), and thus check for an empty list before trying to make a tarball.
Rob Landley <rob@landley.net>
parents: 1390
diff changeset
166 "$BUILD/${TARNAME}" -C "$STAGE_DIR" || dienow
42ec661e3916 Fix BINARY_PACKAGE_TARBALLS generation: some packages produce no output (zlib used to build dropbear for example), and thus check for an empty list before trying to make a tarball.
Rob Landley <rob@landley.net>
parents: 1390
diff changeset
167 } | dotprogress
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: 798
diff changeset
168 fi
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: 798
diff changeset
169
567
5619a7375b74 Add NO_CLEANUP option to config.
Rob Landley <rob@landley.net>
parents: 534
diff changeset
170 if [ ! -z "$NO_CLEANUP" ]
5619a7375b74 Add NO_CLEANUP option to config.
Rob Landley <rob@landley.net>
parents: 534
diff changeset
171 then
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: 798
diff changeset
172 echo "skip cleanup $PACKAGE $@"
567
5619a7375b74 Add NO_CLEANUP option to config.
Rob Landley <rob@landley.net>
parents: 534
diff changeset
173 return
5619a7375b74 Add NO_CLEANUP option to config.
Rob Landley <rob@landley.net>
parents: 534
diff changeset
174 fi
5619a7375b74 Add NO_CLEANUP option to config.
Rob Landley <rob@landley.net>
parents: 534
diff changeset
175
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: 798
diff changeset
176 # Loop deleting directories
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: 798
diff changeset
177
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: 798
diff changeset
178 cd "$WORK" || dienow
1183
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
179 for i in $WORKDIR_LIST
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
180 do
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
181 echo "cleanup $i"
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
182 rm -rf "$i" || dienow
1183
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
183 done
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
184 WORKDIR_LIST=
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
185 }
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
186
1183
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
187 # Create a working directory under TMPDIR, deleting existing contents (if any),
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
188 # and tracking created directories so cleanup can delete them automatically.
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
189
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
190 blank_workdir()
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
191 {
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
192 WORKDIR_LIST="$1 $WORKDIR_LIST"
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
193 NO_CLEANUP= blank_tempdir "$WORK/$1"
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
194 cd "$WORK/$1" || dienow
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
195 }
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
196
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
197 # Extract package $1
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
198
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
199 setupfor()
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
200 {
897
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 844
diff changeset
201 export WRAPPY_LOGPATH="$BUILD/logs/cmdlines.${ARCH_NAME}.${STAGE_NAME}.setupfor"
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
202
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
203 # Make sure the source is already extracted and up-to-date.
1184
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
204 extract_package "$1" || exit 1
1582
6a8114c148d1 Lots of small improvements: check for toybox instead of busybox for host-tools $PATH adjustment, better manifest generation (with toybox in list), make package_cache function to find extracted source (so root-image.sh works when packages contains linux-git snapshot), fix more/record-commands.sh path adjustment.
Rob Landley <rob@landley.net>
parents: 1553
diff changeset
205 SNAPFROM="$(package_cache "$1")"
760
2537f30c2397 Improve version detection for MANIFEST file. Still doesn't detect version for git archive output because git hasn't got any equivalent of mercurial's .hg_archive.txt file.
Rob Landley <rob@landley.net>
parents: 744
diff changeset
206
1183
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
207 # Delete old working copy (even in the NO_CLEANUP case) then make a new
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
208 # tree of links to the package cache.
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
209
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
210 echo "Snapshot '$PACKAGE'..."
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
211
1553
da21ff27331e Add ability to check out repositories in packages, IGNORE_REPOS to build from tarballs anyway, a FAQ entry on it, and more/repo.sh to set up/update some of the common ones.
Rob Landley <rob@landley.net>
parents: 1552
diff changeset
212 # Try hardlink, then symlink, then normal (noclobber) copy
da21ff27331e Add ability to check out repositories in packages, IGNORE_REPOS to build from tarballs anyway, a FAQ entry on it, and more/repo.sh to set up/update some of the common ones.
Rob Landley <rob@landley.net>
parents: 1552
diff changeset
213 for LINKTYPE in l s n
da21ff27331e Add ability to check out repositories in packages, IGNORE_REPOS to build from tarballs anyway, a FAQ entry on it, and more/repo.sh to set up/update some of the common ones.
Rob Landley <rob@landley.net>
parents: 1552
diff changeset
214 do
da21ff27331e Add ability to check out repositories in packages, IGNORE_REPOS to build from tarballs anyway, a FAQ entry on it, and more/repo.sh to set up/update some of the common ones.
Rob Landley <rob@landley.net>
parents: 1552
diff changeset
215 if [ -z "$REUSE_CURSRC" ]
da21ff27331e Add ability to check out repositories in packages, IGNORE_REPOS to build from tarballs anyway, a FAQ entry on it, and more/repo.sh to set up/update some of the common ones.
Rob Landley <rob@landley.net>
parents: 1552
diff changeset
216 then
da21ff27331e Add ability to check out repositories in packages, IGNORE_REPOS to build from tarballs anyway, a FAQ entry on it, and more/repo.sh to set up/update some of the common ones.
Rob Landley <rob@landley.net>
parents: 1552
diff changeset
217 blank_workdir "$PACKAGE"
da21ff27331e Add ability to check out repositories in packages, IGNORE_REPOS to build from tarballs anyway, a FAQ entry on it, and more/repo.sh to set up/update some of the common ones.
Rob Landley <rob@landley.net>
parents: 1552
diff changeset
218 CURSRC="$(pwd)"
da21ff27331e Add ability to check out repositories in packages, IGNORE_REPOS to build from tarballs anyway, a FAQ entry on it, and more/repo.sh to set up/update some of the common ones.
Rob Landley <rob@landley.net>
parents: 1552
diff changeset
219 fi
da21ff27331e Add ability to check out repositories in packages, IGNORE_REPOS to build from tarballs anyway, a FAQ entry on it, and more/repo.sh to set up/update some of the common ones.
Rob Landley <rob@landley.net>
parents: 1552
diff changeset
220
da21ff27331e Add ability to check out repositories in packages, IGNORE_REPOS to build from tarballs anyway, a FAQ entry on it, and more/repo.sh to set up/update some of the common ones.
Rob Landley <rob@landley.net>
parents: 1552
diff changeset
221 cp -${LINKTYPE}fR "$SNAPFROM/"* "$CURSRC" && break
da21ff27331e Add ability to check out repositories in packages, IGNORE_REPOS to build from tarballs anyway, a FAQ entry on it, and more/repo.sh to set up/update some of the common ones.
Rob Landley <rob@landley.net>
parents: 1552
diff changeset
222 done
da21ff27331e Add ability to check out repositories in packages, IGNORE_REPOS to build from tarballs anyway, a FAQ entry on it, and more/repo.sh to set up/update some of the common ones.
Rob Landley <rob@landley.net>
parents: 1552
diff changeset
223
1183
61e7e9be8eb4 Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
Rob Landley <rob@landley.net>
parents: 1162
diff changeset
224 cd "$CURSRC" || dienow
897
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 844
diff changeset
225 export WRAPPY_LOGPATH="$BUILD/logs/cmdlines.${ARCH_NAME}.${STAGE_NAME}.$1"
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
226
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: 798
diff changeset
227 # Ugly bug workaround: timestamp granularity in a lot of filesystems is only
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: 798
diff changeset
228 # 1 second, so find -newer misses things installed in the same second, so we
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: 798
diff changeset
229 # make sure it's a new second before we start actually doing anything.
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: 798
diff changeset
230
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: 798
diff changeset
231 if [ ! -z "$BINARY_PACKAGE_TARBALLS" ]
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: 798
diff changeset
232 then
1390
ac60cab45463 Remove FWL debris and rename do_rename to do_manifest while we're at it. (Based on prompting from Alessio Bogani).
Rob Landley <rob@landley.net>
parents: 1389
diff changeset
233 touch "$CURSRC/BUILD-TIMESTAMP" || dienow
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: 798
diff changeset
234 TIME=$(date +%s)
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: 798
diff changeset
235 while true
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: 798
diff changeset
236 do
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: 798
diff changeset
237 [ $TIME != "$(date +%s)" ] && break
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: 798
diff changeset
238 sleep .1
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: 798
diff changeset
239 done
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: 798
diff changeset
240 fi
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
241 }
440
59fe5a276991 Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents: 436
diff changeset
242
1253
d4b251e78fc0 Break out download_functions.sh into their own file.
Rob Landley <rob@landley.net>
parents: 1229
diff changeset
243 # Given a filename.tar.ext, return the version number.
d4b251e78fc0 Break out download_functions.sh into their own file.
Rob Landley <rob@landley.net>
parents: 1229
diff changeset
244
d4b251e78fc0 Break out download_functions.sh into their own file.
Rob Landley <rob@landley.net>
parents: 1229
diff changeset
245 getversion()
d4b251e78fc0 Break out download_functions.sh into their own file.
Rob Landley <rob@landley.net>
parents: 1229
diff changeset
246 {
d4b251e78fc0 Break out download_functions.sh into their own file.
Rob Landley <rob@landley.net>
parents: 1229
diff changeset
247 echo "$1" | sed -e 's/.*-\(\([0-9\.]\)*\([_-]rc\)*\(-pre\)*\([0-9][a-zA-Z]\)*\)*\(\.tar\..z2*\)$/'"$2"'\1/'
d4b251e78fc0 Break out download_functions.sh into their own file.
Rob Landley <rob@landley.net>
parents: 1229
diff changeset
248 }
d4b251e78fc0 Break out download_functions.sh into their own file.
Rob Landley <rob@landley.net>
parents: 1229
diff changeset
249
464
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
250 # Figure out what version of a package we last built
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
251
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
252 get_download_version()
464
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
253 {
724
3ccce25660f4 Make MANIFEST generation less brittle.
Rob Landley <rob@landley.net>
parents: 720
diff changeset
254 getversion $(sed -n 's@URL=.*/\(.[^ ]*\).*@\1@p' "$TOP/download.sh" | grep ${1}-)
464
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
255 }
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
256
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
257 # Identify subversion or mercurial revision, or release number
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
258
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
259 identify_release()
464
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
260 {
1552
c3b91b70cc42 Remove USE_ALT option, I have a better idea (upcoming patch).
Rob Landley <rob@landley.net>
parents: 1517
diff changeset
261 DIR="$SRCDIR/$1"
c3b91b70cc42 Remove USE_ALT option, I have a better idea (upcoming patch).
Rob Landley <rob@landley.net>
parents: 1517
diff changeset
262 if [ -d "$DIR" ]
464
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
263 then
1552
c3b91b70cc42 Remove USE_ALT option, I have a better idea (upcoming patch).
Rob Landley <rob@landley.net>
parents: 1517
diff changeset
264 (
c3b91b70cc42 Remove USE_ALT option, I have a better idea (upcoming patch).
Rob Landley <rob@landley.net>
parents: 1517
diff changeset
265 cd "$DIR" || dienow
1582
6a8114c148d1 Lots of small improvements: check for toybox instead of busybox for host-tools $PATH adjustment, better manifest generation (with toybox in list), make package_cache function to find extracted source (so root-image.sh works when packages contains linux-git snapshot), fix more/record-commands.sh path adjustment.
Rob Landley <rob@landley.net>
parents: 1553
diff changeset
266 ID="$(git log -1 --format=%H 2>/dev/null)"
1552
c3b91b70cc42 Remove USE_ALT option, I have a better idea (upcoming patch).
Rob Landley <rob@landley.net>
parents: 1517
diff changeset
267 [ ! -z "$ID" ] && echo git "$ID" && return
767
dc19e20734ca Use the git magic tarball comment field to get the version number of unstable git packages for MANIFEST.
Rob Landley <rob@landley.net>
parents: 762
diff changeset
268
1582
6a8114c148d1 Lots of small improvements: check for toybox instead of busybox for host-tools $PATH adjustment, better manifest generation (with toybox in list), make package_cache function to find extracted source (so root-image.sh works when packages contains linux-git snapshot), fix more/record-commands.sh path adjustment.
Rob Landley <rob@landley.net>
parents: 1553
diff changeset
269 ID="$(hg identify -n 2>/dev/null)"
1552
c3b91b70cc42 Remove USE_ALT option, I have a better idea (upcoming patch).
Rob Landley <rob@landley.net>
parents: 1517
diff changeset
270 [ ! -z "$ID" ] && echo hg "$ID" && return
760
2537f30c2397 Improve version detection for MANIFEST file. Still doesn't detect version for git archive output because git hasn't got any equivalent of mercurial's .hg_archive.txt file.
Rob Landley <rob@landley.net>
parents: 744
diff changeset
271
1582
6a8114c148d1 Lots of small improvements: check for toybox instead of busybox for host-tools $PATH adjustment, better manifest generation (with toybox in list), make package_cache function to find extracted source (so root-image.sh works when packages contains linux-git snapshot), fix more/record-commands.sh path adjustment.
Rob Landley <rob@landley.net>
parents: 1553
diff changeset
272 ID="$(svn info 2>/dev/null | sed -n "s/^Revision: //p")"
1552
c3b91b70cc42 Remove USE_ALT option, I have a better idea (upcoming patch).
Rob Landley <rob@landley.net>
parents: 1517
diff changeset
273 [ ! -z "$ID" ] && echo svn "$ID" && return
c3b91b70cc42 Remove USE_ALT option, I have a better idea (upcoming patch).
Rob Landley <rob@landley.net>
parents: 1517
diff changeset
274 )
464
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
275 fi
760
2537f30c2397 Improve version detection for MANIFEST file. Still doesn't detect version for git archive output because git hasn't got any equivalent of mercurial's .hg_archive.txt file.
Rob Landley <rob@landley.net>
parents: 744
diff changeset
276
2537f30c2397 Improve version detection for MANIFEST file. Still doesn't detect version for git archive output because git hasn't got any equivalent of mercurial's .hg_archive.txt file.
Rob Landley <rob@landley.net>
parents: 744
diff changeset
277 echo release version $(get_download_version $1)
464
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
278 }
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
279
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
280 # Create a README identifying package versions in current build.
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
281
1390
ac60cab45463 Remove FWL debris and rename do_rename to do_manifest while we're at it. (Based on prompting from Alessio Bogani).
Rob Landley <rob@landley.net>
parents: 1389
diff changeset
282 do_manifest()
464
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
283 {
1390
ac60cab45463 Remove FWL debris and rename do_rename to do_manifest while we're at it. (Based on prompting from Alessio Bogani).
Rob Landley <rob@landley.net>
parents: 1389
diff changeset
284 # Grab build script version number
464
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
285
1390
ac60cab45463 Remove FWL debris and rename do_rename to do_manifest while we're at it. (Based on prompting from Alessio Bogani).
Rob Landley <rob@landley.net>
parents: 1389
diff changeset
286 [ -z "$SCRIPT_VERS" ] &&
1582
6a8114c148d1 Lots of small improvements: check for toybox instead of busybox for host-tools $PATH adjustment, better manifest generation (with toybox in list), make package_cache function to find extracted source (so root-image.sh works when packages contains linux-git snapshot), fix more/record-commands.sh path adjustment.
Rob Landley <rob@landley.net>
parents: 1553
diff changeset
287 SCRIPT_VERS="mercurial rev $(cd "$TOP"; hg identify -n 2>/dev/null)"
662
1fa9eb882e3b Allow FWL revision number to be overridden in MANIFEST (for releases).
Rob Landley <rob@landley.net>
parents: 647
diff changeset
288
464
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
289 cat << EOF
662
1fa9eb882e3b Allow FWL revision number to be overridden in MANIFEST (for releases).
Rob Landley <rob@landley.net>
parents: 647
diff changeset
290 Built on $(date +%F) from:
464
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
291
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
292 Build script:
1390
ac60cab45463 Remove FWL debris and rename do_rename to do_manifest while we're at it. (Based on prompting from Alessio Bogani).
Rob Landley <rob@landley.net>
parents: 1389
diff changeset
293 Aboriginal Linux (http://landley.net/aboriginal) $SCRIPT_VERS
464
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
294
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
295 Base packages:
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
296 uClibc (http://uclibc.org) $(identify_release uClibc)
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
297 BusyBox (http://busybox.net) $(identify_release busybox)
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
298 Linux (http://kernel.org/pub/linux/kernel) $(identify_release linux)
1582
6a8114c148d1 Lots of small improvements: check for toybox instead of busybox for host-tools $PATH adjustment, better manifest generation (with toybox in list), make package_cache function to find extracted source (so root-image.sh works when packages contains linux-git snapshot), fix more/record-commands.sh path adjustment.
Rob Landley <rob@landley.net>
parents: 1553
diff changeset
299 toybox (http://landley.net/toybox) $(identify_release toybox)
464
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
300
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
301 Toolchain packages:
915
a541c5a96ff3 Don't actually replace cross-compiler with cross-static, when you build both use $PATH to select which one to use.
Rob Landley <rob@landley.net>
parents: 904
diff changeset
302 Binutils (http://www.gnu.org/software/binutils/) $(identify_release binutils)
464
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
303 GCC (http://gcc.gnu.org) $(identify_release gcc-core)
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
304 gmake (http://www.gnu.org/software/make) $(identify_release make)
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
305 bash (ftp://ftp.gnu.org/gnu/bash) $(identify_release bash)
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
306
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
307 Optional packages:
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
308 distcc (http://distcc.samba.org) $(identify_release distcc)
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
309 uClibc++ (http://cxx.uclibc.org) $(identify_release uClibc++)
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
310 EOF
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
311 }
685
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
312
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
313 # When building with a base architecture, symlink to the base arch name.
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
314
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
315 link_arch_name()
685
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
316 {
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
317 [ "$ARCH" == "$ARCH_NAME" ] && return 0
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
318
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
319 rm -rf "$BUILD/$2" &&
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
320 ln -s "$1" "$BUILD/$2" || dienow
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
321 }
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
322
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
323 # Check if this target has a base architecture that's already been built.
915
a541c5a96ff3 Don't actually replace cross-compiler with cross-static, when you build both use $PATH to select which one to use.
Rob Landley <rob@landley.net>
parents: 904
diff changeset
324 # If so, link to it and exit now.
685
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
325
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
326 check_for_base_arch()
685
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
327 {
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
328 # If we're building something with a base architecture, symlink to actual
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
329 # target.
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
330
898
db0f536aee7c Fix hw-target builds so prerequisites build if they don't already exist.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
331 if [ "$ARCH" != "$ARCH_NAME" ]
685
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
332 then
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 778
diff changeset
333 link_arch_name $STAGE_NAME-{"$ARCH","$ARCH_NAME"}
1737
1acbe7e78d9d Switch from bz2 to gz tarball output.
Rob Landley <rob@landley.net>
parents: 1728
diff changeset
334 [ -e $STAGE_NAME-"$ARCH".tar.gz ] &&
1acbe7e78d9d Switch from bz2 to gz tarball output.
Rob Landley <rob@landley.net>
parents: 1728
diff changeset
335 link_arch_name $STAGE_NAME-{"$ARCH","$ARCH_NAME"}.tar.gz
685
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
336
898
db0f536aee7c Fix hw-target builds so prerequisites build if they don't already exist.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
337 if [ -e "$BUILD/$STAGE_NAME-$ARCH" ]
db0f536aee7c Fix hw-target builds so prerequisites build if they don't already exist.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
338 then
1358
9252453c40d0 Combine set_titlebar and "echo ===" stuff into announce() function. Consistently output target/stage info, and yank redundant instances.
Rob Landley <rob@landley.net>
parents: 1253
diff changeset
339 announce "Using existing ${STAGE_NAME}-$ARCH"
898
db0f536aee7c Fix hw-target builds so prerequisites build if they don't already exist.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
340
db0f536aee7c Fix hw-target builds so prerequisites build if they don't already exist.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
341 return 1
db0f536aee7c Fix hw-target builds so prerequisites build if they don't already exist.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
342 else
db0f536aee7c Fix hw-target builds so prerequisites build if they don't already exist.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
343 mkdir -p "$BUILD/$STAGE_NAME-$ARCH" || dienow
db0f536aee7c Fix hw-target builds so prerequisites build if they don't already exist.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
344 fi
685
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
345 fi
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
346 }
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
347
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
348 create_stage_tarball()
685
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
349 {
1033
87b3a69ca71c Delete empty build/temp-* directories when we're done with them.
Rob Landley <rob@landley.net>
parents: 1012
diff changeset
350 # Remove the temporary directory, if empty
87b3a69ca71c Delete empty build/temp-* directories when we're done with them.
Rob Landley <rob@landley.net>
parents: 1012
diff changeset
351
87b3a69ca71c Delete empty build/temp-* directories when we're done with them.
Rob Landley <rob@landley.net>
parents: 1012
diff changeset
352 rmdir "$WORK" 2>/dev/null
87b3a69ca71c Delete empty build/temp-* directories when we're done with them.
Rob Landley <rob@landley.net>
parents: 1012
diff changeset
353
685
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
354 # Handle linking to base architecture if we just built a derivative target.
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
355
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
356 cd "$BUILD" || dienow
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 778
diff changeset
357 link_arch_name $STAGE_NAME-{$ARCH,$ARCH_NAME}
685
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
358
988
30e4bab11f9e Rename SKIP_STAGE_TARBALLS to NO_STAGE_TARBALLS (for consistency), and make system-image.sh use it instead of doing it by hand.
Rob Landley <rob@landley.net>
parents: 984
diff changeset
359 if [ -z "$NO_STAGE_TARBALLS" ]
685
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
360 then
1737
1acbe7e78d9d Switch from bz2 to gz tarball output.
Rob Landley <rob@landley.net>
parents: 1728
diff changeset
361 echo -n creating "$STAGE_NAME-${ARCH}".tar.gz
685
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
362
1737
1acbe7e78d9d Switch from bz2 to gz tarball output.
Rob Landley <rob@landley.net>
parents: 1728
diff changeset
363 { tar czvf "$STAGE_NAME-${ARCH}".tar.gz "$STAGE_NAME-${ARCH}" || dienow
685
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
364 } | dotprogress
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
365
1737
1acbe7e78d9d Switch from bz2 to gz tarball output.
Rob Landley <rob@landley.net>
parents: 1728
diff changeset
366 link_arch_name $STAGE_NAME-{$ARCH,$ARCH_NAME}.tar.gz
685
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
367 fi
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 683
diff changeset
368 }
776
37c083cca810 Move doforklog to sources/functions.sh.
Rob Landley <rob@landley.net>
parents: 773
diff changeset
369
796
5f793a1ca658 Teach host-tools.sh to create multiple symlinks in fallback directories for ccache and distcc.
Rob Landley <rob@landley.net>
parents: 787
diff changeset
370 # Create colon-separated path for $HOSTTOOLS and all fallback directories
5f793a1ca658 Teach host-tools.sh to create multiple symlinks in fallback directories for ccache and distcc.
Rob Landley <rob@landley.net>
parents: 787
diff changeset
371 # (Fallback directories are to support ccache and distcc on the host.)
5f793a1ca658 Teach host-tools.sh to create multiple symlinks in fallback directories for ccache and distcc.
Rob Landley <rob@landley.net>
parents: 787
diff changeset
372
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
373 hosttools_path()
796
5f793a1ca658 Teach host-tools.sh to create multiple symlinks in fallback directories for ccache and distcc.
Rob Landley <rob@landley.net>
parents: 787
diff changeset
374 {
5f793a1ca658 Teach host-tools.sh to create multiple symlinks in fallback directories for ccache and distcc.
Rob Landley <rob@landley.net>
parents: 787
diff changeset
375 local X
5f793a1ca658 Teach host-tools.sh to create multiple symlinks in fallback directories for ccache and distcc.
Rob Landley <rob@landley.net>
parents: 787
diff changeset
376
5f793a1ca658 Teach host-tools.sh to create multiple symlinks in fallback directories for ccache and distcc.
Rob Landley <rob@landley.net>
parents: 787
diff changeset
377 echo -n "$HOSTTOOLS"
5f793a1ca658 Teach host-tools.sh to create multiple symlinks in fallback directories for ccache and distcc.
Rob Landley <rob@landley.net>
parents: 787
diff changeset
378 X=1
5f793a1ca658 Teach host-tools.sh to create multiple symlinks in fallback directories for ccache and distcc.
Rob Landley <rob@landley.net>
parents: 787
diff changeset
379 while [ -e "$HOSTTOOLS/fallback-$X" ]
5f793a1ca658 Teach host-tools.sh to create multiple symlinks in fallback directories for ccache and distcc.
Rob Landley <rob@landley.net>
parents: 787
diff changeset
380 do
5f793a1ca658 Teach host-tools.sh to create multiple symlinks in fallback directories for ccache and distcc.
Rob Landley <rob@landley.net>
parents: 787
diff changeset
381 echo -n ":$HOSTTOOLS/fallback-$X"
5f793a1ca658 Teach host-tools.sh to create multiple symlinks in fallback directories for ccache and distcc.
Rob Landley <rob@landley.net>
parents: 787
diff changeset
382 X=$[$X+1]
5f793a1ca658 Teach host-tools.sh to create multiple symlinks in fallback directories for ccache and distcc.
Rob Landley <rob@landley.net>
parents: 787
diff changeset
383 done
5f793a1ca658 Teach host-tools.sh to create multiple symlinks in fallback directories for ccache and distcc.
Rob Landley <rob@landley.net>
parents: 787
diff changeset
384 }
1606
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
385
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
386 # Archive directory $1 to file $2 (plus extension), type SYSIMAGE_TYPE
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
387
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
388 image_filesystem()
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
389 {
1784
d8ea81a06fdd More verbose output for filesystem image creation.
Rob Landley <rob@landley.net>
parents: 1741
diff changeset
390 echo "make $SYSIMAGE_TYPE $2"
d8ea81a06fdd More verbose output for filesystem image creation.
Rob Landley <rob@landley.net>
parents: 1741
diff changeset
391
1606
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
392 # Embed an initramfs cpio
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
393
1728
b89324905ca2 Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents: 1631
diff changeset
394 if [ "$SYSIMAGE_TYPE" == "cpio" ] || [ "$SYSIMAGE_TYPE" == "rootfs" ]
1606
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
395 then
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
396 # Borrow gen_init_cpio.c out of package cache copy of Linux source
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
397 extract_package linux &&
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
398 $CC "$(package_cache $PACKAGE)/usr/gen_init_cpio.c" -o "$WORK"/my_gen_init_cpio ||
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
399 dienow
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
400 "$WORK"/my_gen_init_cpio <(
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
401 "$SOURCES"/toys/gen_initramfs_list.sh "$1" || dienow
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
402 [ ! -e "$1"/init ] &&
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
403 echo "slink /init /sbin/init.sh 755 0 0"
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
404 [ ! -d "$1"/dev ] && echo "dir /dev 755 0 0"
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
405 echo "nod /dev/console 660 0 0 c 5 1"
1728
b89324905ca2 Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents: 1631
diff changeset
406 ) | gzip -9 > "$2.cpio.gz" || dienow
1606
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
407 echo Initramfs generated.
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
408
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
409 elif [ "$SYSIMAGE_TYPE" == "ext2" ] || [ "$SYSIMAGE_TYPE" == "ext3" ]
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
410 then
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
411 # Generate axn ext2 filesystem image from the $1 directory, with a
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
412 # temporary file defining the /dev nodes for the new filesystem.
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
413
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
414 [ -z "$SYSIMAGE_HDA_MEGS" ] && SYSIMAGE_HDA_MEGS=64
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
415
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
416 # Produce a filesystem with the currently used space plus 20% for filesystem
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
417 # overhead, which should always be big enough.
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
418
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
419 BLOCKS=$[1024*(($(du -m -s "$1" | awk '{print $1}')*12)/10)]
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
420 [ $BLOCKS -lt 4096 ] && BLOCKS=4096
1631
18cafed76d65 Fix ext2/ext3 build failures
Guenter Roeck <linux@roeck-us.net>
parents: 1617
diff changeset
421 FILE="$2.$SYSIMAGE_TYPE"
1606
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
422
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
423 echo "/dev d 755 0 0 - - - - -" > "$WORK/devs" &&
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
424 echo "/dev/console c 640 0 0 5 1 0 0 -" >> "$WORK/devs" &&
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
425 genext2fs -z -D "$WORK/devs" -d "$1" -b $BLOCKS -i 1024 "$FILE" &&
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
426 rm "$WORK/devs" || dienow
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
427
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
428 # Extend image size to HDA_MEGS if necessary, keeping it sparse. (Feeding
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
429 # a larger -b size to genext2fs is insanely slow, and not particularly
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
430 # sparse.)
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
431
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
432 if [ ! -z "$SYSIMAGE_HDA_MEGS" ] &&
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
433 [ $((`stat -c %s "$FILE"` / (1024*1024) )) -lt "$SYSIMAGE_HDA_MEGS" ]
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
434 then
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
435 echo resizing image to $SYSIMAGE_HDA_MEGS
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
436 resize2fs "$FILE" ${SYSIMAGE_HDA_MEGS}M || dienow
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
437 fi
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
438
1631
18cafed76d65 Fix ext2/ext3 build failures
Guenter Roeck <linux@roeck-us.net>
parents: 1617
diff changeset
439 tune2fs -c 0 -i 0 $([ "$SYS_IMAGE_TYPE" = "ext3" ] && echo -j) "$FILE" || dienow
1606
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
440 echo $SYSIMAGE_TYPE generated
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
441
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
442 elif [ "$SYSIMAGE_TYPE" == "squashfs" ]
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
443 then
1738
cdc277cf7b83 Don't add /dev/console to the native-compiler squashfs.
Rob Landley <rob@landley.net>
parents: 1737
diff changeset
444 mksquashfs "$1" "$2.sqf" -noappend -all-root ${FORK:+-no-progress} || dienow
1606
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
445 else
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
446 echo "Unknown image type $SYSIMAGE_TYPE" >&2
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
447 dienow
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
448 fi
941d2bf65620 Move image creation logic into sources/functions.sh so we can create cpio and squashfs in the same build.
Rob Landley <rob@landley.net>
parents: 1582
diff changeset
449 }