aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--catalyst/base/stagebase.py35
-rw-r--r--catalyst/defaults.py1
-rw-r--r--catalyst/support.py13
-rw-r--r--etc/catalyst.conf12
4 files changed, 47 insertions, 14 deletions
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index c800c34d..8891b3fb 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 c5162d68..a0e3ea87 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 e1325685..97fe5620 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 939e9413..734e4284 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.