Gentoo Archives: gentoo-portage-dev

From: Brian Harring <ferringb@×××××.com>
To: gentoo-portage-dev@l.g.o
Cc: Brian Harring <ferringb@×××××.com>
Subject: [gentoo-portage-dev] [PATCH 2/3] add thin manifest support to the Manifest class
Date: Thu, 01 Sep 2011 22:08:46
Message-Id: 1314914835-22420-3-git-send-email-ferringb@gmail.com
In Reply to: [gentoo-portage-dev] [PATCH 0/3] thin manifest support by Brian Harring
1 'thin' is just distfiles. This is primarily useful when the ebuild
2 lives in a vcs- git for example, which already has it's own checksums
3 to rely on.
4 ---
5 pym/portage/manifest.py | 149 ++++++++++++++++++----------
6 pym/portage/package/ebuild/digestcheck.py | 2 +-
7 2 files changed, 97 insertions(+), 54 deletions(-)
8
9 diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
10 index 13efab7..ef1a552 100644
11 --- a/pym/portage/manifest.py
12 +++ b/pym/portage/manifest.py
13 @@ -49,6 +49,12 @@ def guessManifestFileType(filename):
14 else:
15 return "DIST"
16
17 +def guessThinManifestFileType(filename):
18 + type = guessManifestFileType(filename)
19 + if type != "DIST":
20 + return None
21 + return "DIST"
22 +
23 def parseManifest2(mysplit):
24 myentry = None
25 if len(mysplit) > 4 and mysplit[0] in portage.const.MANIFEST2_IDENTIFIERS:
26 @@ -93,12 +99,14 @@ class Manifest2Entry(ManifestEntry):
27 class Manifest(object):
28 parsers = (parseManifest2,)
29 def __init__(self, pkgdir, distdir, fetchlist_dict=None,
30 - manifest1_compat=False, from_scratch=False):
31 + manifest1_compat=False, from_scratch=False, thin=False):
32 """ create new Manifest instance for package in pkgdir
33 and add compability entries for old portage versions if manifest1_compat == True.
34 Do not parse Manifest file if from_scratch == True (only for internal use)
35 The fetchlist_dict parameter is required only for generation of
36 - a Manifest (not needed for parsing and checking sums)."""
37 + a Manifest (not needed for parsing and checking sums).
38 + If thin is specified, then the manifest carries only info for
39 + distfiles."""
40 self.pkgdir = _unicode_decode(pkgdir).rstrip(os.sep) + os.sep
41 self.fhashdict = {}
42 self.hashes = set()
43 @@ -120,7 +128,11 @@ class Manifest(object):
44 else:
45 self.fetchlist_dict = {}
46 self.distdir = distdir
47 - self.guessType = guessManifestFileType
48 + self.thin = thin
49 + if thin:
50 + self.guessType = guessThinManifestFileType
51 + else:
52 + self.guessType = guessManifestFileType
53
54 def getFullname(self):
55 """ Returns the absolute path to the Manifest file for this instance """
56 @@ -313,64 +325,20 @@ class Manifest(object):
57 distfilehashes = {}
58 self.__init__(self.pkgdir, self.distdir,
59 fetchlist_dict=self.fetchlist_dict, from_scratch=True,
60 - manifest1_compat=False)
61 - cpvlist = []
62 + manifest1_compat=False, thin=self.thin)
63 pn = os.path.basename(self.pkgdir.rstrip(os.path.sep))
64 cat = self._pkgdir_category()
65
66 pkgdir = self.pkgdir
67 + if self.thin:
68 + cpvlist = self._update_thin_pkgdir(cat, pn, pkgdir)
69 + else:
70 + cpvlist = self._update_thick_pkgdir(cat, pn, pkgdir)
71
72 - for pkgdir, pkgdir_dirs, pkgdir_files in os.walk(pkgdir):
73 - break
74 - for f in pkgdir_files:
75 - try:
76 - f = _unicode_decode(f,
77 - encoding=_encodings['fs'], errors='strict')
78 - except UnicodeDecodeError:
79 - continue
80 - if f[:1] == ".":
81 - continue
82 - pf = None
83 - if f[-7:] == '.ebuild':
84 - pf = f[:-7]
85 - if pf is not None:
86 - mytype = "EBUILD"
87 - ps = portage.versions._pkgsplit(pf)
88 - cpv = "%s/%s" % (cat, pf)
89 - if not ps:
90 - raise PortagePackageException(
91 - _("Invalid package name: '%s'") % cpv)
92 - if ps[0] != pn:
93 - raise PortagePackageException(
94 - _("Package name does not "
95 - "match directory name: '%s'") % cpv)
96 - cpvlist.append(cpv)
97 - elif manifest2MiscfileFilter(f):
98 - mytype = "MISC"
99 - else:
100 - continue
101 - self.fhashdict[mytype][f] = perform_multiple_checksums(self.pkgdir+f, self.hashes)
102 - recursive_files = []
103 -
104 - pkgdir = self.pkgdir
105 - cut_len = len(os.path.join(pkgdir, "files") + os.sep)
106 - for parentdir, dirs, files in os.walk(os.path.join(pkgdir, "files")):
107 - for f in files:
108 - try:
109 - f = _unicode_decode(f,
110 - encoding=_encodings['fs'], errors='strict')
111 - except UnicodeDecodeError:
112 - continue
113 - full_path = os.path.join(parentdir, f)
114 - recursive_files.append(full_path[cut_len:])
115 - for f in recursive_files:
116 - if not manifest2AuxfileFilter(f):
117 - continue
118 - self.fhashdict["AUX"][f] = perform_multiple_checksums(
119 - os.path.join(self.pkgdir, "files", f.lstrip(os.sep)), self.hashes)
120 distlist = set()
121 for cpv in cpvlist:
122 distlist.update(self._getCpvDistfiles(cpv))
123 +
124 if requiredDistfiles is None:
125 # This allows us to force removal of stale digests for the
126 # ebuild --force digest option (no distfiles are required).
127 @@ -404,6 +372,81 @@ class Manifest(object):
128 if f in requiredDistfiles:
129 raise
130
131 + def _is_cpv(self, cat, pn, filename):
132 + if not filename.endswith(".ebuild"):
133 + return None
134 + pf = filename[:-7]
135 + if pf is None:
136 + return None
137 + ps = portage.versions._pkgsplit(pf)
138 + cpv = "%s/%s" % (cat, pf)
139 + if not ps:
140 + raise PortagePackageException(
141 + _("Invalid package name: '%s'") % cpv)
142 + if ps[0] != pn:
143 + raise PortagePackageException(
144 + _("Package name does not "
145 + "match directory name: '%s'") % cpv)
146 + return cpv
147 +
148 + def _update_thin_pkgdir(self, cat, pn, pkgdir):
149 + for pkgdir, pkgdir_dirs, pkgdir_files in os.walk(pkgdir):
150 + break
151 + cpvlist = []
152 + for f in pkgdir_files:
153 + try:
154 + f = _unicode_decode(f,
155 + encoding=_encodings['fs'], errors='strict')
156 + except UnicodeDecodeError:
157 + continue
158 + if f[:1] == '.':
159 + continue
160 + pf = self._is_cpv(cat, pn, f)
161 + if pf is not None:
162 + cpvlist.append(pf)
163 + return cpvlist
164 +
165 + def _update_thick_pkgdir(self, cat, pn, pkgdir):
166 + cpvlist = []
167 + for pkgdir, pkgdir_dirs, pkgdir_files in os.walk(pkgdir):
168 + break
169 + for f in pkgdir_files:
170 + try:
171 + f = _unicode_decode(f,
172 + encoding=_encodings['fs'], errors='strict')
173 + except UnicodeDecodeError:
174 + continue
175 + if f[:1] == ".":
176 + continue
177 + pf = self._is_cpv(cat, pn, f)
178 + if pf is not None:
179 + mytype = "EBUILD"
180 + cpvlist.append(pf)
181 + elif manifest2MiscfileFilter(f):
182 + mytype = "MISC"
183 + else:
184 + continue
185 + self.fhashdict[mytype][f] = perform_multiple_checksums(self.pkgdir+f, self.hashes)
186 + recursive_files = []
187 +
188 + pkgdir = self.pkgdir
189 + cut_len = len(os.path.join(pkgdir, "files") + os.sep)
190 + for parentdir, dirs, files in os.walk(os.path.join(pkgdir, "files")):
191 + for f in files:
192 + try:
193 + f = _unicode_decode(f,
194 + encoding=_encodings['fs'], errors='strict')
195 + except UnicodeDecodeError:
196 + continue
197 + full_path = os.path.join(parentdir, f)
198 + recursive_files.append(full_path[cut_len:])
199 + for f in recursive_files:
200 + if not manifest2AuxfileFilter(f):
201 + continue
202 + self.fhashdict["AUX"][f] = perform_multiple_checksums(
203 + os.path.join(self.pkgdir, "files", f.lstrip(os.sep)), self.hashes)
204 + return cpvlist
205 +
206 def _pkgdir_category(self):
207 return self.pkgdir.rstrip(os.sep).split(os.sep)[-2]
208
209 diff --git a/pym/portage/package/ebuild/digestcheck.py b/pym/portage/package/ebuild/digestcheck.py
210 index d184301..466fd05 100644
211 --- a/pym/portage/package/ebuild/digestcheck.py
212 +++ b/pym/portage/package/ebuild/digestcheck.py
213 @@ -92,7 +92,7 @@ def digestcheck(myfiles, mysettings, strict=False, justmanifest=None, mf=None):
214 writemsg(_("!!! Got: %s\n") % e.value[2], noiselevel=-1)
215 writemsg(_("!!! Expected: %s\n") % e.value[3], noiselevel=-1)
216 return 0
217 - if allow_missing:
218 + if allow_missing or mf.thin:
219 # In this case we ignore any missing digests that
220 # would otherwise be detected below.
221 return 1
222 --
223 1.7.6.1