diff options
-rw-r--r-- | meta/classes/buildhistory.bbclass | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass index ebb8dafbce..bac2abdab0 100644 --- a/meta/classes/buildhistory.bbclass +++ b/meta/classes/buildhistory.bbclass | |||
@@ -110,6 +110,7 @@ python buildhistory_emit_pkghistory() { | |||
110 | import json | 110 | import json |
111 | import shlex | 111 | import shlex |
112 | import errno | 112 | import errno |
113 | import shutil | ||
113 | 114 | ||
114 | pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE') | 115 | pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE') |
115 | oldpkghistdir = d.getVar('BUILDHISTORY_OLD_DIR_PACKAGE') | 116 | oldpkghistdir = d.getVar('BUILDHISTORY_OLD_DIR_PACKAGE') |
@@ -223,6 +224,20 @@ python buildhistory_emit_pkghistory() { | |||
223 | items.sort() | 224 | items.sort() |
224 | return ' '.join(items) | 225 | return ' '.join(items) |
225 | 226 | ||
227 | def preservebuildhistoryfiles(pkg, preserve): | ||
228 | if os.path.exists(os.path.join(oldpkghistdir, pkg)): | ||
229 | listofobjs = os.listdir(os.path.join(oldpkghistdir, pkg)) | ||
230 | for obj in listofobjs: | ||
231 | if obj not in preserve: | ||
232 | continue | ||
233 | try: | ||
234 | bb.utils.mkdirhier(os.path.join(pkghistdir, pkg)) | ||
235 | shutil.copyfile(os.path.join(oldpkghistdir, pkg, obj), os.path.join(pkghistdir, pkg, obj)) | ||
236 | except IOError as e: | ||
237 | bb.note("Unable to copy file. %s" % e) | ||
238 | except EnvironmentError as e: | ||
239 | bb.note("Unable to copy file. %s" % e) | ||
240 | |||
226 | pn = d.getVar('PN') | 241 | pn = d.getVar('PN') |
227 | pe = d.getVar('PE') or "0" | 242 | pe = d.getVar('PE') or "0" |
228 | pv = d.getVar('PV') | 243 | pv = d.getVar('PV') |
@@ -250,6 +265,14 @@ python buildhistory_emit_pkghistory() { | |||
250 | if not os.path.exists(pkghistdir): | 265 | if not os.path.exists(pkghistdir): |
251 | bb.utils.mkdirhier(pkghistdir) | 266 | bb.utils.mkdirhier(pkghistdir) |
252 | else: | 267 | else: |
268 | # We need to make sure that all files kept in | ||
269 | # buildhistory/old are restored successfully | ||
270 | # otherwise next block of code wont have files to | ||
271 | # check and purge | ||
272 | if d.getVar("BUILDHISTORY_RESET"): | ||
273 | for pkg in packagelist: | ||
274 | preservebuildhistoryfiles(pkg, preserve) | ||
275 | |||
253 | # Remove files for packages that no longer exist | 276 | # Remove files for packages that no longer exist |
254 | for item in os.listdir(pkghistdir): | 277 | for item in os.listdir(pkghistdir): |
255 | if item not in preserve: | 278 | if item not in preserve: |