annotate include.sh @ 237:735ee8a5ca35

Fix the path to calculate the tarball sha1sum, use the sha1file function more than once, fix sha1file to handle multiple arguments.
author Rob Landley <rob@landley.net>
date Tue, 30 Oct 2007 05:42:21 -0500
parents 9c48cf5b65f6
children aeb3788642e4
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
236
9c48cf5b65f6 Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
3 # 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
4
222
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
5 function noversion()
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
6 {
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
7 echo "$1" | sed -r -e 's/-*([0-9\.]|[_-]rc|-pre|[0-9][a-zA-Z])*(\.tar\..z2*)$/\2/'
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
8 }
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
9
236
9c48cf5b65f6 Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
10 # 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
11 function sha1file()
9c48cf5b65f6 Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
12 {
237
735ee8a5ca35 Fix the path to calculate the tarball sha1sum, use the sha1file function more
Rob Landley <rob@landley.net>
parents: 236
diff changeset
13 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
14 }
9c48cf5b65f6 Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
15
9c48cf5b65f6 Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
16 # 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
17 # "$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
18 # 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
19
220
8d2d0feff1ef The "caller" built-in isn't available in bash 2.x.
Rob Landley <rob@landley.net>
parents: 214
diff changeset
20 function extract()
8d2d0feff1ef The "caller" built-in isn't available in bash 2.x.
Rob Landley <rob@landley.net>
parents: 214
diff changeset
21 {
222
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
22 SRCTREE="${BUILD}/sources"
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
23 BASENAME=`noversion "$1"`
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
24 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
25 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
26 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
27
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
28 # 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
29
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
30 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
31 then
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
32 dienow
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
33 fi
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
34
236
9c48cf5b65f6 Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
35 # 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
36 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
37 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
38 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
39 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
40 do
9c48cf5b65f6 Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
41 # Is this sha1 in the file?
9c48cf5b65f6 Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
42 [ -z "$(echo "$SHALIST" | sed -n "s/$i/$i/p" )" ] && break
9c48cf5b65f6 Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
43 # Remove it
9c48cf5b65f6 Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
44 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
45 done
9c48cf5b65f6 Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
46 # 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
47 [ -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
48 fi
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
49
236
9c48cf5b65f6 Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
50 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
51 # 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
52 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
53 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
54
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
55 # 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
56 DECOMPRESS=""
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
57 [ "$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
58 [ "$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
59
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
60 cd "${WORK}" &&
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
61 { tar xv${DECOMPRESS}fC "${SRCDIR}/$1" "${BUILD}/temp" || dienow
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
62 } | dotprogress
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
63
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
64 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
65 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
66 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
67
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
68 [ $? -ne 0 ] && dienow
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
69
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
70 # 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
71
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
72 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
73 do
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
74 if [ -f "$i" ]
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
75 then
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
76 echo "Applying $i"
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
77 (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
78 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
79 fi
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
80 done
220
8d2d0feff1ef The "caller" built-in isn't available in bash 2.x.
Rob Landley <rob@landley.net>
parents: 214
diff changeset
81 }
8d2d0feff1ef The "caller" built-in isn't available in bash 2.x.
Rob Landley <rob@landley.net>
parents: 214
diff changeset
82
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
83 function download()
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
84 {
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
85 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
86 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
87
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
88 # 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
89
222
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
90 for i in "$URL" http://www.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
91 do
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
92 # 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
93
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
94 # 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
95
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
96 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
97 if [ x"$SUM" == x"$SHA1" ] || [ -z "$SHA1" ] && [ -f "$SRCDIR/$FILENAME" ]
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
98 then
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
99 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
100 if [ -z "$SHA1" ]
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
101 then
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
102 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
103 else
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
104 echo "Confirmed $FILENAME"
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
105 fi
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
106 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
107 then
236
9c48cf5b65f6 Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
108 extract "$FILENAME"
222
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
109 fi
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
110 return 0
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
111 fi
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
112
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
113 # 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
114 # 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
115
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
116 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
117
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
118 # 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
119
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
120 if [ -n "$i" ]
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
121 then
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
122 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
123 fi
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
124 done
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
125
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
126 # Return failure.
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
127
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
128 echo "Could not download $FILENAME"
81
6dd38c925bc4 Upgrade some packages, and other cleanups.
Rob Landley <rob@landley.net>
parents: 62
diff changeset
129 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
130 return 1
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
131 }
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
132
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
133 # Clean obsolete files out of the source directory
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
134
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
135 START_TIME=`date +%s`
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
136
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
137 function cleanup_oldfiles()
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
138 {
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
139 for i in "${SRCDIR}"/*
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
140 do
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
141 if [ -f "$i" ] && [ "$(date +%s -r "$i")" -lt "${START_TIME}" ]
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
142 then
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
143 echo Removing old file "$i"
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
144 rm -rf "$i"
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
145 fi
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
146 done
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
147 }
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
148
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
149 function dienow()
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
150 {
220
8d2d0feff1ef The "caller" built-in isn't available in bash 2.x.
Rob Landley <rob@landley.net>
parents: 214
diff changeset
151 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
152 exit 1
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
153 }
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
154
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
155 function dotprogress()
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
156 {
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
157 x=0
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
158 while read i
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
159 do
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
160 x=$[$x + 1]
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
161 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
162 then
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
163 x=0
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
164 echo -n .
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
165 fi
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
166 done
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
167 echo
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
168 }
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
169
222
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
170 # 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
171 # 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
172
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
173 function setupfor()
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
174 {
236
9c48cf5b65f6 Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
175 # 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
176 cd "${SRCDIR}" &&
236
9c48cf5b65f6 Teach extract to check patch files for changes, not just tarballs.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
177 extract "${1}-"*.tar*
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
178
222
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
179 # 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
180
222
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
181 export CURSRC="$1"
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
182 [ ! -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
183 CURSRC="${WORK}/${CURSRC}"
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
184
222
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
185 # Announce package, with easy-to-grep-for "===" marker.
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
186
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 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
188 echo "Snapshot '$1'..."
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
189 cd "${WORK}" &&
222
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
190 mkdir -p "${CURSRC}" &&
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
191 cp -sfR "${SRCTREE}/$1/"* "${CURSRC}"
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
192
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
193 [ $? -ne 0 ] && dienow
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
194
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
195 # Do we have a separate working directory?
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
196
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
197 if [ -z "$2" ]
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
198 then
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
199 cd "$1"* || dienow
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
200 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
201 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
202 cd "$2" || dienow
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
203 fi
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
204 }
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
205
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
206 # Setup
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
207
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
208 umask 022
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
209 unset CFLAGS CXXFLAGS
191
485dabec83c4 Comment one of the non-obvious (and optional) bits.
Rob Landley <rob@landley.net>
parents: 188
diff changeset
210 # 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
211 # 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
212 # 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
213 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
214
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
215 # Find/create directories
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
216
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
217 TOP=`pwd`
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
218 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
219 export SRCDIR="${SOURCES}/packages"
98
b6b4386a6c83 Make host-tools.sh work when run standalone.
Rob Landley <rob@landley.net>
parents: 96
diff changeset
220 export FROMSRC=../packages
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
221 export BUILD="${TOP}/build"
98
b6b4386a6c83 Make host-tools.sh work when run standalone.
Rob Landley <rob@landley.net>
parents: 96
diff changeset
222 export HOSTTOOLS="${BUILD}/host"
b6b4386a6c83 Make host-tools.sh work when run standalone.
Rob Landley <rob@landley.net>
parents: 96
diff changeset
223 export WORK="${BUILD}/host-temp"
b6b4386a6c83 Make host-tools.sh work when run standalone.
Rob Landley <rob@landley.net>
parents: 96
diff changeset
224 export PATH="${HOSTTOOLS}:$PATH"
222
8b0d2080707c Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents: 220
diff changeset
225 mkdir -p "${SRCDIR}"
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 # 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
228 set +h
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
229
47
edaa86240321 Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents: 41
diff changeset
230 # 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
231
edaa86240321 Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents: 41
diff changeset
232 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
233 then
edaa86240321 Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents: 41
diff changeset
234 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
235 shift
edaa86240321 Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents: 41
diff changeset
236 fi
edaa86240321 Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents: 41
diff changeset
237
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
238 # 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
239
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
240 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
241 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
242 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
243 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
244 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
245 then
35
25bfa6ac9f84 Make the "supported architecutes" list have sane line breaks.
Rob Landley <rob@landley.net>
parents: 34
diff changeset
246 echo "Supported architectures: "
25bfa6ac9f84 Make the "supported architecutes" list have sane line breaks.
Rob Landley <rob@landley.net>
parents: 34
diff changeset
247 (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
248 exit 1
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
249 fi
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
250
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
251 # 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
252
62
4125b672b00c Get i686 cross-compiling to work like armv4l cross-compiling by lying to
Rob Landley <rob@landley.net>
parents: 60
diff changeset
253 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
254 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
255 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
256 # 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
257 # 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
258 # 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
259 # 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
260 # wrong libc.)
213
1080306ae20e Allow host to be overridden (to build on MacOS X).
Rob Landley <rob@landley.net>
parents: 210
diff changeset
261 [ -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
262 [ -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
263
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
264 # 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
265
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
266 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
267
62
4125b672b00c Get i686 cross-compiling to work like armv4l cross-compiling by lying to
Rob Landley <rob@landley.net>
parents: 60
diff changeset
268 # 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
269
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
270 export CROSS="${BUILD}/cross-compiler-$ARCH"
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
271 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
272 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
273 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
274
ce1ca3d0f95b Put zImage-$ARCH in build directory, not mini-native-$ARCH, and eliminate
Rob Landley <rob@landley.net>
parents: 145
diff changeset
275
ce1ca3d0f95b Put zImage-$ARCH in build directory, not mini-native-$ARCH, and eliminate
Rob Landley <rob@landley.net>
parents: 145
diff changeset
276 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
277 "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
278 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
279 fi
98
b6b4386a6c83 Make host-tools.sh work when run standalone.
Rob Landley <rob@landley.net>
parents: 96
diff changeset
280 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
281
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff changeset
282 [ -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
283 [ -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
284 if [ -z "$CPUS" ]
fc827ab6166f Autodetect number of processors and feed appropriate -j to make.
Rob Landley <rob@landley.net>
parents: 173
diff changeset
285 then
fc827ab6166f Autodetect number of processors and feed appropriate -j to make.
Rob Landley <rob@landley.net>
parents: 173
diff changeset
286 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
287 [ "$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
288 fi