summaryrefslogtreecommitdiffhomepage
path: root/subr.pkg/pkg_install.subr
diff options
context:
space:
mode:
authorLucía Andrea Illanes Albornoz <lucia@luciaillanes.de>2023-02-17 19:29:28 +0100
committerLucía Andrea Illanes Albornoz <lucia@luciaillanes.de>2023-02-17 19:29:28 +0100
commite9fa0774ed2e7e030a68f5b0ae51fe6dd69fe492 (patch)
tree37e46c2578bd8f4f435073db01abc514976da8a8 /subr.pkg/pkg_install.subr
parent56495632fc8bf612766a9c431e37ff27a903e8c6 (diff)
downloadmidipix_build-e9fa0774ed2e7e030a68f5b0ae51fe6dd69fe492.tar.bz2
midipix_build-e9fa0774ed2e7e030a68f5b0ae51fe6dd69fe492.tar.xz
Make everything a bit faster.
0) Issues several prayers and sacrifices to Enki under threat of a terrible deluge sent down by Ellil 1) Convert fork-write/read exprs to be non-forking 2) Pass mostly everything by reference 3) Don't bother cleaning the variable namespace because Bourne shell is an abomination 4) Removes broken ./pkgtool.sh -s, --restart-at, --update-diff & ./build.sh --dump-{in,on-abort} 5) Cleanup
Diffstat (limited to 'subr.pkg/pkg_install.subr')
-rw-r--r--subr.pkg/pkg_install.subr37
1 files changed, 37 insertions, 0 deletions
diff --git a/subr.pkg/pkg_install.subr b/subr.pkg/pkg_install.subr
new file mode 100644
index 00000000..6fe420df
--- /dev/null
+++ b/subr.pkg/pkg_install.subr
@@ -0,0 +1,37 @@
+#
+# set +o errexit -o noglob -o nounset is assumed.
+#
+
+pkg_install() {
+ local _group_name="${1}" _pkg_name="${2}" _restart_at="${3}" \
+ _destdir="" _destdir_prefix="" _pkglist_name="";
+
+ if ! rtl_fileop mkdir "${PKG_PREFIX}"; then
+ return 1;
+ else for _destdir in "${PKG_DESTDIR}:${PKG_PREFIX}" "${PKG_DESTDIR_HOST}:${PREFIX}"; do
+ rtl_lassign "_destdir _destdir_prefix" ":" "${_destdir}";
+ if [ -e "${_destdir}" ]; then
+ (set +o errexit -o noglob; rtl_flock_acquire 4 || exit "${?}";
+ trap "rm -f \"${BUILD_WORKDIR}/install.lock\"" EXIT;
+ if ! tar -C "${_destdir}" -cpf - . | tar -C "${_destdir_prefix}" --overwrite -xpf -; then
+ exit 1;
+ fi) 4<>"${BUILD_WORKDIR}/install.lock";
+ fi;
+ done;
+ if [ "${?}" -ne 0 ]; 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 ! printf "%s\n" "${_pkglist_name}" >> "${PREFIX}/pkglist.${PKG_BUILD_TYPE}"; then
+ return 1;
+ fi;
+ fi;
+ fi;
+ fi;
+};
+
+# vim:filetype=sh