Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH] repos.conf: support strict-misc-digests attribute (bug 600128)
Date: Thu, 24 Nov 2016 07:07:29
Message-Id: 1479971094-29981-1-git-send-email-zmedico@gentoo.org
1 This setting determines whether digests are checked for files declared
2 in the Manifest with MISC type (includes ChangeLog and metadata.xml
3 files). Defaults to true.
4
5 The current GLEP 60 draft specifies that non-strict handling of MISC
6 digests should be supported.
7
8 X-Gentoo-Bug: 600128
9 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=600128
10 ---
11 man/portage.5 | 9 ++++++++-
12 pym/portage/manifest.py | 6 ++++--
13 pym/portage/package/ebuild/digestcheck.py | 2 +-
14 pym/portage/repository/config.py | 18 ++++++++++++++----
15 4 files changed, 27 insertions(+), 8 deletions(-)
16
17 diff --git a/man/portage.5 b/man/portage.5
18 index 963f49d..2cacafc 100644
19 --- a/man/portage.5
20 +++ b/man/portage.5
21 @@ -1,4 +1,4 @@
22 -.TH "PORTAGE" "5" "Nov 2015" "Portage VERSION" "Portage"
23 +.TH "PORTAGE" "5" "Nov 2016" "Portage VERSION" "Portage"
24 .SH NAME
25 portage \- the heart of Gentoo
26 .SH "DESCRIPTION"
27 @@ -961,6 +961,13 @@ since operations performed by these tools are inherently
28 .B priority
29 Specifies priority of given repository.
30 .TP
31 +.B strict\-misc\-digests
32 +This setting determines whether digests are checked for files declared
33 +in the Manifest with MISC type (includes ChangeLog and metadata.xml
34 +files). Defaults to true.
35 +.br
36 +Valid values: true, false.
37 +.TP
38 .B sync\-cvs\-repo
39 Specifies CVS repository.
40 .TP
41 diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
42 index fe4166c..7278e21 100644
43 --- a/pym/portage/manifest.py
44 +++ b/pym/portage/manifest.py
45 @@ -129,7 +129,7 @@ class Manifest(object):
46 def __init__(self, pkgdir, distdir=None, fetchlist_dict=None,
47 manifest1_compat=DeprecationWarning, from_scratch=False, thin=False,
48 allow_missing=False, allow_create=True, hashes=None,
49 - find_invalid_path_char=None):
50 + find_invalid_path_char=None, strict_misc_digests=True):
51 """ Create new Manifest instance for package in pkgdir.
52 Do not parse Manifest file if from_scratch == True (only for internal use)
53 The fetchlist_dict parameter is required only for generation of
54 @@ -173,6 +173,7 @@ class Manifest(object):
55 self.guessType = guessManifestFileType
56 self.allow_missing = allow_missing
57 self.allow_create = allow_create
58 + self.strict_misc_digests = strict_misc_digests
59
60 def getFullname(self):
61 """ Returns the absolute path to the Manifest file for this instance """
62 @@ -461,7 +462,8 @@ class Manifest(object):
63 fetchlist_dict=self.fetchlist_dict, from_scratch=True,
64 thin=self.thin, allow_missing=self.allow_missing,
65 allow_create=self.allow_create, hashes=self.hashes,
66 - find_invalid_path_char=self._find_invalid_path_char)
67 + find_invalid_path_char=self._find_invalid_path_char,
68 + strict_misc_digests=self.strict_misc_digests)
69 pn = os.path.basename(self.pkgdir.rstrip(os.path.sep))
70 cat = self._pkgdir_category()
71
72 diff --git a/pym/portage/package/ebuild/digestcheck.py b/pym/portage/package/ebuild/digestcheck.py
73 index e207ba8..502950f 100644
74 --- a/pym/portage/package/ebuild/digestcheck.py
75 +++ b/pym/portage/package/ebuild/digestcheck.py
76 @@ -48,7 +48,7 @@ def digestcheck(myfiles, mysettings, strict=False, justmanifest=None, mf=None):
77 eout.ebegin(_("checking auxfile checksums ;-)"))
78 mf.checkTypeHashes("AUX", hash_filter=hash_filter)
79 eout.eend(0)
80 - if mf.fhashdict.get("MISC"):
81 + if mf.strict_misc_digests and mf.fhashdict.get("MISC"):
82 eout.ebegin(_("checking miscfile checksums ;-)"))
83 mf.checkTypeHashes("MISC", ignoreMissingFiles=True,
84 hash_filter=hash_filter)
85 diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py
86 index 0512057..67c717d 100644
87 --- a/pym/portage/repository/config.py
88 +++ b/pym/portage/repository/config.py
89 @@ -80,7 +80,7 @@ class RepoConfig(object):
90 'find_invalid_path_char', 'force', 'format', 'local_config', 'location',
91 'main_repo', 'manifest_hashes', 'masters', 'missing_repo_name',
92 'name', 'portage1_profiles', 'portage1_profiles_compat', 'priority',
93 - 'profile_formats', 'sign_commit', 'sign_manifest',
94 + 'profile_formats', 'sign_commit', 'sign_manifest', 'strict_misc_digests',
95 'sync_depth', 'sync_hooks_only_on_change',
96 'sync_type', 'sync_umask', 'sync_uri', 'sync_user', 'thin_manifest',
97 'update_changelog', '_eapis_banned', '_eapis_deprecated',
98 @@ -172,6 +172,9 @@ class RepoConfig(object):
99 self.sync_hooks_only_on_change = repo_opts.get(
100 'sync-hooks-only-on-change', 'false').lower() == 'true'
101
102 + self.strict_misc_digests = repo_opts.get(
103 + 'strict-misc-digests', 'true').lower() == 'true'
104 +
105 self.module_specific_options = {}
106
107 # Not implemented.
108 @@ -326,6 +329,7 @@ class RepoConfig(object):
109 kwds['allow_missing'] = self.allow_missing_manifest
110 kwds['allow_create'] = self.create_manifest
111 kwds['hashes'] = self.manifest_hashes
112 + kwds['strict_misc_digests'] = self.strict_misc_digests
113 if self.disable_manifest:
114 kwds['from_scratch'] = True
115 kwds['find_invalid_path_char'] = self.find_invalid_path_char
116 @@ -403,6 +407,8 @@ class RepoConfig(object):
117 repo_msg.append(indent + "format: " + self.format)
118 if self.location:
119 repo_msg.append(indent + "location: " + self.location)
120 + if not self.strict_misc_digests:
121 + repo_msg.append(indent + "strict-misc-digests: false")
122 if self.sync_type:
123 repo_msg.append(indent + "sync-type: " + self.sync_type)
124 if self.sync_umask:
125 @@ -500,7 +506,7 @@ class RepoConfigLoader(object):
126 # Selectively copy only the attributes which
127 # repos.conf is allowed to override.
128 for k in ('aliases', 'auto_sync', 'eclass_overrides',
129 - 'force', 'masters', 'priority',
130 + 'force', 'masters', 'priority', 'strict_misc_digests',
131 'sync_depth', 'sync_hooks_only_on_change',
132 'sync_type', 'sync_umask', 'sync_uri', 'sync_user',
133 'module_specific_options'):
134 @@ -922,12 +928,13 @@ class RepoConfigLoader(object):
135 return repo_name in self.prepos
136
137 def config_string(self):
138 + bool_keys = ("strict_misc_digests",)
139 str_or_int_keys = ("auto_sync", "format", "location",
140 "main_repo", "priority",
141 "sync_type", "sync_umask", "sync_uri", 'sync_user')
142 str_tuple_keys = ("aliases", "eclass_overrides", "force")
143 repo_config_tuple_keys = ("masters",)
144 - keys = str_or_int_keys + str_tuple_keys + repo_config_tuple_keys
145 + keys = bool_keys + str_or_int_keys + str_tuple_keys + repo_config_tuple_keys
146 config_string = ""
147 for repo_name, repo in sorted(self.prepos.items(), key=lambda x: (x[0] != "DEFAULT", x[0])):
148 config_string += "\n[%s]\n" % repo_name
149 @@ -935,7 +942,10 @@ class RepoConfigLoader(object):
150 if key == "main_repo" and repo_name != "DEFAULT":
151 continue
152 if getattr(repo, key) is not None:
153 - if key in str_or_int_keys:
154 + if key in bool_keys:
155 + config_string += "%s = %s\n" % (key.replace("_", "-"),
156 + 'true' if getattr(repo, key) else 'false')
157 + elif key in str_or_int_keys:
158 config_string += "%s = %s\n" % (key.replace("_", "-"), getattr(repo, key))
159 elif key in str_tuple_keys:
160 config_string += "%s = %s\n" % (key.replace("_", "-"), " ".join(getattr(repo, key)))
161 --
162 2.7.4

Replies