diff options
author | Michał Górny <mgorny@gentoo.org> | 2017-11-15 17:45:11 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2017-11-15 17:45:11 +0100 |
commit | 23aed48b4c43cc7373d84054b43b607cc9b6e0fb (patch) | |
tree | 44109c873cf05f9adb69be0f38cf11fa6fe2f996 | |
parent | 1b2aa500ac7f32f8931097a9a4c222d842b7f856 (diff) | |
download | gemato-23aed48b4c43cc7373d84054b43b607cc9b6e0fb.tar.gz |
profile: Include standard IGNORE entries in new Manifests
-rw-r--r-- | gemato/profile.py | 17 | ||||
-rw-r--r-- | gemato/recursiveloader.py | 11 | ||||
-rw-r--r-- | tests/test_profile.py | 11 |
3 files changed, 39 insertions, 0 deletions
diff --git a/gemato/profile.py b/gemato/profile.py index eff2624..cf4d66c 100644 --- a/gemato/profile.py +++ b/gemato/profile.py @@ -42,6 +42,17 @@ class DefaultProfile(object): """ return False + def get_ignore_paths_for_new_manifest(self, relpath): + """ + Get the list of IGNORE paths that should be added to the newly + created Manifest in directory @relpath. The paths must be + relative to @relpath. + + This function is only called when a new Manifest file is being + created. + """ + return () + def want_compressed_manifest(self, relpath, manifest, unc_size, compress_watermark): """ @@ -92,6 +103,12 @@ class EbuildRepositoryProfile(DefaultProfile): return True return False + def get_ignore_paths_for_new_manifest(self, relpath): + if relpath == '': + # traditionally present in /usr/portage + return ('distfiles', 'local', 'packages') + return () + def set_loader_options(self, loader): if loader.hashes is None: # layout.conf as of 2017-11-02 diff --git a/gemato/recursiveloader.py b/gemato/recursiveloader.py index 69aba90..270b6ce 100644 --- a/gemato/recursiveloader.py +++ b/gemato/recursiveloader.py @@ -147,6 +147,12 @@ class ManifestRecursiveLoader(object): st = os.stat(os.path.dirname(path)) # trigger saving self.updated_manifests.add(relpath) + + # add initial IGNORE entries + for ip in (self.profile + .get_ignore_paths_for_new_manifest('')): + ie = gemato.manifest.ManifestEntryIGNORE(ip) + m.entries.append(ie) else: raise err @@ -972,6 +978,11 @@ class ManifestRecursiveLoader(object): mpath, 0, {}) new_entries.append(fe) + for ip in (self.profile + .get_ignore_paths_for_new_manifest(relpath)): + ie = gemato.manifest.ManifestEntryIGNORE(ip) + m.entries.append(ie) + if new_entries: mpath, mdirpath, m = manifest_stack[-1] for fe in new_entries: diff --git a/tests/test_profile.py b/tests/test_profile.py index 50e1a53..0a7e4d9 100644 --- a/tests/test_profile.py +++ b/tests/test_profile.py @@ -97,6 +97,12 @@ class EbuildRepositoryTests(TempDirTestCase): } FILES = dict.fromkeys(EXPECTED_TYPES, u'') + EXPECTED_IGNORE = [ + 'distfiles', + 'local', + 'packages', + ] + def test_get_entry_type_for_path(self): p = self.PROFILE() for f, expt in self.EXPECTED_TYPES.items(): @@ -120,6 +126,11 @@ class EbuildRepositoryTests(TempDirTestCase): for f in self.EXPECTED_MANIFESTS: self.assertEqual(m.find_path_entry(f).tag, 'MANIFEST', "type mismatch for {}".format(f)) + for f in self.EXPECTED_IGNORE: + self.assertIsNotNone(m.find_path_entry(f), + "missing IGNORE entry for {}".format(f)) + self.assertEqual(m.find_path_entry(f).tag, 'IGNORE', + "type mismatch for {}".format(f)) return m def test_set_loader_options(self): |