On Thursday 31 May 2012 13:12:45 Andreas Müller wrote:
> A use-case would have been [1].
> 
> The following tests were performed:
> * image from scratch with old buildhistory contents
> * image from scratch with buildhistory contents from scratch
> * decrement a PR for a test recipe and check if the message
>   'ERROR: Package version for xy went backwards' is displayed.
> 
> [1] http://patches.openembedded.org/patch/28841/
> 
> Signed-off-by: Andreas Müller <[email protected]>
> ---
>  meta/classes/buildhistory.bbclass |   80
> +++++++++++++++++++++++-------------- 1 files changed, 50 insertions(+), 30
> deletions(-)
> 
> diff --git a/meta/classes/buildhistory.bbclass
> b/meta/classes/buildhistory.bbclass index d2d19ff..9c49bab 100644
> --- a/meta/classes/buildhistory.bbclass
> +++ b/meta/classes/buildhistory.bbclass
> @@ -57,6 +57,10 @@ python buildhistory_emit_pkghistory() {
>                       self.rrecommends = ""
>                       self.files = ""
>                       self.filelist = ""
> +                     self.preinst = ""
> +                     self.postinst = ""
> +                     self.prerm = ""
> +                     self.postrm = ""
> 
>       # Should check PACKAGES here to see if anything removed
> 
> @@ -74,18 +78,19 @@ python buildhistory_emit_pkghistory() {
>               try:
>                       for line in f:
>                               lns = line.split('=')
> -                             name = lns[0].strip()
> -                             value = lns[1].strip(" \t\r\n").strip('"')
> -                             if name == "PE":
> -                                     rcpinfo.pe = value
> -                             elif name == "PV":
> -                                     rcpinfo.pv = value
> -                             elif name == "PR":
> -                                     rcpinfo.pr = value
> -                             elif name == "DEPENDS":
> -                                     rcpinfo.depends = value
> -                             elif name == "PACKAGES":
> -                                     rcpinfo.packages = value
> +                             if len(lns)==2:
> +                                     name = lns[0].strip()
> +                                     value = lns[1].strip(" 
> \t\r\n").strip('"')
> +                                     if name == "PE":
> +                                             rcpinfo.pe = value
> +                                     elif name == "PV":
> +                                             rcpinfo.pv = value
> +                                     elif name == "PR":
> +                                             rcpinfo.pr = value
> +                                     elif name == "DEPENDS":
> +                                             rcpinfo.depends = value
> +                                     elif name == "PACKAGES":
> +                                             rcpinfo.packages = value
>               finally:
>                       f.close()
>               return rcpinfo
> @@ -96,24 +101,25 @@ python buildhistory_emit_pkghistory() {
>               try:
>                       for line in f:
>                               lns = line.split('=')
> -                             name = lns[0].strip()
> -                             value = lns[1].strip(" \t\r\n").strip('"')
> -                             if name == "PE":
> -                                     pkginfo.pe = value
> -                             elif name == "PV":
> -                                     pkginfo.pv = value
> -                             elif name == "PR":
> -                                     pkginfo.pr = value
> -                             elif name == "RDEPENDS":
> -                                     pkginfo.rdepends = value
> -                             elif name == "RRECOMMENDS":
> -                                     pkginfo.rrecommends = value
> -                             elif name == "PKGSIZE":
> -                                     pkginfo.size = long(value)
> -                             elif name == "FILES":
> -                                     pkginfo.files = value
> -                             elif name == "FILELIST":
> -                                     pkginfo.filelist = value
> +                             if len(lns)==2:
> +                                     name = lns[0].strip()
> +                                     value = lns[1].strip(" 
> \t\r\n").strip('"')
> +                                     if name == "PE":
> +                                             pkginfo.pe = value
> +                                     elif name == "PV":
> +                                             pkginfo.pv = value
> +                                     elif name == "PR":
> +                                             pkginfo.pr = value
> +                                     elif name == "RDEPENDS":
> +                                             pkginfo.rdepends = value
> +                                     elif name == "RRECOMMENDS":
> +                                             pkginfo.rrecommends = value
> +                                     elif name == "PKGSIZE":
> +                                             pkginfo.size = long(value)
> +                                     elif name == "FILES":
> +                                             pkginfo.files = value
> +                                     elif name == "FILELIST":
> +                                             pkginfo.filelist = value
>               finally:
>                       f.close()
>               return pkginfo
> @@ -198,6 +204,12 @@ python buildhistory_emit_pkghistory() {
>               filelist.sort()
>               pkginfo.filelist = " ".join(filelist)
> 
> +             # pre/postinst/rm
> +             pkginfo.preinst = getpkgvar(pkg, 'pkg_preinst') or ""
> +             pkginfo.postinst = getpkgvar(pkg, 'pkg_postinst') or ""
> +             pkginfo.prerm = getpkgvar(pkg, 'pkg_prerm') or ""
> +             pkginfo.postrm = getpkgvar(pkg, 'pkg_postrm') or ""
> +
>               write_pkghistory(pkginfo, d)
> 
>               write_latestlink(pkg, pe, pv, pr, d)
> @@ -246,6 +258,14 @@ def write_pkghistory(pkginfo, d):
>               f.write("PKGSIZE = %d\n" %  pkginfo.size)
>               f.write("FILES = %s\n" %  pkginfo.files)
>               f.write("FILELIST = %s\n" %  pkginfo.filelist)
> +             if pkginfo.preinst != "":
> +                     f.write("\npkg_preinst=\n%s\n" %  pkginfo.preinst)
> +             if pkginfo.postinst != "":
> +                     f.write("\npkg_postinst=\n%s\n" %  pkginfo.postinst)
> +             if pkginfo.prerm != "":
> +                     f.write("\npkg_prerm=\n%s\n" %  pkginfo.prerm)
> +             if pkginfo.postrm != "":
> +                     f.write("\npkg_postrm=\n%s\n" %  pkginfo.postrm)
>       finally:
>               f.close()

I'd still like to rework this to use separate files. What if a line in the 
postinst script includes an = (which is not unlikely)?

Note that I'm happy do the reworking myself, I just won't be able to do it 
until the week after next.

Cheers,
Paul

-- 

Paul Eggleton
Intel Open Source Technology Centre

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Reply via email to