Gentoo Archives: gentoo-commits

From: Brian Dolbec <dolsen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/catalyst:master commit in: etc/, catalyst/, catalyst/base/
Date: Tue, 29 Dec 2015 01:45:38
Message-Id: 1451353433.051f684fe3e6150bf26a445b9c18092742b6a240.dolsen@gentoo
1 commit: 051f684fe3e6150bf26a445b9c18092742b6a240
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Tue Dec 29 01:43:53 2015 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Tue Dec 29 01:43:53 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=051f684f
7
8 Create a file extension search order system for source paths
9
10 Adds a new source_matching setting to the config, defaults to "strict".
11 Allows for the possibility of multiple compression types to be present in teh same directory
12 and allow for a prefered matching system.
13
14 catalyst/base/stagebase.py | 35 +++++++++++++++++++++++------------
15 catalyst/defaults.py | 1 +
16 catalyst/support.py | 13 +++++++++++--
17 etc/catalyst.conf | 12 ++++++++++++
18 4 files changed, 47 insertions(+), 14 deletions(-)
19
20 diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
21 index c800c34..8891b3f 100644
22 --- a/catalyst/base/stagebase.py
23 +++ b/catalyst/base/stagebase.py
24 @@ -143,6 +143,19 @@ class StageBase(TargetBase, ClearBase, GenBase):
25 # This must be set first as other set_ options depend on this
26 self.set_spec_prefix()
27
28 + # Initialize our (de)compressor's)
29 + self.decompressor = CompressMap(self.settings["decompress_definitions"],
30 + env=self.env,
31 + search_order=self.settings["decompressor_search_order"])
32 + self.accepted_extensions = self.decompressor.search_order_extensions(
33 + self.settings["decompressor_search_order"])
34 + log.notice("Source file specification matching setting is: %s",
35 + self.settings["source_matching"])
36 + log.notice("Accepted source file extensions search order: %s",
37 + self.accepted_extensions)
38 + # save resources, it is not always needed
39 + self.compressor = None
40 +
41 # Define all of our core variables
42 self.set_target_profile()
43 self.set_target_subpath()
44 @@ -254,14 +267,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
45 self.env["PORT_LOGDIR"] = self.settings["port_logdir"]
46 self.env["PORT_LOGDIR_CLEAN"] = PORT_LOGDIR_CLEAN
47
48 - # Initialize our (de)compressor's)
49 - self.decompressor = CompressMap(self.settings["decompress_definitions"],
50 - env=self.env,
51 - search_order=self.settings["decompressor_search_order"])
52 -
53 - # save resources, it is not always needed
54 - self.compressor = None
55 -
56 def override_cbuild(self):
57 if "CBUILD" in self.makeconf:
58 self.settings["CBUILD"]=self.makeconf["CBUILD"]
59 @@ -416,7 +421,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
60 self.settings["source_subpath"])
61 self.settings["source_path"] = file_check(
62 normpath(self.settings["storedir"] + "/builds/" +
63 - self.settings["source_subpath"])
64 + self.settings["source_subpath"]),
65 + self.accepted_extensions,
66 + self.settings["source_matching"] in ["strict"]
67 )
68 log.debug('Source path returned from file_check is: %s',
69 self.settings["source_path"])
70 @@ -441,9 +448,13 @@ class StageBase(TargetBase, ClearBase, GenBase):
71 "/root/*", self.settings["portdir"]]
72
73 def set_snapshot_path(self):
74 - self.settings["snapshot_path"]= file_check(normpath(self.settings["storedir"]+\
75 - "/snapshots/" + self.settings["snapshot_name"] +
76 - self.settings["snapshot"]))
77 + self.settings["snapshot_path"]= file_check(
78 + normpath(self.settings["storedir"]+\
79 + "/snapshots/" + self.settings["snapshot_name"] +
80 + self.settings["snapshot"]),
81 + self.accepted_extensions,
82 + self.settings["source_matching"] is "strict"
83 + )
84 log.info('SNAPSHOT_PATH set to: %s', self.settings['snapshot_path'])
85 self.settings["snapshot_path_hash"] = \
86 self.settings["hash_map"].generate_hash(
87
88 diff --git a/catalyst/defaults.py b/catalyst/defaults.py
89 index c5162d6..a0e3ea8 100644
90 --- a/catalyst/defaults.py
91 +++ b/catalyst/defaults.py
92 @@ -43,6 +43,7 @@ confdefaults={
93 "shdir": "/usr/share/catalyst/targets/",
94 "snapshot_cache": "/var/tmp/catalyst/snapshot_cache",
95 "snapshot_name": "portage-",
96 + "source_matching": "strict",
97 "storedir": "/var/tmp/catalyst",
98 }
99
100
101 diff --git a/catalyst/support.py b/catalyst/support.py
102 index e132568..97fe562 100644
103 --- a/catalyst/support.py
104 +++ b/catalyst/support.py
105 @@ -55,7 +55,7 @@ def cmd(mycmd, myexc="", env=None, debug=False, fail_func=None):
106 print_traceback=False)
107
108
109 -def file_check(filepath):
110 +def file_check(filepath, extensions=None, strict=True):
111 '''Check for the files existence and that only one exists
112 if others are found with various extensions
113 '''
114 @@ -68,9 +68,18 @@ def file_check(filepath):
115 files = [x for x in files if not x.endswith(".CONTENTS") and not x.endswith(".DIGESTS")]
116 if len(files) is 1:
117 return files[0]
118 - elif len(files) > 1:
119 + elif len(files) > 1 and strict:
120 msg = "Ambiguos Filename: %s\nPlease specify the correct extension as well" % filepath
121 raise CatalystError(msg, print_traceback=False)
122 + else:
123 + target_file = None
124 + for ext in extensions:
125 + target = filepath + "." + ext
126 + if target in files:
127 + target_file = target
128 + break
129 + if target_file:
130 + return target_file
131 raise CatalystError("File Not Found: %s" % filepath)
132
133
134
135 diff --git a/etc/catalyst.conf b/etc/catalyst.conf
136 index 939e941..734e428 100644
137 --- a/etc/catalyst.conf
138 +++ b/etc/catalyst.conf
139 @@ -102,6 +102,18 @@ snapshot_cache="/var/tmp/catalyst/snapshot_cache"
140 # also where it will put its temporary files and caches.
141 storedir="/var/tmp/catalyst"
142
143 +# source_matching specifies how catalyst will match non-specific file names
144 +# if the filename is not found as an exact match.
145 +# ie: a filename without the extension specified. "/path/to/foo"
146 +#
147 +# possible values are:
148 +# "strict" meaning if more than one file of that name is present with any
149 +# file extension, then it will raise an exception.
150 +# "loose" meaning it will search for an existing filename with an added
151 +# extension from an ordered list of extensions determined from the
152 +# decompressor_search_order specification in the spec file or (default)
153 +source_matching="strict"
154 +
155 # port_logdir is where all build logs will be kept. This dir will be automatically cleaned
156 # of all logs over 30 days old. If left undefined the logs will remain in the build directory
157 # as usual and get cleaned every time a stage build is restarted.