annotate sources/include.sh @ 972:cfa6262528f3

Genericize native build. Break out dropbear and strace packages from download.sh (and clean up what remains, mirror list is now in include.sh). New script setup-native.build.sh downloads, extracts, and creates a system image with "here document" build script to build dropbear and strace. New native-build.sh script works on arbitrary hdc image, providing FTP upload to a directory. The setup/fork logic to build all architectures is now in buildall.sh for this, just like everything else. Update buildall.sh to take optional list of architectures to build on command line. Factor out unique-port.sh (in embeddable manner) so distcc (in run-emulator.sh) and ftp server (in native-build.sh) can both use it. Upgrade to new busybox version while we're there. HGi removed sources/more/setup-native-static-build.sh
author Rob Landley <rob@landley.net>
date Fri, 05 Feb 2010 10:33:06 -0600
parents f1671488c740
children cfeaae1c55ed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
840
96b276eda7f1 Comment tweaks.
Rob Landley <rob@landley.net>
parents: 798
diff changeset
1 #!/bin/echo "This file is sourced, not run"
96b276eda7f1 Comment tweaks.
Rob Landley <rob@landley.net>
parents: 798
diff changeset
2
96b276eda7f1 Comment tweaks.
Rob Landley <rob@landley.net>
parents: 798
diff changeset
3 # Set up all the environment variables and functions for a build stage.
96b276eda7f1 Comment tweaks.
Rob Landley <rob@landley.net>
parents: 798
diff changeset
4 # This file is sourced, not run.
138
7dffe9648a56 Installing bash but not using it. Yeah, there's a political agenda at work
Rob Landley <rob@landley.net>
parents: 125
diff changeset
5
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: 854
diff changeset
6 # Include config and sources/functions.sh
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
7
399
4e11cfb255e2 Break config out from include.sh, so environment variables users can edit to affect the build are collected together in one place with nothing else in it.
Rob Landley <rob@landley.net>
parents: 398
diff changeset
8 [ -e config ] && source config
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: 854
diff changeset
9
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: 743
diff changeset
10 source sources/functions.sh
398
a7daae215647 Implement unstable package download logic, with examples. (Try "USE_UNSTABLE=uClibc,linux ./download.sh" for example.)
Rob Landley <rob@landley.net>
parents: 396
diff changeset
11
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents: 910
diff changeset
12 # List of fallback mirrors to download package source from
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents: 910
diff changeset
13
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents: 910
diff changeset
14 MIRROR_LIST="http://impactlinux.com/firmware/mirror http://landley.net/code/firmware/mirror http://127.0.0.1/code/firmware/mirror"
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents: 910
diff changeset
15
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: 854
diff changeset
16 # Where are our working directories?
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: 854
diff changeset
17
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: 854
diff changeset
18 TOP=`pwd`
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: 854
diff changeset
19 export SOURCES="$TOP/sources"
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: 854
diff changeset
20 export SRCDIR="$TOP/packages"
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: 854
diff changeset
21 export BUILD="$TOP/build"
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: 854
diff changeset
22 export HOSTTOOLS="$BUILD/host"
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: 854
diff changeset
23 export WRAPDIR="$BUILD/wrapdir"
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: 854
diff changeset
24
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: 854
diff changeset
25 # Set a default non-arch
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: 854
diff changeset
26
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: 854
diff changeset
27 export WORK="${BUILD}/host-temp"
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: 854
diff changeset
28 export ARCH_NAME=host
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: 854
diff changeset
29
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
30 # What host compiler should we use?
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
31
739
104e8a35ea2e Move more stuff towards using "cc" instead of "gcc".
Rob Landley <rob@landley.net>
parents: 729
diff changeset
32 [ -z "$CC" ] && export CC=cc
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
33
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
34 # How many processors should make -j use?
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
35
900
266dc7ea04c2 If there's enough memory (half a gig per processor), use 1.5x as many CPUs to try to keep 'em busy.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
36 MEMTOTAL="$(awk '/MemTotal:/{print $2}' /proc/meminfo)"
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
37 if [ -z "$CPUS" ]
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
38 then
553
80f3356577fc Move kernel building from mini-native to package-mini-native in preparation for initramfs packaging option.
Rob Landley <rob@landley.net>
parents: 538
diff changeset
39 export CPUS=$(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
40 [ "$CPUS" -lt 1 ] && CPUS=1
900
266dc7ea04c2 If there's enough memory (half a gig per processor), use 1.5x as many CPUs to try to keep 'em busy.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
41
266dc7ea04c2 If there's enough memory (half a gig per processor), use 1.5x as many CPUs to try to keep 'em busy.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
42 # If there's enough memory, try to make CPUs stay busy.
266dc7ea04c2 If there's enough memory (half a gig per processor), use 1.5x as many CPUs to try to keep 'em busy.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
43
266dc7ea04c2 If there's enough memory (half a gig per processor), use 1.5x as many CPUs to try to keep 'em busy.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
44 [ $(($CPUS*512*1024)) -le $MEMTOTAL ] && CPUS=$((($CPUS*3)/2))
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
45 fi
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
46
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: 854
diff changeset
47 [ -z "$STAGE_NAME" ] && STAGE_NAME=`echo $0 | sed 's@.*/\(.*\)\.sh@\1@'`
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: 854
diff changeset
48 [ ! -z "$BUILD_VERBOSE" ] && VERBOSITY="V=1"
615
7523d1f3b818 Some slight paranoia against multiple host-tools.sh runs that get interrupted in the middle. (Yeah, in general that's not guaranteed to work, but still...)
Rob Landley <rob@landley.net>
parents: 608
diff changeset
49
352
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
50 # Adjust $PATH
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
51
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: 854
diff changeset
52 export OLDPATH="$PATH"
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: 854
diff changeset
53 PATH="$(hosttools_path)"
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: 854
diff changeset
54
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: 854
diff changeset
55 # If record-commands.sh set up a wrapper directory, adjust $PATH again.
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: 854
diff changeset
56 if [ -f "$WRAPDIR/wrappy" ]
352
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
57 then
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: 854
diff changeset
58 export WRAPPY_LOGPATH="$BUILD/logs/cmdlines.$ARCH_NAME.early"
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: 854
diff changeset
59 OLDPATH="$PATH:$OLDPATH"
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: 854
diff changeset
60 PATH="$WRAPDIR"
910
f1671488c740 Split busybox and toybox builds, update toybox and linux package versions.
Rob Landley <rob@landley.net>
parents: 900
diff changeset
61 elif [ ! -f "$HOSTTOOLS/busybox" ] || [ ! -f "$HOSTTOOLS/toybox" ]
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: 854
diff changeset
62 then
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: 854
diff changeset
63 PATH="$PATH:$OLDPATH"
352
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
64 fi
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
65
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: 854
diff changeset
66 # Create files with known permissions
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: 854
diff changeset
67 umask 022
608
ab76d4cdd392 Jean Wolter pointed out that running RECORD_COMMANDS=1 twice could create circular symlinks. Hopefully fixed now, and some related cleanups/clarifications.
Rob Landley <rob@landley.net>
parents: 597
diff changeset
68
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: 854
diff changeset
69 # Tell bash not to cache the $PATH because we modify it. (Without this, bash
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: 854
diff changeset
70 # won't find new executables added after startup.)
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: 854
diff changeset
71 set +h
352
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
72
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: 854
diff changeset
73 # Disable internationalization so sort and sed and such can cope with ASCII.
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: 854
diff changeset
74
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: 854
diff changeset
75 export LC_ALL=C