diff options
author | Robert Yang <liezhi.yang@windriver.com> | 2016-07-17 20:32:49 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-07-26 08:56:29 +0100 |
commit | 2c2f22a5338ce8b71b6d939ca42d47b314391908 (patch) | |
tree | 59f82a10eed1b8995d5cb03dc9adbe0abd659184 /meta/classes/packagefeed-stability.bbclass | |
parent | 600f0b3e04fc97640a935edfd14900c06a99d2ab (diff) | |
download | poky-2c2f22a5338ce8b71b6d939ca42d47b314391908.tar.gz |
packagefeed-stability.bbclass: copy all packages of a recipe
A recipes can generate several rpms such as a.rpm, a-dev.rpm, a-dbg.rpm,
when update one of them in the repo, we'd better update all of them,
otherwise, there might be a-dev.r0.1.rpm and a-dbg.r0.3.rpm in the repo,
which looks strange.
(From OE-Core rev: 2a7f203dbe4fda5dba9137503e93669392719aba)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/packagefeed-stability.bbclass')
-rw-r--r-- | meta/classes/packagefeed-stability.bbclass | 103 |
1 files changed, 35 insertions, 68 deletions
diff --git a/meta/classes/packagefeed-stability.bbclass b/meta/classes/packagefeed-stability.bbclass index 808a18f93a..df4c2babb6 100644 --- a/meta/classes/packagefeed-stability.bbclass +++ b/meta/classes/packagefeed-stability.bbclass | |||
@@ -133,8 +133,10 @@ def package_compare_impl(pkgtype, d): | |||
133 | 133 | ||
134 | pkgwritetask = 'package_write_%s' % pkgtype | 134 | pkgwritetask = 'package_write_%s' % pkgtype |
135 | files = [] | 135 | files = [] |
136 | copypkgs = [] | 136 | docopy = False |
137 | manifest, _ = oe.sstatesig.sstate_get_manifest_filename(pkgwritetask, d) | 137 | manifest, _ = oe.sstatesig.sstate_get_manifest_filename(pkgwritetask, d) |
138 | # Copy recipe's all packages if one of the packages are different to make | ||
139 | # they have the same PR. | ||
138 | with open(manifest, 'r') as f: | 140 | with open(manifest, 'r') as f: |
139 | for line in f: | 141 | for line in f: |
140 | if line.startswith(prepath): | 142 | if line.startswith(prepath): |
@@ -164,88 +166,53 @@ def package_compare_impl(pkgtype, d): | |||
164 | bb.warn('Unable to map %s back to package' % pkgbasename) | 166 | bb.warn('Unable to map %s back to package' % pkgbasename) |
165 | destpathspec = destpath | 167 | destpathspec = destpath |
166 | 168 | ||
167 | oldfiles = glob.glob(destpathspec) | ||
168 | oldfile = None | 169 | oldfile = None |
169 | docopy = True | 170 | if not docopy: |
170 | if oldfiles: | 171 | oldfiles = glob.glob(destpathspec) |
171 | oldfile = oldfiles[-1] | 172 | if oldfiles: |
172 | result = subprocess.call(['pkg-diff.sh', oldfile, srcpath]) | 173 | oldfile = oldfiles[-1] |
173 | if result == 0: | 174 | result = subprocess.call(['pkg-diff.sh', oldfile, srcpath]) |
174 | docopy = False | 175 | if result != 0: |
175 | 176 | docopy = True | |
176 | files.append((pkgname, pkgbasename, srcpath, oldfile, destpath)) | 177 | bb.note("%s and %s are different, will copy packages" % (oldfile, srcpath)) |
177 | bb.debug(2, '%s: package %s %s' % (pn, files[-1], docopy)) | 178 | else: |
178 | if docopy: | 179 | docopy = True |
179 | copypkgs.append(pkgname) | 180 | bb.note("No old packages found for %s, will copy packages" % pkgname) |
180 | 181 | ||
181 | # Ensure that dependencies on specific versions (such as -dev on the | 182 | files.append((pkgname, pkgbasename, srcpath, destpath)) |
182 | # main package) are copied in lock-step | 183 | |
183 | changed = True | 184 | # Remove all the old files and copy again if docopy |
184 | while changed: | 185 | if docopy: |
185 | rpkgdict = {x[0]: x[1] for x in rpkglist} | 186 | bb.plain('Copying packages for recipe %s' % pn) |
186 | changed = False | 187 | pcmanifest = os.path.join(prepath, d.expand('pkg-compare-manifest-${MULTIMACH_TARGET_SYS}-${PN}')) |
187 | for pkgname, pkgbasename, srcpath, oldfile, destpath in files: | 188 | try: |
188 | rdeps = rdepends.get(pkgname, None) | 189 | with open(pcmanifest, 'r') as f: |
189 | if not rdeps: | 190 | for line in f: |
190 | continue | 191 | fn = line.rstrip() |
191 | rdepvers = bb.utils.explode_dep_versions2(rdeps) | 192 | if fn: |
192 | for rdep, versions in rdepvers.items(): | ||
193 | dep = rpkgdict.get(rdep, None) | ||
194 | for version in versions: | ||
195 | if version and version.startswith('= '): | ||
196 | if dep in copypkgs and not pkgname in copypkgs: | ||
197 | bb.debug(2, '%s: copying %s because it has a fixed version dependency on %s and that package is going to be copied' % (pn, pkgname, dep)) | ||
198 | changed = True | ||
199 | copypkgs.append(pkgname) | ||
200 | elif pkgname in copypkgs and not dep in copypkgs: | ||
201 | bb.debug(2, '%s: copying %s because %s has a fixed version dependency on it and that package is going to be copied' % (pn, dep, pkgname)) | ||
202 | changed = True | ||
203 | copypkgs.append(dep) | ||
204 | |||
205 | # Read in old manifest so we can delete any packages we aren't going to replace or preserve | ||
206 | pcmanifest = os.path.join(prepath, d.expand('pkg-compare-manifest-${MULTIMACH_TARGET_SYS}-${PN}')) | ||
207 | try: | ||
208 | with open(pcmanifest, 'r') as f: | ||
209 | knownfiles = [x[3] for x in files if x[3]] | ||
210 | for line in f: | ||
211 | fn = line.rstrip() | ||
212 | if fn: | ||
213 | if fn in knownfiles: | ||
214 | knownfiles.remove(fn) | ||
215 | else: | ||
216 | try: | 193 | try: |
217 | os.remove(fn) | 194 | os.remove(fn) |
218 | bb.warn('Removed old package %s' % fn) | 195 | bb.note('Removed old package %s' % fn) |
219 | except OSError as e: | 196 | except OSError as e: |
220 | if e.errno == errno.ENOENT: | 197 | if e.errno == errno.ENOENT: |
221 | pass | 198 | pass |
222 | except IOError as e: | 199 | except IOError as e: |
223 | if e.errno == errno.ENOENT: | 200 | if e.errno == errno.ENOENT: |
224 | pass | 201 | pass |
225 | 202 | ||
226 | # Create new manifest | 203 | # Create new manifest |
227 | with open(pcmanifest, 'w') as f: | 204 | with open(pcmanifest, 'w') as f: |
228 | for pkgname, pkgbasename, srcpath, oldfile, destpath in files: | 205 | for pkgname, pkgbasename, srcpath, destpath in files: |
229 | if pkgname in copypkgs: | ||
230 | bb.warn('Copying %s' % pkgbasename) | ||
231 | destdir = os.path.dirname(destpath) | 206 | destdir = os.path.dirname(destpath) |
232 | bb.utils.mkdirhier(destdir) | 207 | bb.utils.mkdirhier(destdir) |
233 | if oldfile: | ||
234 | try: | ||
235 | os.remove(oldfile) | ||
236 | except OSError as e: | ||
237 | if e.errno == errno.ENOENT: | ||
238 | pass | ||
239 | if (os.stat(srcpath).st_dev == os.stat(destdir).st_dev): | 208 | if (os.stat(srcpath).st_dev == os.stat(destdir).st_dev): |
240 | # Use a hard link to save space | 209 | # Use a hard link to save space |
241 | os.link(srcpath, destpath) | 210 | os.link(srcpath, destpath) |
242 | else: | 211 | else: |
243 | shutil.copyfile(srcpath, destpath) | 212 | shutil.copyfile(srcpath, destpath) |
244 | f.write('%s\n' % destpath) | 213 | f.write('%s\n' % destpath) |
245 | else: | 214 | else: |
246 | bb.warn('Not copying %s' % pkgbasename) | 215 | bb.plain('Not copying packages for %s' % pn) |
247 | f.write('%s\n' % oldfile) | ||
248 | |||
249 | 216 | ||
250 | do_cleanall_append() { | 217 | do_cleanall_append() { |
251 | import errno | 218 | import errno |