From: "André Erdmann" <dywi@mailerd.de> To: gentoo-commits@lists.gentoo.org Subject: [gentoo-commits] proj/R_overlay:gsoc13/next commit in: files/scripts/ Date: Thu, 18 Jul 2013 19:25:56 +0000 (UTC) [thread overview] Message-ID: <1374175195.f37d415d9c84ecd37a0b7ccf02e37d5106dcf486.dywi@gentoo> (raw) commit: f37d415d9c84ecd37a0b7ccf02e37d5106dcf486 Author: André Erdmann <dywi <AT> mailerd <DOT> de> AuthorDate: Thu Jul 18 19:19:55 2013 +0000 Commit: André Erdmann <dywi <AT> mailerd <DOT> de> CommitDate: Thu Jul 18 19:19:55 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=f37d415d files/scripts: run-roverlay.sh Safely run overlay creation (abort if another process is already running). This can be used to set up a cron job. --- files/scripts/run-roverlay.sh | 93 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/files/scripts/run-roverlay.sh b/files/scripts/run-roverlay.sh new file mode 100755 index 0000000..0ce26b4 --- /dev/null +++ b/files/scripts/run-roverlay.sh @@ -0,0 +1,93 @@ +#!/usr/bin/roverlay-sh +# +# This script runs R overlay creation and repoman afterwards. +# +# It will exit immediately if another instance is already running. +# To achieve this, filesystem locks are used (/run/lock/roverlay.lock). +# +# So, it's safe to set up a cronjob that calls this script. +# +set -u + +# reset DEBUG, VERBOSE, QUIET +DEBUG=n; QUIET=n; VERBOSE=y + +LC_COLLATE=C + +. "${FUNCTIONS?}" || exit 9 + +readonly MY_LOCK=/run/lock/roverlay +MY_LOCK_PID= + +# void run__cleanup ( **MY_LOCK_PID!, **MY_LOCK ) +# +# Atexit function that releases the lock. +# +run__cleanup() { + # release trap + trap - INT TERM EXIT + + # release lock + if [ -n "${MY_LOCK_PID-}" ]; then + kill "${MY_LOCK_PID}" + wait "${MY_LOCK_PID}" 2>>${DEVNULL} && MY_LOCK_PID= + fi + lockfile-remove "${MY_LOCK}" || true +} + + +# prepare: + +# (TODO) +REPOMAN_ARGS="--pretend full" + +WANT_ROVERLAY_CREATE=y +WANT_ROVERLAY_SYNC=y +WANT_REPOMAN=y + +# parse args +doshift=1 +while [ $# -gt 0 ]; do + case "${1?}" in + '+C'|'--no-create') WANT_ROVERLAY_CREATE=n ;; + '+S'|'--no-sync') WANT_ROVERLAY_SYNC=n ;; + '+R'|'--no-repoman') WANT_REPOMAN=n ;; + *) + die "unknown arg: ${1}" ${EX_ARG_ERR?} + ;; + esac + shift ${doshift} || OUT_OF_BOUNDS + doshift=1 +done +unset -v doshift + +# anything to do? + +# main: +# +# anything to do? acquire lock +if ! list_has y \ + "${WANT_ROVERLAY_CREATE}" "${WANT_ROVERLAY_SYNC}" "${WANT_REPOMAN}" +then + die 'nothing to do' 2 +elif lockfile-create --retry 0 "${MY_LOCK}" 2>>${DEVNULL}; then + # hold lock until done + lockfile-touch "${MY_LOCK}" & + MY_LOCK_PID="$!" + trap run__cleanup INT TERM EXIT + + roverlay_opts="" + roverlay_opts() { roverlay_opts="${roverlay_opts-}${roverlay_opts:+ }$*"; } + + ! yesno "${WANT_ROVERLAY_SYNC}" || roverlay_opts "--nosync" + + # run roverlay + if ${ROVERLAY_EXE} ${roverlay_opts}; then + # success, continue with repoman + if yesno "${WANT_REPOMAN}"; then + ( cd "${S}" && repoman ${REPOMAN_ARGS} 2>&1 1>"${WORKDIR}/repoman.log"; ) + fi + fi +else + die "another instance is already running" 0 +fi
WARNING: multiple messages have this Message-ID (diff)
From: "André Erdmann" <dywi@mailerd.de> To: gentoo-commits@lists.gentoo.org Subject: [gentoo-commits] proj/R_overlay:master commit in: files/scripts/ Date: Tue, 23 Jul 2013 07:51:30 +0000 (UTC) [thread overview] Message-ID: <1374175195.f37d415d9c84ecd37a0b7ccf02e37d5106dcf486.dywi@gentoo> (raw) Message-ID: <20130723075130.ljsDHo6k62mJz6ZdncfSHUyPX4sM6G-bAPGBjCXolRk@z> (raw) commit: f37d415d9c84ecd37a0b7ccf02e37d5106dcf486 Author: André Erdmann <dywi <AT> mailerd <DOT> de> AuthorDate: Thu Jul 18 19:19:55 2013 +0000 Commit: André Erdmann <dywi <AT> mailerd <DOT> de> CommitDate: Thu Jul 18 19:19:55 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=f37d415d files/scripts: run-roverlay.sh Safely run overlay creation (abort if another process is already running). This can be used to set up a cron job. --- files/scripts/run-roverlay.sh | 93 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/files/scripts/run-roverlay.sh b/files/scripts/run-roverlay.sh new file mode 100755 index 0000000..0ce26b4 --- /dev/null +++ b/files/scripts/run-roverlay.sh @@ -0,0 +1,93 @@ +#!/usr/bin/roverlay-sh +# +# This script runs R overlay creation and repoman afterwards. +# +# It will exit immediately if another instance is already running. +# To achieve this, filesystem locks are used (/run/lock/roverlay.lock). +# +# So, it's safe to set up a cronjob that calls this script. +# +set -u + +# reset DEBUG, VERBOSE, QUIET +DEBUG=n; QUIET=n; VERBOSE=y + +LC_COLLATE=C + +. "${FUNCTIONS?}" || exit 9 + +readonly MY_LOCK=/run/lock/roverlay +MY_LOCK_PID= + +# void run__cleanup ( **MY_LOCK_PID!, **MY_LOCK ) +# +# Atexit function that releases the lock. +# +run__cleanup() { + # release trap + trap - INT TERM EXIT + + # release lock + if [ -n "${MY_LOCK_PID-}" ]; then + kill "${MY_LOCK_PID}" + wait "${MY_LOCK_PID}" 2>>${DEVNULL} && MY_LOCK_PID= + fi + lockfile-remove "${MY_LOCK}" || true +} + + +# prepare: + +# (TODO) +REPOMAN_ARGS="--pretend full" + +WANT_ROVERLAY_CREATE=y +WANT_ROVERLAY_SYNC=y +WANT_REPOMAN=y + +# parse args +doshift=1 +while [ $# -gt 0 ]; do + case "${1?}" in + '+C'|'--no-create') WANT_ROVERLAY_CREATE=n ;; + '+S'|'--no-sync') WANT_ROVERLAY_SYNC=n ;; + '+R'|'--no-repoman') WANT_REPOMAN=n ;; + *) + die "unknown arg: ${1}" ${EX_ARG_ERR?} + ;; + esac + shift ${doshift} || OUT_OF_BOUNDS + doshift=1 +done +unset -v doshift + +# anything to do? + +# main: +# +# anything to do? acquire lock +if ! list_has y \ + "${WANT_ROVERLAY_CREATE}" "${WANT_ROVERLAY_SYNC}" "${WANT_REPOMAN}" +then + die 'nothing to do' 2 +elif lockfile-create --retry 0 "${MY_LOCK}" 2>>${DEVNULL}; then + # hold lock until done + lockfile-touch "${MY_LOCK}" & + MY_LOCK_PID="$!" + trap run__cleanup INT TERM EXIT + + roverlay_opts="" + roverlay_opts() { roverlay_opts="${roverlay_opts-}${roverlay_opts:+ }$*"; } + + ! yesno "${WANT_ROVERLAY_SYNC}" || roverlay_opts "--nosync" + + # run roverlay + if ${ROVERLAY_EXE} ${roverlay_opts}; then + # success, continue with repoman + if yesno "${WANT_REPOMAN}"; then + ( cd "${S}" && repoman ${REPOMAN_ARGS} 2>&1 1>"${WORKDIR}/repoman.log"; ) + fi + fi +else + die "another instance is already running" 0 +fi
next reply other threads:[~2013-07-18 19:26 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-07-18 19:25 André Erdmann [this message] 2013-07-23 7:51 ` [gentoo-commits] proj/R_overlay:master commit in: files/scripts/ André Erdmann
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1374175195.f37d415d9c84ecd37a0b7ccf02e37d5106dcf486.dywi@gentoo \ --to=dywi@mailerd.de \ --cc=gentoo-commits@lists.gentoo.org \ --cc=gentoo-dev@lists.gentoo.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox