midipix / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame subr/pkg_install.subr

Lucio Andrés Illanes Albornoz (arab, vxp) 570129
#
Lucio Andrés Illanes Albornoz e1d469
# set +o errexit -o noglob -o nounset is assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
#
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
Lucio Andrés Illanes Albornoz 8a4e16
pkgp_install_perms() {
Lucio Andrés Illanes Albornoz 64c946
	local _destdir="${1}" _fname="" IFS;
Lucio Andrés Illanes Albornoz 64c946
	rtl_set_IFS_nl;
Lucio Andrés Illanes Albornoz 64c946
	for _fname in $(find "${_destdir}" -type d); do
Lucio Andrés Illanes Albornoz 8a4e16
		if ! rtl_fileop chmod 0755 "${_fname}"; then
Lucio Andrés Illanes Albornoz 8a4e16
			return 1;
Lucio Andrés Illanes Albornoz 8a4e16
		fi;
Lucio Andrés Illanes Albornoz 8a4e16
	done;
Lucio Andrés Illanes Albornoz 8a4e16
	for _fname in $(find "${_destdir}" \( -not -perm /0111 \) -type f); do
Lucio Andrés Illanes Albornoz 8a4e16
		if ! rtl_fileop chmod 0644 "${_fname}"; then
Lucio Andrés Illanes Albornoz 8a4e16
			return 1;
Lucio Andrés Illanes Albornoz 8a4e16
		fi;
Lucio Andrés Illanes Albornoz 8a4e16
	done;
Lucio Andrés Illanes Albornoz 8a4e16
	for _fname in $(find "${_destdir}" -perm /0111 -type f); do
Lucio Andrés Illanes Albornoz 8a4e16
		if ! rtl_fileop chmod 0755 "${_fname}"; then
Lucio Andrés Illanes Albornoz 8a4e16
			return 1;
Lucio Andrés Illanes Albornoz 8a4e16
		fi;
Lucio Andrés Illanes Albornoz 8a4e16
	done;
Lucio Andrés Illanes Albornoz 8a4e16
};
Lucio Andrés Illanes Albornoz 8a4e16
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
pkg_install() {
Lucio Andrés Illanes Albornoz 0875f5
	local _destdir="" _destdir_prefix="" _pkglist_name="";
Lucio Andrés Illanes Albornoz bf9edf
	if ! rtl_fileop mkdir "${PKG_PREFIX}"; then
Lucio Andrés Illanes Albornoz bf9edf
		return 1;
Lucio Andrés Illanes Albornoz 8a4e16
	else	for _destdir in "${PKG_DESTDIR}:${PKG_PREFIX}" "${PKG_DESTDIR_HOST}:${PREFIX}"; do
Lucio Andrés Illanes Albornoz 0875f5
			rtl_lassign "_destdir _destdir_prefix" ":" "${_destdir}";
Lucio Andrés Illanes Albornoz 8a4e16
			if [ -e "${_destdir}" ]; then
Lucio Andrés Illanes Albornoz 8a4e16
				pkgp_install_perms "${_destdir}";
Lucio Andrés Illanes Albornoz 8a4e16
				(set +o errexit -o noglob; rtl_flock_acquire 4 || exit "${?}"; date;
Lucio Andrés Illanes Albornoz 8a4e16
				trap "rm -f \"${BUILD_WORKDIR}/install.lock\"" EXIT;
Lucio Andrés Illanes Albornoz 8a4e16
				if ! tar -C "${_destdir}" -cpf - . | tar -C "${_destdir_prefix}" --overwrite -xpf -; then
Lucio Andrés Illanes Albornoz 8a4e16
					exit 1;
Lucio Andrés Illanes Albornoz 8a4e16
				fi) 4<>"${BUILD_WORKDIR}/install.lock";
Lucio Andrés Illanes Albornoz bf9edf
			fi;
Lucio Andrés Illanes Albornoz bf9edf
		done;
Lucio Andrés Illanes Albornoz 6054d4
		if [ "${?}" -ne 0 ]; then
Lucio Andrés Illanes Albornoz bf9edf
			return 1;
Lucio Andrés Illanes Albornoz bf9edf
		elif [ "${PKG_PKGLIST_DISABLE:-0}" -eq 0 ]; then
Lucio Andrés Illanes Albornoz bf9edf
			if [ ! -e "${PREFIX}/pkglist.${PKG_BUILD_TYPE}" ]\
Lucio Andrés Illanes Albornoz bf9edf
			&& ! touch "${PREFIX}/pkglist.${PKG_BUILD_TYPE}"; then
Lucio Andrés Illanes Albornoz bf9edf
				return 1;
Lucio Andrés Illanes Albornoz bf9edf
			else
Lucio Andrés Illanes Albornoz bf9edf
				_pkglist_name="${PKG_BASE_DIR##*/}"; _pkglist_name="${_pkglist_name%%-*}";
Lucio Andrés Illanes Albornoz e1d469
				if ! printf "%s\n" "${_pkglist_name}" >> "${PREFIX}/pkglist.${PKG_BUILD_TYPE}"; then
Lucio Andrés Illanes Albornoz bf9edf
					return 1;
Lucio Andrés Illanes Albornoz bf9edf
				fi;
Lucio Andrés Illanes Albornoz 2b85d0
			fi;
Lucio Andrés Illanes Albornoz d02931
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 435d7a
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
};
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
# vim:filetype=sh