Mercurial > hg > aboriginal
annotate include.sh @ 352:1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
by the build into log files named "build/cmdlines.$STAGE.$PACKAGE".
author | Rob Landley <rob@landley.net> |
---|---|
date | Wed, 02 Jul 2008 22:37:41 -0500 |
parents | 7f529baf0b57 |
children | 5c61d556fe0c |
rev | line source |
---|---|
173
8b4c243a212e
Add better debug info to a status report, and stop fighting ubuntu so much
Rob Landley <rob@landley.net>
parents:
170
diff
changeset
|
1 #!/bin/bash |
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
|
2 |
351
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
3 # Setup |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
4 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
5 # If this is set, mini-native won't include development tools, just uClibc |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
6 # and busybox. (Set it to "headers" to include kernel headers if you'd like |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
7 # to add your own toolchain, such as tinycc.) |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
8 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
9 # export BUILD_SHORT=1 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
10 |
352
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
11 # If this is set, the build records the command lines run by each build into |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
12 # log files in the build directory, ala "build/cmdlines.$PACKAGENAME" |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
13 |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
14 # export RECORD_COMMANDS=1 |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
15 |
351
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
16 # 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
|
17 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
18 [ -z "$CC" ] && CC=gcc |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
19 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
20 # 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
|
21 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
22 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
|
23 then |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
24 export CPUS=$[$(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)+0] |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
25 [ "$CPUS" -lt 1 ] && CPUS=1 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
26 fi |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
27 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
28 umask 022 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
29 unset CFLAGS CXXFLAGS |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
30 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
31 # This tells gcc to aggressively garbage collect its internal data |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
32 # structures. Without this, gcc triggers the OOM killer trying to rebuild |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
33 # itself in 128 megs of ram, which is the QEMU default size. Don't do |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
34 # this on a 64 bit host or gcc will slow to a crawl due to insufficient memory. |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
35 [ "$(uname -m)" != "x86_64" ] && |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
36 export CFLAGS="--param ggc-min-expand=0 --param ggc-min-heapsize=8192" |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
37 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
38 # Find/create directories |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
39 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
40 TOP=`pwd` |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
41 export SOURCES="${TOP}/sources" |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
42 export SRCDIR="${SOURCES}/packages" |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
43 export FROMSRC=../packages |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
44 export BUILD="${TOP}/build" |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
45 export HOSTTOOLS="${BUILD}/host" |
352
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
46 |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
47 # 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
|
48 |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
49 if [ "$PATH" != "$HOSTTOOLS" ] |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
50 then |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
51 if [ -f "$HOSTTOOLS/busybox" ] |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
52 then |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
53 PATH="$HOSTTOOLS" |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
54 else |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
55 PATH="${HOSTTOOLS}:$PATH" |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
56 fi |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
57 fi |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
58 |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
59 STAGE_NAME=`echo $0 | sed 's@.*/\(.*\)\.sh@\1@'` |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
60 export WRAPPY_LOGPATH="$BUILD/cmdlines.${STAGE_NAME}.setupfor" |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
61 if [ -f "$BUILD/wrapdir/wrappy" ] |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
62 then |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
63 export WRAPPY_REALPATH="$PATH" |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
64 PATH="$BUILD/wrapdir" |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
65 fi |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
66 |
351
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
67 mkdir -p "${SRCDIR}" |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
68 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
69 # Tell bash not to cache the $PATH because we modify it. Without this, bash |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
70 # won't find new executables added after startup. |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
71 set +h |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
72 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
73 # Get target platform from first command line argument. |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
74 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
75 if [ -z "$NO_ARCH" ] |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
76 then |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
77 ARCH_NAME="$1" |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
78 ARCH="$(echo "$1" | sed 's@.*/@@')" |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
79 if [ ! -f "${TOP}/sources/configs/${ARCH}" ] |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
80 then |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
81 echo "Supported architectures: " |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
82 (cd "${TOP}/sources/configs" && ls) |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
83 exit 1 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
84 fi |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
85 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
86 # Which platform are we building for? |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
87 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
88 export WORK="${BUILD}/temp-$ARCH" |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
89 mkdir -p "${WORK}" |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
90 # Say "unknown" in two different ways so it doesn't assume we're NOT |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
91 # cross compiling when the host and target are the same processor. (If host |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
92 # and target match, the binutils/gcc/make builds won't use the cross compiler |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
93 # during mini-native.sh, and the host compiler links binaries against the |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
94 # wrong libc.) |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
95 [ -z "$CROSS_HOST" ] && export CROSS_HOST=`uname -m`-walrus-linux |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
96 [ -z "$CROSS_TARGET" ] && export CROSS_TARGET=${ARCH}-unknown-linux |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
97 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
98 # Read the relevant config file. |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
99 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
100 source "${TOP}/sources/configs/${ARCH}" |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
101 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
102 # Setup directories and add the cross compiler to the start of the path. |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
103 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
104 export CROSS="${BUILD}/cross-compiler-$ARCH" |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
105 export NATIVE="${BUILD}/mini-native-$ARCH" |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
106 export PATH="${CROSS}/bin:$PATH" |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
107 else |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
108 export WORK="${BUILD}/host-temp" |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
109 mkdir -p "${WORK}" |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
110 fi |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
111 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
112 [ $? -ne 0 ] && dienow |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
113 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
114 # Everything after here is utility functions used by the other scripts. |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
115 |
236
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
116 # Strip the version number off a tarball |
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
117 |
301
309b574a5059
Redo the $CLEANUP logic to a cleanup function in include.sh (meaning if a
Rob Landley <rob@landley.net>
parents:
290
diff
changeset
|
118 function cleanup() |
309b574a5059
Redo the $CLEANUP logic to a cleanup function in include.sh (meaning if a
Rob Landley <rob@landley.net>
parents:
290
diff
changeset
|
119 { |
309b574a5059
Redo the $CLEANUP logic to a cleanup function in include.sh (meaning if a
Rob Landley <rob@landley.net>
parents:
290
diff
changeset
|
120 if [ $? -ne 0 ] |
309b574a5059
Redo the $CLEANUP logic to a cleanup function in include.sh (meaning if a
Rob Landley <rob@landley.net>
parents:
290
diff
changeset
|
121 then |
309b574a5059
Redo the $CLEANUP logic to a cleanup function in include.sh (meaning if a
Rob Landley <rob@landley.net>
parents:
290
diff
changeset
|
122 dienow |
309b574a5059
Redo the $CLEANUP logic to a cleanup function in include.sh (meaning if a
Rob Landley <rob@landley.net>
parents:
290
diff
changeset
|
123 else |
309b574a5059
Redo the $CLEANUP logic to a cleanup function in include.sh (meaning if a
Rob Landley <rob@landley.net>
parents:
290
diff
changeset
|
124 rm -rf "$@" |
309b574a5059
Redo the $CLEANUP logic to a cleanup function in include.sh (meaning if a
Rob Landley <rob@landley.net>
parents:
290
diff
changeset
|
125 fi |
309b574a5059
Redo the $CLEANUP logic to a cleanup function in include.sh (meaning if a
Rob Landley <rob@landley.net>
parents:
290
diff
changeset
|
126 } |
309b574a5059
Redo the $CLEANUP logic to a cleanup function in include.sh (meaning if a
Rob Landley <rob@landley.net>
parents:
290
diff
changeset
|
127 |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
128 function noversion() |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
129 { |
256
e1d156c264bc
Ok, the non-sed -r version is noticeably uglier than my first guess at it.
Rob Landley <rob@landley.net>
parents:
255
diff
changeset
|
130 echo "$1" | sed -e 's/-*\(\([0-9\.]\)*\([_-]rc\)*\(-pre\)*\([0-9][a-zA-Z]\)*\)*\(\.tar\..z2*\)$/\6/' |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
131 } |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
132 |
236
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
133 # output the sha1sum of a file |
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
134 function sha1file() |
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
135 { |
237
735ee8a5ca35
Fix the path to calculate the tarball sha1sum, use the sha1file function more
Rob Landley <rob@landley.net>
parents:
236
diff
changeset
|
136 sha1sum "$@" | awk '{print $1}' |
236
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
137 } |
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
138 |
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
139 # Extract tarball named in $1 and apply all relevant patches into |
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
140 # "$BUILD/sources/$1". Record sha1sum of tarball and patch files in |
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
141 # sha1-for-source.txt. Re-extract if tarball or patches change. |
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
142 |
220
8d2d0feff1ef
The "caller" built-in isn't available in bash 2.x.
Rob Landley <rob@landley.net>
parents:
214
diff
changeset
|
143 function extract() |
8d2d0feff1ef
The "caller" built-in isn't available in bash 2.x.
Rob Landley <rob@landley.net>
parents:
214
diff
changeset
|
144 { |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
145 SRCTREE="${BUILD}/sources" |
256
e1d156c264bc
Ok, the non-sed -r version is noticeably uglier than my first guess at it.
Rob Landley <rob@landley.net>
parents:
255
diff
changeset
|
146 BASENAME="$(noversion "$1")" |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
147 BASENAME="${BASENAME/%\.tar\.*/}" |
236
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
148 SHA1FILE="$(echo "${SRCTREE}/${BASENAME}/sha1-for-source.txt")" |
237
735ee8a5ca35
Fix the path to calculate the tarball sha1sum, use the sha1file function more
Rob Landley <rob@landley.net>
parents:
236
diff
changeset
|
149 SHA1TAR="$(sha1file "${SRCDIR}/$1")" |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
150 |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
151 # Sanity check: don't ever "rm -rf /". Just don't. |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
152 |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
153 if [ -z "$BASENAME" ] || [ -z "$SRCTREE" ] |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
154 then |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
155 dienow |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
156 fi |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
157 |
236
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
158 # If it's already extracted and up to date (including patches), do nothing. |
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
159 SHALIST=$(cat "$SHA1FILE" 2> /dev/null) |
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
160 if [ ! -z "$SHALIST" ] |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
161 then |
237
735ee8a5ca35
Fix the path to calculate the tarball sha1sum, use the sha1file function more
Rob Landley <rob@landley.net>
parents:
236
diff
changeset
|
162 for i in "$SHA1TAR" $(sha1file "${SOURCES}/patches/$BASENAME"* 2>/dev/null) |
236
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
163 do |
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
164 # Is this sha1 in the file? |
248
f32b23bbf83a
Properly detect a short sha1list during tarball extraction (I.E. notice if
Rob Landley <rob@landley.net>
parents:
246
diff
changeset
|
165 if [ -z "$(echo "$SHALIST" | sed -n "s/$i/$i/p" )" ] |
f32b23bbf83a
Properly detect a short sha1list during tarball extraction (I.E. notice if
Rob Landley <rob@landley.net>
parents:
246
diff
changeset
|
166 then |
f32b23bbf83a
Properly detect a short sha1list during tarball extraction (I.E. notice if
Rob Landley <rob@landley.net>
parents:
246
diff
changeset
|
167 SHALIST=missing |
f32b23bbf83a
Properly detect a short sha1list during tarball extraction (I.E. notice if
Rob Landley <rob@landley.net>
parents:
246
diff
changeset
|
168 break |
f32b23bbf83a
Properly detect a short sha1list during tarball extraction (I.E. notice if
Rob Landley <rob@landley.net>
parents:
246
diff
changeset
|
169 fi |
236
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
170 # Remove it |
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
171 SHALIST="$(echo "$SHALIST" | sed "s/$i//" )" |
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
172 done |
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
173 # If we matched all the sha1sums, nothing more to do. |
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
174 [ -z "$SHALIST" ] && return 0 |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
175 fi |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
176 |
236
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
177 echo -n "Extracting '${BASENAME}'" |
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
178 # Delete the old tree (if any). Create new empty working directories. |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
179 rm -rf "${BUILD}/temp" "${SRCTREE}/${BASENAME}" 2>/dev/null |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
180 mkdir -p "${BUILD}"/{temp,sources} || dienow |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
181 |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
182 # Is it a bzip2 or gzip tarball? |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
183 DECOMPRESS="" |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
184 [ "$1" != "${1/%\.tar\.bz2/}" ] && DECOMPRESS="j" |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
185 [ "$1" != "${1/%\.tar\.gz/}" ] && DECOMPRESS="z" |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
186 |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
187 cd "${WORK}" && |
252
aa03feec947a
Minor tweaks: one error check was missed, use hard links instead of
Rob Landley <rob@landley.net>
parents:
248
diff
changeset
|
188 { tar -xv${DECOMPRESS} -f "${SRCDIR}/$1" -C "${BUILD}/temp" || dienow |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
189 } | dotprogress |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
190 |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
191 mv "${BUILD}/temp/"* "${SRCTREE}/${BASENAME}" && |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
192 rmdir "${BUILD}/temp" && |
236
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
193 echo "$SHA1TAR" > "$SHA1FILE" |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
194 |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
195 [ $? -ne 0 ] && dienow |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
196 |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
197 # Apply any patches to this package |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
198 |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
199 ls "${SOURCES}/patches/$BASENAME"* 2> /dev/null | sort | while read i |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
200 do |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
201 if [ -f "$i" ] |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
202 then |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
203 echo "Applying $i" |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
204 (cd "${SRCTREE}/${BASENAME}" && patch -p1 -i "$i") || dienow |
237
735ee8a5ca35
Fix the path to calculate the tarball sha1sum, use the sha1file function more
Rob Landley <rob@landley.net>
parents:
236
diff
changeset
|
205 sha1file "$i" >> "$SHA1FILE" |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
206 fi |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
207 done |
220
8d2d0feff1ef
The "caller" built-in isn't available in bash 2.x.
Rob Landley <rob@landley.net>
parents:
214
diff
changeset
|
208 } |
8d2d0feff1ef
The "caller" built-in isn't available in bash 2.x.
Rob Landley <rob@landley.net>
parents:
214
diff
changeset
|
209 |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
210 function download() |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
211 { |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
212 FILENAME=`echo "$URL" | sed 's .*/ '` |
255
c3e8c6662b58
Fix include.sh to consistently use noversion, and rephrase the sed invocation
Rob Landley <rob@landley.net>
parents:
252
diff
changeset
|
213 BASENAME=`noversion "$FILENAME"` |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
214 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
215 # The extra "" is so we test the sha1sum after the last download. |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
216 |
340
595332f94fea
Add timeout to wget, and add another mirror (impactlinux.com) so there's a
Rob Landley <rob@landley.net>
parents:
329
diff
changeset
|
217 for i in "$URL" http://impactlinux.com/firmware/mirror/"$FILENAME" \ |
352
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
218 http://landley.net/code/firmware/mirror/"$FILENAME" "" |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
219 do |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
220 # Return success if we have a valid copy of the file |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
221 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
222 # Test first (so we don't re-download a file we've already got). |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
223 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
224 SUM=`cat "$SRCDIR/$FILENAME" | sha1sum | awk '{print $1}'` |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
225 if [ x"$SUM" == x"$SHA1" ] || [ -z "$SHA1" ] && [ -f "$SRCDIR/$FILENAME" ] |
41 | 226 then |
227 touch "$SRCDIR/$FILENAME" | |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
228 if [ -z "$SHA1" ] |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
229 then |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
230 echo "No SHA1 for $FILENAME ($SUM)" |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
231 else |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
232 echo "Confirmed $FILENAME" |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
233 fi |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
234 if [ ! -z "$EXTRACT_ALL" ] |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
235 then |
236
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
236 extract "$FILENAME" |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
237 fi |
244
aeb3788642e4
Notice when patch isn't installed and abort properly.
Rob Landley <rob@landley.net>
parents:
237
diff
changeset
|
238 return $? |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
239 fi |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
240 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
241 # If there's a corrupted file, delete it. In theory it would be nice |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
242 # to resume downloads, but wget creates "*.1" files instead. |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
243 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
244 rm "$SRCDIR/$FILENAME" 2> /dev/null |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
245 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
246 # If we have another source, try to download file. |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
247 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
248 if [ -n "$i" ] |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
249 then |
340
595332f94fea
Add timeout to wget, and add another mirror (impactlinux.com) so there's a
Rob Landley <rob@landley.net>
parents:
329
diff
changeset
|
250 wget -t 2 -T 20 -P "$SRCDIR" "$i" |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
251 fi |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
252 done |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
253 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
254 # Return failure. |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
255 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
256 echo "Could not download $FILENAME" |
81
6dd38c925bc4
Upgrade some packages, and other cleanups.
Rob Landley <rob@landley.net>
parents:
62
diff
changeset
|
257 echo -en "\e[0m" |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
258 return 1 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
259 } |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
260 |
41 | 261 # Clean obsolete files out of the source directory |
262 | |
263 START_TIME=`date +%s` | |
264 | |
265 function cleanup_oldfiles() | |
266 { | |
267 for i in "${SRCDIR}"/* | |
268 do | |
269 if [ -f "$i" ] && [ "$(date +%s -r "$i")" -lt "${START_TIME}" ] | |
270 then | |
271 echo Removing old file "$i" | |
272 rm -rf "$i" | |
273 fi | |
274 done | |
275 } | |
276 | |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
277 function dienow() |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
278 { |
220
8d2d0feff1ef
The "caller" built-in isn't available in bash 2.x.
Rob Landley <rob@landley.net>
parents:
214
diff
changeset
|
279 echo -e "\e[31mExiting due to errors\e[0m" |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
280 exit 1 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
281 } |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
282 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
283 function dotprogress() |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
284 { |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
285 x=0 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
286 while read i |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
287 do |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
288 x=$[$x + 1] |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
289 if [[ "$x" -eq 25 ]] |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
290 then |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
291 x=0 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
292 echo -n . |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
293 fi |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
294 done |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
295 echo |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
296 } |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
297 |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
298 # Extract package $1, use out-of-tree build directory $2 (or $1 if no $2) |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
299 # Use symlink directory $3 (or $1 if no $3) |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
300 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
301 function setupfor() |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
302 { |
352
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
303 export WRAPPY_LOGPATH="$BUILD/cmdlines.${STAGE_NAME}.setupfor" |
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
304 |
236
9c48cf5b65f6
Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents:
222
diff
changeset
|
305 # Make sure the source is already extracted and up-to-date. |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
306 cd "${SRCDIR}" && |
252
aa03feec947a
Minor tweaks: one error check was missed, use hard links instead of
Rob Landley <rob@landley.net>
parents:
248
diff
changeset
|
307 extract "${1}-"*.tar* || exit 1 |
41 | 308 |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
309 # Set CURSRC |
173
8b4c243a212e
Add better debug info to a status report, and stop fighting ubuntu so much
Rob Landley <rob@landley.net>
parents:
170
diff
changeset
|
310 |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
311 export CURSRC="$1" |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
312 [ ! -z "$3" ] && CURSRC="$3" |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
313 CURSRC="${WORK}/${CURSRC}" |
41 | 314 |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
315 # Announce package, with easy-to-grep-for "===" marker. |
41 | 316 |
125
2dd9f480ff4e
Set PATH for run-mini-native.sh and add more obvious arch display info when
Rob Landley <rob@landley.net>
parents:
124
diff
changeset
|
317 echo "=== Building $1 ($ARCH_NAME)" |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
318 echo "Snapshot '$1'..." |
306
358ef8a27085
Break up run-$ARCH.sh, move more temp files into temp dir, fix deletion logic.
Rob Landley <rob@landley.net>
parents:
301
diff
changeset
|
319 cd "${WORK}" || dienow |
358ef8a27085
Break up run-$ARCH.sh, move more temp files into temp dir, fix deletion logic.
Rob Landley <rob@landley.net>
parents:
301
diff
changeset
|
320 if [ $# -lt 3 ] |
358ef8a27085
Break up run-$ARCH.sh, move more temp files into temp dir, fix deletion logic.
Rob Landley <rob@landley.net>
parents:
301
diff
changeset
|
321 then |
358ef8a27085
Break up run-$ARCH.sh, move more temp files into temp dir, fix deletion logic.
Rob Landley <rob@landley.net>
parents:
301
diff
changeset
|
322 rm -rf "${CURSRC}" || dienow |
358ef8a27085
Break up run-$ARCH.sh, move more temp files into temp dir, fix deletion logic.
Rob Landley <rob@landley.net>
parents:
301
diff
changeset
|
323 fi |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
324 mkdir -p "${CURSRC}" && |
252
aa03feec947a
Minor tweaks: one error check was missed, use hard links instead of
Rob Landley <rob@landley.net>
parents:
248
diff
changeset
|
325 cp -lfR "${SRCTREE}/$1/"* "${CURSRC}" |
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
326 |
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
220
diff
changeset
|
327 [ $? -ne 0 ] && dienow |
41 | 328 |
329 # Do we have a separate working directory? | |
330 | |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
331 if [ -z "$2" ] |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
332 then |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
333 cd "$1"* || dienow |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
334 else |
47
edaa86240321
Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents:
41
diff
changeset
|
335 mkdir -p "$2" && |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
336 cd "$2" || dienow |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
337 fi |
352
1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents:
351
diff
changeset
|
338 export WRAPPY_LOGPATH="$BUILD/cmdlines.${STAGE_NAME}.$1" |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
339 } |