annotate sources/functions.sh @ 1200:8651437b2b44

Add DEBUG_PACKAGE config variable to build just one package with CPUS=1.
author Rob Landley <rob@landley.net>
date Tue, 10 Aug 2010 00:04:30 -0500
parents aa8992b35e15
children ac8d9db5cf37
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
919
8b69eeb17ebf Break up sources/functions.sh starting with some of the more obviously independent ones.
Rob Landley <rob@landley.net>
parents: 915
diff changeset
5 source sources/utility_functions.sh
8b69eeb17ebf Break up sources/functions.sh starting with some of the more obviously independent ones.
Rob Landley <rob@landley.net>
parents: 915
diff changeset
6
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
7 # 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
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 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
10 {
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
11 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
12
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
13 # 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
14
944
fc134a13357e Largeish refactoring and cleanup of compiler build:
Rob Landley <rob@landley.net>
parents: 942
diff changeset
15 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
16 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
17 [ -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
18 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
19 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
20 }
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
21
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
22 read_arch_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
23 {
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
24 # 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
25
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
26 ARCH_NAME="$1"
817
a6cb42614a1d Rename build/sources to build/packages to reduce confusion (since sources/packages got moved up to just packages, and this contains the extracted contents of that). And use $SOURCES instead of $TOP/sources in a few places.
Rob Landley <rob@landley.net>
parents: 815
diff changeset
27 if [ ! -f "${SOURCES}/targets/${ARCH_NAME}/settings" ]
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
28 then
759adf5a0fe9 Refactor so include.sh mostly just sets environment variables. Move read_arch_dir to function and call it explicitly (no more need for $NO_ARCH). Make blank_tempdir a function, called explicitly by stages when needed, with some sanity checks. Insert prerequisite tests to later stages so they can detect failure early and provide an explicit erro rmessage, and have those tests happen before blanking $WORK dir, to preserve debugging info. Make buildall.sh depend on prerequisite tests rather than trying to avoid calling later stages (and thus do flow control from asynchronous context). Add FAIL_QUIET option so buildall.sh doesn't spam the log with the new prerequisite error messages.
Rob Landley <rob@landley.net>
parents: 727
diff changeset
29 echo "Supported architectures: "
817
a6cb42614a1d Rename build/sources to build/packages to reduce confusion (since sources/packages got moved up to just packages, and this contains the extracted contents of that). And use $SOURCES instead of $TOP/sources in a few places.
Rob Landley <rob@landley.net>
parents: 815
diff changeset
30 (cd "${SOURCES}/targets" && ls)
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
31
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
32 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
33 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
34
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
35 # Read the relevant config file.
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
36
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 ARCH="$ARCH_NAME"
817
a6cb42614a1d Rename build/sources to build/packages to reduce confusion (since sources/packages got moved up to just packages, and this contains the extracted contents of that). And use $SOURCES instead of $TOP/sources in a few places.
Rob Landley <rob@landley.net>
parents: 815
diff changeset
38 CONFIG_DIR="${SOURCES}/targets"
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
39 source "${CONFIG_DIR}/${ARCH}/settings"
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
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
41 # 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
42
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
43 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
44
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
45 # 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
46 # 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
47 # 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
48 # 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
49 # wrong libc.)
984
9840847885e8 Add export_if_blank and make lots of build paths overrideable.
Rob Landley <rob@landley.net>
parents: 973
diff changeset
50 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
51 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
52
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
53 # 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
54
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
55 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
56
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
57 blank_tempdir "$STAGE_DIR"
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
58 blank_tempdir "$WORK"
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
59
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
60 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
61 [ ! -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
62 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
63
944
fc134a13357e Largeish refactoring and cleanup of compiler build:
Rob Landley <rob@landley.net>
parents: 942
diff changeset
64 DO_CROSS="CROSS_COMPILE=${ARCH}-"
798
2c9f22daa8fe Allow target settings to specify BUILD_STATIC.
Rob Landley <rob@landley.net>
parents: 796
diff changeset
65
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
66 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
67 }
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
820
d1a88d878e18 Factor out and unify binutils, gcc, and ccwrap builds.
Rob Landley <rob@landley.net>
parents: 818
diff changeset
69 # 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
70 # 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
71
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
72 build_section()
820
d1a88d878e18 Factor out and unify binutils, gcc, and ccwrap builds.
Rob Landley <rob@landley.net>
parents: 818
diff changeset
73 {
1084
b52ba5df878d Don't build anything statically in host-tools.sh, glibc is broken.
Rob Landley <rob@landley.net>
parents: 1083
diff changeset
74 # 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
75 # 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
76 # 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
77 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
78
1200
8651437b2b44 Add DEBUG_PACKAGE config variable to build just one package with CPUS=1.
Rob Landley <rob@landley.net>
parents: 1184
diff changeset
79 OLDCPUS=$CPUS
8651437b2b44 Add DEBUG_PACKAGE config variable to build just one package with CPUS=1.
Rob Landley <rob@landley.net>
parents: 1184
diff changeset
80 is_in_list $1 $DEBUG_PACKAGE && CPUS=1
8651437b2b44 Add DEBUG_PACKAGE config variable to build just one package with CPUS=1.
Rob Landley <rob@landley.net>
parents: 1184
diff changeset
81
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
82 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
83 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
84 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
85 . "$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
86 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
87 else
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
88 echo "=== build section $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
89 . "$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
90 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
91 CPUS=$OLDCPUS
820
d1a88d878e18 Factor out and unify binutils, gcc, and ccwrap builds.
Rob Landley <rob@landley.net>
parents: 818
diff changeset
92 }
d1a88d878e18 Factor out and unify binutils, gcc, and ccwrap builds.
Rob Landley <rob@landley.net>
parents: 818
diff changeset
93
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
94 # 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
95
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
96 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
97 {
1082
255488af0bbb Convert unstable() to is_in_list() taking the list to check as the second argument.
Rob Landley <rob@landley.net>
parents: 1081
diff changeset
98 for i in $(is_in_list $1 $USE_UNSTABLE && echo {$ARCH_NAME,$ARCH}/miniconfig-alt-$1) \
581
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 567
diff changeset
99 {$ARCH_NAME,$ARCH}/miniconfig-$1
9dffdd74c186 More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents: 567
diff changeset
100 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
101 [ -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
102 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
103
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
104 # 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
105 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
106 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
107 }
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
108
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
109 # 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
110
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
111 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
112 {
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
113 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
114 (cd "$STAGE_DIR" || 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
115 find . -depth -newer "$CURSRC/FWL-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
116 | 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
117 ) | 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
118 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
119 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
120
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
121 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
122 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
123 # 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
124 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
125 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
126 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
127 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
128 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
129 }
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
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
131 # Strip the version number off a tarball
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
132
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
133 cleanup()
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
134 {
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
135 # 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
136
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
137 [ $? -ne 0 ] && dienow
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
138
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
139 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
140 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
141 TARNAME="$PACKAGE-$STAGE_NAME-${ARCH_NAME}".tar.bz2
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 echo -n Creating "$TARNAME"
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 { recent_binary_files | xargs -0 tar -cjvf \
1012
4d59b8946220 Bugfix by David Seikel: don't append .tar.bz2 twice to BINARY_PACKAGE_TARBALLS.
Rob Landley <rob@landley.net>
parents: 1010
diff changeset
144 "$BUILD/${TARNAME}" -C "$STAGE_DIR" || 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
145 } | dotprogress
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 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
147
567
5619a7375b74 Add NO_CLEANUP option to config.
Rob Landley <rob@landley.net>
parents: 534
diff changeset
148 if [ ! -z "$NO_CLEANUP" ]
5619a7375b74 Add NO_CLEANUP option to config.
Rob Landley <rob@landley.net>
parents: 534
diff changeset
149 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
150 echo "skip cleanup $PACKAGE $@"
567
5619a7375b74 Add NO_CLEANUP option to config.
Rob Landley <rob@landley.net>
parents: 534
diff changeset
151 return
5619a7375b74 Add NO_CLEANUP option to config.
Rob Landley <rob@landley.net>
parents: 534
diff changeset
152 fi
5619a7375b74 Add NO_CLEANUP option to config.
Rob Landley <rob@landley.net>
parents: 534
diff changeset
153
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
154 # 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
155
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 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
157 for i in $WORKDIR_LIST
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
158 do
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
159 echo "cleanup $i"
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
160 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
161 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
162 WORKDIR_LIST=
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
163 }
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
164
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
165 # Give filename.tar.ext minus the version number.
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
166
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
167 noversion()
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
168 {
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
169 echo "$1" | sed -e 's/-*\(\([0-9\.]\)*\([_-]rc\)*\(-pre\)*\([0-9][a-zA-Z]\)*\)*\(\.tar\..z2*\)$/'"$2"'\6/'
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
170 }
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
171
440
59fe5a276991 Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents: 436
diff changeset
172 # Given a filename.tar.ext, return the versino number.
59fe5a276991 Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents: 436
diff changeset
173
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
174 getversion()
440
59fe5a276991 Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents: 436
diff changeset
175 {
59fe5a276991 Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents: 436
diff changeset
176 echo "$1" | sed -e 's/.*-\(\([0-9\.]\)*\([_-]rc\)*\(-pre\)*\([0-9][a-zA-Z]\)*\)*\(\.tar\..z2*\)$/'"$2"'\1/'
59fe5a276991 Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents: 436
diff changeset
177 }
59fe5a276991 Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents: 436
diff changeset
178
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
179 # Give package name, minus file's version number and archive extension.
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
180
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
181 basename()
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
182 {
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
183 noversion $1 | sed 's/\.tar\..z2*$//'
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
184 }
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
185
1010
98dbfffd3b0a Allow existing extracted source directry to be patched if necessary, even if tarball doesn't exist. (This lets a git bisect happen in situ under build/packages.)
Rob Landley <rob@landley.net>
parents: 998
diff changeset
186 # Apply any patches to this package
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
187 patch_package()
1010
98dbfffd3b0a Allow existing extracted source directry to be patched if necessary, even if tarball doesn't exist. (This lets a git bisect happen in situ under build/packages.)
Rob Landley <rob@landley.net>
parents: 998
diff changeset
188 {
98dbfffd3b0a Allow existing extracted source directry to be patched if necessary, even if tarball doesn't exist. (This lets a git bisect happen in situ under build/packages.)
Rob Landley <rob@landley.net>
parents: 998
diff changeset
189 ls "$PATCHDIR/${PACKAGE}"-* 2> /dev/null | sort | while read i
98dbfffd3b0a Allow existing extracted source directry to be patched if necessary, even if tarball doesn't exist. (This lets a git bisect happen in situ under build/packages.)
Rob Landley <rob@landley.net>
parents: 998
diff changeset
190 do
98dbfffd3b0a Allow existing extracted source directry to be patched if necessary, even if tarball doesn't exist. (This lets a git bisect happen in situ under build/packages.)
Rob Landley <rob@landley.net>
parents: 998
diff changeset
191 if [ -f "$i" ]
98dbfffd3b0a Allow existing extracted source directry to be patched if necessary, even if tarball doesn't exist. (This lets a git bisect happen in situ under build/packages.)
Rob Landley <rob@landley.net>
parents: 998
diff changeset
192 then
98dbfffd3b0a Allow existing extracted source directry to be patched if necessary, even if tarball doesn't exist. (This lets a git bisect happen in situ under build/packages.)
Rob Landley <rob@landley.net>
parents: 998
diff changeset
193 echo "Applying $i"
1162
9ea6b72beabc Fix patching so sha1-for-source.txt only gets updated _after_ patch successfully applies (race with signal delivery), and make dienow output go to stderr instead of stdout.
Rob Landley <rob@landley.net>
parents: 1158
diff changeset
194 (cd "${SRCTREE}/${PACKAGE}" &&
9ea6b72beabc Fix patching so sha1-for-source.txt only gets updated _after_ patch successfully applies (race with signal delivery), and make dienow output go to stderr instead of stdout.
Rob Landley <rob@landley.net>
parents: 1158
diff changeset
195 patch -p1 -i "$i" &&
9ea6b72beabc Fix patching so sha1-for-source.txt only gets updated _after_ patch successfully applies (race with signal delivery), and make dienow output go to stderr instead of stdout.
Rob Landley <rob@landley.net>
parents: 1158
diff changeset
196 sha1file "$i" >> "$SHA1FILE") ||
1098
8f72a8d4acc3 Add ALLOW_PATCH_FAILURE config switch to continue despite failed patches.
Rob Landley <rob@landley.net>
parents: 1094
diff changeset
197 ([ -z "$ALLOW_PATCH_FAILURE" ] && dienow)
1010
98dbfffd3b0a Allow existing extracted source directry to be patched if necessary, even if tarball doesn't exist. (This lets a git bisect happen in situ under build/packages.)
Rob Landley <rob@landley.net>
parents: 998
diff changeset
198 fi
98dbfffd3b0a Allow existing extracted source directry to be patched if necessary, even if tarball doesn't exist. (This lets a git bisect happen in situ under build/packages.)
Rob Landley <rob@landley.net>
parents: 998
diff changeset
199 done
98dbfffd3b0a Allow existing extracted source directry to be patched if necessary, even if tarball doesn't exist. (This lets a git bisect happen in situ under build/packages.)
Rob Landley <rob@landley.net>
parents: 998
diff changeset
200 }
98dbfffd3b0a Allow existing extracted source directry to be patched if necessary, even if tarball doesn't exist. (This lets a git bisect happen in situ under build/packages.)
Rob Landley <rob@landley.net>
parents: 998
diff changeset
201
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
202 # Extract tarball named in $1 and apply all relevant patches into
817
a6cb42614a1d Rename build/sources to build/packages to reduce confusion (since sources/packages got moved up to just packages, and this contains the extracted contents of that). And use $SOURCES instead of $TOP/sources in a few places.
Rob Landley <rob@landley.net>
parents: 815
diff changeset
203 # "$BUILD/packages/$1". Record sha1sum of tarball and patch files in
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
204 # sha1-for-source.txt. Re-extract if tarball or patches change.
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
205
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
206 extract_package()
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
207 {
1184
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
208 mkdir -p "$SRCTREE" || dienow
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
209
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
210 # Figure out whether we're using an unstable package.
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
211
1184
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
212 PACKAGE="$1"
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
213 is_in_list "$PACKAGE" $USE_UNSTABLE && PACKAGE=alt-"$PACKAGE"
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
214
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
215 # Announce to the world that we're cracking open a new package
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
216
1184
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
217 echo "=== $PACKAGE ($ARCH_NAME $STAGE_NAME)"
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
218 set_titlebar "$ARCH_NAME $STAGE_NAME $PACKAGE"
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
219
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
220 # Find tarball, and determine type
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
221
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
222 FILENAME="$(echo "$SRCDIR/${PACKAGE}-"*.tar*)"
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
223 DECOMPRESS=""
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
224 [ "$FILENAME" != "${FILENAME/%\.tar\.bz2/}" ] && DECOMPRESS="j"
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
225 [ "$FILENAME" != "${FILENAME/%\.tar\.gz/}" ] && DECOMPRESS="z"
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
226
665
17fc6a3bffa4 Allow build to run with build/sources but not source tarballs. (Makes build-static-toolchains.sh slightly easier.)
Rob Landley <rob@landley.net>
parents: 662
diff changeset
227 # If the source tarball doesn't exist, but the extracted directory is there,
17fc6a3bffa4 Allow build to run with build/sources but not source tarballs. (Makes build-static-toolchains.sh slightly easier.)
Rob Landley <rob@landley.net>
parents: 662
diff changeset
228 # assume everything's ok.
17fc6a3bffa4 Allow build to run with build/sources but not source tarballs. (Makes build-static-toolchains.sh slightly easier.)
Rob Landley <rob@landley.net>
parents: 662
diff changeset
229
1184
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
230 SHA1FILE="$SRCTREE/$PACKAGE/sha1-for-source.txt"
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
231 if [ ! -e "$FILENAME" ] && [ -e "$SRCTREE/$PACKAGE" ]
1010
98dbfffd3b0a Allow existing extracted source directry to be patched if necessary, even if tarball doesn't exist. (This lets a git bisect happen in situ under build/packages.)
Rob Landley <rob@landley.net>
parents: 998
diff changeset
232 then
1184
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
233 # If the sha1sum file isn't there, re-patch the package.
1010
98dbfffd3b0a Allow existing extracted source directry to be patched if necessary, even if tarball doesn't exist. (This lets a git bisect happen in situ under build/packages.)
Rob Landley <rob@landley.net>
parents: 998
diff changeset
234 [ ! -e "$SHA1FILE" ] && patch_package
98dbfffd3b0a Allow existing extracted source directry to be patched if necessary, even if tarball doesn't exist. (This lets a git bisect happen in situ under build/packages.)
Rob Landley <rob@landley.net>
parents: 998
diff changeset
235 return 0
98dbfffd3b0a Allow existing extracted source directry to be patched if necessary, even if tarball doesn't exist. (This lets a git bisect happen in situ under build/packages.)
Rob Landley <rob@landley.net>
parents: 998
diff changeset
236 fi
676
112dc7b787d3 Fix hg 665 so it actually works. (Make setupfor work when build/sources/package exists but there's no packages/package-*.tar* file.)
Rob Landley <rob@landley.net>
parents: 668
diff changeset
237
1184
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
238 # Check the sha1 list from the previous extract. If the source is already
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
239 # up to date (including patches), keep it.
665
17fc6a3bffa4 Allow build to run with build/sources but not source tarballs. (Makes build-static-toolchains.sh slightly easier.)
Rob Landley <rob@landley.net>
parents: 662
diff changeset
240
1184
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
241 SHA1TAR="$(sha1file "$FILENAME")"
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
242 SHALIST=$(cat "$SHA1FILE" 2> /dev/null)
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
243 if [ ! -z "$SHALIST" ]
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
244 then
1184
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
245 for i in "$SHA1TAR" $(sha1file "$PATCHDIR/$PACKAGE"-* 2>/dev/null)
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
246 do
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
247 # Is this sha1 in the file?
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
248 if [ -z "$(echo "$SHALIST" | sed -n "s/$i/$i/p" )" ]
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
249 then
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
250 SHALIST=missing
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
251 break
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
252 fi
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
253 # Remove it
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
254 SHALIST="$(echo "$SHALIST" | sed "s/$i//" )"
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
255 done
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
256 # If we matched all the sha1sums, nothing more to do.
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
257 [ -z "$SHALIST" ] && return 0
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
258 fi
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
259
1184
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
260 # Re-extract the package, deleting the old one (if any)..
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
261
1184
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
262 echo -n "Extracting '$PACKAGE'"
989
93830ce35f85 Make extract use unique temporary directories so it's parallelizable.
Rob Landley <rob@landley.net>
parents: 988
diff changeset
263 (
990
00704bb2c556 Add FORK=1 support to download.sh, and work around bash's $$ refusing to give an actual unique $PID for subshells by groveling around in /proc to find something usable.
Rob Landley <rob@landley.net>
parents: 989
diff changeset
264 UNIQUE=$(readlink /proc/self)
00704bb2c556 Add FORK=1 support to download.sh, and work around bash's $$ refusing to give an actual unique $PID for subshells by groveling around in /proc to find something usable.
Rob Landley <rob@landley.net>
parents: 989
diff changeset
265 trap 'rm -rf "$BUILD/temp-'$UNIQUE'"' EXIT
1184
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
266 rm -rf "$SRCTREE/$PACKAGE" 2>/dev/null
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
267 mkdir -p "$BUILD"/{temp-$UNIQUE,packages} || dienow
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
268
1184
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
269 { tar -xv${DECOMPRESS} -f "$FILENAME" -C "$BUILD/temp-$UNIQUE" || dienow
989
93830ce35f85 Make extract use unique temporary directories so it's parallelizable.
Rob Landley <rob@landley.net>
parents: 988
diff changeset
270 } | dotprogress
93830ce35f85 Make extract use unique temporary directories so it's parallelizable.
Rob Landley <rob@landley.net>
parents: 988
diff changeset
271
1184
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
272 mv "$BUILD/temp-$UNIQUE/"* "$SRCTREE/$PACKAGE" &&
989
93830ce35f85 Make extract use unique temporary directories so it's parallelizable.
Rob Landley <rob@landley.net>
parents: 988
diff changeset
273 echo "$SHA1TAR" > "$SHA1FILE"
93830ce35f85 Make extract use unique temporary directories so it's parallelizable.
Rob Landley <rob@landley.net>
parents: 988
diff changeset
274 )
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
275
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
276 [ $? -ne 0 ] && dienow
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
277
1010
98dbfffd3b0a Allow existing extracted source directry to be patched if necessary, even if tarball doesn't exist. (This lets a git bisect happen in situ under build/packages.)
Rob Landley <rob@landley.net>
parents: 998
diff changeset
278 patch_package
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
279 }
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
280
961
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
281 # Confirm that a file has the appropriate checksum (or exists but SHA1 is blank)
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
282 # Delete invalid file.
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
283
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
284 confirm_checksum()
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
285 {
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
286 SUM="$(sha1file "$SRCDIR/$FILENAME" 2>/dev/null)"
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
287 if [ x"$SUM" == x"$SHA1" ] || [ -z "$SHA1" ] && [ -f "$SRCDIR/$FILENAME" ]
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
288 then
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
289 if [ -z "$SHA1" ]
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
290 then
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
291 echo "No SHA1 for $FILENAME ($SUM)"
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
292 else
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
293 echo "Confirmed $FILENAME"
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
294 fi
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
295
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
296 # Preemptively extract source packages?
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
297
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
298 [ -z "$EXTRACT_ALL" ] && return 0
1184
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
299 extract_package "$(basename "$FILENAME")"
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
300 return $?
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
301 fi
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
302
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
303 # If there's a corrupted file, delete it. In theory it would be nice
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
304 # to resume downloads, but wget creates "*.1" files instead.
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
305
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
306 rm "$SRCDIR/$FILENAME" 2> /dev/null
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
307
961
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
308 return 1
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
309 }
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
310
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
311 # Attempt to obtain file from a specific location
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
312
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
313 download_from()
961
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
314 {
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
315 # Return success if we already have a valid copy of the file
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
316
961
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
317 confirm_checksum && return 0
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
318
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
319 # If we have another source, try to download file from there.
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
320
965
bcab030a2394 Fix thinko in download_from.
Rob Landley <rob@landley.net>
parents: 961
diff changeset
321 [ -z "$1" ] && return 1
961
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
322 wget -t 2 -T 20 -O "$SRCDIR/$FILENAME" "$1" ||
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
323 (rm "$SRCDIR/$FILENAME"; return 2)
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
324 touch -c "$SRCDIR/$FILENAME"
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
325
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
326 confirm_checksum
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
327 }
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
328
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
329 # Confirm a file matches sha1sum, else try to download it from mirror list.
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
330
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
331 download()
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
332 {
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
333 FILENAME=`echo "$URL" | sed 's .*/ '`
683
3c09987974c8 Allow UNSTABLE=squashfs to download cvs snapshot with 4.0 support (but still not equivalent to genext2fs -D or gen_cpio_init's text file input, for creating /dev/console without root access).
Rob Landley <rob@landley.net>
parents: 676
diff changeset
334 [ -z "$RENAME" ] || FILENAME="$(echo "$FILENAME" | sed -r "$RENAME")"
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
335 ALTFILENAME=alt-"$(noversion "$FILENAME" -0)"
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
336
595
161e2bca18f4 Add slightly more debugging/status info to download.
Rob Landley <rob@landley.net>
parents: 582
diff changeset
337 echo -ne "checking $FILENAME\r"
161e2bca18f4 Add slightly more debugging/status info to download.
Rob Landley <rob@landley.net>
parents: 582
diff changeset
338
768
27f007ea2129 Keep unstable tarballs around even when you do a build that doesn't use 'em.
Rob Landley <rob@landley.net>
parents: 767
diff changeset
339 # Update timestamps on both stable and unstable tarballs (if any)
961
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
340 # so cleanup_oldfiles doesn't delete stable when we're building unstable
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
341 # or vice versa
1b971ccf5193 More code cleanups (rename try_checksum to confirm_checksum).
Rob Landley <rob@landley.net>
parents: 959
diff changeset
342
768
27f007ea2129 Keep unstable tarballs around even when you do a build that doesn't use 'em.
Rob Landley <rob@landley.net>
parents: 767
diff changeset
343 touch -c "$SRCDIR"/{"$FILENAME","$ALTFILENAME"} 2>/dev/null
27f007ea2129 Keep unstable tarballs around even when you do a build that doesn't use 'em.
Rob Landley <rob@landley.net>
parents: 767
diff changeset
344
959
5a2afff0d00c Rename try_download() to download_from().
Rob Landley <rob@landley.net>
parents: 944
diff changeset
345 # If unstable version selected, try from listed location, and fall back
5a2afff0d00c Rename try_download() to download_from().
Rob Landley <rob@landley.net>
parents: 944
diff changeset
346 # to PREFERRED_MIRROR. Do not try normal mirror locations for unstable.
5a2afff0d00c Rename try_download() to download_from().
Rob Landley <rob@landley.net>
parents: 944
diff changeset
347
1082
255488af0bbb Convert unstable() to is_in_list() taking the list to check as the second argument.
Rob Landley <rob@landley.net>
parents: 1081
diff changeset
348 if is_in_list "$(basename "$FILENAME")" $USE_UNSTABLE
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
349 then
959
5a2afff0d00c Rename try_download() to download_from().
Rob Landley <rob@landley.net>
parents: 944
diff changeset
350 FILENAME="$ALTFILENAME"
5a2afff0d00c Rename try_download() to download_from().
Rob Landley <rob@landley.net>
parents: 944
diff changeset
351 SHA1=
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
352 # Download new one as alt-packagename.tar.ext
959
5a2afff0d00c Rename try_download() to download_from().
Rob Landley <rob@landley.net>
parents: 944
diff changeset
353 download_from "$UNSTABLE" ||
5a2afff0d00c Rename try_download() to download_from().
Rob Landley <rob@landley.net>
parents: 944
diff changeset
354 ([ ! -z "$PREFERRED_MIRROR" ] &&
5a2afff0d00c Rename try_download() to download_from().
Rob Landley <rob@landley.net>
parents: 944
diff changeset
355 download_from "$PREFERRED_MIRROR/$ALTFILENAME")
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
356 return $?
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
357 fi
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
358
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
359 # If environment variable specifies a preferred mirror, try that first.
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
360
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
361 if [ ! -z "$PREFERRED_MIRROR" ]
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
362 then
959
5a2afff0d00c Rename try_download() to download_from().
Rob Landley <rob@landley.net>
parents: 944
diff changeset
363 download_from "$PREFERRED_MIRROR/$FILENAME" && return 0
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
364 fi
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
365
959
5a2afff0d00c Rename try_download() to download_from().
Rob Landley <rob@landley.net>
parents: 944
diff changeset
366 # Try original location, then mirrors.
582
d66eae57a344 Move mirror list into download.sh.
Rob Landley <rob@landley.net>
parents: 581
diff changeset
367 # Note: the URLs in mirror list cannot contain whitespace.
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
368
959
5a2afff0d00c Rename try_download() to download_from().
Rob Landley <rob@landley.net>
parents: 944
diff changeset
369 download_from "$URL" && return 0
582
d66eae57a344 Move mirror list into download.sh.
Rob Landley <rob@landley.net>
parents: 581
diff changeset
370 for i in $MIRROR_LIST
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
371 do
959
5a2afff0d00c Rename try_download() to download_from().
Rob Landley <rob@landley.net>
parents: 944
diff changeset
372 download_from "$i/$FILENAME" && return 0
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
373 done
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
374
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
375 # Return failure.
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
376
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
377 echo "Could not download $FILENAME"
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
378 echo -en "\e[0m"
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
379 return 1
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
380 }
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
381
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
382 # Clean obsolete files out of the source directory
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
383
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
384 START_TIME=`date +%s`
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
385
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
386 cleanup_oldfiles()
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
387 {
1094
fb9423e8bd09 Move wait into cleanup_oldfiles.
Rob Landley <rob@landley.net>
parents: 1090
diff changeset
388 # wait for asynchronous downloads to complete
fb9423e8bd09 Move wait into cleanup_oldfiles.
Rob Landley <rob@landley.net>
parents: 1090
diff changeset
389
fb9423e8bd09 Move wait into cleanup_oldfiles.
Rob Landley <rob@landley.net>
parents: 1090
diff changeset
390 wait
fb9423e8bd09 Move wait into cleanup_oldfiles.
Rob Landley <rob@landley.net>
parents: 1090
diff changeset
391
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
392 for i in "${SRCDIR}"/*
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
393 do
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
394 if [ -f "$i" ] && [ "$(date +%s -r "$i")" -lt "${START_TIME}" ]
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
395 then
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
396 echo Removing old file "$i"
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
397 rm -rf "$i"
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
398 fi
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
399 done
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
400 }
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
401
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
402 # 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
403 # 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
404
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
405 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
406 {
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
407 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
408 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
409 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
410 }
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
411
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
412 # Extract package $1
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
413
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
414 setupfor()
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
415 {
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
416 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
417
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
418 # 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
419 extract_package "$1" || exit 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
420
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
421 # 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
422 # 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
423
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
424 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
425
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
426 if [ -z "$REUSE_CURSRC" ]
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
427 then
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
428 blank_workdir "$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
429 CURSRC="$(pwd)"
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
430 fi
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
431
623
6f7f4d9011af Add SNAPSHOT_SYMLINK option so extracted source packages can live in a different filesystem than the build directory.
Rob Landley <rob@landley.net>
parents: 595
diff changeset
432 [ -z "$SNAPSHOT_SYMLINK" ] && LINKTYPE="l" || LINKTYPE="s"
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
433 cp -${LINKTYPE}fR "$SRCTREE/$PACKAGE/"* "$CURSRC"
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
434
1158
df7814a794a1 Better error message.
Rob Landley <rob@landley.net>
parents: 1152
diff changeset
435 if [ $? -ne 0 ]
df7814a794a1 Better error message.
Rob Landley <rob@landley.net>
parents: 1152
diff changeset
436 then
df7814a794a1 Better error message.
Rob Landley <rob@landley.net>
parents: 1152
diff changeset
437 echo "$PACKAGE not found. Did you run download.sh?" >&2
df7814a794a1 Better error message.
Rob Landley <rob@landley.net>
parents: 1152
diff changeset
438 dienow
df7814a794a1 Better error message.
Rob Landley <rob@landley.net>
parents: 1152
diff changeset
439 fi
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
440
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
441 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
442 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
443
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
444 # 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
445 # 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
446 # 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
447
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
448 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
449 then
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
450 touch "$CURSRC/FWL-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
451 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
452 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
453 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
454 [ $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
455 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
456 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
457 fi
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
458 }
440
59fe5a276991 Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents: 436
diff changeset
459
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
460 # 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
461
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
462 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
463 {
724
3ccce25660f4 Make MANIFEST generation less brittle.
Rob Landley <rob@landley.net>
parents: 720
diff changeset
464 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
465 }
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
466
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
467 # 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
468
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
469 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
470 {
1082
255488af0bbb Convert unstable() to is_in_list() taking the list to check as the second argument.
Rob Landley <rob@landley.net>
parents: 1081
diff changeset
471 if is_in_list "$1" $USE_UNSTABLE
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
472 then
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
473 for i in "b" ""
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
474 do
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
475 FILE="$(echo "$SRCDIR/alt-$1-"*.tar.$i*)"
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
476 if [ -f "$FILE" ]
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
477 then
1102
5c9a877f3f32 Suppress error messages from manfiest generation.
Rob Landley <rob@landley.net>
parents: 1099
diff changeset
478 GITID="$(${i}zcat "$FILE" 2> /dev/null | git get-tar-commit-id 2>/dev/null)"
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
479 if [ ! -z "$GITID" ]
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
480 then
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
481 # The first dozen chars should form a unique id.
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
482
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
483 echo $GITID | sed 's/^\(................\).*/git \1/'
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
484 return
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
485 fi
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
486 fi
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
487 done
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
488
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
489 # Need to extract unstable packages to determine source control version.
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
490
1184
aa8992b35e15 Make extract_package directly callable, and do so where necessary.
Rob Landley <rob@landley.net>
parents: 1183
diff changeset
491 extract_package "$1" >&2
817
a6cb42614a1d Rename build/sources to build/packages to reduce confusion (since sources/packages got moved up to just packages, and this contains the extracted contents of that). And use $SOURCES instead of $TOP/sources in a few places.
Rob Landley <rob@landley.net>
parents: 815
diff changeset
492 DIR="${BUILD}/packages/alt-$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
493
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
494 if [ -d "$DIR/.svn" ]
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
495 then
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
496 ( cd "$DIR"; echo subversion rev \
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
497 $(svn info | sed -n "s/^Revision: //p")
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
498 )
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
499 return 0
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
500 elif [ -d "$DIR/.hg" ]
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
501 then
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
502 ( echo mercurial rev \
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
503 $(hg tip | sed -n 's/changeset: *\([0-9]*\).*/\1/p')
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
504 )
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
505 return 0
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
506 fi
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
507 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
508
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
509 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
510 }
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
511
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
512 # 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
513
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
514 do_readme()
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
515 {
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
516 # Grab FWL version 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
517
662
1fa9eb882e3b Allow FWL revision number to be overridden in MANIFEST (for releases).
Rob Landley <rob@landley.net>
parents: 647
diff changeset
518 [ -z "$FWL_VERS" ] &&
787
23bff7aa79eb Teach buildall.sh to use new build.sh infrastructure, and replace doforklog with orthogonal maybe_fork and maybe_quiet functions.
Rob Landley <rob@landley.net>
parents: 783
diff changeset
519 FWL_VERS="mercurial rev $(cd "$TOP"; hg tip 2>/dev/null | sed -n 's/changeset: *\([0-9]*\).*/\1/p')"
662
1fa9eb882e3b Allow FWL revision number to be overridden in MANIFEST (for releases).
Rob Landley <rob@landley.net>
parents: 647
diff changeset
520
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
521 cat << EOF
662
1fa9eb882e3b Allow FWL revision number to be overridden in MANIFEST (for releases).
Rob Landley <rob@landley.net>
parents: 647
diff changeset
522 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
523
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
524 Build script:
662
1fa9eb882e3b Allow FWL revision number to be overridden in MANIFEST (for releases).
Rob Landley <rob@landley.net>
parents: 647
diff changeset
525 Firmware Linux (http://landley.net/code/firmware) $FWL_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
526
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
527 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
528 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
529 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
530 Linux (http://kernel.org/pub/linux/kernel) $(identify_release linux)
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
531
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
532 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
533 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
534 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
535 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
536 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
537
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
538 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
539 Toybox (http://landley.net/code/toybox) $(identify_release toybox)
99e039a4b8bc Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents: 461
diff changeset
540 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
541 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
542 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
543 }
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
544
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
545 # 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
546
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
547 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
548 {
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
549 [ "$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
550
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
551 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
552 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
553 }
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
554
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
555 # 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
556 # 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
557
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
558 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
559 {
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
560 # 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
561 # 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
562
898
db0f536aee7c Fix hw-target builds so prerequisites build if they don't already exist.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
563 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
564 then
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 778
diff changeset
565 link_arch_name $STAGE_NAME-{"$ARCH","$ARCH_NAME"}
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 778
diff changeset
566 [ -e $STAGE_NAME-"$ARCH".tar.bz2 ] &&
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 778
diff changeset
567 link_arch_name $STAGE_NAME-{"$ARCH","$ARCH_NAME"}.tar.bz2
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
568
898
db0f536aee7c Fix hw-target builds so prerequisites build if they don't already exist.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
569 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
570 then
db0f536aee7c Fix hw-target builds so prerequisites build if they don't already exist.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
571 echo "=== Using existing ${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
572
db0f536aee7c Fix hw-target builds so prerequisites build if they don't already exist.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
573 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
574 else
db0f536aee7c Fix hw-target builds so prerequisites build if they don't already exist.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
575 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
576 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
577 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
578 }
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
579
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
580 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
581 {
1033
87b3a69ca71c Delete empty build/temp-* directories when we're done with them.
Rob Landley <rob@landley.net>
parents: 1012
diff changeset
582 # 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
583
87b3a69ca71c Delete empty build/temp-* directories when we're done with them.
Rob Landley <rob@landley.net>
parents: 1012
diff changeset
584 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
585
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
586 # 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
587
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
588 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
589 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
590
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
591 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
592 then
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 778
diff changeset
593 echo -n creating "$STAGE_NAME-${ARCH}".tar.bz2
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
594
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 778
diff changeset
595 { tar cjvf "$STAGE_NAME-${ARCH}".tar.bz2 "$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
596 } | 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
597
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 778
diff changeset
598 link_arch_name $STAGE_NAME-{$ARCH,$ARCH_NAME}.tar.bz2
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
599 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
600 }
776
37c083cca810 Move doforklog to sources/functions.sh.
Rob Landley <rob@landley.net>
parents: 773
diff changeset
601
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
602 # 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
603 # (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
604
1081
e992bc65b048 Remove unnecessary "function" label from shell functions.
Rob Landley <rob@landley.net>
parents: 1067
diff changeset
605 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
606 {
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
607 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
608
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
609 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
610 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
611 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
612 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
613 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
614 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
615 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
616 }