summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--subr/pkg_install.subr13
-rw-r--r--subr/rtl_complex.subr13
-rw-r--r--subr/rtl_fetch.subr20
3 files changed, 17 insertions, 29 deletions
diff --git a/subr/pkg_install.subr b/subr/pkg_install.subr
index 8a033572..ef3fed28 100644
--- a/subr/pkg_install.subr
+++ b/subr/pkg_install.subr
@@ -22,17 +22,8 @@ pkg_install() {
return 1;
fi;
done; IFS="${_ifs_old}";
- (set +o errexit -o noglob; trap "rm -f \"${BUILD_WORKDIR}/install.lock\"" EXIT;
- date;
- while true; do
- if flock -E 622 -w 600 4; then
- break;
- elif [ "${?}" -eq 622 ]; then
- continue;
- else
- exit "${?}";
- fi;
- done;
+ (set +o errexit -o noglob; rtl_flock_acquire 4 || exit "${?}"; date;
+ trap "rm -f \"${BUILD_WORKDIR}/install.lock\"" EXIT;
if ! tar -C "${PKG_DESTDIR}" -cpf - . | tar -C "${PKG_PREFIX}" --overwrite -xpf -; then
exit 1;
fi) 4<>"${BUILD_WORKDIR}/install.lock";
diff --git a/subr/rtl_complex.subr b/subr/rtl_complex.subr
index 2ce5dd16..8aa59bec 100644
--- a/subr/rtl_complex.subr
+++ b/subr/rtl_complex.subr
@@ -95,6 +95,19 @@ rtl_filter_vars() {
printf "%s" "${_vars}";
};
+rtl_flock_acquire() {
+ local _fd="${1}" _conflict_exit_code="${2:-622}" _wait="${3:-3600}"
+ while true; do
+ if flock -E "${_conflict_exit_code}" -w "${_wait}" "${_fd}"; then
+ break;
+ elif [ "${?}" -eq "${_conflict_exit_code}" ]; then
+ continue;
+ else
+ return "${?}";
+ fi;
+ done;
+};
+
rtl_get_cpu_count() {
local _line="" _ncpus=0 _rc=0 _sname="$(uname -s 2>/dev/null)"; _status="";
case "${_sname}" in
diff --git a/subr/rtl_fetch.subr b/subr/rtl_fetch.subr
index 1fd72e99..cf7e3955 100644
--- a/subr/rtl_fetch.subr
+++ b/subr/rtl_fetch.subr
@@ -6,16 +6,8 @@ exp_rtl_fetch_url_git() {
local _tgtdir="${1}" _subdir="${2}" _url="${3}" _branch="${4}" \
_oldpwd="";
(set -o errexit -o noglob -o nounset;
+ rtl_flock_acquire 4 || exit "${?}";
trap "rm -f \"${BUILD_DLCACHEDIR}/${_subdir%%[/]}.fetching\"" EXIT;
- while true; do
- if flock -E 622 -w 3600 4; then
- break;
- elif [ "${?}" -eq 622 ]; then
- continue;
- else
- exit "${?}";
- fi;
- done;
if [ -e "${BUILD_DLCACHEDIR}/${_subdir}" ]; then
(rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\
git pull ${DEFAULT_GIT_ARGS} origin "${_branch:-main}");
@@ -69,16 +61,8 @@ rtl_fetch_url_wget() {
fi;
_url_dst="${BUILD_DLCACHEDIR}/${_target_fname}";
(set -o errexit -o noglob -o nounset;
+ rtl_flock_acquire 4 || exit "${?}";
trap "_rc=\"\${?}\" ;rm -f \"${_url_dst}.fetching\"; exit \"\${_rc}\";" EXIT;
- while true; do
- if flock -E 622 -w 3600 4; then
- break;
- elif [ "${?}" -eq 622 ]; then
- continue;
- else
- exit "${?}";
- fi;
- done;
if [ ! -e "${_url_dst}.fetched" ]; then
wget ${DEFAULT_WGET_ARGS} -O "${_url_dst}" "${_url}";
if [ -n "${_sha256sum_src}" ]; then