* [gentoo-commits] proj/R_overlay:gsoc13/next commit in: files/scripts/
@ 2013-07-18 19:25 André Erdmann
2013-07-23 7:51 ` [gentoo-commits] proj/R_overlay:master " André Erdmann
0 siblings, 1 reply; 2+ messages in thread
From: André Erdmann @ 2013-07-18 19:25 UTC (permalink / raw
To: gentoo-commits
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-commits] proj/R_overlay:master commit in: files/scripts/
2013-07-18 19:25 [gentoo-commits] proj/R_overlay:gsoc13/next commit in: files/scripts/ André Erdmann
@ 2013-07-23 7:51 ` André Erdmann
0 siblings, 0 replies; 2+ messages in thread
From: André Erdmann @ 2013-07-23 7:51 UTC (permalink / raw
To: gentoo-commits
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-07-23 7:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-18 19:25 [gentoo-commits] proj/R_overlay:gsoc13/next commit in: files/scripts/ André Erdmann
2013-07-23 7:51 ` [gentoo-commits] proj/R_overlay:master " André Erdmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox