Patchwork [2/2] classes/buildhistory: sort list fields in package info

login
register
mail settings
Submitter Paul Eggleton
Date Feb. 7, 2012, 4:25 p.m.
Message ID <fce0db04f4b95798f3bdf6c925f1707faf14f2ed.1328631790.git.paul.eggleton@linux.intel.com>
Download mbox | patch
Permalink /patch/20889/
State New
Headers show

Comments

Paul Eggleton - Feb. 7, 2012, 4:25 p.m.
Sort DEPENDS, PACKAGES, RDEPENDS, and RRECOMMENDS in package info files
so that any changes in order (which are not important) are smoothed out
in the change history.

Fixes [YOCTO #1961]

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 meta/classes/buildhistory.bbclass |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)
Koen Kooi - Feb. 7, 2012, 5:50 p.m.
Op 7 feb. 2012, om 17:25 heeft Paul Eggleton het volgende geschreven:

> Sort DEPENDS, PACKAGES, RDEPENDS, and RRECOMMENDS in package info files
> so that any changes in order (which are not important) are smoothed out
> in the change history.
> 
> Fixes [YOCTO #1961]
> 
> Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
> ---
> meta/classes/buildhistory.bbclass |   19 +++++++++++++++----
> 1 files changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
> 
> -	packages = squashspaces(d.getVar('PACKAGES', True))
> +	packages = sortlist(squashspaces(d.getVar('PACKAGES', True)))

Sorting PACKAGES is a bad idea, since order does matter in there.

> 
> 	rcpinfo = RecipeInfo(pn)
> 	rcpinfo.pe = pe
> 	rcpinfo.pv = pv
> 	rcpinfo.pr = pr
> -	rcpinfo.depends = squashspaces(d.getVar('DEPENDS', True) or "")
> +	rcpinfo.depends = sortlist(squashspaces(d.getVar('DEPENDS', True) or ""))
> 	rcpinfo.packages = packages
> 	write_recipehistory(rcpinfo, d)
> 	write_latestlink(None, pe, pv, pr, d)
> @@ -164,8 +175,8 @@ python buildhistory_emit_pkghistory() {
> 		pkginfo.pe = pe
> 		pkginfo.pv = pv
> 		pkginfo.pr = pr
> -		pkginfo.rdepends = squashspaces(getpkgvar(pkg, 'RDEPENDS') or "")
> -		pkginfo.rrecommends = squashspaces(getpkgvar(pkg, 'RRECOMMENDS') or "")
> +		pkginfo.rdepends = sortpkglist(squashspaces(getpkgvar(pkg, 'RDEPENDS') or ""))
> +		pkginfo.rrecommends = sortpkglist(squashspaces(getpkgvar(pkg, 'RRECOMMENDS') or ""))

Not sure what went wrong, but R* didn't seem to get sorted after these patches: https://github.com/Angstrom-distribution/buildhistory/commit/7a9f2f9308b468706799be18b3f400410ee1f664

regards,

Koen
Otavio Salvador - Feb. 7, 2012, 5:52 p.m.
On Tue, Feb 7, 2012 at 15:50, Koen Kooi <koen@dominion.thruhere.net> wrote:

> Sorting PACKAGES is a bad idea, since order does matter in there.


Agreed. Even installed depends might change depending on the installation
order.
Koen Kooi - Feb. 7, 2012, 5:52 p.m.
Op 7 feb. 2012, om 18:50 heeft Koen Kooi het volgende geschreven:

> 
> Op 7 feb. 2012, om 17:25 heeft Paul Eggleton het volgende geschreven:
> 
>> Sort DEPENDS, PACKAGES, RDEPENDS, and RRECOMMENDS in package info files
>> so that any changes in order (which are not important) are smoothed out
>> in the change history.
>> 
>> Fixes [YOCTO #1961]
>> 
>> Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
>> ---
>> meta/classes/buildhistory.bbclass |   19 +++++++++++++++----
>> 1 files changed, 15 insertions(+), 4 deletions(-)
>> 
>> diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
>> 
>> -	packages = squashspaces(d.getVar('PACKAGES', True))
>> +	packages = sortlist(squashspaces(d.getVar('PACKAGES', True)))
> 
> Sorting PACKAGES is a bad idea, since order does matter in there.
> 
>> 
>> 	rcpinfo = RecipeInfo(pn)
>> 	rcpinfo.pe = pe
>> 	rcpinfo.pv = pv
>> 	rcpinfo.pr = pr
>> -	rcpinfo.depends = squashspaces(d.getVar('DEPENDS', True) or "")
>> +	rcpinfo.depends = sortlist(squashspaces(d.getVar('DEPENDS', True) or ""))
>> 	rcpinfo.packages = packages
>> 	write_recipehistory(rcpinfo, d)
>> 	write_latestlink(None, pe, pv, pr, d)
>> @@ -164,8 +175,8 @@ python buildhistory_emit_pkghistory() {
>> 		pkginfo.pe = pe
>> 		pkginfo.pv = pv
>> 		pkginfo.pr = pr
>> -		pkginfo.rdepends = squashspaces(getpkgvar(pkg, 'RDEPENDS') or "")
>> -		pkginfo.rrecommends = squashspaces(getpkgvar(pkg, 'RRECOMMENDS') or "")
>> +		pkginfo.rdepends = sortpkglist(squashspaces(getpkgvar(pkg, 'RDEPENDS') or ""))
>> +		pkginfo.rrecommends = sortpkglist(squashspaces(getpkgvar(pkg, 'RRECOMMENDS') or ""))
> 
> Not sure what went wrong, but R* didn't seem to get sorted after these patches: https://github.com/Angstrom-distribution/buildhistory/commit/7a9f2f9308b468706799be18b3f400410ee1f664

*blush* checking the console showed the error;

ERROR: Error executing a python function in /OE/tentacle/sources/meta-openembedded/meta-oe/recipes-core/systemd/systemd_git.bb:
NameError: global name 'pkgs' is not defined

ERROR: The stack trace of python calls that resulted in this exception/failure was:
ERROR:   File "buildhistory_emit_pkghistory", line 176, in <module>
ERROR:
ERROR:   File "buildhistory_emit_pkghistory", line 155, in buildhistory_emit_pkghistory
ERROR:
ERROR:   File "buildhistory_emit_pkghistory", line 107, in sortpkglist
ERROR:
ERROR: The code that was being executed was:
ERROR:      0172:
ERROR:      0173:               write_latestlink(pkg, pe, pv, pr, d)
ERROR:      0174:
ERROR:      0175:
ERROR:  *** 0176:buildhistory_emit_pkghistory(d)
ERROR:      0177:
ERROR: (file: 'buildhistory_emit_pkghistory', lineno: 176, function: <module>)
ERROR:      0151:               pkginfo = PackageInfo(pkg)
ERROR:      0152:               pkginfo.pe = pe
ERROR:      0153:               pkginfo.pv = pv
ERROR:      0154:               pkginfo.pr = pr
ERROR:  *** 0155:               pkginfo.rdepends = sortpkglist(squashspaces(getpkgvar(pkg, 'RDEPENDS') or ""))
ERROR:      0156:               pkginfo.rrecommends = sortpkglist(squashspaces(getpkgvar(pkg, 'RRECOMMENDS') or ""))
ERROR:      0157:               pkginfo.files = squashspaces(getpkgvar(pkg, 'FILES') or "")
ERROR:      0158:
ERROR:      0159:               # Gather information about packaged files
ERROR: (file: 'buildhistory_emit_pkghistory', lineno: 155, function: buildhistory_emit_pkghistory)
ERROR: Function failed: buildhistory_emit_pkghistory
ERROR: Logfile of failure stored in: /OE/tentacle/build/tmp-angstrom_2010_x-eglibc/work/armv7a-angstrom-linux-gnueabi/systemd-git-r15/temp/log.do_package.14521
NOTE: package systemd-git-r15: task do_package: Failed
ERROR: Task 9 (/OE/tentacle/sources/meta-openembedded/meta-oe/recipes-core/systemd/systemd_git.bb, do_package) failed with exit code '1'
NOTE: Tasks Summary: Attempted 2635 tasks of which 2626 didn't need to be rerun and 1 failed.
+ cd /OE/tentacle/build/tmp-angstrom_2010_x-eglibc/work/armv7a-angstrom-linux-gnueabi/bblayers-1.0-r0/bblayers-1.0
+ buildhistory_commit
+ '[' '!' -d /data/ssd/OE/buildhistory/ ']'
+ cd /data/ssd/OE/buildhistory//
+ '[' '!' -d .git ']'
++ git status --porcelain
+ repostatus=' M packages/armv7a-angstrom-linux-gnueabi/systemd/latest'
+ '[' ' M packages/armv7a-angstrom-linux-gnueabi/systemd/latest' '!=' '' ']'
+ git add /data/ssd/OE/buildhistory//README /data/ssd/OE/buildhistory//images /data/ssd/OE/buildhistory//packages
++ cat /etc/hostname
+ HOSTNAME=dominion
+ git commit /data/ssd/OE/buildhistory// -m 'Build Angstrom v2012.02-core of angstrom v2012.02-core for machine beagleboard on dominion' --author 'Koen Kooi <koen@dominion.thruhere.net>'
+ '[' git@github.com:Angstrom-distribution/buildhistory.git '!=' '' ']'
+ git push -q git@github.com:Angstrom-distribution/buildhistory.git
Paul Eggleton - Feb. 7, 2012, 5:59 p.m.
On Tuesday 07 February 2012 18:52:44 Koen Kooi wrote:
> *blush* checking the console showed the error;

Whoops. You know I really did test this patch; I'm unsure as to how I did not 
get this error because the patch is definitely wrong.

Not sure what I was thinking on PACKAGES sorting either. Will submit a v2.

Cheers,
Paul

Patch

diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
index 3964247..26d1a91 100644
--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -126,17 +126,28 @@  python buildhistory_emit_pkghistory() {
 	def squashspaces(string):
 		return re.sub("\s+", " ", string)
 
+	def sortpkglist(string):
+		pkgiter = re.finditer(r'[a-zA-Z0-9.-]+( \([><=]+ [^ )]+\))?', pkgs, 0)
+		pkglist = [p.group(0) for p in pkgiter]
+		pkglist.sort()
+		return ' '.join(pkglist)
+
+	def sortlist(string):
+		items = string.split(' ')
+		items.sort()
+		return ' '.join(items)
+
 	pn = d.getVar('PN', True)
 	pe = d.getVar('PE', True) or "0"
 	pv = d.getVar('PV', True)
 	pr = d.getVar('PR', True)
-	packages = squashspaces(d.getVar('PACKAGES', True))
+	packages = sortlist(squashspaces(d.getVar('PACKAGES', True)))
 
 	rcpinfo = RecipeInfo(pn)
 	rcpinfo.pe = pe
 	rcpinfo.pv = pv
 	rcpinfo.pr = pr
-	rcpinfo.depends = squashspaces(d.getVar('DEPENDS', True) or "")
+	rcpinfo.depends = sortlist(squashspaces(d.getVar('DEPENDS', True) or ""))
 	rcpinfo.packages = packages
 	write_recipehistory(rcpinfo, d)
 	write_latestlink(None, pe, pv, pr, d)
@@ -164,8 +175,8 @@  python buildhistory_emit_pkghistory() {
 		pkginfo.pe = pe
 		pkginfo.pv = pv
 		pkginfo.pr = pr
-		pkginfo.rdepends = squashspaces(getpkgvar(pkg, 'RDEPENDS') or "")
-		pkginfo.rrecommends = squashspaces(getpkgvar(pkg, 'RRECOMMENDS') or "")
+		pkginfo.rdepends = sortpkglist(squashspaces(getpkgvar(pkg, 'RDEPENDS') or ""))
+		pkginfo.rrecommends = sortpkglist(squashspaces(getpkgvar(pkg, 'RRECOMMENDS') or ""))
 		pkginfo.files = squashspaces(getpkgvar(pkg, 'FILES') or "")
 
 		# Gather information about packaged files