aboutsummaryrefslogtreecommitdiff
path: root/libexec/build-make-install
blob: 915a2ffa5c62df466488dfd69e140656a176a395 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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
#!/usr/bin/env build

build_make_install()
{(
	echo "installing: ${1}"
	load_rules "${1}"

	if [ ! -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" ]; then
		die "archive does not exist for package '${NAME}'"
	fi
	if [ ! -d "${SYSROOT}" ]; then
		mkdir -p "${SYSROOT}" || die "failed to create system root @ '${SYSROOT}'"
	fi

	# FIXME the builder configs should decide the binpkg archive format.
	case "${ARCHIVE_FORMAT}" in
	(tbz2|tar.bz2)	ARCHIVE_DECOMPRESSOR="bzip2 -dc";;
	(tgz|tar.gz)	ARCHIVE_DECOMPRESSOR="gzip -dc";;
	(*)		die "unsupported archive format '${ARCHIVE_FORMAT}'";;
	esac

	cd "${SYSROOT}"

	if [ -f "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" ]; then
		echo "${NAME}: removing previous version"
		cat "var/db/binpkgs/${CATEGORY}/${NAME}" | xargs -0 rm  -f
		rm "var/db/binpkgs/${CATEGORY}/${NAME}"
	fi

	${ARCHIVE_DECOMPRESSOR} "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" | tar x
	touch "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}"
)}

if test "${BUILDER_CALL_STACK}" = '__main__'; then
	simple_usage 'install' '[all|[<category>/]<package|all>]' "$@"
	build_make_install "${@}"
fi



# vim: filetype=sh