Patchwork [2/2] package_{ipk, deb, rpm}.bbclass: support additional user-defined metadata

login
register
mail settings
Submitter Leonid Borisenko
Date May 13, 2012, 1:28 p.m.
Message ID <1336915722-8155-3-git-send-email-ive.found@gmail.com>
Download mbox | patch
Permalink /patch/27523/
State New
Headers show

Comments

Leonid Borisenko - May 13, 2012, 1:28 p.m.
Additional metadata from user-defined variable is written into
control/spec file of binary package.

Three variables are searched for adiitional package metadata:

  * PACKAGE_ADD_METADATA_<PKGTYPE>_<PN>
  * PACKAGE_ADD_METADATA_<PKGTYPE>
  * PACKAGE_ADD_METADATA

First found variable with defined value wins.

<PN> is a package name. <PKGTYPE> is a distinct name of specific
package type:

  * IPK for .ipk packages
  * DEB for .deb packages
  * RPM for .rpm packages

Variable can contain multiple [one-line] metadata fields separated by
literal sequence '\n'. Separator can be redefined through variable flag
'separator'. In package control/spec file separator is replaced by
newline character.

Signed-off-by: Leonid Borisenko <ive.found@gmail.com>
---
 meta/classes/package_deb.bbclass |    5 +++++
 meta/classes/package_ipk.bbclass |    5 +++++
 meta/classes/package_rpm.bbclass |    7 +++++++
 3 files changed, 17 insertions(+)

Patch

diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass
index 4096fa2..7a45cec 100644
--- a/meta/classes/package_deb.bbclass
+++ b/meta/classes/package_deb.bbclass
@@ -330,6 +330,11 @@  python do_package_deb () {
             raise bb.build.FuncFailed("Missing field for deb generation: %s" % value)
         # more fields
 
+        custom_fields_chunk = get_package_additional_metadata("deb", localdata)
+        if custom_fields_chunk is not None:
+            ctrlfile.write(unicode(custom_fields_chunk))
+            ctrlfile.write("\n")
+
         mapping_rename_hook(localdata)
 
         rdepends = bb.utils.explode_dep_versions(localdata.getVar("RDEPENDS", True) or "")
diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass
index 73ec0ee..e3a8262 100644
--- a/meta/classes/package_ipk.bbclass
+++ b/meta/classes/package_ipk.bbclass
@@ -367,6 +367,11 @@  python do_package_ipk () {
 			raise bb.build.FuncFailed("Missing field for ipk generation: %s" % value)
 		# more fields
 
+		custom_fields_chunk = get_package_additional_metadata("ipk", localdata)
+		if custom_fields_chunk is not None:
+			ctrlfile.write(custom_fields_chunk)
+			ctrlfile.write("\n")
+
 		mapping_rename_hook(localdata)
 
 		rdepends = bb.utils.explode_dep_versions(localdata.getVar("RDEPENDS", True) or "")
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
index 2da7a8b..799e5aa 100644
--- a/meta/classes/package_rpm.bbclass
+++ b/meta/classes/package_rpm.bbclass
@@ -638,6 +638,7 @@  python write_specfile () {
 	srcmaintainer  = d.getVar('MAINTAINER', True)
 	srchomepage    = d.getVar('HOMEPAGE', True)
 	srcdescription = d.getVar('DESCRIPTION', True) or "."
+	srccustomtagschunk = get_package_additional_metadata("rpm", d)
 
 	srcdepends     = strip_multilib(d.getVar('DEPENDS', True), d)
 	srcrdepends    = []
@@ -691,6 +692,7 @@  python write_specfile () {
 		splitlicense = (localdata.getVar('LICENSE', True) or "")
 		splitsection = (localdata.getVar('SECTION', True) or "")
 		splitdescription = (localdata.getVar('DESCRIPTION', True) or ".")
+		splitcustomtagschunk = get_package_additional_metadata("rpm", localdata)
 
 		translate_vers('RDEPENDS', localdata)
 		translate_vers('RRECOMMENDS', localdata)
@@ -759,6 +761,9 @@  python write_specfile () {
 			spec_preamble_bottom.append('License: %s' % splitlicense)
 		spec_preamble_bottom.append('Group: %s' % splitsection)
 
+		if srccustomtagschunk != splitcustomtagschunk:
+			spec_preamble_bottom.append(splitcustomtagschunk)
+
 		# Replaces == Obsoletes && Provides
 		if splitrreplaces and splitrreplaces.strip() != "":
 			for dep in splitrreplaces.split(','):
@@ -849,6 +854,8 @@  python write_specfile () {
 	spec_preamble_top.append('Group: %s' % srcsection)
 	spec_preamble_top.append('Packager: %s' % srcmaintainer)
 	spec_preamble_top.append('URL: %s' % srchomepage)
+	if srccustomtagschunk:
+		spec_preamble_top.append(srccustomtagschunk)
 	source_list = get_tarballs(d)
 	tail_source(d,source_list,None)