Check-in [4a0ff085ab]
Overview
Comment:Many build script updates
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | packages
Files: files | file ages | folders
SHA1: 4a0ff085ab1147d8408129df286f820e8b71d330
User & Date: rkeene on 2018-11-16 21:38:43
Other Links: branch diff | manifest | tags
Context
2018-11-16
21:38
Many build script updates Leaf check-in: 4a0ff085ab user: rkeene tags: packages
21:38
Upgraded to latest Tcl check-in: 3f2cfe4d81 user: rkeene tags: packages
Changes

Modified build from [28a52cfdd8] to [970bc0b0dc].

14
15
16
17
18
19
20




21
22
23
24
25
26
27
28
29

30
31
32
33
34
35
36
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







+
+
+
+








-
+







pkg="$(echo "$1" | sed 's@/*$@@;s@^\.*/*@@')"

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

	exit 1
fi

function predownload() {
	:
}

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

		## Fetch file
		wget -O src.new "${url}" || exit 1
		wget --no-check-certificate -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
102
103
104
105
106
107
108





















109
110
111
112
113
114
115
116
117
118
119
120
121
122





123
124
125
126
127
128
129
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+














+
+
+
+
+







		patch -p1 < "${patch}"
	done
}

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

	SAVE_PKG_CONFIG_PATH="${PKG_CONFIG_PATH}"
	PKG_CONFIG_PATH=''
	export PKG_CONFIG_PATH

	use_native_platform='0'
	for pkg in "${require[@]}"; do
		case "${pkg}" in
			@native-os)
				use_native_platform='1'
				;;
		esac
	done

	if [ "${use_native_platform}" = '1' ]; then
		add_headers_str='-I'
	else
		add_headers_str='-isystem '
	fi

	for pkg in "${require[@]}"; do
		pkgdomain=''
		pkgversion=''
		pkgchanges=(CFLAGS LDFLAGS PATH PKG_CONFIG_PATH)

		case "${pkg}" in
			*:*)
				pkgchanges=($(echo "${pkg}" | cut -f 2 -d ':'))
				pkg="$(echo "${pkg}" | cut -f 1 -d ':')"
				;;
		esac

		case "${pkg}" in
			@native-os)
				PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${SAVE_PKG_CONFIG_PATH}"

				continue
				;;
			@*)
				# Fake package
				continue
				;;
			*/*@*)
				pkgdomain="$(echo "${pkg}" | cut -f 2 -d '@')"
				pkgversion="$(echo "${pkg}" | cut -f 2 -d '/' | cut -f 1 -d '@')"
140
141
142
143
144
145
146

147

148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167




168
169
170
171
172
173
174
175






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




192
193
194
195
196
197
198
199

200
201







202
203
204
205
206
207








208
209
210
211
212
213
214
170
171
172
173
174
175
176
177

178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195



196
197
198
199
200
201
202
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







+
-
+

















-
-
-
+
+
+
+






-
-
+
+
+
+
+
+
















+
+
+
+








+
-
-
+
+
+
+
+
+
+

-
-
-
-
-
+
+
+
+
+
+
+
+







		esac

		if [ -z "${pkgdomain}" ]; then
			pkgdomain="${domain}"
		fi

		pkgfound='0'
		ADD_PATH=''
		for pkgdir in "/opt/appfs/${pkgdomain}/${pkg}/platform"/${pkgversion:-latest} "/opt/appfs/${pkgdomain}/${pkg}/platform"/${pkgversion:-*}; do
		for pkgdir in "/opt/appfs/${pkgdomain}/${pkg}/${os}-${arch}"/${pkgversion:-latest} "/opt/appfs/${pkgdomain}/${pkg}/${os}-${arch}"/${pkgversion:-*}; do
			pkgconfigdir="${pkgdir}/lib/pkgconfig"

			if [ ! -d "${pkgdir}" ]; then
				continue
			fi

			# If the package version was unspecified, fully resolve
			# the directory that we found
			if [ -z "${pkgversion}" ]; then
				pkgdir="$(readlink -f "${pkgdir}")"
			fi

			pkgfound='1'

			for pkgchange in "${pkgchanges[@]}"; do
				case "${pkgchange}" in
					CFLAGS)
						CFLAGS="${CFLAGS} -isystem ${pkgdir}/include"
						CPPFLAGS="${CPPFLAGS} -isystem ${pkgdir}/include"
						export CFLAGS CPPFLAGS
						CFLAGS="${CFLAGS} ${add_headers_str}${pkgdir}/include"
						CXXFLAGS="${CFLAGS} ${add_headers_str}${pkgdir}/include"
						CPPFLAGS="${CPPFLAGS} ${add_headers_str}${pkgdir}/include"
						export CFLAGS CXXFLAGS CPPFLAGS
						;;
					LDFLAGS)
						LDFLAGS="${LDFLAGS} -L${pkgdir}/lib -Wl,-rpath,${pkgdir}/lib"
						export LDFLAGS
						;;
					PATH)
						PATH="${PATH}:${pkgdir}/bin"
						export PATH
						ADD_PATH="${ADD_PATH}:${pkgdir}/bin"
						;;
					PERL5LIB)
						PERL5LIB="${pkgdir}/lib/perl5:${PERL5LIB}"
						PERL5LIB="${pkgdir}/lib/site_perl:${PERL5LIB}"
						export PERL5LIB
						;;
					PKG_CONFIG_PATH)
						if [ -d "${pkgconfigdir}" ]; then
							PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${pkgconfigdir}"
							export PKG_CONFIG_PATH
						fi
						;;
				esac
			done

			break
		done

		if [ "${pkgfound}" = '0' ]; then
			die "Package ${pkg}/${pkgversion:-*}@${pkgdomain} not found."
		fi

		ADD_PATH="$(echo "${ADD_PATH}" | sed 's@^:*@@')"

		PATH="${ADD_PATH}:${PATH}"
	done
}

function verifyPrerequisites() {
	:
}

function determineOsArch() {
	if [ -z "${APPFS_BUILD_OS}" ]; then
	os="$(uname -s | dd conv=lcase 2>/dev/null)"
	arch="$(uname -m | dd conv=lcase 2>/dev/null)"
		os="$(uname -s | dd conv=lcase 2>/dev/null)"
	else
		os="${APPFS_BUILD_OS}"
	fi

	if [ -z "${APPFS_BUILD_ARCH}" ]; then
		arch="$(uname -m | dd conv=lcase 2>/dev/null)"

	case "${arch}" in
		i?86)
			arch='ix86'
			;;
	esac
		case "${arch}" in
			i?86)
				arch='ix86'
				;;
		esac
	else
		arch="${APPFS_BUILD_ARCH}"
	fi
}

function determinePrefix() {
	determineOsArch

	prefixsuffix="${pkg}/${os}-${arch}/${version}"
	prefix="/opt/appfs/${domain}/${prefixsuffix}"
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
277
278
279
280

281
282
283
284
285
286
287
273
274
275
276
277
278
279

280
281
282

283
284
285

286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304

305
306
307


308
309
310
311
312
313
314
315


316
317
318
319
320
321
322
323
324
325

326
327
328
329
330
331
332
333
334

335
336
337
338
339
340
341
342







-
+


-
+


-
+


















-
+
+

-
-
+
+






-
-
+
+




+
+

+
-
+
+
+






-
+







function postconfigure() {
	:
}

function configure_gcc() {
	local glibcdir linuxheadersdir
	local dynlinker
	local gcc_default_headers
	local gcc_default_headers_c gcc_default_headers_cxx
	local pkg use_native_platform

	glibcdir="/opt/appfs/core.appfs.rkeene.org/glibc/platform/latest"
	glibcdir="/opt/appfs/core.appfs.rkeene.org/glibc/${os}-${arch}/latest"
	glibcdir="$(readlink -f "${glibcdir}")"

	linuxheadersdir="/opt/appfs/core.appfs.rkeene.org/linux-headers/platform/latest"
	linuxheadersdir="/opt/appfs/core.appfs.rkeene.org/linux-headers/${os}-${arch}/latest"
	linuxheadersdir="$(readlink -f "${linuxheadersdir}")"

	dynlinker="$(ls "${glibcdir}"/lib/ld-linux*.so.* | tail -n 1)"

	if [ ! -f "${dynlinker}" ]; then
		die 'glibc directory is not available (appfs running/working?)'
	fi

	use_native_platform='0'
	for pkg in "${require[@]}"; do
		case "${pkg}" in
			@native-os)
				use_native_platform='1'
				;;
		esac
	done

	if [ "${use_native_platform}" = '0' ]; then
		gcc_default_headers="$(echo '' | ${CPP:-cpp} -v 2>&1 | sed '/^End of search list/,$ d;0,/search starts here:$/ d' | grep '/gcc/' | sed 's@^ *@-isystem @' | tr $'\n' ' ')"
		gcc_default_headers_c="$(echo '' | ${CPP:-cpp} -v 2>&1 | sed '/^End of search list/,$ d;0,/search starts here:$/ d' | grep '/gcc/' | sed 's@^ *@-isystem @' | tr $'\n' ' ')"
		gcc_default_headers_cxx="$(echo '' | ${CPP:-cpp} -x c++ -v 2>&1 | sed '/^End of search list/,$ d;0,/search starts here:$/ d' | grep '/gcc/' | sed 's@^ *@-isystem @' | tr $'\n' ' ')"

		CC="${CC:-gcc} -nostdinc ${gcc_default_headers} -isystem ${glibcdir}/include"
		CXX="${CXX:-g++} -nostdinc ${gcc_default_headers} -isystem ${glibcdir}/include"
		CC="${CC:-gcc} -nostdinc ${gcc_default_headers_c} -isystem ${glibcdir}/include"
		CXX="${CXX:-g++} -nostdinc ${gcc_default_headers_cxx} -isystem ${glibcdir}/include"

		if ! echo " ${require[*]} " | grep ' linux-headers[/@: ]' >/dev/null; then
			CC="${CC} -isystem ${linuxheadersdir}/include"
			CXX="${CXX} -isystem ${linuxheadersdir}/include"
		fi
	else
		CC="${CC:-gcc} -isystem ${glibcdir}/include"
		CXX="${CXX:-g++} -isystem ${glibcdir}/include"
		CC="${CC:-gcc}"
		CXX="${CXX:-g++}"
	fi

	BUILD_CC="${CC}"
	HOST_CC="${CC}"
	BUILD_CXX="${CXX}"
	HOST_CXX="${CXX}"

	if [ "${use_native_platform}" = '0' ]; then
	LDFLAGS="${LDFLAGS} -L${glibcdir}/lib -Wl,-rpath,${glibcdir}/lib -Wl,--dynamic-linker,${dynlinker}"
		LDFLAGS="${LDFLAGS} -L${glibcdir}/lib -Wl,-rpath,${glibcdir}/lib -Wl,--dynamic-linker,${dynlinker}"
	fi

	if [ -z "${appfs_build_no_default_symver}" ]; then
		LDFLAGS="${LDFLAGS} -Wl,--default-symver"
	fi

	PKG_CONFIG_LIBDIR="${glibcdir}/lib/pkgconfig"

	export CC BUILD_CC HOST_CC LDFLAGS PKG_CONFIG_LIBDIR
	export CC CXX BUILD_CC HOST_CC BUILD_CXX HOST_CXX LDFLAGS PKG_CONFIG_LIBDIR
}

function configure() {
	configure_gcc
	./configure --prefix="${prefix}" --sysconfdir="${prefix}/etc" --libdir="${prefix}/lib" --localstatedir=/var "${configure_extra[@]}"
}

304
305
306
307
308
309
310
311

312
313
314
315
316
317
318
359
360
361
362
363
364
365

366
367
368
369
370
371
372
373







-
+







}

function postinstall() {
	:
}

function install() {
	make install DESTDIR="${destdir}"
	make "${make_extra[@]}" install DESTDIR="${destdir}"
}

function cleanup() {
	cd "${workdir}" || exit 1
	cd .. || exit 1
	rm -rf "${workdir}"
}
368
369
370
371
372
373
374

375
376
377
378
379
380
381
382


383


384
385
386
387
388


389
390
391
392
393
394



395
396
397
398
399
400
401
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440

441
442
443
444



445
446
447
448
449
450


451
452
453
454
455
456
457
458
459
460







+








+
+
-
+
+


-
-
-
+
+




-
-
+
+
+







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

# Download
predownload
download

# Extract
extract

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

# Verify pre-requisites are met
verifyRequiredPackages || die 'Required packages missing'
verifyPrerequisites || die 'Prerequisities failed'
# Determine properties
determinePrefix

# Start logging
set -x

# Determine properties
determinePrefix
# Verify pre-requisites are met
verifyRequiredPackages || die 'Required packages missing'
verifyPrerequisites || die 'Prerequisities failed'

# Apply patches
apply_patches

# Start the build
preconfigure || die 'preconfigure failed'
configure || die 'configure failed'