aboutsummaryrefslogtreecommitdiff
path: root/libexec/build-install
blob: 7a2c121408505a75c146f3a4eb71ccbdbb44c932 (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
#!/usr/bin/env build

echo "installing: ${1}"
eval $(build-query --environ "${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}"

# vim: filetype=sh