annotate include.sh @ 220:8d2d0feff1ef

The "caller" built-in isn't available in bash 2.x.
author Rob Landley <rob@landley.net>
date Tue, 18 Sep 2007 15:10:13 -0500
parents 0c60dc8d7fd5
children 8b0d2080707c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
220
8d2d0feff1ef The "caller" built-in isn't available in bash 2.x.
Rob Landley <rob@landley.net>
parents: 214
diff changeset
3 function extract()
8d2d0feff1ef The "caller" built-in isn't available in bash 2.x.
Rob Landley <rob@landley.net>
parents: 214
diff changeset
4 {
8d2d0feff1ef The "caller" built-in isn't available in bash 2.x.
Rob Landley <rob@landley.net>
parents: 214
diff changeset
5 }
8d2d0feff1ef The "caller" built-in isn't available in bash 2.x.
Rob Landley <rob@landley.net>
parents: 214
diff changeset
6
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
7 function download()
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
8 {
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
9 FILENAME=`echo "$URL" | sed 's .*/ '`
166
87feb7deddbc Mike released an actual uClibc 0.9.29-rc1 (even though it's named weird), so
Rob Landley <rob@landley.net>
parents: 163
diff changeset
10 BASENAME=`echo "$FILENAME" | sed -r -e 's/-*([0-9\.]|[_-]rc|-pre|[0-9][a-zA-Z])*(\.tar\..z2*)$/\2/'`
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
11
36
2f1a6a4645ed Why didn't "hg mv build.sh cross-compiler.sh" figure out what build.sh had
Rob Landley <rob@landley.net>
parents: 35
diff changeset
12 if [ ! -z "$LINKDIR" ]
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
13 then
36
2f1a6a4645ed Why didn't "hg mv build.sh cross-compiler.sh" figure out what build.sh had
Rob Landley <rob@landley.net>
parents: 35
diff changeset
14 rm -f "$LINKDIR/$BASENAME" 2> /dev/null
163
729dd17a7b74 Point uClibc at the 0.9.29-pre1 I just uploaded, teach include.sh about
Rob Landley <rob@landley.net>
parents: 155
diff changeset
15 ln -s "$FROMSRC/$FILENAME" "$LINKDIR/$BASENAME" || dienow
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
16 fi
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
17
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
18 # 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
19
101
9b7fcdfbe11c Add a third mirror, with older versions.
Rob Landley <rob@landley.net>
parents: 98
diff changeset
20 for i in "$URL" http://www.landley.net/code/firmware/mirror/"$FILENAME" \
9b7fcdfbe11c Add a third mirror, with older versions.
Rob Landley <rob@landley.net>
parents: 98
diff changeset
21 http://engineering.timesys.com/~landley/mirror/"$FILENAME" ""
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
22 do
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
23 # 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
24
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
25 # 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
26
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
27 SUM=`cat "$SRCDIR/$FILENAME" | sha1sum | awk '{print $1}'`
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
28 if [ -z "$SHA1" ] && [ -f "$SRCDIR/$FILENAME" ]
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
29 then
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
30 touch "$SRCDIR/$FILENAME"
210
9bd872911a60 Slightly better debug info: show sha1sum of file when none to compare against.
Rob Landley <rob@landley.net>
parents: 191
diff changeset
31 echo "No SHA1 for $FILENAME ($SUM)"
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
32 return 0
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
33 elif [ x"$SUM" == x"$SHA1" ]
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
34 then
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
35 touch "$SRCDIR/$FILENAME"
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
36 echo "Confirmed $FILENAME"
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
37 return 0
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
38 fi
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
39
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
40 # 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
41 # 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
42
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
43 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
44
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
45 # 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
46
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
47 if [ -n "$i" ]
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
48 then
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
49 wget -P "$SRCDIR" "$i"
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
50 fi
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
51 done
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
52
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
53 # Return failure.
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
54
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
55 echo "Could not download $FILENAME"
81
6dd38c925bc4 Upgrade some packages, and other cleanups.
Rob Landley <rob@landley.net>
parents: 62
diff changeset
56 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
57 return 1
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
58 }
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
59
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
60 # Clean obsolete files out of the source directory
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
61
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
62 START_TIME=`date +%s`
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
63
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
64 function cleanup_oldfiles()
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
65 {
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
66 for i in "${SRCDIR}"/*
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
67 do
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
68 if [ -f "$i" ] && [ "$(date +%s -r "$i")" -lt "${START_TIME}" ]
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
69 then
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
70 echo Removing old file "$i"
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
71 rm -rf "$i"
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
72 fi
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
73 done
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
74 }
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
75
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
76 function dienow()
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
77 {
220
8d2d0feff1ef The "caller" built-in isn't available in bash 2.x.
Rob Landley <rob@landley.net>
parents: 214
diff changeset
78 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
79 exit 1
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
80 }
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
81
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
82 function dotprogress()
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
83 {
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
84 x=0
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
85 while read i
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
86 do
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
87 x=$[$x + 1]
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
88 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
89 then
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
90 x=0
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
91 echo -n .
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
92 fi
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
93 done
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
94 echo
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
95 }
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
96
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
97 # Extract package $1, use work directory $2 (or $1 if no $2), use source
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
98 # directory $3 (or $1 if no $3)
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
99
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
100 function setupfor()
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
101 {
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
102 # Is it a bzip2 or gzip tarball?
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
103
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
104 FILE="$1".tar.bz2
8b4c243a212e Add better debug info to a status report, and stop fighting ubuntu so much
Rob Landley <rob@landley.net>
parents: 170
diff changeset
105 DECOMPRESS="j"
8b4c243a212e Add better debug info to a status report, and stop fighting ubuntu so much
Rob Landley <rob@landley.net>
parents: 170
diff changeset
106
8b4c243a212e Add better debug info to a status report, and stop fighting ubuntu so much
Rob Landley <rob@landley.net>
parents: 170
diff changeset
107 if [ ! -f "${LINKDIR}/${FILE}" ]
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
108 then
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
109 FILE="$1".tar.gz
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
110 DECOMPRESS="z"
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
111 fi
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
112
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
113 # Announce package, with easy-to-grep-for "===" marker. Extract it.
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
114
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
115 echo "=== Building $1 ($ARCH_NAME)"
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
116 echo -n "Extracting '${FILE}'"
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
117 cd "${WORK}" &&
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
118 { tar xv${DECOMPRESS}f "${LINKDIR}/${FILE}" || dienow
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
119 } | dotprogress
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
120
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
121 # Do we have a separate working directory?
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
122
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
123 if [ -z "$2" ]
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
124 then
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
125 cd "$1"* || dienow
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
126 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
127 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
128 cd "$2" || dienow
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
129 fi
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
130
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
131 # Set CURSRC
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
132
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
133 export CURSRC="$1"
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
134 [ ! -z "$3" ] && CURSRC="$3"
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
135 export CURSRC=`echo "${WORK}/${CURSRC}"*`
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
136 [ ! -d "${CURSRC}" ] && dienow
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
137
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
138 # Apply any patches to this package
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
139
214
0c60dc8d7fd5 Make sure the patches are sorted even if the filesystem doesn't do it for us.
Rob Landley <rob@landley.net>
parents: 213
diff changeset
140 ls "${SOURCES}/patches/$1"* 2> /dev/null | sort | while read i
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
141 do
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
142 if [ -f "$i" ]
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
143 then
188
ee8aefd2760b Note which patch is being applied, in case it doesn't.
Rob Landley <rob@landley.net>
parents: 182
diff changeset
144 echo "Applying $i"
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
145 (cd "${CURSRC}" && patch -p1 -i "$i") || dienow
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
146 fi
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
147 done
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
148 }
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
149
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
150 # Setup
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
151
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
152 umask 022
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
153 unset CFLAGS CXXFLAGS
191
485dabec83c4 Comment one of the non-obvious (and optional) bits.
Rob Landley <rob@landley.net>
parents: 188
diff changeset
154 # This tells gcc to aggressively garbage collect its internal data
485dabec83c4 Comment one of the non-obvious (and optional) bits.
Rob Landley <rob@landley.net>
parents: 188
diff changeset
155 # structures. Without this, gcc triggers the OOM killer trying to rebuild
485dabec83c4 Comment one of the non-obvious (and optional) bits.
Rob Landley <rob@landley.net>
parents: 188
diff changeset
156 # itself in 128 megs of ram, which is the QEMU default size.
124
d5e9d5cf0172 According to http://hostingfu.com/article/compiling-with-gcc-on-low-memory-vps
Rob Landley <rob@landley.net>
parents: 120
diff changeset
157 export CFLAGS="--param ggc-min-expand=0 --param ggc-min-heapsize=8192"
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
158
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
159 # Find/create directories
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
160
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
161 TOP=`pwd`
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
162 export SOURCES="${TOP}/sources"
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
163 export SRCDIR="${SOURCES}/packages"
98
b6b4386a6c83 Make host-tools.sh work when run standalone.
Rob Landley <rob@landley.net>
parents: 96
diff changeset
164 export FROMSRC=../packages
36
2f1a6a4645ed Why didn't "hg mv build.sh cross-compiler.sh" figure out what build.sh had
Rob Landley <rob@landley.net>
parents: 35
diff changeset
165 export LINKDIR="${SOURCES}/build-links"
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
166 export BUILD="${TOP}/build"
98
b6b4386a6c83 Make host-tools.sh work when run standalone.
Rob Landley <rob@landley.net>
parents: 96
diff changeset
167 export HOSTTOOLS="${BUILD}/host"
b6b4386a6c83 Make host-tools.sh work when run standalone.
Rob Landley <rob@landley.net>
parents: 96
diff changeset
168 export WORK="${BUILD}/host-temp"
b6b4386a6c83 Make host-tools.sh work when run standalone.
Rob Landley <rob@landley.net>
parents: 96
diff changeset
169 export PATH="${HOSTTOOLS}:$PATH"
62
4125b672b00c Get i686 cross-compiling to work like armv4l cross-compiling by lying to
Rob Landley <rob@landley.net>
parents: 60
diff changeset
170 mkdir -p "${SRCDIR}" "${LINKDIR}"
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
171
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
172 # For bash: check the $PATH for new executables added after startup.
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
173 set +h
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
174
47
edaa86240321 Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents: 41
diff changeset
175 # Are we doing a short build?
edaa86240321 Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents: 41
diff changeset
176
edaa86240321 Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents: 41
diff changeset
177 if [ "$1" == "--short" ]
edaa86240321 Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents: 41
diff changeset
178 then
edaa86240321 Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents: 41
diff changeset
179 export BUILD_SHORT=1
edaa86240321 Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents: 41
diff changeset
180 shift
edaa86240321 Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents: 41
diff changeset
181 fi
edaa86240321 Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents: 41
diff changeset
182
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
183 # Get target platform from first command line argument.
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
184
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
185 if [ -z "$NO_ARCH" ]
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
186 then
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
187 ARCH_NAME="$1"
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
188 ARCH="$(echo "$1" | sed 's@.*/@@')"
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
189 if [ ! -f "${TOP}/sources/configs/${ARCH}" ]
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
190 then
35
25bfa6ac9f84 Make the "supported architecutes" list have sane line breaks.
Rob Landley <rob@landley.net>
parents: 34
diff changeset
191 echo "Supported architectures: "
25bfa6ac9f84 Make the "supported architecutes" list have sane line breaks.
Rob Landley <rob@landley.net>
parents: 34
diff changeset
192 (cd "${TOP}/sources/configs" && ls)
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
193 exit 1
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
194 fi
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
195
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
196 # Which platform are we building for?
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
197
62
4125b672b00c Get i686 cross-compiling to work like armv4l cross-compiling by lying to
Rob Landley <rob@landley.net>
parents: 60
diff changeset
198 export WORK="${BUILD}/temp-$ARCH"
107
72f414b2939d Have to make the include directory before we can put config files in it.
Rob Landley <rob@landley.net>
parents: 101
diff changeset
199 rm -rf "${WORK}"
72f414b2939d Have to make the include directory before we can put config files in it.
Rob Landley <rob@landley.net>
parents: 101
diff changeset
200 mkdir -p "${WORK}"
62
4125b672b00c Get i686 cross-compiling to work like armv4l cross-compiling by lying to
Rob Landley <rob@landley.net>
parents: 60
diff changeset
201 # Say "unknown" in two different ways so it doesn't assume we're NOT
4125b672b00c Get i686 cross-compiling to work like armv4l cross-compiling by lying to
Rob Landley <rob@landley.net>
parents: 60
diff changeset
202 # cross compiling when the host and target are the same processor. (If host
4125b672b00c Get i686 cross-compiling to work like armv4l cross-compiling by lying to
Rob Landley <rob@landley.net>
parents: 60
diff changeset
203 # and target match, the binutils/gcc/make builds won't use the cross compiler
4125b672b00c Get i686 cross-compiling to work like armv4l cross-compiling by lying to
Rob Landley <rob@landley.net>
parents: 60
diff changeset
204 # during mini-native.sh, and the host compiler links binaries against the
4125b672b00c Get i686 cross-compiling to work like armv4l cross-compiling by lying to
Rob Landley <rob@landley.net>
parents: 60
diff changeset
205 # wrong libc.)
213
1080306ae20e Allow host to be overridden (to build on MacOS X).
Rob Landley <rob@landley.net>
parents: 210
diff changeset
206 [ -z "$CROSS_HOST" ] && export CROSS_HOST=`uname -m`-walrus-linux
1080306ae20e Allow host to be overridden (to build on MacOS X).
Rob Landley <rob@landley.net>
parents: 210
diff changeset
207 [ -z "$CROSS_TARGET" ] && export CROSS_TARGET=${ARCH}-unknown-linux
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
208
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
209 # Read the relevant config file.
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
210
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
211 source "${TOP}/sources/configs/${ARCH}"
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
212
62
4125b672b00c Get i686 cross-compiling to work like armv4l cross-compiling by lying to
Rob Landley <rob@landley.net>
parents: 60
diff changeset
213 # Setup directories and add the cross compiler to the start of the path.
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
214
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
215 export CROSS="${BUILD}/cross-compiler-$ARCH"
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
216 export NATIVE="${BUILD}/mini-native-$ARCH"
145
b174c242934b Remove redundant $PATH element pointed out by George Boudreau.
Rob Landley <rob@landley.net>
parents: 138
diff changeset
217 export PATH="${CROSS}/bin:$PATH"
108
b66d638a3844 Build User Mode Linux and have that do the ext2 packaging (for now, anyway).
Rob Landley <rob@landley.net>
parents: 107
diff changeset
218 export IMAGE="${BUILD}/image-${ARCH}.ext2"
155
ce1ca3d0f95b Put zImage-$ARCH in build directory, not mini-native-$ARCH, and eliminate
Rob Landley <rob@landley.net>
parents: 145
diff changeset
219
ce1ca3d0f95b Put zImage-$ARCH in build directory, not mini-native-$ARCH, and eliminate
Rob Landley <rob@landley.net>
parents: 145
diff changeset
220
ce1ca3d0f95b Put zImage-$ARCH in build directory, not mini-native-$ARCH, and eliminate
Rob Landley <rob@landley.net>
parents: 145
diff changeset
221 emulator_command image-$ARCH.ext2 zImage-$ARCH \
ce1ca3d0f95b Put zImage-$ARCH in build directory, not mini-native-$ARCH, and eliminate
Rob Landley <rob@landley.net>
parents: 145
diff changeset
222 "rw init=/tools/bin/sh panic=1 PATH=/tools/bin" > "$BUILD/run-$ARCH.sh" &&
ce1ca3d0f95b Put zImage-$ARCH in build directory, not mini-native-$ARCH, and eliminate
Rob Landley <rob@landley.net>
parents: 145
diff changeset
223 chmod +x "$BUILD/run-$ARCH.sh"
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
224 fi
98
b6b4386a6c83 Make host-tools.sh work when run standalone.
Rob Landley <rob@landley.net>
parents: 96
diff changeset
225 mkdir -p "${WORK}"
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
226
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
227 [ -z "$CLEANUP" ] && CLEANUP="rm -rf"
110
62f6268ff61b Build uClibc's readelf and ldd by hand to work around inadequate cross-compile
Rob Landley <rob@landley.net>
parents: 108
diff changeset
228 [ -z "$CC" ] && CC=gcc
182
fc827ab6166f Autodetect number of processors and feed appropriate -j to make.
Rob Landley <rob@landley.net>
parents: 173
diff changeset
229 if [ -z "$CPUS" ]
fc827ab6166f Autodetect number of processors and feed appropriate -j to make.
Rob Landley <rob@landley.net>
parents: 173
diff changeset
230 then
fc827ab6166f Autodetect number of processors and feed appropriate -j to make.
Rob Landley <rob@landley.net>
parents: 173
diff changeset
231 export CPUS=$[$(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)+0]
fc827ab6166f Autodetect number of processors and feed appropriate -j to make.
Rob Landley <rob@landley.net>
parents: 173
diff changeset
232 [ "$CPUS" -lt 1 ] && CPUS=1
fc827ab6166f Autodetect number of processors and feed appropriate -j to make.
Rob Landley <rob@landley.net>
parents: 173
diff changeset
233 fi