public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/catalyst:master commit in: doc/, etc/, catalyst/
@ 2015-10-08 17:19 Mike Frysinger
  0 siblings, 0 replies; only message in thread
From: Mike Frysinger @ 2015-10-08 17:19 UTC (permalink / raw
  To: gentoo-commits

commit:     6a4a77f2b22783b9b0fbad557ea5a8b63422bbda
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Oct  6 20:18:31 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Oct  6 20:18:31 2015 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=6a4a77f2

catalyst: add support for digests=auto

Rather than require people to list all possible hashes, add support for
an "auto" keyword.  This serves two purposes:
- any digest that is missing system support (e.g. missing prog), then
  that digest will be silently skipped
- if it's the only value, then all available digests will be added

 catalyst/main.py          | 47 +++++++++++++++++++++++++++++++++++------------
 doc/catalyst-config.5.txt |  2 +-
 etc/catalyst.conf         |  6 ++++--
 3 files changed, 40 insertions(+), 15 deletions(-)

diff --git a/catalyst/main.py b/catalyst/main.py
index ebec4d3..65e34ef 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -259,23 +259,46 @@ def main():
 
 	# Start checking that digests are valid now that hash_map is initialized
 	if "digests" in conf_values:
-		for i in conf_values["digests"].split():
-			if i not in HASH_DEFINITIONS:
-				print
-				print i+" is not a valid digest entry"
-				print "Valid digest entries:"
-				print HASH_DEFINITIONS.keys()
-				print
-				print "Catalyst aborting...."
-				sys.exit(2)
-			if find_binary(hash_map.hash_map[i].cmd) == None:
+		digests = set(conf_values['digests'].split())
+		valid_digests = set(HASH_DEFINITIONS.keys())
+
+		# Use the magic keyword "auto" to use all algos that are available.
+		skip_missing = False
+		if 'auto' in digests:
+			skip_missing = True
+			digests.remove('auto')
+			if not digests:
+				digests = set(valid_digests)
+
+		# First validate all the requested digests are valid keys.
+		if digests - valid_digests:
+			print
+			print "These are not a valid digest entries:"
+			print ', '.join(digests - valid_digests)
+			print "Valid digest entries:"
+			print ', '.join(sorted(valid_digests))
+			print
+			print "Catalyst aborting...."
+			sys.exit(2)
+
+		# Then check for any programs that the hash func requires.
+		for digest in digests:
+			if find_binary(hash_map.hash_map[digest].cmd) == None:
+				# In auto mode, just ignore missing support.
+				if skip_missing:
+					digests.remove(digest)
+					continue
 				print
-				print "digest=" + i
-				print "\tThe " + hash_map.hash_map[i].cmd + \
+				print "digest=" + digest
+				print "\tThe " + hash_map.hash_map[digest].cmd + \
 					" binary was not found. It needs to be in your system path"
 				print
 				print "Catalyst aborting...."
 				sys.exit(2)
+
+		# Now reload the config with our updated value.
+		conf_values['digests'] = ' '.join(digests)
+
 	if "hash_function" in conf_values:
 		if conf_values["hash_function"] not in HASH_DEFINITIONS:
 			print

diff --git a/doc/catalyst-config.5.txt b/doc/catalyst-config.5.txt
index 31c4fe9..f778a80 100644
--- a/doc/catalyst-config.5.txt
+++ b/doc/catalyst-config.5.txt
@@ -24,7 +24,7 @@ and empty lines are interpreted as comments.  For example:
 
 ---------------------------------
 # /etc/catalyst/catalyst.conf
-digests="md5 sha1 sha512 whirlpool"
+digests="auto"
 contents="auto"
 distdir="/usr/portage/distfiles"
 envscript="/etc/catalyst/catalystrc"

diff --git a/etc/catalyst.conf b/etc/catalyst.conf
index a2abb4a..939e941 100644
--- a/etc/catalyst.conf
+++ b/etc/catalyst.conf
@@ -4,13 +4,15 @@
 # documentation for more information.
 
 # Creates a .DIGESTS file containing the hash output from any of the supported
-# options below.  Adding them all may take a long time.
+# options below.  Adding them all may take a long time on slower systems.  The
+# special "auto" keyword will skip digests that the system does not support,
+# and if it's the only keyword given, will default to enabling all digests.
 # Supported hashes:
 # adler32, crc32, crc32b, gost, haval128, haval160, haval192, haval224,
 # haval256, md2, md4, md5, ripemd128, ripemd160, ripemd256, ripemd320, sha1,
 # sha224, sha256, sha384, sha512, snefru128, snefru256, tiger, tiger128,
 # tiger160, whirlpool
-digests="md5 sha1 sha512 whirlpool"
+digests="auto"
 
 # Creates a .CONTENTS file listing the contents of the file. Pick from any of
 # the supported options below:


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

only message in thread, other threads:[~2015-10-08 17:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-08 17:19 [gentoo-commits] proj/catalyst:master commit in: doc/, etc/, catalyst/ Mike Frysinger

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