This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch master in repository buildscripts. from 57dda5c bin/build-{deb-package,nsis-package.sh}: replace some more common logic regarding (dynamic) binary variables. new 41b35f1 bin/{build-{{deb,rpm}-package,nsis-package.sh},common.sh}: phase out some more shared functions. new 533a9bb bin/common.sh: add or clarify comments for the first two shell functions. The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: bin/build-deb-package | 31 +++------------------------- bin/build-nsis-package.sh | 30 +++------------------------ bin/build-rpm-package | 31 +++------------------------- bin/common.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 58 insertions(+), 84 deletions(-) -- Alioth's /srv/git/code.x2go.org/buildscripts.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/buildscripts.git
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@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
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository buildscripts. commit 533a9bbf00b5d3c0ce1ac7b3ced73513f9866621 Author: Mihai Moldovan <ionic@ionic.de> Date: Sun May 10 06:28:01 2015 +0200 bin/common.sh: add or clarify comments for the first two shell functions. --- bin/common.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/common.sh b/bin/common.sh index b20438d..9d77386 100644 --- a/bin/common.sh +++ b/bin/common.sh @@ -19,6 +19,10 @@ export PATH="${HOME}/bin:${PATH}" +# Takes a pseudo-boolean string representation and converts it into +# either 0 or 1. +# The result is printed as a string without a trailing newline. +# The return code is always 0. function make_boolean () { typeset -l OPTION="${1}" @@ -33,7 +37,8 @@ function make_boolean () { } # Repeats an input string. -# Returns the repeated input string. +# Returns the repeated input string without a trailing newline. +# The return code is always 0. repeat_str () { # INPUT COUNT typeset INPUT="${1:?"Error: no input string passed to ${FUNCNAME}()."}" typeset COUNT="${2:?"Error: no count passed to ${FUNCNAME}()."}" -- Alioth's /srv/git/code.x2go.org/buildscripts.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/buildscripts.git