From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 8305059CA5 for ; Wed, 23 Mar 2016 18:23:22 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 56BBC21C002; Wed, 23 Mar 2016 18:23:20 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 052DE21C002 for ; Wed, 23 Mar 2016 18:23:19 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 130EE340C42 for ; Wed, 23 Mar 2016 18:23:18 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id BEA6285D for ; Wed, 23 Mar 2016 18:23:15 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1458757252.51b8860d23dd16bd51d6e87a0d13d2bb6ae27073.vapier@gentoo> Subject: [gentoo-commits] proj/releng:master commit in: tools/ X-VCS-Repository: proj/releng X-VCS-Files: tools/catalyst-auto X-VCS-Directories: tools/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 51b8860d23dd16bd51d6e87a0d13d2bb6ae27073 X-VCS-Branch: master Date: Wed, 23 Mar 2016 18:23:15 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: de1bda6e-cb66-4206-8a66-0d8c785d4810 X-Archives-Hash: c631af44df28612c0f13737a7993f8bc commit: 51b8860d23dd16bd51d6e87a0d13d2bb6ae27073 Author: Mike Frysinger gentoo org> AuthorDate: Wed Mar 23 18:20:52 2016 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Wed Mar 23 18:20:52 2016 +0000 URL: https://gitweb.gentoo.org/proj/releng.git/commit/?id=51b8860d catalyst-auto: add an option to hold a lock while running This makes it easy to put into a cronjob and not worry about a copy already/still running. tools/catalyst-auto | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/catalyst-auto b/tools/catalyst-auto index 0b1c389..75f6a84 100755 --- a/tools/catalyst-auto +++ b/tools/catalyst-auto @@ -26,6 +26,7 @@ keep_tmpdir=0 testing=0 preclean=0 lastrun=0 +lock_file= # Set pipefail so that run_cmd returns the right value in $? set -o pipefail @@ -48,6 +49,7 @@ Options: -k|--keep-tmpdir Don't remove temp dir when build finishes -t|--test Stop after mangling specs and copying files --interval Exit if last successful run was less than ago + -l|--lock File to grab a lock on to prevent multiple invocations -h|--help Show this message and quit EOH @@ -130,6 +132,10 @@ do lastrun=$1 shift ;; + -l|--lock) + lock_file=$1 + shift + ;; -*) usage "ERROR: You have specified an invalid option: ${a}" exit 1 @@ -137,6 +143,15 @@ do esac done +( + +if [[ -n ${lock_file} ]]; then + if ! flock -n 9; then + echo "catalyst-auto already running" + exit 1 + fi +fi + # Probe the default gitdir from this script name. GITDIR=$(dirname "$(dirname "$(realpath "$0")")") @@ -331,3 +346,5 @@ if [ ${build_failure} = 0 ]; then else send_email "Catalyst build complete, but with errors" "Build process has completed, but there were errors. Please consult previous emails to determine the problem." fi + +) 9>"${lock_file:-/dev/null}"