Mercurial > hg > aboriginal
annotate sources/functions.sh @ 724:3ccce25660f4
Make MANIFEST generation less brittle.
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 28 Apr 2009 04:08:11 -0500 |
parents | 74850275fe41 |
children | cc0b6deda270 |
rev | line source |
---|---|
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
1 # Lots of reusable functions. This file is sourced, not run. |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
2 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
3 # Figure out if we're using the stable or unstable versions of a package. |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
4 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
5 function unstable() |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
6 { |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
7 [ ! -z "$(echo ,"$USE_UNSTABLE", | grep ,"$1",)" ] |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
8 } |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
9 |
530
ea7a010e5c47
Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents:
494
diff
changeset
|
10 # Find appropriate miniconfig file |
ea7a010e5c47
Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents:
494
diff
changeset
|
11 |
ea7a010e5c47
Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents:
494
diff
changeset
|
12 function getconfig() |
ea7a010e5c47
Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents:
494
diff
changeset
|
13 { |
581
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
567
diff
changeset
|
14 for i in $(unstable $1 && echo {$ARCH_NAME,$ARCH}/miniconfig-alt-$1) \ |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
567
diff
changeset
|
15 {$ARCH_NAME,$ARCH}/miniconfig-$1 |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
567
diff
changeset
|
16 do |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
567
diff
changeset
|
17 if [ -f "$CONFIG_DIR/$i" ] |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
567
diff
changeset
|
18 then |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
567
diff
changeset
|
19 echo "$CONFIG_DIR/$i" |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
567
diff
changeset
|
20 return |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
567
diff
changeset
|
21 fi |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
567
diff
changeset
|
22 done |
530
ea7a010e5c47
Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents:
494
diff
changeset
|
23 |
581
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
567
diff
changeset
|
24 echo "getconfig $1 failed" >&2 |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
567
diff
changeset
|
25 dienow |
530
ea7a010e5c47
Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents:
494
diff
changeset
|
26 } |
ea7a010e5c47
Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents:
494
diff
changeset
|
27 |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
28 # Strip the version number off a tarball |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
29 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
30 function cleanup() |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
31 { |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
32 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
33 [ $? -ne 0 ] && dienow |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
34 |
567
5619a7375b74
Add NO_CLEANUP option to config.
Rob Landley <rob@landley.net>
parents:
534
diff
changeset
|
35 if [ ! -z "$NO_CLEANUP" ] |
5619a7375b74
Add NO_CLEANUP option to config.
Rob Landley <rob@landley.net>
parents:
534
diff
changeset
|
36 then |
5619a7375b74
Add NO_CLEANUP option to config.
Rob Landley <rob@landley.net>
parents:
534
diff
changeset
|
37 echo "skip cleanup $@" |
5619a7375b74
Add NO_CLEANUP option to config.
Rob Landley <rob@landley.net>
parents:
534
diff
changeset
|
38 return |
5619a7375b74
Add NO_CLEANUP option to config.
Rob Landley <rob@landley.net>
parents:
534
diff
changeset
|
39 fi |
5619a7375b74
Add NO_CLEANUP option to config.
Rob Landley <rob@landley.net>
parents:
534
diff
changeset
|
40 |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
41 for i in "$@" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
42 do |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
43 unstable "$i" && i="$PACKAGE" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
44 echo "cleanup $i" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
45 rm -rf "$i" || dienow |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
46 done |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
47 } |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
48 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
49 # Give filename.tar.ext minus the version number. |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
50 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
51 function noversion() |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
52 { |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
53 echo "$1" | sed -e 's/-*\(\([0-9\.]\)*\([_-]rc\)*\(-pre\)*\([0-9][a-zA-Z]\)*\)*\(\.tar\..z2*\)$/'"$2"'\6/' |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
54 } |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
55 |
440
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
56 # Given a filename.tar.ext, return the versino number. |
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
57 |
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
58 function getversion() |
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
59 { |
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
60 echo "$1" | sed -e 's/.*-\(\([0-9\.]\)*\([_-]rc\)*\(-pre\)*\([0-9][a-zA-Z]\)*\)*\(\.tar\..z2*\)$/'"$2"'\1/' |
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
61 } |
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
62 |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
63 # Give package name, minus file's version number and archive extension. |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
64 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
65 function basename() |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
66 { |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
67 noversion $1 | sed 's/\.tar\..z2*$//' |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
68 } |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
69 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
70 # output the sha1sum of a file |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
71 function sha1file() |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
72 { |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
73 sha1sum "$@" | awk '{print $1}' |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
74 } |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
75 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
76 # Extract tarball named in $1 and apply all relevant patches into |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
77 # "$BUILD/sources/$1". Record sha1sum of tarball and patch files in |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
78 # sha1-for-source.txt. Re-extract if tarball or patches change. |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
79 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
80 function extract() |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
81 { |
676
112dc7b787d3
Fix hg 665 so it actually works. (Make setupfor work when build/sources/package exists but there's no packages/package-*.tar* file.)
Rob Landley <rob@landley.net>
parents:
668
diff
changeset
|
82 FILENAME="$1" |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
83 SRCTREE="${BUILD}/sources" |
676
112dc7b787d3
Fix hg 665 so it actually works. (Make setupfor work when build/sources/package exists but there's no packages/package-*.tar* file.)
Rob Landley <rob@landley.net>
parents:
668
diff
changeset
|
84 SHA1FILE="$(echo "${SRCTREE}/${PACKAGE}/sha1-for-source.txt")" |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
85 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
86 # Sanity check: don't ever "rm -rf /". Just don't. |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
87 |
676
112dc7b787d3
Fix hg 665 so it actually works. (Make setupfor work when build/sources/package exists but there's no packages/package-*.tar* file.)
Rob Landley <rob@landley.net>
parents:
668
diff
changeset
|
88 if [ -z "$PACKAGE" ] || [ -z "$SRCTREE" ] |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
89 then |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
90 dienow |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
91 fi |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
92 |
665
17fc6a3bffa4
Allow build to run with build/sources but not source tarballs. (Makes build-static-toolchains.sh slightly easier.)
Rob Landley <rob@landley.net>
parents:
662
diff
changeset
|
93 # If the source tarball doesn't exist, but the extracted directory is there, |
17fc6a3bffa4
Allow build to run with build/sources but not source tarballs. (Makes build-static-toolchains.sh slightly easier.)
Rob Landley <rob@landley.net>
parents:
662
diff
changeset
|
94 # assume everything's ok. |
17fc6a3bffa4
Allow build to run with build/sources but not source tarballs. (Makes build-static-toolchains.sh slightly easier.)
Rob Landley <rob@landley.net>
parents:
662
diff
changeset
|
95 |
676
112dc7b787d3
Fix hg 665 so it actually works. (Make setupfor work when build/sources/package exists but there's no packages/package-*.tar* file.)
Rob Landley <rob@landley.net>
parents:
668
diff
changeset
|
96 [ ! -e "$FILENAME" ] && [ -e "$SHA1FILE" ] && return 0 |
112dc7b787d3
Fix hg 665 so it actually works. (Make setupfor work when build/sources/package exists but there's no packages/package-*.tar* file.)
Rob Landley <rob@landley.net>
parents:
668
diff
changeset
|
97 |
112dc7b787d3
Fix hg 665 so it actually works. (Make setupfor work when build/sources/package exists but there's no packages/package-*.tar* file.)
Rob Landley <rob@landley.net>
parents:
668
diff
changeset
|
98 SHA1TAR="$(sha1file "${SRCDIR}/${FILENAME}")" |
665
17fc6a3bffa4
Allow build to run with build/sources but not source tarballs. (Makes build-static-toolchains.sh slightly easier.)
Rob Landley <rob@landley.net>
parents:
662
diff
changeset
|
99 |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
100 # If it's already extracted and up to date (including patches), do nothing. |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
101 SHALIST=$(cat "$SHA1FILE" 2> /dev/null) |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
102 if [ ! -z "$SHALIST" ] |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
103 then |
676
112dc7b787d3
Fix hg 665 so it actually works. (Make setupfor work when build/sources/package exists but there's no packages/package-*.tar* file.)
Rob Landley <rob@landley.net>
parents:
668
diff
changeset
|
104 for i in "$SHA1TAR" $(sha1file "${SOURCES}/patches/${PACKAGE}"-* 2>/dev/null) |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
105 do |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
106 # Is this sha1 in the file? |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
107 if [ -z "$(echo "$SHALIST" | sed -n "s/$i/$i/p" )" ] |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
108 then |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
109 SHALIST=missing |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
110 break |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
111 fi |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
112 # Remove it |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
113 SHALIST="$(echo "$SHALIST" | sed "s/$i//" )" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
114 done |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
115 # If we matched all the sha1sums, nothing more to do. |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
116 [ -z "$SHALIST" ] && return 0 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
117 fi |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
118 |
676
112dc7b787d3
Fix hg 665 so it actually works. (Make setupfor work when build/sources/package exists but there's no packages/package-*.tar* file.)
Rob Landley <rob@landley.net>
parents:
668
diff
changeset
|
119 echo -n "Extracting '${PACKAGE}'" |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
120 # Delete the old tree (if any). Create new empty working directories. |
676
112dc7b787d3
Fix hg 665 so it actually works. (Make setupfor work when build/sources/package exists but there's no packages/package-*.tar* file.)
Rob Landley <rob@landley.net>
parents:
668
diff
changeset
|
121 rm -rf "${BUILD}/temp" "${SRCTREE}/${PACKAGE}" 2>/dev/null |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
122 mkdir -p "${BUILD}"/{temp,sources} || dienow |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
123 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
124 # Is it a bzip2 or gzip tarball? |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
125 DECOMPRESS="" |
676
112dc7b787d3
Fix hg 665 so it actually works. (Make setupfor work when build/sources/package exists but there's no packages/package-*.tar* file.)
Rob Landley <rob@landley.net>
parents:
668
diff
changeset
|
126 [ "$FILENAME" != "${FILENAME/%\.tar\.bz2/}" ] && DECOMPRESS="j" |
112dc7b787d3
Fix hg 665 so it actually works. (Make setupfor work when build/sources/package exists but there's no packages/package-*.tar* file.)
Rob Landley <rob@landley.net>
parents:
668
diff
changeset
|
127 [ "$FILENAME" != "${FILENAME/%\.tar\.gz/}" ] && DECOMPRESS="z" |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
128 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
129 cd "${WORK}" && |
676
112dc7b787d3
Fix hg 665 so it actually works. (Make setupfor work when build/sources/package exists but there's no packages/package-*.tar* file.)
Rob Landley <rob@landley.net>
parents:
668
diff
changeset
|
130 { tar -xv${DECOMPRESS} -f "${SRCDIR}/${FILENAME}" -C "${BUILD}/temp" || dienow |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
131 } | dotprogress |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
132 |
676
112dc7b787d3
Fix hg 665 so it actually works. (Make setupfor work when build/sources/package exists but there's no packages/package-*.tar* file.)
Rob Landley <rob@landley.net>
parents:
668
diff
changeset
|
133 mv "${BUILD}/temp/"* "${SRCTREE}/${PACKAGE}" && |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
134 rmdir "${BUILD}/temp" && |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
135 echo "$SHA1TAR" > "$SHA1FILE" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
136 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
137 [ $? -ne 0 ] && dienow |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
138 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
139 # Apply any patches to this package |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
140 |
676
112dc7b787d3
Fix hg 665 so it actually works. (Make setupfor work when build/sources/package exists but there's no packages/package-*.tar* file.)
Rob Landley <rob@landley.net>
parents:
668
diff
changeset
|
141 ls "${SOURCES}/patches/${PACKAGE}"-* 2> /dev/null | sort | while read i |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
142 do |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
143 if [ -f "$i" ] |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
144 then |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
145 echo "Applying $i" |
676
112dc7b787d3
Fix hg 665 so it actually works. (Make setupfor work when build/sources/package exists but there's no packages/package-*.tar* file.)
Rob Landley <rob@landley.net>
parents:
668
diff
changeset
|
146 (cd "${SRCTREE}/${PACKAGE}" && patch -p1 -i "$i") || dienow |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
147 sha1file "$i" >> "$SHA1FILE" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
148 fi |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
149 done |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
150 } |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
151 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
152 function try_checksum() |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
153 { |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
154 SUM="$(sha1file "$SRCDIR/$FILENAME" 2>/dev/null)" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
155 if [ x"$SUM" == x"$SHA1" ] || [ -z "$SHA1" ] && [ -f "$SRCDIR/$FILENAME" ] |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
156 then |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
157 touch "$SRCDIR/$FILENAME" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
158 if [ -z "$SHA1" ] |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
159 then |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
160 echo "No SHA1 for $FILENAME ($SUM)" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
161 else |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
162 echo "Confirmed $FILENAME" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
163 fi |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
164 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
165 [ -z "$EXTRACT_ALL" ] && return 0 |
676
112dc7b787d3
Fix hg 665 so it actually works. (Make setupfor work when build/sources/package exists but there's no packages/package-*.tar* file.)
Rob Landley <rob@landley.net>
parents:
668
diff
changeset
|
166 PACKAGE="$(basename "$FILENAME")" extract "$FILENAME" |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
167 return $? |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
168 fi |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
169 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
170 return 1 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
171 } |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
172 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
173 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
174 function try_download() |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
175 { |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
176 # Return success if we have a valid copy of the file |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
177 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
178 try_checksum && return 0 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
179 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
180 # If there's a corrupted file, delete it. In theory it would be nice |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
181 # to resume downloads, but wget creates "*.1" files instead. |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
182 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
183 rm "$SRCDIR/$FILENAME" 2> /dev/null |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
184 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
185 # If we have another source, try to download file. |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
186 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
187 if [ -n "$1" ] |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
188 then |
668
e7eb5123258c
Support PREFERRED_MIRROR for USE_UNSTABLE.
Rob Landley <rob@landley.net>
parents:
665
diff
changeset
|
189 wget -t 2 -T 20 -O "$SRCDIR/$FILENAME" "$1" || |
e7eb5123258c
Support PREFERRED_MIRROR for USE_UNSTABLE.
Rob Landley <rob@landley.net>
parents:
665
diff
changeset
|
190 (rm "$SRCDIR/$FILENAME"; return 2) |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
191 fi |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
192 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
193 try_checksum |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
194 } |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
195 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
196 # Confirm a file matches sha1sum, else try to download it from mirror list. |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
197 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
198 function download() |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
199 { |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
200 FILENAME=`echo "$URL" | sed 's .*/ '` |
683
3c09987974c8
Allow UNSTABLE=squashfs to download cvs snapshot with 4.0 support (but still not equivalent to genext2fs -D or gen_cpio_init's text file input, for creating /dev/console without root access).
Rob Landley <rob@landley.net>
parents:
676
diff
changeset
|
201 [ -z "$RENAME" ] || FILENAME="$(echo "$FILENAME" | sed -r "$RENAME")" |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
202 ALTFILENAME=alt-"$(noversion "$FILENAME" -0)" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
203 |
595
161e2bca18f4
Add slightly more debugging/status info to download.
Rob Landley <rob@landley.net>
parents:
582
diff
changeset
|
204 echo -ne "checking $FILENAME\r" |
161e2bca18f4
Add slightly more debugging/status info to download.
Rob Landley <rob@landley.net>
parents:
582
diff
changeset
|
205 |
581
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
567
diff
changeset
|
206 # Is the unstable version selected? |
9dffdd74c186
More changes for initramfs and hw- targets with a base architecture.
Rob Landley <rob@landley.net>
parents:
567
diff
changeset
|
207 if unstable "$(basename "$FILENAME")" |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
208 then |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
209 # Keep old version around, if present. |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
210 touch -c "$SRCDIR/$FILENAME" 2>/dev/null |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
211 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
212 # Download new one as alt-packagename.tar.ext |
668
e7eb5123258c
Support PREFERRED_MIRROR for USE_UNSTABLE.
Rob Landley <rob@landley.net>
parents:
665
diff
changeset
|
213 FILENAME="$ALTFILENAME" SHA1= try_download "$UNSTABLE" || |
e7eb5123258c
Support PREFERRED_MIRROR for USE_UNSTABLE.
Rob Landley <rob@landley.net>
parents:
665
diff
changeset
|
214 ([ ! -z "$PREFERRED_MIRROR" ] && SHA1= FILENAME="$ALTFILENAME" try_download "$PREFERRED_MIRROR/$ALTFILENAME") |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
215 return $? |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
216 fi |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
217 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
218 # If environment variable specifies a preferred mirror, try that first. |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
219 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
220 if [ ! -z "$PREFERRED_MIRROR" ] |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
221 then |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
222 try_download "$PREFERRED_MIRROR/$FILENAME" && return 0 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
223 fi |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
224 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
225 # Try standard locations |
582
d66eae57a344
Move mirror list into download.sh.
Rob Landley <rob@landley.net>
parents:
581
diff
changeset
|
226 # Note: the URLs in mirror list cannot contain whitespace. |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
227 |
582
d66eae57a344
Move mirror list into download.sh.
Rob Landley <rob@landley.net>
parents:
581
diff
changeset
|
228 try_download "$URL" && return 0 |
d66eae57a344
Move mirror list into download.sh.
Rob Landley <rob@landley.net>
parents:
581
diff
changeset
|
229 for i in $MIRROR_LIST |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
230 do |
582
d66eae57a344
Move mirror list into download.sh.
Rob Landley <rob@landley.net>
parents:
581
diff
changeset
|
231 try_download "$i/$FILENAME" && return 0 |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
232 done |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
233 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
234 # Return failure. |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
235 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
236 echo "Could not download $FILENAME" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
237 echo -en "\e[0m" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
238 return 1 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
239 } |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
240 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
241 # Clean obsolete files out of the source directory |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
242 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
243 START_TIME=`date +%s` |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
244 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
245 function cleanup_oldfiles() |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
246 { |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
247 for i in "${SRCDIR}"/* |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
248 do |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
249 if [ -f "$i" ] && [ "$(date +%s -r "$i")" -lt "${START_TIME}" ] |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
250 then |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
251 echo Removing old file "$i" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
252 rm -rf "$i" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
253 fi |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
254 done |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
255 } |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
256 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
257 # An exit function that works properly even from a subshell. |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
258 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
259 function actually_dienow() |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
260 { |
629 | 261 echo -e "\n\e[31mExiting due to errors ($ARCH_NAME $STAGE_NAME $PACKAGE)\e[0m" |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
262 exit 1 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
263 } |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
264 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
265 trap actually_dienow SIGUSR1 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
266 TOPSHELL=$$ |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
267 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
268 function dienow() |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
269 { |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
270 kill -USR1 $TOPSHELL |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
271 exit 1 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
272 } |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
273 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
274 # Turn a bunch of output lines into a much quieter series of periods. |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
275 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
276 function dotprogress() |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
277 { |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
278 x=0 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
279 while read i |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
280 do |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
281 x=$[$x + 1] |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
282 if [[ "$x" -eq 25 ]] |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
283 then |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
284 x=0 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
285 echo -n . |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
286 fi |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
287 done |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
288 echo |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
289 } |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
290 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
291 # Extract package $1, use out-of-tree build directory $2 (or $1 if no $2) |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
292 # Use link directory $3 (or $1 if no $3) |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
293 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
294 function setupfor() |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
295 { |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
296 export WRAPPY_LOGPATH="$WRAPPY_LOGDIR/cmdlines.${STAGE_NAME}.setupfor" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
297 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
298 # Figure out whether we're using an unstable package. |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
299 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
300 PACKAGE="$1" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
301 unstable "$PACKAGE" && PACKAGE=alt-"$PACKAGE" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
302 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
303 # Make sure the source is already extracted and up-to-date. |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
304 cd "${SRCDIR}" && |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
305 extract "${PACKAGE}-"*.tar* || exit 1 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
306 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
307 # Set CURSRC |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
308 CURSRC="$PACKAGE" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
309 if [ ! -z "$3" ] |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
310 then |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
311 CURSRC="$3" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
312 unstable "$CURSRC" && CURSRC=alt-"$CURSRC" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
313 fi |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
314 export CURSRC="${WORK}/${CURSRC}" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
315 |
623
6f7f4d9011af
Add SNAPSHOT_SYMLINK option so extracted source packages can live in a different filesystem than the build directory.
Rob Landley <rob@landley.net>
parents:
595
diff
changeset
|
316 [ -z "$SNAPSHOT_SYMLINK" ] && LINKTYPE="l" || LINKTYPE="s" |
6f7f4d9011af
Add SNAPSHOT_SYMLINK option so extracted source packages can live in a different filesystem than the build directory.
Rob Landley <rob@landley.net>
parents:
595
diff
changeset
|
317 |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
318 # Announce package, with easy-to-grep-for "===" marker. |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
319 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
320 echo "=== Building $PACKAGE ($ARCH_NAME)" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
321 echo "Snapshot '$PACKAGE'..." |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
322 cd "${WORK}" || dienow |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
323 if [ $# -lt 3 ] |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
324 then |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
325 rm -rf "${CURSRC}" || dienow |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
326 fi |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
327 mkdir -p "${CURSRC}" && |
623
6f7f4d9011af
Add SNAPSHOT_SYMLINK option so extracted source packages can live in a different filesystem than the build directory.
Rob Landley <rob@landley.net>
parents:
595
diff
changeset
|
328 cp -${LINKTYPE}fR "${SRCTREE}/$PACKAGE/"* "${CURSRC}" |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
329 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
330 [ $? -ne 0 ] && dienow |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
331 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
332 # Do we have a separate working directory? |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
333 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
334 if [ -z "$2" ] |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
335 then |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
336 cd "$PACKAGE"* || dienow |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
337 else |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
338 mkdir -p "$2" && cd "$2" || dienow |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
339 fi |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
340 export WRAPPY_LOGPATH="$WRAPPY_LOGDIR/cmdlines.${STAGE_NAME}.$1" |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
341 |
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
342 # Change window title bar to package now |
449
765d6566fb54
Display tweak. (When the build window is minimized, all it shows is "Building...")
Rob Landley <rob@landley.net>
parents:
440
diff
changeset
|
343 echo -en "\033]2;$ARCH_NAME $STAGE_NAME $PACKAGE\007" |
428
c88e25996320
Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
344 } |
440
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
345 |
720
74850275fe41
Make "wait4background" with no arguments wait for all background tasks.
Rob Landley <rob@landley.net>
parents:
685
diff
changeset
|
346 # usage: wait4background [count] |
440
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
347 |
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
348 function wait4background() |
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
349 { |
720
74850275fe41
Make "wait4background" with no arguments wait for all background tasks.
Rob Landley <rob@landley.net>
parents:
685
diff
changeset
|
350 local COUNT="$1" |
454
ccca664cbac1
Upgrade build wrapper, teach wait4background to skip certain processes (such as ssh) mentioned in optional second argument.
Rob Landley <rob@landley.net>
parents:
449
diff
changeset
|
351 local EXCLUDE="$2" |
720
74850275fe41
Make "wait4background" with no arguments wait for all background tasks.
Rob Landley <rob@landley.net>
parents:
685
diff
changeset
|
352 |
74850275fe41
Make "wait4background" with no arguments wait for all background tasks.
Rob Landley <rob@landley.net>
parents:
685
diff
changeset
|
353 [ -z "$COUNT" ] && COUNT=0 |
454
ccca664cbac1
Upgrade build wrapper, teach wait4background to skip certain processes (such as ssh) mentioned in optional second argument.
Rob Landley <rob@landley.net>
parents:
449
diff
changeset
|
354 [ -z "$EXCLUDE" ] && EXCLUDE="thisdoesnotmatchanything" |
440
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
355 # Wait for background tasks to finish |
720
74850275fe41
Make "wait4background" with no arguments wait for all background tasks.
Rob Landley <rob@landley.net>
parents:
685
diff
changeset
|
356 while [ $(jobs | grep -v "$EXCLUDE" | wc -l) -gt $COUNT ] |
440
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
357 do |
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
358 sleep 1 |
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
359 # Without this next line, bash never notices a change in the number of jobs. |
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
360 # Bug noticed in Ubuntu 7.04 |
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
361 jobs > /dev/null |
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
362 done |
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
363 } |
59fe5a276991
Add getversion() and wait4background(), useful to build wrappers.
Rob Landley <rob@landley.net>
parents:
436
diff
changeset
|
364 |
464
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
365 # Figure out what version of a package we last built |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
366 |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
367 function get_download_version() |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
368 { |
724
3ccce25660f4
Make MANIFEST generation less brittle.
Rob Landley <rob@landley.net>
parents:
720
diff
changeset
|
369 getversion $(sed -n 's@URL=.*/\(.[^ ]*\).*@\1@p' "$TOP/download.sh" | grep ${1}-) |
464
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
370 } |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
371 |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
372 # Identify subversion or mercurial revision, or release number |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
373 |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
374 function identify_release() |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
375 { |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
376 if [ -d build/sources/alt-$1/.svn ] |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
377 then |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
378 echo subversion rev \ |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
379 $(svn info build/sources/alt-uClibc | sed -n "s/^Revision: //p") |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
380 elif [ -d build/sources/alt-$1/.hg ] |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
381 then |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
382 echo mercurial rev \ |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
383 $(hg tip | sed -n 's/changeset: *\([0-9]*\).*/\1/p') |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
384 else |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
385 echo release version $(get_download_version $1) |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
386 fi |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
387 } |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
388 |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
389 # Create a README identifying package versions in current build. |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
390 |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
391 function do_readme() |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
392 { |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
393 # Grab FWL version number |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
394 |
662
1fa9eb882e3b
Allow FWL revision number to be overridden in MANIFEST (for releases).
Rob Landley <rob@landley.net>
parents:
647
diff
changeset
|
395 [ -z "$FWL_VERS" ] && |
1fa9eb882e3b
Allow FWL revision number to be overridden in MANIFEST (for releases).
Rob Landley <rob@landley.net>
parents:
647
diff
changeset
|
396 FWL_VERS="mercurial rev $(cd "$TOP"; hg tip | sed -n 's/changeset: *\([0-9]*\).*/\1/p')" |
1fa9eb882e3b
Allow FWL revision number to be overridden in MANIFEST (for releases).
Rob Landley <rob@landley.net>
parents:
647
diff
changeset
|
397 |
464
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
398 cat << EOF |
662
1fa9eb882e3b
Allow FWL revision number to be overridden in MANIFEST (for releases).
Rob Landley <rob@landley.net>
parents:
647
diff
changeset
|
399 Built on $(date +%F) from: |
464
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
400 |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
401 Build script: |
662
1fa9eb882e3b
Allow FWL revision number to be overridden in MANIFEST (for releases).
Rob Landley <rob@landley.net>
parents:
647
diff
changeset
|
402 Firmware Linux (http://landley.net/code/firmware) $FWL_VERS |
464
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
403 |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
404 Base packages: |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
405 uClibc (http://uclibc.org) $(identify_release uClibc) |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
406 BusyBox (http://busybox.net) $(identify_release busybox) |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
407 Linux (http://kernel.org/pub/linux/kernel) $(identify_release linux) |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
408 |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
409 Toolchain packages: |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
410 Binutils (http://www.gnu.org/software/binutils/) $(identify_release binutils |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
411 ) |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
412 GCC (http://gcc.gnu.org) $(identify_release gcc-core) |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
413 gmake (http://www.gnu.org/software/make) $(identify_release make) |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
414 bash (ftp://ftp.gnu.org/gnu/bash) $(identify_release bash) |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
415 |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
416 Optional packages: |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
417 Toybox (http://landley.net/code/toybox) $(identify_release toybox) |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
418 distcc (http://distcc.samba.org) $(identify_release distcc) |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
419 uClibc++ (http://cxx.uclibc.org) $(identify_release uClibc++) |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
420 EOF |
99e039a4b8bc
Move README generation to functions.sh, clean up build-all-target.sh option parsing.
Rob Landley <rob@landley.net>
parents:
461
diff
changeset
|
421 } |
685
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
422 |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
423 # When building with a base architecture, symlink to the base arch name. |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
424 |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
425 function link_arch_name() |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
426 { |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
427 [ "$ARCH" == "$ARCH_NAME" ] && return 0 |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
428 |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
429 rm -rf "$BUILD/$2" && |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
430 ln -s "$1" "$BUILD/$2" || dienow |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
431 } |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
432 |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
433 # Check if this target has a base architecture that's already been built. |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
434 # If so, just tar it up and exit now. |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
435 |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
436 function check_for_base_arch() |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
437 { |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
438 # If we're building something with a base architecture, symlink to actual |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
439 # target. |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
440 |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
441 if [ "$ARCH" != "$ARCH_NAME" ] && [ -e "$BUILD/$1-$ARCH" ] |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
442 then |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
443 echo === Using existing $1-"$ARCH" |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
444 |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
445 link_arch_name $1-{"$ARCH","$ARCH_NAME"} |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
446 [ -e $1-"$ARCH".tar.bz2 ] && |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
447 link_arch_name $1-{"$ARCH","$ARCH_NAME"}.tar.bz2 |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
448 |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
449 return 1 |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
450 fi |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
451 } |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
452 |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
453 function create_stage_tarball() |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
454 { |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
455 # Handle linking to base architecture if we just built a derivative target. |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
456 |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
457 cd "$BUILD" || dienow |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
458 link_arch_name $1-{$ARCH,$ARCH_NAME} |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
459 |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
460 if [ -z "$SKIP_STAGE_TARBALLS" ] |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
461 then |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
462 echo -n creating "$1-${ARCH}".tar.bz2 |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
463 |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
464 { tar cjvf "$1-${ARCH}".tar.bz2 "$1-${ARCH}" || dienow |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
465 } | dotprogress |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
466 |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
467 link_arch_name $1-{$ARCH,$ARCH_NAME}.tar.bz2 |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
468 fi |
90ab1a1f4db5
Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
469 } |