summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPedro Ferreira <pedro.silva.ferreira@criticaltechworks.com>2024-08-06 13:59:55 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-08-07 15:47:15 +0100
commit7355465f9ead0c4969adbfc167d7f29d0ca1fc11 (patch)
tree6526a36e5a6c883be6c02cd59f0a1bed37894533
parent738b3b1e6516625c7c99ff81ca28d183bc30e200 (diff)
downloadpoky-7355465f9ead0c4969adbfc167d7f29d0ca1fc11.tar.gz
buildhistory: Restoring files from preserve list
This fix will ensure that, when we activate feature `BUILDHISTORY_RESET`, files marked to keep on feature `BUILDHISTORY_PRESERVE` will indeed exist is buildhistory final path since they are moved to buildhistory/old but not restored at any point. (From OE-Core rev: 9f68a45aa238ae5fcdfaca71ba0e7015e9cb720e) Signed-off-by: Pedro Ferreira <Pedro.Silva.Ferreira@criticaltechworks.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/buildhistory.bbclass23
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: