[X2Go-Commits] [buildscripts] 01/02: bin/{build-{{deb, rpm}-package, nsis-package.sh}, common.sh}: phase out some more shared functions.
git-admin at x2go.org
git-admin at x2go.org
Sun May 10 06:27:59 CEST 2015
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository buildscripts.
commit 41b35f18b316b2fc93104095e3227461ad69e339
Author: Mihai Moldovan <ionic at ionic.de>
Date: Sun May 10 06:26:05 2015 +0200
bin/{build-{{deb,rpm}-package,nsis-package.sh},common.sh}: phase out some more shared functions.
There are:
- wait_for_lock()
- lock_workspace()
- unlock_workspace()
- delay_build()
---
bin/build-deb-package | 31 +++----------------------------
bin/build-nsis-package.sh | 30 +++---------------------------
bin/build-rpm-package | 31 +++----------------------------
bin/common.sh | 43 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 52 insertions(+), 83 deletions(-)
diff --git a/bin/build-deb-package b/bin/build-deb-package
index 9f8f151..0c7124e 100755
--- a/bin/build-deb-package
+++ b/bin/build-deb-package
@@ -374,31 +374,6 @@ upload_packages() {
return 0
}
-wait_for_lock() {
- while [ -f "${LOCK_FILE}" ]; do
- pid="$(head -n1 "${LOCK_FILE}")"
- if ! ps "${pid}" 1>/dev/null; then
- rm -f -- "${LOCK_FILE}"
- else
- echo "PROJECT directory is locked, sleeping for 10 seconds..."
- sleep 10
- fi
- done
-}
-
-lock_workspace() {
- wait_for_lock
-
- echo "${$}" > "${LOCK_FILE}"
-}
-
-unlock_workspace() {
- rm -f -- "${LOCK_FILE}"
-}
-
-delay_build() {
- sleep $[ ( ${RANDOM} % 30 ) + 1 ]s
-}
### MAIN ###
set_vars "${@}" && {
@@ -412,13 +387,13 @@ set_vars "${@}" && {
if [ "${FORCE_BUILD}" -eq "1" ] && [ "${NO_DELAY}" -eq "0" ]; then
delay_build
fi
- lock_workspace
+ lock_workspace "${LOCK_FILE}"
prepare_workspace && {
- unlock_workspace
+ unlock_workspace "${LOCK_FILE}"
clear_pkgdist
build_packages
}
- unlock_workspace
+ unlock_workspace "${LOCK_FILE}"
}
fi
if [ "x$(basename "${0}")" = "x${PREFIX}-upload-deb-package" ] || [ "x$(basename "${0}")" = "x${PREFIX}-build+upload-deb-package" ]; then
diff --git a/bin/build-nsis-package.sh b/bin/build-nsis-package.sh
index 5c99ed3..9739d2b 100755
--- a/bin/build-nsis-package.sh
+++ b/bin/build-nsis-package.sh
@@ -270,30 +270,6 @@ upload_packages() {
return 0
}
-wait_for_lock() {
- while [ -f "${LOCK_FILE}" ]; do
- pid="$(head -n1 "${LOCK_FILE}")"
- if ! ps "${pid}" 1>/dev/null; then
- rm -f "${LOCK_FILE}"
- else
- echo "PROJECT directory is locked, sleeping for 10 seconds..."
- sleep 10
- fi
- done
-}
-
-lock_workspace() {
- wait_for_lock
- echo "${$}" > "${LOCK_FILE}"
-}
-
-unlock_workspace() {
- rm -f "${LOCK_FILE}"
-}
-
-delay_build() {
- sleep $[ ( ${RANDOM} % 30 ) + 1 ]s
-}
### MAIN ###
set_vars "${@}" && {
@@ -307,13 +283,13 @@ set_vars "${@}" && {
if [ "${FORCE_BUILD}" -eq "1" ] && [ "${NO_DELAY}" -eq "0" ]; then
delay_build
fi
- lock_workspace
+ lock_workspace "${LOCK_FILE}"
prepare_workspace && {
- unlock_workspace
+ unlock_workspace "${LOCK_FILE}"
# clear_pkgdist
build_packages
}
- unlock_workspace
+ unlock_workspace "${LOCK_FILE}"
}
fi
if [ "x$(basename "${0}")" = "xupload-nsis-package.sh" ] || [ "x$(basename "${0}")" = "xbuild+upload-nsis-package.sh" ]; then
diff --git a/bin/build-rpm-package b/bin/build-rpm-package
index b2ed316..4b8623c 100755
--- a/bin/build-rpm-package
+++ b/bin/build-rpm-package
@@ -885,31 +885,6 @@ upload_packages() {
return 0
}
-wait_for_lock() {
- while [ -f "${LOCK_FILE}" ]; do
- pid="$(head -n1 "${LOCK_FILE}")"
- if ! ps "${pid}" 1>/dev/null; then
- rm -f -- "${LOCK_FILE}"
- else
- echo "PROJECT directory is locked, sleeping for 10 seconds..."
- sleep 10
- fi
- done
-}
-
-lock_workspace() {
- wait_for_lock
- echo "${$}" > "${LOCK_FILE}"
-}
-
-unlock_workspace() {
- rm -f -- "${LOCK_FILE}"
-}
-
-delay_build() {
- sleep $[ ( ( ${RANDOM} % 10 ) + 1 ) * 10 ]s
-}
-
### MAIN ###
set_vars "${@}" && {
@@ -925,13 +900,13 @@ set_vars "${@}" && {
if [ "${FORCE_BUILD}" -eq "1" ] && [ "${NO_DELAY}" -eq "0" ]; then
delay_build
fi
- lock_workspace
+ lock_workspace "${LOCK_FILE}"
prepare_workspace && {
- unlock_workspace
+ unlock_workspace "${LOCK_FILE}"
clear_pkgdist
build_packages
}
- unlock_workspace
+ unlock_workspace "${LOCK_FILE}"
}
fi
if [ "x$(basename "${0}")" = "x${PREFIX}-upload-rpm-package" ] || [ "x$(basename "${0}")" = "x${PREFIX}-build+upload-rpm-package" ]; then
diff --git a/bin/common.sh b/bin/common.sh
index 946ae58..b20438d 100644
--- a/bin/common.sh
+++ b/bin/common.sh
@@ -49,3 +49,46 @@ repeat_str () { # INPUT COUNT
return 0
}
+
+# Takes a lock file path as its first argument and spins
+# while the lock exists, sleeping 10 seconds after every check.
+# Has no explicit return value.
+wait_for_lock () {
+ typeset lock_file="${1}"
+
+ while [ -f "${lock_file}" ]; do
+ pid="$(head -n1 "${lock_file}")"
+ if ! ps "${pid}" 1>/dev/null; then
+ rm -f -- "${lock_file}"
+ else
+ echo "PROJECT directory is locked, sleeping for 10 seconds..."
+ sleep 10
+ fi
+ done
+}
+
+# Takes a lock file path as its first argument and creates
+# this lock file. Its only content will be the current PID.
+# Has no explicit return value.
+lock_workspace () {
+ typeset lock_file="${1}"
+
+ wait_for_lock "${lock_file}"
+ echo "${$}" > "${lock_file}"
+}
+
+# Takes a lock file path as its first argument and deletes
+# this lock file.
+# Has no explicit return value.
+unlock_workspace () {
+ typeset lock_file="${1}"
+
+ rm -f -- "${lock_file}"
+}
+
+# Delays further execution of the script by a pseudo-random
+# amount of seconds. Values range from 1 second to 100 seconds.
+# Has no explicit return value.
+delay_build () {
+ sleep "$(((${RANDOM} % 100) + 1))s"
+}
--
Alioth's /srv/git/code.x2go.org/buildscripts.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/buildscripts.git
More information about the x2go-commits
mailing list