public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/catalyst:master commit in: etc/, catalyst/, catalyst/base/
@ 2015-12-29  1:45 Brian Dolbec
  0 siblings, 0 replies; only message in thread
From: Brian Dolbec @ 2015-12-29  1:45 UTC (permalink / raw
  To: gentoo-commits

commit:     051f684fe3e6150bf26a445b9c18092742b6a240
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 29 01:43:53 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Dec 29 01:43:53 2015 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=051f684f

Create a file extension search order system for source paths

Adds a new source_matching setting to the config, defaults to "strict".
Allows for the possibility of multiple compression types to be present in teh same directory
and allow for a prefered matching system.

 catalyst/base/stagebase.py | 35 +++++++++++++++++++++++------------
 catalyst/defaults.py       |  1 +
 catalyst/support.py        | 13 +++++++++++--
 etc/catalyst.conf          | 12 ++++++++++++
 4 files changed, 47 insertions(+), 14 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index c800c34..8891b3f 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -143,6 +143,19 @@ class StageBase(TargetBase, ClearBase, GenBase):
 		# This must be set first as other set_ options depend on this
 		self.set_spec_prefix()
 
+		# Initialize our (de)compressor's)
+		self.decompressor = CompressMap(self.settings["decompress_definitions"],
+			env=self.env,
+			search_order=self.settings["decompressor_search_order"])
+		self.accepted_extensions = self.decompressor.search_order_extensions(
+			self.settings["decompressor_search_order"])
+		log.notice("Source file specification matching setting is: %s",
+			self.settings["source_matching"])
+		log.notice("Accepted source file extensions search order: %s",
+			self.accepted_extensions)
+		# save resources, it is not always needed
+		self.compressor = None
+
 		# Define all of our core variables
 		self.set_target_profile()
 		self.set_target_subpath()
@@ -254,14 +267,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
 			self.env["PORT_LOGDIR"] = self.settings["port_logdir"]
 			self.env["PORT_LOGDIR_CLEAN"] = PORT_LOGDIR_CLEAN
 
-		# Initialize our (de)compressor's)
-		self.decompressor = CompressMap(self.settings["decompress_definitions"],
-			env=self.env,
-			search_order=self.settings["decompressor_search_order"])
-
-		# save resources, it is not always needed
-		self.compressor = None
-
 	def override_cbuild(self):
 		if "CBUILD" in self.makeconf:
 			self.settings["CBUILD"]=self.makeconf["CBUILD"]
@@ -416,7 +421,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
 				self.settings["source_subpath"])
 			self.settings["source_path"] = file_check(
 				normpath(self.settings["storedir"] + "/builds/" +
-					self.settings["source_subpath"])
+					self.settings["source_subpath"]),
+				self.accepted_extensions,
+				self.settings["source_matching"] in ["strict"]
 				)
 			log.debug('Source path returned from file_check is: %s',
 				self.settings["source_path"])
@@ -441,9 +448,13 @@ class StageBase(TargetBase, ClearBase, GenBase):
 			"/root/*", self.settings["portdir"]]
 
 	def set_snapshot_path(self):
-		self.settings["snapshot_path"]= file_check(normpath(self.settings["storedir"]+\
-			"/snapshots/" + self.settings["snapshot_name"] +
-			self.settings["snapshot"]))
+		self.settings["snapshot_path"]= file_check(
+			normpath(self.settings["storedir"]+\
+				"/snapshots/" + self.settings["snapshot_name"] +
+				self.settings["snapshot"]),
+			self.accepted_extensions,
+			self.settings["source_matching"] is "strict"
+			)
 		log.info('SNAPSHOT_PATH set to: %s', self.settings['snapshot_path'])
 		self.settings["snapshot_path_hash"] = \
 			self.settings["hash_map"].generate_hash(

diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index c5162d6..a0e3ea8 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -43,6 +43,7 @@ confdefaults={
 	"shdir": "/usr/share/catalyst/targets/",
 	"snapshot_cache": "/var/tmp/catalyst/snapshot_cache",
 	"snapshot_name": "portage-",
+	"source_matching": "strict",
 	"storedir": "/var/tmp/catalyst",
 	}
 

diff --git a/catalyst/support.py b/catalyst/support.py
index e132568..97fe562 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -55,7 +55,7 @@ def cmd(mycmd, myexc="", env=None, debug=False, fail_func=None):
 			print_traceback=False)
 
 
-def file_check(filepath):
+def file_check(filepath, extensions=None, strict=True):
 	'''Check for the files existence and that only one exists
 	if others are found with various extensions
 	'''
@@ -68,9 +68,18 @@ def file_check(filepath):
 	files = [x for x in files if not x.endswith(".CONTENTS") and not x.endswith(".DIGESTS")]
 	if len(files) is 1:
 		return files[0]
-	elif len(files) > 1:
+	elif len(files) > 1 and strict:
 		msg = "Ambiguos Filename: %s\nPlease specify the correct extension as well" % filepath
 		raise CatalystError(msg, print_traceback=False)
+	else:
+		target_file = None
+		for ext in extensions:
+			target = filepath + "." + ext
+			if target in files:
+				target_file = target
+				break
+		if target_file:
+			return target_file
 	raise CatalystError("File Not Found: %s" % filepath)
 
 

diff --git a/etc/catalyst.conf b/etc/catalyst.conf
index 939e941..734e428 100644
--- a/etc/catalyst.conf
+++ b/etc/catalyst.conf
@@ -102,6 +102,18 @@ snapshot_cache="/var/tmp/catalyst/snapshot_cache"
 # also where it will put its temporary files and caches.
 storedir="/var/tmp/catalyst"
 
+# source_matching specifies how catalyst will match non-specific file names
+# if the filename is not found as an exact match.
+# ie: a filename without the extension specified.  "/path/to/foo"
+#
+# possible values are:
+#   "strict" meaning if more than one file of that name is present with any
+#            file extension, then it will raise an exception.
+#   "loose"  meaning it will search for an existing filename with an added
+#            extension from an ordered list of extensions determined from the
+#            decompressor_search_order specification in the spec file or (default)
+source_matching="strict"
+
 # port_logdir is where all build logs will be kept. This dir will be automatically cleaned
 # of all logs over 30 days old. If left undefined the logs will remain in the build directory
 # as usual and get cleaned every time a stage build is restarted.


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

only message in thread, other threads:[~2015-12-29  1:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-29  1:45 [gentoo-commits] proj/catalyst:master commit in: etc/, catalyst/, catalyst/base/ Brian Dolbec

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