summaryrefslogtreecommitdiff
path: root/morphlib
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@gmail.com>2014-09-24 21:21:17 +0000
committerRichard Maw <richard.maw@gmail.com>2014-10-01 09:30:15 +0000
commitbb43c48bd3ee9e18ce07d1a9b0649afe1676a3c1 (patch)
tree3b90c32b175b603c91e9d4d97f8a82f6a8528aea /morphlib
parent037baabc2064700d2d2fa21cdacbf65058b3ce96 (diff)
downloadmorph-bb43c48bd3ee9e18ce07d1a9b0649afe1676a3c1.tar.gz
Remove overlap detection logic
I've rarely needed to use it, and on those rare occasions, it would have been easy enough to calculate it. Let's get rid of this step, and save everyone some time in future.
Diffstat (limited to 'morphlib')
-rw-r--r--morphlib/builder2.py64
-rw-r--r--morphlib/plugins/artifact_inspection_plugin.py32
2 files changed, 0 insertions, 96 deletions
diff --git a/morphlib/builder2.py b/morphlib/builder2.py
index 20cae225..9cd3a074 100644
--- a/morphlib/builder2.py
+++ b/morphlib/builder2.py
@@ -162,46 +162,6 @@ def get_stratum_files(f, lac): # pragma: no cover
cf.close()
-def get_overlaps(source, constituents, lac): # pragma: no cover
- # check whether strata overlap
- installed = defaultdict(set)
- for dep in constituents:
- handle = lac.get(dep)
- if source.morphology['kind'] == 'stratum':
- for filename in get_chunk_files(handle):
- installed[filename].add(dep)
- elif source.morphology['kind'] == 'system':
- for filename in get_stratum_files(handle, lac):
- installed[filename].add(dep)
- handle.close()
- overlaps = defaultdict(set)
- for filename, artifacts in installed.iteritems():
- if len(artifacts) > 1:
- overlaps[frozenset(artifacts)].add(filename)
- return overlaps
-
-
-def log_overlaps(overlaps): # pragma: no cover
- for overlapping, files in sorted(overlaps.iteritems()):
- logging.warning(' Artifacts %s overlap with files:' %
- ', '.join(sorted(a.name for a in overlapping)))
- for filename in sorted(files):
- logging.warning(' %s' % filename)
-
-
-def write_overlap_metadata(artifact, overlaps, lac): # pragma: no cover
- f = lac.put_artifact_metadata(artifact, 'overlaps')
- # the big list comprehension is because json can't serialize
- # artifacts, sets or dicts with non-string keys
- json.dump(
- [
- [
- [a.name for a in afs], list(files)
- ] for afs, files in overlaps.iteritems()
- ], f, indent=4, encoding='unicode-escape')
- f.close()
-
-
class BuilderBase(object):
'''Base class for building artifacts.'''
@@ -559,18 +519,6 @@ class StratumBuilder(BuilderBase):
download_depends(constituents,
self.local_artifact_cache,
self.remote_artifact_cache)
- # check for chunk overlaps
- overlaps = get_overlaps(self.source, constituents,
- self.local_artifact_cache)
- if len(overlaps) > 0:
- logging.warning(
- 'Overlaps in stratum artifact %s detected' %a_name)
- log_overlaps(overlaps)
- self.app.status(msg='Overlaps in stratum artifact '
- '%(stratum_name)s detected',
- stratum_name=a_name, error=True)
- write_overlap_metadata(a, overlaps,
- self.local_artifact_cache)
with self.build_watch('create-chunk-list'):
lac = self.local_artifact_cache
@@ -674,18 +622,6 @@ class SystemBuilder(BuilderBase): # pragma: no cover
self.remote_artifact_cache)
f.close()
- # check whether the strata overlap
- overlaps = get_overlaps(self.source, self.source.dependencies,
- self.local_artifact_cache)
- if len(overlaps) > 0:
- self.app.status(msg='Overlaps in system artifact '
- '%(artifact_name)s detected',
- artifact_name=a_name,
- error=True)
- log_overlaps(overlaps)
- write_overlap_metadata(a, overlaps,
- self.local_artifact_cache)
-
# unpack it from the local artifact cache
for stratum_artifact in self.source.dependencies:
self.unpack_one_stratum(stratum_artifact, path)
diff --git a/morphlib/plugins/artifact_inspection_plugin.py b/morphlib/plugins/artifact_inspection_plugin.py
index d47de334..74645f41 100644
--- a/morphlib/plugins/artifact_inspection_plugin.py
+++ b/morphlib/plugins/artifact_inspection_plugin.py
@@ -257,9 +257,6 @@ class ManifestGenerator(object):
class ArtifactInspectionPlugin(cliapp.Plugin):
def enable(self):
- self.app.add_subcommand('run-in-artifact',
- self.run_in_artifact,
- arg_synopsis='ARTIFACT CMD')
self.app.add_subcommand('generate-manifest',
self.generate_manifest,
arg_synopsis='SYSTEM-ARTIFACT')
@@ -267,35 +264,6 @@ class ArtifactInspectionPlugin(cliapp.Plugin):
def disable(self):
pass
- def run_in_artifact(self, args):
- '''Run a command inside an extracted/mounted chunk or system.
-
- Command line arguments:
-
- * `ARTIFACT` is a filename for the artifact.
- * `CMD` is the command to run.
-
- run-in-artifact unpacks an artifact, and runs a command in
- the temporary directory it was unpacked to.
-
- The command must be given to Morph as a single argument, so
- use shell quoting appropriately.
-
- '''
-
- if len(args) < 2:
- raise cliapp.AppException(
- 'run-in-artifact requires arguments: a chunk or '
- 'system artifact and a a shell command')
-
- artifact, cmd = args[0], args[1:]
-
- def run_command_in_dir(dirname):
- output = self.app.runcmd(cmd, cwd=dirname)
- self.app.output.write(output)
-
- call_in_artifact_directory(self.app, artifact, run_command_in_dir)
-
def generate_manifest(self, args):
'''Generate a content manifest for a system image.