Check-in [d6d2c4eb25]
Overview
Comment:Moved extract and download to functions
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | packages
Files: files | file ages | folders
SHA1: d6d2c4eb25d1a34df3999cd4652ab428bc9dee69
User & Date: rkeene on 2014-11-05 20:44:41
Other Links: branch diff | manifest | tags
Context
2014-11-06
18:20
Added Linux headers package check-in: e138f0dde7 user: rkeene tags: packages
2014-11-05
20:44
Moved extract and download to functions check-in: d6d2c4eb25 user: rkeene tags: packages
19:41
More work towards making a build script to build working software check-in: a6c3672582 user: rkeene tags: packages
Changes

Modified build from [093497ea45] to [88d46e0f28].

14
15
16
17
18
19
20


























































21
22
23
24
25
26
27
pkg="$(echo "$1" | sed 's@/*$@@;s@^\.*/*@@')"

if [ -z "${pkg}" ]; then
	echo "Usage: build [--cpio] <package>" 2>&1

	exit 1
fi



























































function verifyRequiredPackages() {
	local pkg pkgdomain pkgversion
	local pkgdir pkgconfigdir pkgfound

	for pkg in "${require[@]}"; do
		pkgdomain=''







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
pkg="$(echo "$1" | sed 's@/*$@@;s@^\.*/*@@')"

if [ -z "${pkg}" ]; then
	echo "Usage: build [--cpio] <package>" 2>&1

	exit 1
fi

function download() {
	if [ ! -e "${pkgarchive}" ]; then
		# Download
		## Cleanup
		rm -f src.new

		## Fetch file
		wget -O src.new "${url}" || exit 1

		## Verify signature
		src_sha256="$(openssl sha256 'src.new' | sed 's@^.*= @@')"
		if [ "${src_sha256}" != "${sha256}" ]; then
			echo "SHA256 mismatch:  Downloaded: ${src_sha256} != Expected: ${sha256}" >&2

			exit 1
		fi

		## Move file into place
		mv src.new "${pkgarchive}"
	fi
}

function extract() {
	local decompress

	# Decompress archive
	## Determine type of archive
	case "${url}" in
		*.tar.xz|*.tar.xz'?'*|*.txz)
			decompress='xz'
			;;
		*.tar.gz|*.tar.gz'?'*|*.tgz)
			decompress='gzip'
			;;
		*.tar.bz2|*.tar.bz2'?'*|*.tbz2)
			decompress='bzip2'
			;;
		*.zip|*.zip'?'*)
			decompress='unzip'
			;;
		*)
			echo "Unknown compression method: ${url}" >&2

			exit 1
			;;
	esac

	## Do decompression
	case "${decompress}" in
		unzip)
			unzip "${pkgarchive}" || die 'Unable to uncompress archive'
			;;
		*)
			"${decompress}" -dc "${pkgarchive}" | tar -xf - || die 'Unable to uncompress archive'
			;;
	esac
}

function verifyRequiredPackages() {
	local pkg pkgdomain pkgversion
	local pkgdir pkgconfigdir pkgfound

	for pkg in "${require[@]}"; do
		pkgdomain=''
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132

	CFLAGS="${CFLAGS} -I${glibcdir}/include"
	CPPFLAGS="${CPPFLAGS} -I${glibcdir}/include"
	LDFLAGS="${LDFLAGS} -Wl,--rpath,${glibcdir}/lib -Wl,--dynamic-linker,${dynlinker}"
	PKG_CONFIG_LIBDIR="${glibcdir}/lib/pkgconfig"
	export CFLAGS CPPFLAGS LDFLAGS PKG_CONFIG_LIBDIR

	./configure --prefix="${prefix}" --sysconfdir=/etc --localstatedir=/var
}

function prebuild() {
	:
}

function postbuild() {







|







176
177
178
179
180
181
182
183
184
185
186
187
188
189
190

	CFLAGS="${CFLAGS} -I${glibcdir}/include"
	CPPFLAGS="${CPPFLAGS} -I${glibcdir}/include"
	LDFLAGS="${LDFLAGS} -Wl,--rpath,${glibcdir}/lib -Wl,--dynamic-linker,${dynlinker}"
	PKG_CONFIG_LIBDIR="${glibcdir}/lib/pkgconfig"
	export CFLAGS CPPFLAGS LDFLAGS PKG_CONFIG_LIBDIR

	./configure --prefix="${prefix}" --sysconfdir=/etc --localstatedir=/var "${configure_extra[@]}"
}

function prebuild() {
	:
}

function postbuild() {
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
	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)"
fi

. "${pkgfile}"

archivedir="$(pwd)/ARCHIVE"
workdir="workdir-$$${RANDOM}${RANDOM}${RANDOM}"
srcfile="${archivedir}/${pkg}"
mkdir "${archivedir}" >/dev/null 2>/dev/null
mkdir "${workdir}" || exit 1
cd "${workdir}" || exit 1
workdir="$(pwd)"

if [ ! -e "${srcfile}" ]; then
	# Download
	## Cleanup
	rm -f src.new src

	## Fetch file
	wget -O src.new "${url}" || exit 1

	## Verify signature
	src_sha256="$(openssl sha256 'src.new' | sed 's@^.*= @@')"
	if [ "${src_sha256}" != "${sha256}" ]; then
		echo "SHA256 mismatch:  Downloaded: ${src_sha256} != Expected: ${sha256}" >&2

		exit 1
	fi

	## Move file into place
	mv src.new "${archivedir}/${pkg}"
fi

# Decompress archive
## Determine type of archive
case "${url}" in
	*.tar.xz|*.tar.xz'?'*|*.txz)
		decompress='xz'
		;;
	*.tar.gz|*.tar.gz'?'*|*.tgz)
		decompress='gzip'
		;;
	*.tar.bz2|*.tar.bz2'?'*|*.tbz2)
		decompress='bzip2'
		;;
	*.zip|*.zip'?'*)
		decompress='unzip'
		;;
	*)
		echo "Unknown compression method: ${url}" >&2

		exit 1
		;;
esac

## Do decompression
case "${decompress}" in
	unzip)
		unzip "${srcfile}" || die 'Unable to uncompress archive'
		;;
	*)
		"${decompress}" -dc "${srcfile}" | tar -xf - || die 'Unable to uncompress archive'
		;;
esac

## Cleanup source
rm -f src

# If we just have one directory, use that directory
dir="$(echo *)"
if [ -e "${dir}" ]; then
	mv "${dir}"/* .
fi








|





<
|
<
<
|
<
<

<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<







261
262
263
264
265
266
267
268
269
270
271
272
273

274


275


276




277



























278













279
280
281
282
283
284
285
	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)"
fi

. "${pkgfile}"

archivedir="$(pwd)/ARCHIVE"
workdir="workdir-$$${RANDOM}${RANDOM}${RANDOM}"
pkgarchive="${archivedir}/${pkg}-${version}"
mkdir "${archivedir}" >/dev/null 2>/dev/null
mkdir "${workdir}" || exit 1
cd "${workdir}" || exit 1
workdir="$(pwd)"


# Download


download







# Extract



























extract














# If we just have one directory, use that directory
dir="$(echo *)"
if [ -e "${dir}" ]; then
	mv "${dir}"/* .
fi