Message ID | 20240919100127.2857748-2-pmi183@gmail.com |
---|---|
State | Accepted, archived |
Commit | 8160fd3c042283a47a2601e1797847c303e1e7e5 |
Delegated to: | Steve Sakoman |
Headers | show |
Series | [kirkstone,v3,1/3] buildhistory: Fix intermittent package file list creation | expand |
Hi, you should request backporting: https://lists.openembedded.org/g/openembedded-core/message/203338 as well as it now fails in kirkstone (and possibly in scarthgap as well) due to these buildhistory changes being backported (libdevmapper in meta-oe has the same issue, backport was already sent there, but I haven't seen one for meta-world-pkgdata). On Thu, Sep 19, 2024 at 12:01 PM Pedro Ferreira via lists.openembedded.org <pmi183=gmail.com@lists.openembedded.org> wrote: > > From: Pedro Ferreira <pedro.silva.ferreira@criticaltechworks.com> > > 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. > > Signed-off-by: Pedro Ferreira <Pedro.Silva.Ferreira@criticaltechworks.com> > Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> > (cherry picked from commit 9f68a45aa238ae5fcdfaca71ba0e7015e9cb720e) > --- > meta/classes/buildhistory.bbclass | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > 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() { > import json > import shlex > import errno > + import shutil > > pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE') > oldpkghistdir = d.getVar('BUILDHISTORY_OLD_DIR_PACKAGE') > @@ -221,6 +222,20 @@ python buildhistory_emit_pkghistory() { > items.sort() > 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') > pe = d.getVar('PE') or "0" > pv = d.getVar('PV') > @@ -248,6 +263,14 @@ python buildhistory_emit_pkghistory() { > if not os.path.exists(pkghistdir): > bb.utils.mkdirhier(pkghistdir) > 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 > for item in os.listdir(pkghistdir): > if item not in preserve: > -- > 2.34.1 > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#204663): https://lists.openembedded.org/g/openembedded-core/message/204663 > Mute This Topic: https://lists.openembedded.org/mt/108536777/3617156 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [martin.jansa@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- >
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() { import json import shlex import errno + import shutil pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE') oldpkghistdir = d.getVar('BUILDHISTORY_OLD_DIR_PACKAGE') @@ -221,6 +222,20 @@ python buildhistory_emit_pkghistory() { items.sort() 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') pe = d.getVar('PE') or "0" pv = d.getVar('PV') @@ -248,6 +263,14 @@ python buildhistory_emit_pkghistory() { if not os.path.exists(pkghistdir): bb.utils.mkdirhier(pkghistdir) 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 for item in os.listdir(pkghistdir): if item not in preserve: