mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 12:29:55 +00:00
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: 93ee5b0ee71a51daba9a332e8dba93d78a849677) 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>
This commit is contained in:
committed by
Steve Sakoman
parent
4c0730341e
commit
4a64de8691
@@ -110,6 +110,7 @@ python buildhistory_emit_pkghistory() {
|
|||||||
import json
|
import json
|
||||||
import shlex
|
import shlex
|
||||||
import errno
|
import errno
|
||||||
|
import shutil
|
||||||
|
|
||||||
pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE')
|
pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE')
|
||||||
oldpkghistdir = d.getVar('BUILDHISTORY_OLD_DIR_PACKAGE')
|
oldpkghistdir = d.getVar('BUILDHISTORY_OLD_DIR_PACKAGE')
|
||||||
@@ -223,6 +224,20 @@ python buildhistory_emit_pkghistory() {
|
|||||||
items.sort()
|
items.sort()
|
||||||
return ' '.join(items)
|
return ' '.join(items)
|
||||||
|
|
||||||
|
def preservebuildhistoryfiles(pkg, preserve):
|
||||||
|
if os.path.exists(os.path.join(oldpkghistdir, pkg)):
|
||||||
|
listofobjs = os.listdir(os.path.join(oldpkghistdir, pkg))
|
||||||
|
for obj in listofobjs:
|
||||||
|
if obj not in preserve:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
bb.utils.mkdirhier(os.path.join(pkghistdir, pkg))
|
||||||
|
shutil.copyfile(os.path.join(oldpkghistdir, pkg, obj), os.path.join(pkghistdir, pkg, obj))
|
||||||
|
except IOError as e:
|
||||||
|
bb.note("Unable to copy file. %s" % e)
|
||||||
|
except EnvironmentError as e:
|
||||||
|
bb.note("Unable to copy file. %s" % e)
|
||||||
|
|
||||||
pn = d.getVar('PN')
|
pn = d.getVar('PN')
|
||||||
pe = d.getVar('PE') or "0"
|
pe = d.getVar('PE') or "0"
|
||||||
pv = d.getVar('PV')
|
pv = d.getVar('PV')
|
||||||
@@ -250,6 +265,14 @@ python buildhistory_emit_pkghistory() {
|
|||||||
if not os.path.exists(pkghistdir):
|
if not os.path.exists(pkghistdir):
|
||||||
bb.utils.mkdirhier(pkghistdir)
|
bb.utils.mkdirhier(pkghistdir)
|
||||||
else:
|
else:
|
||||||
|
# We need to make sure that all files kept in
|
||||||
|
# buildhistory/old are restored successfully
|
||||||
|
# otherwise next block of code wont have files to
|
||||||
|
# check and purge
|
||||||
|
if d.getVar("BUILDHISTORY_RESET"):
|
||||||
|
for pkg in packagelist:
|
||||||
|
preservebuildhistoryfiles(pkg, preserve)
|
||||||
|
|
||||||
# Remove files for packages that no longer exist
|
# Remove files for packages that no longer exist
|
||||||
for item in os.listdir(pkghistdir):
|
for item in os.listdir(pkghistdir):
|
||||||
if item not in preserve:
|
if item not in preserve:
|
||||||
|
|||||||
Reference in New Issue
Block a user