diff options
author | Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de> | 2020-03-02 11:16:26 +0000 |
---|---|---|
committer | Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de> | 2020-03-02 11:16:26 +0000 |
commit | 6054d40c03c13989692038f9ae860f9a873a19ee (patch) | |
tree | 5273b765a148958f0df63e7e5355c8464dc01d4a | |
parent | 221ee9ab8f7be62b3bf1adf14e406d138a96ac08 (diff) | |
download | midipix_build-6054d40c03c13989692038f9ae860f9a873a19ee.tar.bz2 midipix_build-6054d40c03c13989692038f9ae860f9a873a19ee.tar.xz |
subr/pkg_install.subr: serialise simultaneous installation to ${PKG_PREFIX} w/ flock(1).
-rw-r--r-- | subr/pkg_install.subr | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/subr/pkg_install.subr b/subr/pkg_install.subr index 4bc789ef..ffe2d8dd 100644 --- a/subr/pkg_install.subr +++ b/subr/pkg_install.subr @@ -22,7 +22,21 @@ pkg_install() { return 1; fi; done; IFS="${_ifs_old}"; + (set +o errexit -o noglob; trap "rm -f \"${BUILD_DLCACHEDIR}/install.lock\"" EXIT; + date; echo trying to grab lock + while true; do + if flock -E 622 -w 600 4; then + break; + elif [ "${?}" -eq 622 ]; then + continue; + else + exit "${?}"; + fi; + done; if ! tar -C "${PKG_DESTDIR}" -cpf - . | tar -C "${PKG_PREFIX}" --overwrite -xpf -; then + exit 1; + fi) 4<>"${BUILD_WORKDIR}/install.lock"; + if [ "${?}" -ne 0 ]; then return 1; elif [ "${PKG_PKGLIST_DISABLE:-0}" -eq 0 ]; then if [ ! -e "${PREFIX}/pkglist.${PKG_BUILD_TYPE}" ]\ |