Diff

Differences From Artifact [9ef058ff69]:

To Artifact [f6aa807d46]:


8
9
10
11
12
13
14






15
16
17
18
19
20
21

	exit 1
fi

cd "$(dirname "${ourScript}")" || exit 1

patchDir="$(pwd)/patches"







function download() {
	local url file hash
	local hashMethod
	local chkHash

	url="$1"







>
>
>
>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

	exit 1
fi

cd "$(dirname "${ourScript}")" || exit 1

patchDir="$(pwd)/patches"

if [ -z "${NACL_SDK_PEPPER}" ]; then
	echo "error: Please set NACL_SDK_PEPPER to the path of the current pepper target" >&2

	exit 1
fi

function download() {
	local url file hash
	local hashMethod
	local chkHash

	url="$1"
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
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
	unset LIBUSB_LIBS LIBUSB_CFLAGS

	rm -rf "${cackeyChromeExtCCIDDir}"
	rm -rf "${workdir}"

	cackeyChromeExtPCSCLiteDir="$(cd "${instdir}" && pwd)"
	export PCSC_CFLAGS="-I${cackeyChromeExtPCSCLiteDir}/include/PCSC"
	export PCSC_LIBS="-L${cackeyChromeExtPCSCLiteDir}/lib -lpcsclite -pthread"


	cp "${cackeyChromeExtPCSCLiteDir}/bin/pcscd" "${outdir}" || return 1


	mkdir "${outdir}/include" || return 1

	cp "${cackeyChromeExtPCSCLiteDir}/include/PCSC"/*.h "${outdir}/include" || return 1

	return 0
}

function buildCACKey() {

	local file copied










	(
		cd ../.. || exit 1

		make distclean

		./configure --with-pcsc-headers="${cackeyChromeExtPCSCLiteDir}/include/PCSC" --with-pcsc-libs="${PCSC_LIBS}" || exit 1
		make || exit 1
	) || return 1

	copied='0'
	for file in ../../libcackey{,_g}.{so,dll,dylib}; do
		if [ -f "${file}" ]; then


			cp "${file}" "${outdir}"
			copied='1'
		fi
	done

	if [ "${copied}" = '0' ]; then
		echo "error: Unable to copy built libcackey to local directory" >&2

		return 1
	fi






	rm -rf "${cackeyChromeExtPCSCLiteDir}"
	unset PCSC_CFLAGS PCSC_LIBS




	return 0

}

outdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.out"
rm -rf "${outdir}"
mkdir "${outdir}" || exit 1

buildPCSCLite || exit 1

buildCACKey || exit 1

















exit 0







|

>
|
>

<
>
|





>

>
>
>
>
>
>
>
>
>






|






>
>
|










>
>
>
>
>
|
|
>

>
>
|
>








|

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

264
265
266
267
268
269
270
271
272
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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
	unset LIBUSB_LIBS LIBUSB_CFLAGS

	rm -rf "${cackeyChromeExtCCIDDir}"
	rm -rf "${workdir}"

	cackeyChromeExtPCSCLiteDir="$(cd "${instdir}" && pwd)"
	export PCSC_CFLAGS="-I${cackeyChromeExtPCSCLiteDir}/include/PCSC"
	export PCSC_LIBS="-L${cackeyChromeExtPCSCLiteDir}/lib/dummy -lpcsclite"

	# Create dummy PC/SC library -- just enough to past CACKey linking test
	mkdir "${cackeyChromeExtPCSCLiteDir}/lib/dummy" || return 1
	echo 'void SCardEstablishContext(void) { return; }; void SCardConnect(void) { return; }' | gcc -x c - -fPIC -shared -o "${cackeyChromeExtPCSCLiteDir}/lib/dummy/libpcsclite.so"


	# Copy statically linked "pcscd" out
	cp "${cackeyChromeExtPCSCLiteDir}/bin/pcscd" "${outdir}" || return 1

	return 0
}

function buildCACKey() {
	local platform
	local file copied

	platform="$1"
	shift

	if [ -z "${platform}" ]; then
		echo 'error: Platform not specified' >&2

		return 1
	fi

	(
		cd ../.. || exit 1

		make distclean

		./configure --with-pcsc-headers="${cackeyChromeExtPCSCLiteDir}/include/PCSC" --with-pcsc-libs="${PCSC_LIBS}" "$@" || exit 1
		make || exit 1
	) || return 1

	copied='0'
	for file in ../../libcackey{,_g}.{so,dll,dylib}; do
		if [ -f "${file}" ]; then
			mkdir -p "${outdir}/${platform}"

			cp "${file}" "${outdir}/${platform}"
			copied='1'
		fi
	done

	if [ "${copied}" = '0' ]; then
		echo "error: Unable to copy built libcackey to local directory" >&2

		return 1
	fi

	return 0
}

function cleanup() {
	if [ -n "${cackeyChromeExtPCSCLiteDir}" ]; then
		rm -rf "${cackeyChromeExtPCSCLiteDir}"
		unset PCSC_CFLAGS PCSC_LIBS
	fi

	if [ -n "${cackeyChromeExtLibUSBDir}" ]; then
		rm -rf "${cackeyChromeExtLibUSBDir}"
		unset LIBUSB_LIBS LIBUSB_CFLAGS
	fi
}

outdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.out"
rm -rf "${outdir}"
mkdir "${outdir}" || exit 1

buildPCSCLite || exit 1

buildCACKey build || exit 1

buildOutputType="$(echo 'int main(int argc, char **argv) { return(0); }' | "${CC:-cc}" -x c - -o /dev/stdout | file -)" || exit 1
case "${buildOutputType}" in
	*x86-64*)
		naclTopDir='linux_x86_glibc'
		naclPlatform='x86_64-nacl'
		;;
	*)
		echo "error: Unrecognized platform output: \"${buildOutputType}\"" >&2

		exit 1
		;;
esac
PATH="${PATH}:${NACL_SDK_PEPPER}/toolchain/${naclTopDir}/bin" buildCACKey "${naclPlatform}" --host="${naclPlatform}" CC=${naclPlatform}-gcc LD=${naclPlatform}-ld OBJCOPY=${naclPlatform}-objcopy STRIP=${naclPlatform}-strip || exit 1

cleanup

exit 0