public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-catalyst] releng catalyst-auto misc cleanups
@ 2022-03-13  5:55 nic boet
  0 siblings, 0 replies; only message in thread
From: nic boet @ 2022-03-13  5:55 UTC (permalink / raw
  To: gentoo-catalyst


[-- Attachment #1.1: Type: text/plain, Size: 2328 bytes --]

Greetings-
Please find attached patch for cleanups and bug fixes of releng
./tools/catalyst-auto script.
I realize there is more than one issue fixed, and some if not most is
cosmetic. Happy to split into multiple patch files, each diff section is
unique and is in order as described here.

==
update copyright header
Cosmetic :)

==
improve send_mail() because it acts more like the logger
 * output failure events to stdout if verbose set, useful for those without
a mailer
 * do not email if recipient var is undef; allows flexibility for
non-releng use cases

I was trying to troubleshoot why the script kept terminating, I didn't have
a mailer setup on that build system yet.
Figured it would also be handy to disable broadcasting messages to the
gentoo devs if testing or for unofficial user builds

==
do not source catalyst.conf as it's not bash syntax
 * non-bash formatted lines are executed; results in several "command not
found" errors
 * instead, parse the file for the specific var

These errors are cleared
/etc/catalyst/catalyst.conf: line 13: digests: command not found
/etc/catalyst/catalyst.conf: line 19: envscript: command not found
/etc/catalyst/catalyst.conf: line 22: options: command not found
/etc/catalyst/catalyst.conf: line 26: autoresume,: command not found
/etc/catalyst/catalyst.conf: line 33: bindist,: command not found
/etc/catalyst/catalyst.conf: line 39: distcc,: command not found
/etc/catalyst/catalyst.conf: line 50: kerncache,: command not found
/etc/catalyst/catalyst.conf: line 53: pkgcache,: command not found
/etc/catalyst/catalyst.conf: line 57: seedcache,: command not found
/etc/catalyst/catalyst.conf: line 66: ]: command not found
/etc/catalyst/catalyst.conf: line 87: distcc_hosts: command not found


==
make it more apparent that bash time is not used.

This will still output "which: no time", with more info now as how to
correct
which: no time in
(/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/lib/llvm/13/bin)


==
snapshot_cache was removed Apr 2020 catalyst commit
6493f3bc534f97468c514a12035b10e3107c4ecf
* --preclean would fail as catalyst.conf is invalid

Storedir now becomes the only var extracted from
/etc/catalyst/catalyst.cong using the new catalyst_var() function redefined
in this patch


Hope this helps
Thank you :)

-- 

Nic

[-- Attachment #1.2: Type: text/html, Size: 3174 bytes --]

[-- Attachment #2: catalyst-auto_misc-cleanups.patch --]
[-- Type: text/x-patch, Size: 2434 bytes --]

# Signed-off-by: Nic Boet <nic@boet.cc>
#
# update copyright header
#
# improve send_mail() because it acts more like the logger
#  * output failure events to stdout if verbose set, useful for those without a mailer
#  * do not email if recipient var is undef; allows flexibility for non-releng use cases
#
# do not source catalyst.conf as it's not bash syntax
# * non-bash formatted lines are executed; results in several "command not found" errors
# * instead, parse the file for the specific var
#
# make it more apparent that bash time is not used
#
# snapshot_cache was removed Apr 2020
# * catalyst commit 6493f3bc534f97468c514a12035b10e3107c4ecf
# * --preclean would fail as catalyst.conf is invalid
#
--- ../releng/tools/catalyst-auto	2022-03-12 09:24:33.823162592 -0600
+++ tools/catalyst-auto	2022-03-12 22:36:43.362350405 -0600
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2014 Gentoo Foundation
+# Copyright 2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 CATALYST_CONFIG=/etc/catalyst/catalyst.conf
@@ -53,8 +53,14 @@
 }
 
 send_email() {
+	if [[ ${verbose} -ge 1 ]]; then
+		echo "$1 $2 build log at $3"
+	fi
+
 	[[ ${nonetwork} == 0 ]] || return
 
+	[[ ! -z ${EMAIL_TO} ]] || return
+
 	local subject="${EMAIL_SUBJECT_PREPEND} $1"
 	local message=$2
 	local logfile=$3
@@ -113,8 +119,8 @@
 
 catalyst_var() {
 	# Extract a setting from the catalyst.conf.
-	local var=$1
-	(. "${CATALYST_CONFIG}"; echo "${!var}")
+	local var=$(grep --color=never -Po "^${1}\s*=\s*\K.*" "${CATALYST_CONFIG}" || true)
+	[[ -z ${var} ]] || echo "${var}"
 }
 
 trigger_post_build() {
@@ -323,14 +282,9 @@
 	if [[ ${preclean} == 1 ]]; then
 		rm -rf "${TMP_PATH:-/tmp}/catalyst-auto".*
 
-		snapshot_cache=$(catalyst_var snapshot_cache)
-		if [[ -z ${snapshot_cache} ]]; then
-			echo "error: snapshot_cache not set in config file"
-			exit 1
-		fi
 		pushd "${BUILD_SRCDIR_BASE}" >/dev/null || exit 1
 		rm -rf --one-file-system \
-			kerncache packages snapshots tmp "${snapshot_cache}"/*
+			kerncache packages snapshots tmp
 		popd >/dev/null
 	fi
 
@@ -421,8 +375,13 @@
 
 	build_failure=0
 
-	timeprefix=()
-	which time >/dev/null && timeprefix=( "time" )
+	# bash built-in time function is not used
+	if ! which time >/dev/null ; then
+		timeprefix=()
+		echo "sys-process/time is optional for build resource utilization"
+	else
+		timeprefix=( "time" )
+	fi
 
 	JOB_PIDS=()
 	JOB_RETS=()

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-13  5:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-13  5:55 [gentoo-catalyst] releng catalyst-auto misc cleanups nic boet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox