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 525BC59CA6 for ; Tue, 22 Mar 2016 01:49:02 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D42C821C01D; Tue, 22 Mar 2016 01:48:59 +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 2292B21C01D for ; Tue, 22 Mar 2016 01:48:59 +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 2E120340B07 for ; Tue, 22 Mar 2016 01:48:58 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 49619864 for ; Tue, 22 Mar 2016 01:48:54 +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: <1458538452.f34a62d0ab062674ba70d60611c35e88dc60c112.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: f34a62d0ab062674ba70d60611c35e88dc60c112 X-VCS-Branch: master Date: Tue, 22 Mar 2016 01:48:54 +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: 29d7b362-e58c-4665-9aae-f44c38200e8e X-Archives-Hash: 5c8520bd0964ce90d04cd1992843bcd2 commit: f34a62d0ab062674ba70d60611c35e88dc60c112 Author: Mike Frysinger gentoo org> AuthorDate: Mon Mar 21 05:34:12 2016 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Mon Mar 21 05:34:12 2016 +0000 URL: https://gitweb.gentoo.org/proj/releng.git/commit/?id=f34a62d0 catalyst-auto: add a time delay option We usually run catalyst on systems via cronjob, and do so at weekly (or so) intervals. But if a failure hits a run, it will be a while before we know if changes fixed the situation. Instead, let's push the delay logic into the script itself so we can run this tool once a day. When it passes, it will take care of quitting early. When it fails, it will retry once a day until it passes. tools/catalyst-auto | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/catalyst-auto b/tools/catalyst-auto index a018dc9..f20aa1d 100755 --- a/tools/catalyst-auto +++ b/tools/catalyst-auto @@ -25,6 +25,7 @@ verbose=0 keep_tmpdir=0 testing=0 preclean=0 +lastrun=0 # Set pipefail so that run_cmd returns the right value in $? set -o pipefail @@ -46,6 +47,7 @@ Options: -v|--verbose Send output of commands to console as well as log -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 -h|--help Show this message and quit EOH @@ -124,6 +126,10 @@ do -C|--preclean) preclean=1 ;; + --interval) + lastrun=$1 + shift + ;; -*) usage "ERROR: You have specified an invalid option: ${a}" exit 1 @@ -151,6 +157,16 @@ fi BUILD_SRCDIR_BASE=$(catalyst_var storedir) +# See if we had a recent success. +if [[ ${lastrun} -ne 0 ]]; then + last_success_file="${BUILD_SRCDIR_BASE}/.last_success" + delay=$(( lastrun * 24 * 60 * 60 )) + last_success=$(head -1 "${last_success_file}" 2>/dev/null || echo 0) + if [[ $(date +%s) -lt $(( last_success + delay )) ]]; then + exit 0 + fi +fi + TMPDIR=$(mktemp -d --tmpdir="${TMP_PATH:-/tmp}" catalyst-auto.XXXXXX) DATESTAMP=$(date +%Y%m%d) @@ -298,6 +314,11 @@ if ! run_cmd "post_build" "${TMPDIR}/log/post_build.log"; then fi if [ ${build_failure} = 0 ]; then + if [[ ${lastrun} -ne 0 ]]; then + stamp=$(date) + (date -d"${stamp}" +%s; echo "${stamp}") >"${last_success_file}" + fi + send_email "Catalyst build success" "Build process complete." if [ "${keep_tmpdir}" = 0 ]; then