Differences From
Artifact [093497ea45]:
14 14 pkg="$(echo "$1" | sed 's@/*$@@;s@^\.*/*@@')"
15 15
16 16 if [ -z "${pkg}" ]; then
17 17 echo "Usage: build [--cpio] <package>" 2>&1
18 18
19 19 exit 1
20 20 fi
21 +
22 +function download() {
23 + if [ ! -e "${pkgarchive}" ]; then
24 + # Download
25 + ## Cleanup
26 + rm -f src.new
27 +
28 + ## Fetch file
29 + wget -O src.new "${url}" || exit 1
30 +
31 + ## Verify signature
32 + src_sha256="$(openssl sha256 'src.new' | sed 's@^.*= @@')"
33 + if [ "${src_sha256}" != "${sha256}" ]; then
34 + echo "SHA256 mismatch: Downloaded: ${src_sha256} != Expected: ${sha256}" >&2
35 +
36 + exit 1
37 + fi
38 +
39 + ## Move file into place
40 + mv src.new "${pkgarchive}"
41 + fi
42 +}
43 +
44 +function extract() {
45 + local decompress
46 +
47 + # Decompress archive
48 + ## Determine type of archive
49 + case "${url}" in
50 + *.tar.xz|*.tar.xz'?'*|*.txz)
51 + decompress='xz'
52 + ;;
53 + *.tar.gz|*.tar.gz'?'*|*.tgz)
54 + decompress='gzip'
55 + ;;
56 + *.tar.bz2|*.tar.bz2'?'*|*.tbz2)
57 + decompress='bzip2'
58 + ;;
59 + *.zip|*.zip'?'*)
60 + decompress='unzip'
61 + ;;
62 + *)
63 + echo "Unknown compression method: ${url}" >&2
64 +
65 + exit 1
66 + ;;
67 + esac
68 +
69 + ## Do decompression
70 + case "${decompress}" in
71 + unzip)
72 + unzip "${pkgarchive}" || die 'Unable to uncompress archive'
73 + ;;
74 + *)
75 + "${decompress}" -dc "${pkgarchive}" | tar -xf - || die 'Unable to uncompress archive'
76 + ;;
77 + esac
78 +}
21 79
22 80 function verifyRequiredPackages() {
23 81 local pkg pkgdomain pkgversion
24 82 local pkgdir pkgconfigdir pkgfound
25 83
26 84 for pkg in "${require[@]}"; do
27 85 pkgdomain=''
................................................................................
118 176
119 177 CFLAGS="${CFLAGS} -I${glibcdir}/include"
120 178 CPPFLAGS="${CPPFLAGS} -I${glibcdir}/include"
121 179 LDFLAGS="${LDFLAGS} -Wl,--rpath,${glibcdir}/lib -Wl,--dynamic-linker,${dynlinker}"
122 180 PKG_CONFIG_LIBDIR="${glibcdir}/lib/pkgconfig"
123 181 export CFLAGS CPPFLAGS LDFLAGS PKG_CONFIG_LIBDIR
124 182
125 - ./configure --prefix="${prefix}" --sysconfdir=/etc --localstatedir=/var
183 + ./configure --prefix="${prefix}" --sysconfdir=/etc --localstatedir=/var "${configure_extra[@]}"
126 184 }
127 185
128 186 function prebuild() {
129 187 :
130 188 }
131 189
132 190 function postbuild() {
................................................................................
203 261 pkgdate="$(find "${pkgdir}" -type f -printf '%TY%Tm%Td%TH%TM.%TS\n' 2>/dev/null | cut -f 1-2 -d '.' | sort -n | tail -n 1)"
204 262 fi
205 263
206 264 . "${pkgfile}"
207 265
208 266 archivedir="$(pwd)/ARCHIVE"
209 267 workdir="workdir-$$${RANDOM}${RANDOM}${RANDOM}"
210 -srcfile="${archivedir}/${pkg}"
268 +pkgarchive="${archivedir}/${pkg}-${version}"
211 269 mkdir "${archivedir}" >/dev/null 2>/dev/null
212 270 mkdir "${workdir}" || exit 1
213 271 cd "${workdir}" || exit 1
214 272 workdir="$(pwd)"
215 273
216 -if [ ! -e "${srcfile}" ]; then
217 - # Download
218 - ## Cleanup
219 - rm -f src.new src
274 +# Download
275 +download
220 276
221 - ## Fetch file
222 - wget -O src.new "${url}" || exit 1
223 -
224 - ## Verify signature
225 - src_sha256="$(openssl sha256 'src.new' | sed 's@^.*= @@')"
226 - if [ "${src_sha256}" != "${sha256}" ]; then
227 - echo "SHA256 mismatch: Downloaded: ${src_sha256} != Expected: ${sha256}" >&2
228 -
229 - exit 1
230 - fi
231 -
232 - ## Move file into place
233 - mv src.new "${archivedir}/${pkg}"
234 -fi
235 -
236 -# Decompress archive
237 -## Determine type of archive
238 -case "${url}" in
239 - *.tar.xz|*.tar.xz'?'*|*.txz)
240 - decompress='xz'
241 - ;;
242 - *.tar.gz|*.tar.gz'?'*|*.tgz)
243 - decompress='gzip'
244 - ;;
245 - *.tar.bz2|*.tar.bz2'?'*|*.tbz2)
246 - decompress='bzip2'
247 - ;;
248 - *.zip|*.zip'?'*)
249 - decompress='unzip'
250 - ;;
251 - *)
252 - echo "Unknown compression method: ${url}" >&2
253 -
254 - exit 1
255 - ;;
256 -esac
257 -
258 -## Do decompression
259 -case "${decompress}" in
260 - unzip)
261 - unzip "${srcfile}" || die 'Unable to uncompress archive'
262 - ;;
263 - *)
264 - "${decompress}" -dc "${srcfile}" | tar -xf - || die 'Unable to uncompress archive'
265 - ;;
266 -esac
267 -
268 -## Cleanup source
269 -rm -f src
277 +# Extract
278 +extract
270 279
271 280 # If we just have one directory, use that directory
272 281 dir="$(echo *)"
273 282 if [ -e "${dir}" ]; then
274 283 mv "${dir}"/* .
275 284 fi
276 285