From 5cb3c8d4ebbfffb2dafe3ae0f74570a774e200f4 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Mon, 24 Nov 2014 21:15:38 +0100 Subject: [PATCH] meta-tizen: manifests: add support for SRC_URI MANIFESTFILES assumes that the file comes out of the source or build process. The new SRC_URI support for files ending in .manifest or .manifest.in makes it possible to add manifest files as pure packaging meta data. The "pkg" parameter determines which package the manifest file is used for. If not set or empty, it is used for all. If set, the value is a comma-separated list of package names. The first suitable manifest file is used. Fake example file_%.bbappend: SRC_URI += "file://libmagic.manifest.in;pkg=libmagic,libmagic-data file://file.manifest" FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" When turning a .manifest.in file into .manifest, @[a-zA-Z0-9]+@ will get replaced by the value of the corresponding Bitbake variable (for example, "bindir"). This could also cover Tizen multi-user variables (https://wiki.tizen.org/wiki/Multi-user_Platform_Metadata) if those were added to the active distro or build conf. Change-Id: I33e49ea4e97670a70bc06bff21a265272a48626e (From meta-tizen rev: fa636dbe0d05ad75398221b4b45729a3e21d352c) Signed-off-by: Patrick Ohly --- .../classes/metatizen.bbclass | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/meta-tizen/meta-tizen-common-base/classes/metatizen.bbclass b/meta-tizen/meta-tizen-common-base/classes/metatizen.bbclass index 3977f47..5f77686 100644 --- a/meta-tizen/meta-tizen-common-base/classes/metatizen.bbclass +++ b/meta-tizen/meta-tizen-common-base/classes/metatizen.bbclass @@ -25,6 +25,46 @@ def package_rpm_extra_pkgdata(splitname, spec_file, d): if d.getVar('MANIFESTFILES', True): # Must use .manifest files at the location where tizen_copy_manifest() put it. spec_file.append('%%manifest ../packages-split/%s' % (d.getVar('MANIFESTFILES', True))) + else: + fetch = bb.fetch2.Fetch([], d) + for url in fetch.urls: + local = fetch.localpath(url) + base = os.path.basename(local) + if base.endswith('.manifest.in'): + manifest = base[:-3] + else: + manifest = base + if manifest.endswith('.manifest'): + urldata = fetch.ud[url] + if 'pkg' in urldata.parm: + pkg = urldata.parm['pkg'].split(',') + enabled = splitname in pkg or not pkg + else: + enabled = True + if enabled: + # Optionally replace placeholders with content of the corresponding variables, + # otherwise just copy to a place where rpm can find it. Absolute paths + # refering to a file on the host do not work, because rpm interprets them + # relative to the build dir. + content = open(local).read() + if base != manifest: + import re + def replace(m): + word = m.group(1) + # Must be a known variable. + return d.getVar(word, True) + content = re.sub('@([a-zA-Z0-9_]+)@', replace, content) + # Create relative to _builddir = $S, see package_rpm.bbclass/do_package_rpm (). + dvar = d.getVar('S', True) + copy = os.path.join(dvar, manifest) + print '***', copy + if not os.path.exists(dvar): + os.makedirs(dvar) + f = open(copy, 'w') + f.write(content) + f.close() + spec_file.append('%%manifest %s' % manifest) + break # Copies manifest files from source to packages-split. Necessary because # source is not always available during packaging (for example, when -- 2.7.4