summaryrefslogtreecommitdiffhomepage
path: root/subr/pkg_install.subr
blob: 4afd07501abc49dce11355ff4358ca650b59c439 (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
42
43
44
#
# set +o errexit -o noglob is assumed.
#

pkg_install() {
	local _fname="" _ifs_old="${IFS}" _pkglist_name="" IFS;
	if ! rtl_fileop mkdir "${PKG_PREFIX}"; then
		return 1;
	else	IFS="
";		for _fname in $(find "${PKG_DESTDIR}" -type d); do
			if ! rtl_fileop chmod 0755 "${_fname}"; then
				return 1;
			fi;
		done;
		for _fname in $(find "${PKG_DESTDIR}" \( -not -perm /0111 \) -type f); do
			if ! rtl_fileop chmod 0644 "${_fname}"; then
				return 1;
			fi;
		done;
		for _fname in $(find "${PKG_DESTDIR}" -perm /0111 -type f); do
			if ! rtl_fileop chmod 0755 "${_fname}"; then
				return 1;
			fi;
		done; IFS="${_ifs_old}";
		if ! tar -C "${PKG_DESTDIR}" -cpf - . | tar -C "${PKG_PREFIX}" --overwrite -xpf -; then
			return 1;
		elif rtl_lmatch "${ARG_DIST}" "pkg" ","\
		&& ! tar -C "${PKG_DESTDIR}" -cpf - . | gzip -c -9 - > "${PKG_BASE_DIR}/${PKG_NAME}.tgz"; then
			return 1;
		elif [ "${PKG_PKGLIST_DISABLE:-0}" -eq 0 ]; then
			if [ ! -e "${PREFIX}/pkglist.${PKG_BUILD_TYPE}" ]\
			&& ! touch "${PREFIX}/pkglist.${PKG_BUILD_TYPE}"; then
				return 1;
			else
				_pkglist_name="${PKG_BASE_DIR##*/}"; _pkglist_name="${_pkglist_name%%-*}";
				if ! echo "${_pkglist_name}" >> "${PREFIX}/pkglist.${PKG_BUILD_TYPE}"; then
					return 1;
				fi;
			fi;
		fi;
	fi;
};

# vim:filetype=sh