diff options
| author | Pedro Ferreira <pedro.silva.ferreira@criticaltechworks.com> | 2024-09-19 11:01:26 +0100 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2024-09-27 05:57:35 -0700 |
| commit | 958eaccc88604d4159d8c0f6be9c18fb872b87f2 (patch) | |
| tree | 821cb5821ed0b4294dc9e0af469d8dfe2626dc3a /meta/classes | |
| parent | e4de762adbfa38af7c5fdc86b46c840e77f4f984 (diff) | |
| download | poky-958eaccc88604d4159d8c0f6be9c18fb872b87f2.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: 8160fd3c042283a47a2601e1797847c303e1e7e5)
Signed-off-by: Pedro Ferreira <Pedro.Silva.Ferreira@criticaltechworks.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 9f68a45aa238ae5fcdfaca71ba0e7015e9cb720e)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta/classes')
| -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 b35508db27..8adb44eba5 100644 --- a/meta/classes/buildhistory.bbclass +++ b/meta/classes/buildhistory.bbclass | |||
| @@ -108,6 +108,7 @@ python buildhistory_emit_pkghistory() { | |||
| 108 | import json | 108 | import json |
| 109 | import shlex | 109 | import shlex |
| 110 | import errno | 110 | import errno |
| 111 | import shutil | ||
| 111 | 112 | ||
| 112 | pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE') | 113 | pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE') |
| 113 | oldpkghistdir = d.getVar('BUILDHISTORY_OLD_DIR_PACKAGE') | 114 | oldpkghistdir = d.getVar('BUILDHISTORY_OLD_DIR_PACKAGE') |
| @@ -221,6 +222,20 @@ python buildhistory_emit_pkghistory() { | |||
| 221 | items.sort() | 222 | items.sort() |
| 222 | return ' '.join(items) | 223 | return ' '.join(items) |
| 223 | 224 | ||
| 225 | def preservebuildhistoryfiles(pkg, preserve): | ||
| 226 | if os.path.exists(os.path.join(oldpkghistdir, pkg)): | ||
| 227 | listofobjs = os.listdir(os.path.join(oldpkghistdir, pkg)) | ||
| 228 | for obj in listofobjs: | ||
| 229 | if obj not in preserve: | ||
| 230 | continue | ||
| 231 | try: | ||
| 232 | bb.utils.mkdirhier(os.path.join(pkghistdir, pkg)) | ||
| 233 | shutil.copyfile(os.path.join(oldpkghistdir, pkg, obj), os.path.join(pkghistdir, pkg, obj)) | ||
| 234 | except IOError as e: | ||
| 235 | bb.note("Unable to copy file. %s" % e) | ||
| 236 | except EnvironmentError as e: | ||
| 237 | bb.note("Unable to copy file. %s" % e) | ||
| 238 | |||
| 224 | pn = d.getVar('PN') | 239 | pn = d.getVar('PN') |
| 225 | pe = d.getVar('PE') or "0" | 240 | pe = d.getVar('PE') or "0" |
| 226 | pv = d.getVar('PV') | 241 | pv = d.getVar('PV') |
| @@ -248,6 +263,14 @@ python buildhistory_emit_pkghistory() { | |||
| 248 | if not os.path.exists(pkghistdir): | 263 | if not os.path.exists(pkghistdir): |
| 249 | bb.utils.mkdirhier(pkghistdir) | 264 | bb.utils.mkdirhier(pkghistdir) |
| 250 | else: | 265 | else: |
| 266 | # We need to make sure that all files kept in | ||
| 267 | # buildhistory/old are restored successfully | ||
| 268 | # otherwise next block of code wont have files to | ||
| 269 | # check and purge | ||
| 270 | if d.getVar("BUILDHISTORY_RESET"): | ||
| 271 | for pkg in packagelist: | ||
| 272 | preservebuildhistoryfiles(pkg, preserve) | ||
| 273 | |||
| 251 | # Remove files for packages that no longer exist | 274 | # Remove files for packages that no longer exist |
| 252 | for item in os.listdir(pkghistdir): | 275 | for item in os.listdir(pkghistdir): |
| 253 | if item not in preserve: | 276 | if item not in preserve: |
