2005-08-31 10:45:47 +00:00
|
|
|
inherit package
|
2008-08-18 08:01:41 +00:00
|
|
|
|
2006-09-19 09:04:09 +00:00
|
|
|
IMAGE_PKGTYPE ?= "rpm"
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2010-09-03 17:43:41 +00:00
|
|
|
RPM="rpm"
|
|
|
|
RPMBUILD="rpmbuild"
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2010-08-20 16:52:39 +00:00
|
|
|
PKGWRITEDIRRPM = "${WORKDIR}/deploy-rpms"
|
2008-08-18 08:01:41 +00:00
|
|
|
|
2012-02-09 09:51:10 +00:00
|
|
|
# Maintaining the perfile dependencies has singificant overhead when writing the
|
|
|
|
# packages. When set, this value merges them for efficiency.
|
|
|
|
MERGEPERFILEDEPS = "1"
|
|
|
|
|
|
|
|
# Construct per file dependencies file
|
|
|
|
def write_rpm_perfiledata(srcname, d):
|
2016-12-14 21:13:04 +00:00
|
|
|
workdir = d.getVar('WORKDIR')
|
|
|
|
packages = d.getVar('PACKAGES')
|
|
|
|
pkgd = d.getVar('PKGD')
|
2012-02-09 09:51:10 +00:00
|
|
|
|
|
|
|
def dump_filerdeps(varname, outfile, d):
|
|
|
|
outfile.write("#!/usr/bin/env python\n\n")
|
|
|
|
outfile.write("# Dependency table\n")
|
|
|
|
outfile.write('deps = {\n')
|
|
|
|
for pkg in packages.split():
|
|
|
|
dependsflist_key = 'FILE' + varname + 'FLIST' + "_" + pkg
|
2016-12-14 21:13:04 +00:00
|
|
|
dependsflist = (d.getVar(dependsflist_key) or "")
|
2012-02-09 09:51:10 +00:00
|
|
|
for dfile in dependsflist.split():
|
|
|
|
key = "FILE" + varname + "_" + dfile + "_" + pkg
|
2016-12-14 21:13:04 +00:00
|
|
|
depends_dict = bb.utils.explode_dep_versions(d.getVar(key) or "")
|
2012-02-09 09:51:10 +00:00
|
|
|
file = dfile.replace("@underscore@", "_")
|
|
|
|
file = file.replace("@closebrace@", "]")
|
|
|
|
file = file.replace("@openbrace@", "[")
|
|
|
|
file = file.replace("@tab@", "\t")
|
|
|
|
file = file.replace("@space@", " ")
|
|
|
|
file = file.replace("@at@", "@")
|
|
|
|
outfile.write('"' + pkgd + file + '" : "')
|
|
|
|
for dep in depends_dict:
|
|
|
|
ver = depends_dict[dep]
|
|
|
|
if dep and ver:
|
|
|
|
ver = ver.replace("(","")
|
|
|
|
ver = ver.replace(")","")
|
|
|
|
outfile.write(dep + " " + ver + " ")
|
|
|
|
else:
|
|
|
|
outfile.write(dep + " ")
|
|
|
|
outfile.write('",\n')
|
|
|
|
outfile.write('}\n\n')
|
|
|
|
outfile.write("import sys\n")
|
|
|
|
outfile.write("while 1:\n")
|
|
|
|
outfile.write("\tline = sys.stdin.readline().strip()\n")
|
|
|
|
outfile.write("\tif not line:\n")
|
|
|
|
outfile.write("\t\tsys.exit(0)\n")
|
|
|
|
outfile.write("\tif line in deps:\n")
|
|
|
|
outfile.write("\t\tprint(deps[line] + '\\n')\n")
|
|
|
|
|
|
|
|
# OE-core dependencies a.k.a. RPM requires
|
|
|
|
outdepends = workdir + "/" + srcname + ".requires"
|
|
|
|
|
2017-01-21 14:18:01 +00:00
|
|
|
dependsfile = open(outdepends, 'w')
|
2012-02-09 09:51:10 +00:00
|
|
|
|
|
|
|
dump_filerdeps('RDEPENDS', dependsfile, d)
|
|
|
|
|
|
|
|
dependsfile.close()
|
2013-05-07 10:23:40 +00:00
|
|
|
os.chmod(outdepends, 0o755)
|
2012-02-09 09:51:10 +00:00
|
|
|
|
|
|
|
# OE-core / RPM Provides
|
|
|
|
outprovides = workdir + "/" + srcname + ".provides"
|
|
|
|
|
2017-01-21 14:18:01 +00:00
|
|
|
providesfile = open(outprovides, 'w')
|
2012-02-09 09:51:10 +00:00
|
|
|
|
|
|
|
dump_filerdeps('RPROVIDES', providesfile, d)
|
|
|
|
|
|
|
|
providesfile.close()
|
2013-05-07 10:23:40 +00:00
|
|
|
os.chmod(outprovides, 0o755)
|
2012-02-09 09:51:10 +00:00
|
|
|
|
|
|
|
return (outdepends, outprovides)
|
|
|
|
|
|
|
|
|
2010-08-20 16:52:39 +00:00
|
|
|
python write_specfile () {
|
2012-07-11 17:33:43 +00:00
|
|
|
import oe.packagedata
|
|
|
|
|
|
|
|
# append information for logs and patches to %prep
|
|
|
|
def add_prep(d,spec_files_bottom):
|
2016-12-14 21:13:06 +00:00
|
|
|
if d.getVarFlag('ARCHIVER_MODE', 'srpm') == '1' and bb.data.inherits_class('archiver', d):
|
2016-12-14 21:13:04 +00:00
|
|
|
spec_files_bottom.append('%%prep -n %s' % d.getVar('PN') )
|
2012-07-11 17:33:43 +00:00
|
|
|
spec_files_bottom.append('%s' % "echo \"include logs and patches, Please check them in SOURCES\"")
|
|
|
|
spec_files_bottom.append('')
|
|
|
|
|
|
|
|
# append the name of tarball to key word 'SOURCE' in xxx.spec.
|
2012-08-24 06:06:59 +00:00
|
|
|
def tail_source(d):
|
2016-12-14 21:13:06 +00:00
|
|
|
if d.getVarFlag('ARCHIVER_MODE', 'srpm') == '1' and bb.data.inherits_class('archiver', d):
|
2016-12-14 21:13:04 +00:00
|
|
|
ar_outdir = d.getVar('ARCHIVER_OUTDIR')
|
2014-01-13 10:46:43 +00:00
|
|
|
if not os.path.exists(ar_outdir):
|
|
|
|
return
|
|
|
|
source_list = os.listdir(ar_outdir)
|
2012-07-11 17:33:43 +00:00
|
|
|
source_number = 0
|
|
|
|
for source in source_list:
|
archiver.bbclass: fix the fakeroot and other issues
* Fix the fakeroot issue
The archiver.bbclass is used for archiving sources, patches, and logs,
it uses the "rpmbuild -bs" from the package_rpm.bbclass to generate the
.src.rpm, but it didn't work (it's not easy to explain it clearly):
Reason:
- It directly used the "fakeroot" command, we don't have such a
command in native tools, so it would use the fakeroot from the host,
and it would fail when there is no fakeroot on the host.
- The "rpmbuild -bs" doesn't need to work under root, but it is in the
function do_package_write_rpm which is running under fakeroot, and
"rpmbuild" needs to know the source file's user/group name, the source
file is the tarball which is created by the postfuncs of do_unpack
or do_patch which doesn't use the fakeroot, so the created file's
owner would be the real user, e.g.: robert, but there is no such a
user under our native tools' fakeroot(pseudo), then the rpmbuild would
fail. It worked when use the host's fakeroot in the past was because
that the host's fakeroot knows the users on the host.
Fix:
- Remove the incorrect "fakeroot".
- Change the source file's owner to root.root under fakeroot will fix the
problem.
* Other fixes:
- The typo: "do_remove_taball -> do_remove_tarball" which will cause the
tarball is not removed.
- Add the _sourcedir defination to the rpmbuild command since the the
SOURCES would be added to the specfile when archiver.bbclass is
inherited, otherwise there would be errors when "rpmbuild -bb", though
the build is OK. It only added the defination to "rpmbuild -bs",
didn't add to "rpmbuild -bb".
[YOCTO #2619]
(From OE-Core rev: ac152f277fdff256def01af4268215a05685a0f7)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-08-22 07:34:34 +00:00
|
|
|
# The rpmbuild doesn't need the root permission, but it needs
|
|
|
|
# to know the file's user and group name, the only user and
|
|
|
|
# group in fakeroot is "root" when working in fakeroot.
|
2014-01-13 10:46:43 +00:00
|
|
|
f = os.path.join(ar_outdir, source)
|
|
|
|
os.chown(f, 0, 0)
|
|
|
|
spec_preamble_top.append('Source%s: %s' % (source_number, source))
|
2012-07-11 17:33:43 +00:00
|
|
|
source_number += 1
|
|
|
|
# We need a simple way to remove the MLPREFIX from the package name,
|
|
|
|
# and dependency information...
|
|
|
|
def strip_multilib(name, d):
|
2016-12-14 21:13:04 +00:00
|
|
|
multilibs = d.getVar('MULTILIBS') or ""
|
2012-07-11 17:33:43 +00:00
|
|
|
for ext in multilibs.split():
|
|
|
|
eext = ext.split(':')
|
|
|
|
if len(eext) > 1 and eext[0] == 'multilib' and name and name.find(eext[1] + '-') >= 0:
|
|
|
|
name = "".join(name.split(eext[1] + '-'))
|
|
|
|
return name
|
|
|
|
|
2012-10-02 10:37:07 +00:00
|
|
|
def strip_multilib_deps(deps, d):
|
|
|
|
depends = bb.utils.explode_dep_versions2(deps or "")
|
|
|
|
newdeps = {}
|
|
|
|
for dep in depends:
|
|
|
|
newdeps[strip_multilib(dep, d)] = depends[dep]
|
|
|
|
return bb.utils.join_deps(newdeps)
|
|
|
|
|
2016-12-14 21:13:04 +00:00
|
|
|
# ml = d.getVar("MLPREFIX")
|
2012-07-11 17:33:43 +00:00
|
|
|
# if ml and name and len(ml) != 0 and name.find(ml) == 0:
|
|
|
|
# return ml.join(name.split(ml, 1)[1:])
|
|
|
|
# return name
|
|
|
|
|
|
|
|
# In RPM, dependencies are of the format: pkg <>= Epoch:Version-Release
|
|
|
|
# This format is similar to OE, however there are restrictions on the
|
|
|
|
# characters that can be in a field. In the Version field, "-"
|
|
|
|
# characters are not allowed. "-" is allowed in the Release field.
|
|
|
|
#
|
|
|
|
# We translate the "-" in the version to a "+", by loading the PKGV
|
|
|
|
# from the dependent recipe, replacing the - with a +, and then using
|
|
|
|
# that value to do a replace inside of this recipe's dependencies.
|
|
|
|
# This preserves the "-" separator between the version and release, as
|
|
|
|
# well as any "-" characters inside of the release field.
|
|
|
|
#
|
|
|
|
# All of this has to happen BEFORE the mapping_rename_hook as
|
|
|
|
# after renaming we cannot look up the dependencies in the packagedata
|
|
|
|
# store.
|
|
|
|
def translate_vers(varname, d):
|
2016-12-14 21:13:04 +00:00
|
|
|
depends = d.getVar(varname)
|
2012-07-11 17:33:43 +00:00
|
|
|
if depends:
|
2012-10-02 10:37:07 +00:00
|
|
|
depends_dict = bb.utils.explode_dep_versions2(depends)
|
2012-07-11 17:33:43 +00:00
|
|
|
newdeps_dict = {}
|
|
|
|
for dep in depends_dict:
|
2012-10-02 10:37:07 +00:00
|
|
|
verlist = []
|
|
|
|
for ver in depends_dict[dep]:
|
2012-07-11 17:33:43 +00:00
|
|
|
if '-' in ver:
|
|
|
|
subd = oe.packagedata.read_subpkgdata_dict(dep, d)
|
|
|
|
if 'PKGV' in subd:
|
2013-03-14 00:15:10 +00:00
|
|
|
pv = subd['PV']
|
|
|
|
pkgv = subd['PKGV']
|
|
|
|
reppv = pkgv.replace('-', '+')
|
2013-03-20 00:29:22 +00:00
|
|
|
ver = ver.replace(pv, reppv).replace(pkgv, reppv)
|
|
|
|
if 'PKGR' in subd:
|
|
|
|
# Make sure PKGR rather than PR in ver
|
|
|
|
pr = '-' + subd['PR']
|
|
|
|
pkgr = '-' + subd['PKGR']
|
|
|
|
if pkgr not in ver:
|
|
|
|
ver = ver.replace(pr, pkgr)
|
|
|
|
verlist.append(ver)
|
2012-10-02 10:37:07 +00:00
|
|
|
else:
|
|
|
|
verlist.append(ver)
|
|
|
|
newdeps_dict[dep] = verlist
|
2012-07-11 17:33:43 +00:00
|
|
|
depends = bb.utils.join_deps(newdeps_dict)
|
|
|
|
d.setVar(varname, depends.strip())
|
|
|
|
|
|
|
|
# We need to change the style the dependency from BB to RPM
|
|
|
|
# This needs to happen AFTER the mapping_rename_hook
|
|
|
|
def print_deps(variable, tag, array, d):
|
|
|
|
depends = variable
|
|
|
|
if depends:
|
2012-10-02 10:37:07 +00:00
|
|
|
depends_dict = bb.utils.explode_dep_versions2(depends)
|
2012-07-11 17:33:43 +00:00
|
|
|
for dep in depends_dict:
|
2012-10-02 10:37:07 +00:00
|
|
|
for ver in depends_dict[dep]:
|
2012-07-11 17:33:43 +00:00
|
|
|
ver = ver.replace('(', '')
|
|
|
|
ver = ver.replace(')', '')
|
|
|
|
array.append("%s: %s %s" % (tag, dep, ver))
|
2012-10-02 10:37:07 +00:00
|
|
|
if not len(depends_dict[dep]):
|
2012-07-11 17:33:43 +00:00
|
|
|
array.append("%s: %s" % (tag, dep))
|
|
|
|
|
2014-08-29 17:39:12 +00:00
|
|
|
def walk_files(walkpath, target, conffiles, dirfiles):
|
2013-11-05 22:08:04 +00:00
|
|
|
# We can race against the ipk/deb backends which create CONTROL or DEBIAN directories
|
|
|
|
# when packaging. We just ignore these files which are created in
|
|
|
|
# packages-split/ and not package/
|
2014-01-15 17:47:45 +00:00
|
|
|
# We have the odd situation where the CONTROL/DEBIAN directory can be removed in the middle of
|
|
|
|
# of the walk, the isdir() test would then fail and the walk code would assume its a file
|
|
|
|
# hence we check for the names in files too.
|
2012-07-11 17:33:43 +00:00
|
|
|
for rootpath, dirs, files in os.walk(walkpath):
|
|
|
|
path = rootpath.replace(walkpath, "")
|
2013-11-05 22:08:04 +00:00
|
|
|
if path.endswith("DEBIAN") or path.endswith("CONTROL"):
|
|
|
|
continue
|
2015-05-20 14:48:19 +00:00
|
|
|
path = path.replace("%", "%%%%%%%%")
|
2016-12-22 02:19:56 +00:00
|
|
|
path = path.replace("[", "?")
|
|
|
|
path = path.replace("]", "?")
|
2014-08-29 17:39:12 +00:00
|
|
|
|
2015-02-25 14:53:29 +00:00
|
|
|
# Treat all symlinks to directories as normal files.
|
|
|
|
# os.walk() lists them as directories.
|
|
|
|
def move_to_files(dir):
|
|
|
|
if os.path.islink(os.path.join(rootpath, dir)):
|
|
|
|
files.append(dir)
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
dirs[:] = [dir for dir in dirs if not move_to_files(dir)]
|
|
|
|
|
2014-08-29 17:39:12 +00:00
|
|
|
# Directory handling can happen in two ways, either DIRFILES is not set at all
|
|
|
|
# in which case we fall back to the older behaviour of packages owning all their
|
|
|
|
# directories
|
|
|
|
if dirfiles is None:
|
|
|
|
for dir in dirs:
|
|
|
|
if dir == "CONTROL" or dir == "DEBIAN":
|
|
|
|
continue
|
2015-05-20 14:48:19 +00:00
|
|
|
dir = dir.replace("%", "%%%%%%%%")
|
2016-12-22 02:19:56 +00:00
|
|
|
dir = dir.replace("[", "?")
|
|
|
|
dir = dir.replace("]", "?")
|
2014-08-29 17:39:12 +00:00
|
|
|
# All packages own the directories their files are in...
|
|
|
|
target.append('%dir "' + path + '/' + dir + '"')
|
|
|
|
else:
|
|
|
|
# packages own only empty directories or explict directory.
|
|
|
|
# This will prevent the overlapping of security permission.
|
|
|
|
if path and not files and not dirs:
|
|
|
|
target.append('%dir "' + path + '"')
|
|
|
|
elif path and path in dirfiles:
|
|
|
|
target.append('%dir "' + path + '"')
|
|
|
|
|
2012-07-11 17:33:43 +00:00
|
|
|
for file in files:
|
2014-01-15 17:47:45 +00:00
|
|
|
if file == "CONTROL" or file == "DEBIAN":
|
|
|
|
continue
|
2015-05-20 14:48:19 +00:00
|
|
|
file = file.replace("%", "%%%%%%%%")
|
2016-12-22 02:19:56 +00:00
|
|
|
file = file.replace("[", "?")
|
|
|
|
file = file.replace("]", "?")
|
2012-07-11 17:33:43 +00:00
|
|
|
if conffiles.count(path + '/' + file):
|
|
|
|
target.append('%config "' + path + '/' + file + '"')
|
|
|
|
else:
|
|
|
|
target.append('"' + path + '/' + file + '"')
|
|
|
|
|
|
|
|
# Prevent the prerm/postrm scripts from being run during an upgrade
|
|
|
|
def wrap_uninstall(scriptvar):
|
|
|
|
scr = scriptvar.strip()
|
|
|
|
if scr.startswith("#!"):
|
|
|
|
pos = scr.find("\n") + 1
|
|
|
|
else:
|
|
|
|
pos = 0
|
|
|
|
scr = scr[:pos] + 'if [ "$1" = "0" ] ; then\n' + scr[pos:] + '\nfi'
|
|
|
|
return scr
|
|
|
|
|
2012-02-09 09:51:10 +00:00
|
|
|
def get_perfile(varname, pkg, d):
|
|
|
|
deps = []
|
|
|
|
dependsflist_key = 'FILE' + varname + 'FLIST' + "_" + pkg
|
2016-12-14 21:13:04 +00:00
|
|
|
dependsflist = (d.getVar(dependsflist_key) or "")
|
2012-02-09 09:51:10 +00:00
|
|
|
for dfile in dependsflist.split():
|
|
|
|
key = "FILE" + varname + "_" + dfile + "_" + pkg
|
2016-12-14 21:13:04 +00:00
|
|
|
depends = d.getVar(key)
|
2012-02-09 09:51:10 +00:00
|
|
|
if depends:
|
|
|
|
deps.append(depends)
|
|
|
|
return " ".join(deps)
|
|
|
|
|
2013-06-19 05:25:38 +00:00
|
|
|
def append_description(spec_preamble, text):
|
|
|
|
"""
|
|
|
|
Add the description to the spec file.
|
|
|
|
"""
|
|
|
|
import textwrap
|
|
|
|
dedent_text = textwrap.dedent(text).strip()
|
|
|
|
# Bitbake saves "\n" as "\\n"
|
|
|
|
if '\\n' in dedent_text:
|
|
|
|
for t in dedent_text.split('\\n'):
|
|
|
|
spec_preamble.append(t.strip())
|
|
|
|
else:
|
|
|
|
spec_preamble.append('%s' % textwrap.fill(dedent_text, width=75))
|
|
|
|
|
2016-12-14 21:13:04 +00:00
|
|
|
packages = d.getVar('PACKAGES')
|
2012-07-11 17:33:43 +00:00
|
|
|
if not packages or packages == '':
|
|
|
|
bb.debug(1, "No packages; nothing to do")
|
|
|
|
return
|
|
|
|
|
2016-12-14 21:13:04 +00:00
|
|
|
pkgdest = d.getVar('PKGDEST')
|
2012-07-11 17:33:43 +00:00
|
|
|
if not pkgdest:
|
|
|
|
bb.fatal("No PKGDEST")
|
|
|
|
|
2016-12-14 21:13:04 +00:00
|
|
|
outspecfile = d.getVar('OUTSPECFILE')
|
2012-07-11 17:33:43 +00:00
|
|
|
if not outspecfile:
|
|
|
|
bb.fatal("No OUTSPECFILE")
|
|
|
|
|
|
|
|
# Construct the SPEC file...
|
2016-12-14 21:13:04 +00:00
|
|
|
srcname = strip_multilib(d.getVar('PN'), d)
|
|
|
|
srcsummary = (d.getVar('SUMMARY') or d.getVar('DESCRIPTION') or ".")
|
|
|
|
srcversion = d.getVar('PKGV').replace('-', '+')
|
|
|
|
srcrelease = d.getVar('PKGR')
|
|
|
|
srcepoch = (d.getVar('PKGE') or "")
|
|
|
|
srclicense = d.getVar('LICENSE')
|
|
|
|
srcsection = d.getVar('SECTION')
|
|
|
|
srcmaintainer = d.getVar('MAINTAINER')
|
|
|
|
srchomepage = d.getVar('HOMEPAGE')
|
|
|
|
srcdescription = d.getVar('DESCRIPTION') or "."
|
2012-11-16 18:29:26 +00:00
|
|
|
srccustomtagschunk = get_package_additional_metadata("rpm", d)
|
2012-07-11 17:33:43 +00:00
|
|
|
|
2016-12-14 21:13:04 +00:00
|
|
|
srcdepends = strip_multilib_deps(d.getVar('DEPENDS'), d)
|
2012-07-11 17:33:43 +00:00
|
|
|
srcrdepends = []
|
|
|
|
srcrrecommends = []
|
|
|
|
srcrsuggests = []
|
|
|
|
srcrprovides = []
|
|
|
|
srcrreplaces = []
|
|
|
|
srcrconflicts = []
|
|
|
|
srcrobsoletes = []
|
|
|
|
|
2012-11-15 21:31:11 +00:00
|
|
|
srcrpreinst = []
|
|
|
|
srcrpostinst = []
|
|
|
|
srcrprerm = []
|
|
|
|
srcrpostrm = []
|
2012-07-11 17:33:43 +00:00
|
|
|
|
|
|
|
spec_preamble_top = []
|
|
|
|
spec_preamble_bottom = []
|
|
|
|
|
|
|
|
spec_scriptlets_top = []
|
|
|
|
spec_scriptlets_bottom = []
|
|
|
|
|
|
|
|
spec_files_top = []
|
|
|
|
spec_files_bottom = []
|
|
|
|
|
2016-12-14 21:13:04 +00:00
|
|
|
perfiledeps = (d.getVar("MERGEPERFILEDEPS") or "0") == "0"
|
|
|
|
extra_pkgdata = (d.getVar("RPM_EXTRA_PKGDATA") or "0") == "1"
|
2012-02-09 09:51:10 +00:00
|
|
|
|
2012-07-11 17:33:43 +00:00
|
|
|
for pkg in packages.split():
|
|
|
|
localdata = bb.data.createCopy(d)
|
|
|
|
|
|
|
|
root = "%s/%s" % (pkgdest, pkg)
|
|
|
|
|
|
|
|
localdata.setVar('ROOT', '')
|
|
|
|
localdata.setVar('ROOT_%s' % pkg, root)
|
2016-12-14 21:13:04 +00:00
|
|
|
pkgname = localdata.getVar('PKG_%s' % pkg)
|
2012-07-11 17:33:43 +00:00
|
|
|
if not pkgname:
|
|
|
|
pkgname = pkg
|
|
|
|
localdata.setVar('PKG', pkgname)
|
|
|
|
|
2015-06-02 14:06:13 +00:00
|
|
|
localdata.setVar('OVERRIDES', d.getVar("OVERRIDES", False) + ":" + pkg)
|
2012-07-11 17:33:43 +00:00
|
|
|
|
2015-02-17 02:08:12 +00:00
|
|
|
conffiles = get_conffiles(pkg, d)
|
2016-12-14 21:13:04 +00:00
|
|
|
dirfiles = localdata.getVar('DIRFILES')
|
2014-08-29 17:39:12 +00:00
|
|
|
if dirfiles is not None:
|
|
|
|
dirfiles = dirfiles.split()
|
2012-07-11 17:33:43 +00:00
|
|
|
|
|
|
|
splitname = strip_multilib(pkgname, d)
|
|
|
|
|
2016-12-14 21:13:04 +00:00
|
|
|
splitsummary = (localdata.getVar('SUMMARY') or localdata.getVar('DESCRIPTION') or ".")
|
|
|
|
splitversion = (localdata.getVar('PKGV') or "").replace('-', '+')
|
|
|
|
splitrelease = (localdata.getVar('PKGR') or "")
|
|
|
|
splitepoch = (localdata.getVar('PKGE') or "")
|
|
|
|
splitlicense = (localdata.getVar('LICENSE') or "")
|
|
|
|
splitsection = (localdata.getVar('SECTION') or "")
|
|
|
|
splitdescription = (localdata.getVar('DESCRIPTION') or ".")
|
2012-11-16 18:29:26 +00:00
|
|
|
splitcustomtagschunk = get_package_additional_metadata("rpm", localdata)
|
2012-07-11 17:33:43 +00:00
|
|
|
|
|
|
|
translate_vers('RDEPENDS', localdata)
|
|
|
|
translate_vers('RRECOMMENDS', localdata)
|
|
|
|
translate_vers('RSUGGESTS', localdata)
|
|
|
|
translate_vers('RPROVIDES', localdata)
|
|
|
|
translate_vers('RREPLACES', localdata)
|
|
|
|
translate_vers('RCONFLICTS', localdata)
|
|
|
|
|
|
|
|
# Map the dependencies into their final form
|
|
|
|
mapping_rename_hook(localdata)
|
|
|
|
|
2016-12-14 21:13:04 +00:00
|
|
|
splitrdepends = strip_multilib_deps(localdata.getVar('RDEPENDS'), d)
|
|
|
|
splitrrecommends = strip_multilib_deps(localdata.getVar('RRECOMMENDS'), d)
|
|
|
|
splitrsuggests = strip_multilib_deps(localdata.getVar('RSUGGESTS'), d)
|
|
|
|
splitrprovides = strip_multilib_deps(localdata.getVar('RPROVIDES'), d)
|
|
|
|
splitrreplaces = strip_multilib_deps(localdata.getVar('RREPLACES'), d)
|
|
|
|
splitrconflicts = strip_multilib_deps(localdata.getVar('RCONFLICTS'), d)
|
2012-07-11 17:33:43 +00:00
|
|
|
splitrobsoletes = []
|
|
|
|
|
2016-12-14 21:13:04 +00:00
|
|
|
splitrpreinst = localdata.getVar('pkg_preinst')
|
|
|
|
splitrpostinst = localdata.getVar('pkg_postinst')
|
|
|
|
splitrprerm = localdata.getVar('pkg_prerm')
|
|
|
|
splitrpostrm = localdata.getVar('pkg_postrm')
|
2012-11-15 21:31:11 +00:00
|
|
|
|
2012-02-09 09:51:10 +00:00
|
|
|
|
|
|
|
if not perfiledeps:
|
|
|
|
# Add in summary of per file dependencies
|
|
|
|
splitrdepends = splitrdepends + " " + get_perfile('RDEPENDS', pkg, d)
|
|
|
|
splitrprovides = splitrprovides + " " + get_perfile('RPROVIDES', pkg, d)
|
|
|
|
|
2012-07-11 17:33:43 +00:00
|
|
|
# Gather special src/first package data
|
|
|
|
if srcname == splitname:
|
|
|
|
srcrdepends = splitrdepends
|
|
|
|
srcrrecommends = splitrrecommends
|
|
|
|
srcrsuggests = splitrsuggests
|
|
|
|
srcrprovides = splitrprovides
|
|
|
|
srcrreplaces = splitrreplaces
|
|
|
|
srcrconflicts = splitrconflicts
|
|
|
|
|
2012-11-15 21:31:11 +00:00
|
|
|
srcrpreinst = splitrpreinst
|
|
|
|
srcrpostinst = splitrpostinst
|
|
|
|
srcrprerm = splitrprerm
|
|
|
|
srcrpostrm = splitrpostrm
|
2012-07-11 17:33:43 +00:00
|
|
|
|
|
|
|
file_list = []
|
2014-08-29 17:39:12 +00:00
|
|
|
walk_files(root, file_list, conffiles, dirfiles)
|
2015-06-18 14:14:16 +00:00
|
|
|
if not file_list and localdata.getVar('ALLOW_EMPTY', False) != "1":
|
2012-07-11 17:33:43 +00:00
|
|
|
bb.note("Not creating empty RPM package for %s" % splitname)
|
|
|
|
else:
|
|
|
|
bb.note("Creating RPM package for %s" % splitname)
|
|
|
|
spec_files_top.append('%files')
|
2014-09-01 16:32:26 +00:00
|
|
|
if extra_pkgdata:
|
|
|
|
package_rpm_extra_pkgdata(splitname, spec_files_top, localdata)
|
2012-07-11 17:33:43 +00:00
|
|
|
spec_files_top.append('%defattr(-,-,-,-)')
|
|
|
|
if file_list:
|
|
|
|
bb.note("Creating RPM package for %s" % splitname)
|
|
|
|
spec_files_top.extend(file_list)
|
|
|
|
else:
|
|
|
|
bb.note("Creating EMPTY RPM Package for %s" % splitname)
|
|
|
|
spec_files_top.append('')
|
|
|
|
continue
|
|
|
|
|
|
|
|
# Process subpackage data
|
|
|
|
spec_preamble_bottom.append('%%package -n %s' % splitname)
|
|
|
|
spec_preamble_bottom.append('Summary: %s' % splitsummary)
|
|
|
|
if srcversion != splitversion:
|
|
|
|
spec_preamble_bottom.append('Version: %s' % splitversion)
|
|
|
|
if srcrelease != splitrelease:
|
|
|
|
spec_preamble_bottom.append('Release: %s' % splitrelease)
|
|
|
|
if srcepoch != splitepoch:
|
|
|
|
spec_preamble_bottom.append('Epoch: %s' % splitepoch)
|
|
|
|
if srclicense != splitlicense:
|
|
|
|
spec_preamble_bottom.append('License: %s' % splitlicense)
|
|
|
|
spec_preamble_bottom.append('Group: %s' % splitsection)
|
|
|
|
|
2012-11-16 18:29:26 +00:00
|
|
|
if srccustomtagschunk != splitcustomtagschunk:
|
|
|
|
spec_preamble_bottom.append(splitcustomtagschunk)
|
|
|
|
|
2012-07-11 17:33:43 +00:00
|
|
|
# Replaces == Obsoletes && Provides
|
2012-10-02 10:37:07 +00:00
|
|
|
robsoletes = bb.utils.explode_dep_versions2(splitrobsoletes or "")
|
|
|
|
rprovides = bb.utils.explode_dep_versions2(splitrprovides or "")
|
|
|
|
rreplaces = bb.utils.explode_dep_versions2(splitrreplaces or "")
|
|
|
|
for dep in rreplaces:
|
|
|
|
if not dep in robsoletes:
|
|
|
|
robsoletes[dep] = rreplaces[dep]
|
|
|
|
if not dep in rprovides:
|
|
|
|
rprovides[dep] = rreplaces[dep]
|
|
|
|
splitrobsoletes = bb.utils.join_deps(robsoletes, commasep=False)
|
|
|
|
splitrprovides = bb.utils.join_deps(rprovides, commasep=False)
|
2012-07-11 17:33:43 +00:00
|
|
|
|
|
|
|
print_deps(splitrdepends, "Requires", spec_preamble_bottom, d)
|
2012-11-15 21:31:11 +00:00
|
|
|
if splitrpreinst:
|
|
|
|
print_deps(splitrdepends, "Requires(pre)", spec_preamble_bottom, d)
|
|
|
|
if splitrpostinst:
|
|
|
|
print_deps(splitrdepends, "Requires(post)", spec_preamble_bottom, d)
|
|
|
|
if splitrprerm:
|
|
|
|
print_deps(splitrdepends, "Requires(preun)", spec_preamble_bottom, d)
|
|
|
|
if splitrpostrm:
|
|
|
|
print_deps(splitrdepends, "Requires(postun)", spec_preamble_bottom, d)
|
|
|
|
|
2017-01-19 17:24:37 +00:00
|
|
|
print_deps(splitrrecommends, "Recommends", spec_preamble_bottom, d)
|
|
|
|
print_deps(splitrsuggests, "Suggests", spec_preamble_bottom, d)
|
2012-07-11 17:33:43 +00:00
|
|
|
print_deps(splitrprovides, "Provides", spec_preamble_bottom, d)
|
|
|
|
print_deps(splitrobsoletes, "Obsoletes", spec_preamble_bottom, d)
|
|
|
|
|
|
|
|
# conflicts can not be in a provide! We will need to filter it.
|
|
|
|
if splitrconflicts:
|
2012-10-02 10:37:07 +00:00
|
|
|
depends_dict = bb.utils.explode_dep_versions2(splitrconflicts)
|
2012-07-11 17:33:43 +00:00
|
|
|
newdeps_dict = {}
|
|
|
|
for dep in depends_dict:
|
|
|
|
if dep not in splitrprovides:
|
|
|
|
newdeps_dict[dep] = depends_dict[dep]
|
|
|
|
if newdeps_dict:
|
|
|
|
splitrconflicts = bb.utils.join_deps(newdeps_dict)
|
|
|
|
else:
|
|
|
|
splitrconflicts = ""
|
|
|
|
|
|
|
|
print_deps(splitrconflicts, "Conflicts", spec_preamble_bottom, d)
|
|
|
|
|
|
|
|
spec_preamble_bottom.append('')
|
|
|
|
|
|
|
|
spec_preamble_bottom.append('%%description -n %s' % splitname)
|
2013-06-19 05:25:38 +00:00
|
|
|
append_description(spec_preamble_bottom, splitdescription)
|
2012-07-11 17:33:43 +00:00
|
|
|
|
|
|
|
spec_preamble_bottom.append('')
|
|
|
|
|
|
|
|
# Now process scriptlets
|
2012-11-15 21:31:11 +00:00
|
|
|
if splitrpreinst:
|
|
|
|
spec_scriptlets_bottom.append('%%pre -n %s' % splitname)
|
2013-03-01 10:02:13 +00:00
|
|
|
spec_scriptlets_bottom.append('# %s - preinst' % splitname)
|
2012-11-15 21:31:11 +00:00
|
|
|
spec_scriptlets_bottom.append(splitrpreinst)
|
|
|
|
spec_scriptlets_bottom.append('')
|
|
|
|
if splitrpostinst:
|
|
|
|
spec_scriptlets_bottom.append('%%post -n %s' % splitname)
|
2013-03-01 10:02:13 +00:00
|
|
|
spec_scriptlets_bottom.append('# %s - postinst' % splitname)
|
2012-11-15 21:31:11 +00:00
|
|
|
spec_scriptlets_bottom.append(splitrpostinst)
|
|
|
|
spec_scriptlets_bottom.append('')
|
|
|
|
if splitrprerm:
|
|
|
|
spec_scriptlets_bottom.append('%%preun -n %s' % splitname)
|
2013-03-01 10:02:13 +00:00
|
|
|
spec_scriptlets_bottom.append('# %s - prerm' % splitname)
|
2012-11-15 21:31:11 +00:00
|
|
|
scriptvar = wrap_uninstall(splitrprerm)
|
|
|
|
spec_scriptlets_bottom.append(scriptvar)
|
|
|
|
spec_scriptlets_bottom.append('')
|
|
|
|
if splitrpostrm:
|
|
|
|
spec_scriptlets_bottom.append('%%postun -n %s' % splitname)
|
2013-03-01 10:02:13 +00:00
|
|
|
spec_scriptlets_bottom.append('# %s - postrm' % splitname)
|
2012-11-15 21:31:11 +00:00
|
|
|
scriptvar = wrap_uninstall(splitrpostrm)
|
2012-07-11 17:33:43 +00:00
|
|
|
spec_scriptlets_bottom.append(scriptvar)
|
|
|
|
spec_scriptlets_bottom.append('')
|
|
|
|
|
|
|
|
# Now process files
|
|
|
|
file_list = []
|
2014-08-29 17:39:12 +00:00
|
|
|
walk_files(root, file_list, conffiles, dirfiles)
|
2015-06-18 14:14:16 +00:00
|
|
|
if not file_list and localdata.getVar('ALLOW_EMPTY', False) != "1":
|
2012-07-11 17:33:43 +00:00
|
|
|
bb.note("Not creating empty RPM package for %s" % splitname)
|
|
|
|
else:
|
|
|
|
spec_files_bottom.append('%%files -n %s' % splitname)
|
2014-09-01 16:32:26 +00:00
|
|
|
if extra_pkgdata:
|
|
|
|
package_rpm_extra_pkgdata(splitname, spec_files_bottom, localdata)
|
2012-07-11 17:33:43 +00:00
|
|
|
spec_files_bottom.append('%defattr(-,-,-,-)')
|
|
|
|
if file_list:
|
|
|
|
bb.note("Creating RPM package for %s" % splitname)
|
|
|
|
spec_files_bottom.extend(file_list)
|
|
|
|
else:
|
|
|
|
bb.note("Creating EMPTY RPM Package for %s" % splitname)
|
|
|
|
spec_files_bottom.append('')
|
|
|
|
|
|
|
|
del localdata
|
2012-03-26 10:49:23 +00:00
|
|
|
|
2012-07-11 17:33:43 +00:00
|
|
|
add_prep(d,spec_files_bottom)
|
|
|
|
spec_preamble_top.append('Summary: %s' % srcsummary)
|
|
|
|
spec_preamble_top.append('Name: %s' % srcname)
|
|
|
|
spec_preamble_top.append('Version: %s' % srcversion)
|
|
|
|
spec_preamble_top.append('Release: %s' % srcrelease)
|
|
|
|
if srcepoch and srcepoch.strip() != "":
|
|
|
|
spec_preamble_top.append('Epoch: %s' % srcepoch)
|
|
|
|
spec_preamble_top.append('License: %s' % srclicense)
|
|
|
|
spec_preamble_top.append('Group: %s' % srcsection)
|
|
|
|
spec_preamble_top.append('Packager: %s' % srcmaintainer)
|
2014-02-06 13:33:45 +00:00
|
|
|
if srchomepage:
|
|
|
|
spec_preamble_top.append('URL: %s' % srchomepage)
|
2012-11-16 18:29:26 +00:00
|
|
|
if srccustomtagschunk:
|
|
|
|
spec_preamble_top.append(srccustomtagschunk)
|
2012-08-24 06:06:59 +00:00
|
|
|
tail_source(d)
|
2012-07-11 17:33:43 +00:00
|
|
|
|
|
|
|
# Replaces == Obsoletes && Provides
|
2012-10-02 10:37:07 +00:00
|
|
|
robsoletes = bb.utils.explode_dep_versions2(srcrobsoletes or "")
|
|
|
|
rprovides = bb.utils.explode_dep_versions2(srcrprovides or "")
|
|
|
|
rreplaces = bb.utils.explode_dep_versions2(srcrreplaces or "")
|
|
|
|
for dep in rreplaces:
|
|
|
|
if not dep in robsoletes:
|
|
|
|
robsoletes[dep] = rreplaces[dep]
|
|
|
|
if not dep in rprovides:
|
|
|
|
rprovides[dep] = rreplaces[dep]
|
|
|
|
srcrobsoletes = bb.utils.join_deps(robsoletes, commasep=False)
|
|
|
|
srcrprovides = bb.utils.join_deps(rprovides, commasep=False)
|
2012-07-11 17:33:43 +00:00
|
|
|
|
|
|
|
print_deps(srcdepends, "BuildRequires", spec_preamble_top, d)
|
|
|
|
print_deps(srcrdepends, "Requires", spec_preamble_top, d)
|
2012-11-15 21:31:11 +00:00
|
|
|
if srcrpreinst:
|
|
|
|
print_deps(srcrdepends, "Requires(pre)", spec_preamble_top, d)
|
|
|
|
if srcrpostinst:
|
|
|
|
print_deps(srcrdepends, "Requires(post)", spec_preamble_top, d)
|
|
|
|
if srcrprerm:
|
|
|
|
print_deps(srcrdepends, "Requires(preun)", spec_preamble_top, d)
|
|
|
|
if srcrpostrm:
|
|
|
|
print_deps(srcrdepends, "Requires(postun)", spec_preamble_top, d)
|
|
|
|
|
2017-01-19 17:24:37 +00:00
|
|
|
print_deps(srcrrecommends, "Recommends", spec_preamble_top, d)
|
|
|
|
print_deps(srcrsuggests, "Suggests", spec_preamble_top, d)
|
2017-02-20 10:23:20 +00:00
|
|
|
print_deps(srcrprovides + (" /bin/sh" if srcname.startswith("nativesdk-") else ""), "Provides", spec_preamble_top, d)
|
2012-07-11 17:33:43 +00:00
|
|
|
print_deps(srcrobsoletes, "Obsoletes", spec_preamble_top, d)
|
|
|
|
|
|
|
|
# conflicts can not be in a provide! We will need to filter it.
|
|
|
|
if srcrconflicts:
|
2012-10-02 10:37:07 +00:00
|
|
|
depends_dict = bb.utils.explode_dep_versions2(srcrconflicts)
|
2012-07-11 17:33:43 +00:00
|
|
|
newdeps_dict = {}
|
|
|
|
for dep in depends_dict:
|
|
|
|
if dep not in srcrprovides:
|
|
|
|
newdeps_dict[dep] = depends_dict[dep]
|
|
|
|
if newdeps_dict:
|
|
|
|
srcrconflicts = bb.utils.join_deps(newdeps_dict)
|
|
|
|
else:
|
|
|
|
srcrconflicts = ""
|
|
|
|
|
|
|
|
print_deps(srcrconflicts, "Conflicts", spec_preamble_top, d)
|
|
|
|
|
|
|
|
spec_preamble_top.append('')
|
|
|
|
|
|
|
|
spec_preamble_top.append('%description')
|
2013-06-19 05:25:38 +00:00
|
|
|
append_description(spec_preamble_top, srcdescription)
|
2012-07-11 17:33:43 +00:00
|
|
|
|
|
|
|
spec_preamble_top.append('')
|
|
|
|
|
2012-11-15 21:31:11 +00:00
|
|
|
if srcrpreinst:
|
2012-07-11 17:33:43 +00:00
|
|
|
spec_scriptlets_top.append('%pre')
|
|
|
|
spec_scriptlets_top.append('# %s - preinst' % srcname)
|
2012-11-15 21:31:11 +00:00
|
|
|
spec_scriptlets_top.append(srcrpreinst)
|
2012-07-11 17:33:43 +00:00
|
|
|
spec_scriptlets_top.append('')
|
2012-11-15 21:31:11 +00:00
|
|
|
if srcrpostinst:
|
2012-07-11 17:33:43 +00:00
|
|
|
spec_scriptlets_top.append('%post')
|
|
|
|
spec_scriptlets_top.append('# %s - postinst' % srcname)
|
2012-11-15 21:31:11 +00:00
|
|
|
spec_scriptlets_top.append(srcrpostinst)
|
2012-07-11 17:33:43 +00:00
|
|
|
spec_scriptlets_top.append('')
|
2012-11-15 21:31:11 +00:00
|
|
|
if srcrprerm:
|
2012-07-11 17:33:43 +00:00
|
|
|
spec_scriptlets_top.append('%preun')
|
|
|
|
spec_scriptlets_top.append('# %s - prerm' % srcname)
|
2012-11-15 21:31:11 +00:00
|
|
|
scriptvar = wrap_uninstall(srcrprerm)
|
2012-07-11 17:33:43 +00:00
|
|
|
spec_scriptlets_top.append(scriptvar)
|
|
|
|
spec_scriptlets_top.append('')
|
2012-11-15 21:31:11 +00:00
|
|
|
if srcrpostrm:
|
2012-07-11 17:33:43 +00:00
|
|
|
spec_scriptlets_top.append('%postun')
|
|
|
|
spec_scriptlets_top.append('# %s - postrm' % srcname)
|
2012-11-15 21:31:11 +00:00
|
|
|
scriptvar = wrap_uninstall(srcrpostrm)
|
2012-07-11 17:33:43 +00:00
|
|
|
spec_scriptlets_top.append(scriptvar)
|
|
|
|
spec_scriptlets_top.append('')
|
|
|
|
|
|
|
|
# Write the SPEC file
|
2017-01-21 14:18:01 +00:00
|
|
|
specfile = open(outspecfile, 'w')
|
2012-07-11 17:33:43 +00:00
|
|
|
|
|
|
|
# RPMSPEC_PREAMBLE is a way to add arbitrary text to the top
|
|
|
|
# of the generated spec file
|
2016-12-14 21:13:04 +00:00
|
|
|
external_preamble = d.getVar("RPMSPEC_PREAMBLE")
|
2012-07-11 17:33:43 +00:00
|
|
|
if external_preamble:
|
|
|
|
specfile.write(external_preamble + "\n")
|
|
|
|
|
|
|
|
for line in spec_preamble_top:
|
|
|
|
specfile.write(line + "\n")
|
|
|
|
|
|
|
|
for line in spec_preamble_bottom:
|
|
|
|
specfile.write(line + "\n")
|
|
|
|
|
|
|
|
for line in spec_scriptlets_top:
|
|
|
|
specfile.write(line + "\n")
|
|
|
|
|
|
|
|
for line in spec_scriptlets_bottom:
|
|
|
|
specfile.write(line + "\n")
|
|
|
|
|
|
|
|
for line in spec_files_top:
|
|
|
|
specfile.write(line + "\n")
|
|
|
|
|
|
|
|
for line in spec_files_bottom:
|
|
|
|
specfile.write(line + "\n")
|
|
|
|
|
|
|
|
specfile.close()
|
2010-08-20 16:52:39 +00:00
|
|
|
}
|
2015-08-25 16:57:37 +00:00
|
|
|
# Otherwise allarch packages may change depending on override configuration
|
|
|
|
write_specfile[vardepsexclude] = "OVERRIDES"
|
2010-08-20 16:52:39 +00:00
|
|
|
|
|
|
|
python do_package_rpm () {
|
2012-07-11 17:33:43 +00:00
|
|
|
# We need a simple way to remove the MLPREFIX from the package name,
|
|
|
|
# and dependency information...
|
|
|
|
def strip_multilib(name, d):
|
2016-12-14 21:13:04 +00:00
|
|
|
ml = d.getVar("MLPREFIX")
|
2012-07-11 17:33:43 +00:00
|
|
|
if ml and name and len(ml) != 0 and name.find(ml) >= 0:
|
|
|
|
return "".join(name.split(ml))
|
|
|
|
return name
|
|
|
|
|
2016-12-14 21:13:04 +00:00
|
|
|
workdir = d.getVar('WORKDIR')
|
|
|
|
tmpdir = d.getVar('TMPDIR')
|
|
|
|
pkgd = d.getVar('PKGD')
|
|
|
|
pkgdest = d.getVar('PKGDEST')
|
2013-09-11 18:36:19 +00:00
|
|
|
if not workdir or not pkgd or not tmpdir:
|
2012-07-11 17:33:43 +00:00
|
|
|
bb.error("Variables incorrectly set, unable to package")
|
|
|
|
return
|
|
|
|
|
2016-12-14 21:13:04 +00:00
|
|
|
packages = d.getVar('PACKAGES')
|
2012-07-11 17:33:43 +00:00
|
|
|
if not packages or packages == '':
|
|
|
|
bb.debug(1, "No packages; nothing to do")
|
|
|
|
return
|
|
|
|
|
|
|
|
# Construct the spec file...
|
2013-07-09 08:27:43 +00:00
|
|
|
# If the spec file already exist, and has not been stored into
|
|
|
|
# pseudo's files.db, it maybe cause rpmbuild src.rpm fail,
|
|
|
|
# so remove it before doing rpmbuild src.rpm.
|
2016-12-14 21:13:04 +00:00
|
|
|
srcname = strip_multilib(d.getVar('PN'), d)
|
2012-07-11 17:33:43 +00:00
|
|
|
outspecfile = workdir + "/" + srcname + ".spec"
|
2013-07-09 08:27:43 +00:00
|
|
|
if os.path.isfile(outspecfile):
|
|
|
|
os.remove(outspecfile)
|
2012-07-11 17:33:43 +00:00
|
|
|
d.setVar('OUTSPECFILE', outspecfile)
|
|
|
|
bb.build.exec_func('write_specfile', d)
|
|
|
|
|
2016-12-14 21:13:04 +00:00
|
|
|
perfiledeps = (d.getVar("MERGEPERFILEDEPS") or "0") == "0"
|
2012-02-09 09:51:10 +00:00
|
|
|
if perfiledeps:
|
|
|
|
outdepends, outprovides = write_rpm_perfiledata(srcname, d)
|
2012-07-11 17:33:43 +00:00
|
|
|
|
|
|
|
# Setup the rpmbuild arguments...
|
2016-12-14 21:13:04 +00:00
|
|
|
rpmbuild = d.getVar('RPMBUILD')
|
|
|
|
targetsys = d.getVar('TARGET_SYS')
|
|
|
|
targetvendor = d.getVar('HOST_VENDOR')
|
2017-01-09 14:37:28 +00:00
|
|
|
# Too many places in dnf stack assume that arch-independent packages are "noarch".
|
|
|
|
# Let's not fight against this.
|
|
|
|
package_arch = (d.getVar('PACKAGE_ARCH') or "").replace("-", "_").replace("all", "noarch")
|
2016-12-14 21:13:04 +00:00
|
|
|
sdkpkgsuffix = (d.getVar('SDKPKGSUFFIX') or "nativesdk").replace("-", "_")
|
2014-06-25 00:28:04 +00:00
|
|
|
if package_arch not in "all any noarch".split() and not package_arch.endswith(sdkpkgsuffix):
|
2016-12-14 21:13:04 +00:00
|
|
|
ml_prefix = (d.getVar('MLPREFIX') or "").replace("-", "_")
|
2012-07-11 17:33:43 +00:00
|
|
|
d.setVar('PACKAGE_ARCH_EXTEND', ml_prefix + package_arch)
|
|
|
|
else:
|
|
|
|
d.setVar('PACKAGE_ARCH_EXTEND', package_arch)
|
|
|
|
pkgwritedir = d.expand('${PKGWRITEDIRRPM}/${PACKAGE_ARCH_EXTEND}')
|
2015-08-21 14:21:57 +00:00
|
|
|
d.setVar('RPM_PKGWRITEDIR', pkgwritedir)
|
2016-12-14 21:13:04 +00:00
|
|
|
bb.debug(1, 'PKGWRITEDIR: %s' % d.getVar('RPM_PKGWRITEDIR'))
|
2014-07-03 00:57:46 +00:00
|
|
|
pkgarch = d.expand('${PACKAGE_ARCH_EXTEND}${HOST_VENDOR}-${HOST_OS}')
|
2013-09-01 07:52:40 +00:00
|
|
|
bb.utils.mkdirhier(pkgwritedir)
|
2013-05-07 10:23:40 +00:00
|
|
|
os.chmod(pkgwritedir, 0o755)
|
2012-07-11 17:33:43 +00:00
|
|
|
|
|
|
|
cmd = rpmbuild
|
2017-02-02 13:20:41 +00:00
|
|
|
cmd = cmd + " --noclean --nodeps --short-circuit --target " + pkgarch + " --buildroot " + pkgd
|
2012-07-11 17:33:43 +00:00
|
|
|
cmd = cmd + " --define '_topdir " + workdir + "' --define '_rpmdir " + pkgwritedir + "'"
|
2016-12-14 21:13:04 +00:00
|
|
|
cmd = cmd + " --define '_builddir " + d.getVar('S') + "'"
|
2012-07-11 17:33:43 +00:00
|
|
|
cmd = cmd + " --define '_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'"
|
|
|
|
cmd = cmd + " --define '_use_internal_dependency_generator 0'"
|
2012-02-09 09:51:10 +00:00
|
|
|
if perfiledeps:
|
|
|
|
cmd = cmd + " --define '__find_requires " + outdepends + "'"
|
|
|
|
cmd = cmd + " --define '__find_provides " + outprovides + "'"
|
|
|
|
else:
|
|
|
|
cmd = cmd + " --define '__find_requires %{nil}'"
|
|
|
|
cmd = cmd + " --define '__find_provides %{nil}'"
|
2012-07-11 17:33:43 +00:00
|
|
|
cmd = cmd + " --define '_unpackaged_files_terminate_build 0'"
|
|
|
|
cmd = cmd + " --define 'debug_package %{nil}'"
|
|
|
|
cmd = cmd + " --define '_tmppath " + workdir + "'"
|
2016-12-14 21:13:06 +00:00
|
|
|
if d.getVarFlag('ARCHIVER_MODE', 'srpm') == '1' and bb.data.inherits_class('archiver', d):
|
2016-12-14 21:13:04 +00:00
|
|
|
cmd = cmd + " --define '_sourcedir " + d.getVar('ARCHIVER_OUTDIR') + "'"
|
|
|
|
cmdsrpm = cmd + " --define '_srcrpmdir " + d.getVar('ARCHIVER_OUTDIR') + "'"
|
archiver.bbclass: fix the fakeroot and other issues
* Fix the fakeroot issue
The archiver.bbclass is used for archiving sources, patches, and logs,
it uses the "rpmbuild -bs" from the package_rpm.bbclass to generate the
.src.rpm, but it didn't work (it's not easy to explain it clearly):
Reason:
- It directly used the "fakeroot" command, we don't have such a
command in native tools, so it would use the fakeroot from the host,
and it would fail when there is no fakeroot on the host.
- The "rpmbuild -bs" doesn't need to work under root, but it is in the
function do_package_write_rpm which is running under fakeroot, and
"rpmbuild" needs to know the source file's user/group name, the source
file is the tarball which is created by the postfuncs of do_unpack
or do_patch which doesn't use the fakeroot, so the created file's
owner would be the real user, e.g.: robert, but there is no such a
user under our native tools' fakeroot(pseudo), then the rpmbuild would
fail. It worked when use the host's fakeroot in the past was because
that the host's fakeroot knows the users on the host.
Fix:
- Remove the incorrect "fakeroot".
- Change the source file's owner to root.root under fakeroot will fix the
problem.
* Other fixes:
- The typo: "do_remove_taball -> do_remove_tarball" which will cause the
tarball is not removed.
- Add the _sourcedir defination to the rpmbuild command since the the
SOURCES would be added to the specfile when archiver.bbclass is
inherited, otherwise there would be errors when "rpmbuild -bb", though
the build is OK. It only added the defination to "rpmbuild -bs",
didn't add to "rpmbuild -bb".
[YOCTO #2619]
(From OE-Core rev: ac152f277fdff256def01af4268215a05685a0f7)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-08-22 07:34:34 +00:00
|
|
|
cmdsrpm = cmdsrpm + " -bs " + outspecfile
|
2012-08-24 06:06:59 +00:00
|
|
|
# Build the .src.rpm
|
2012-07-11 17:33:43 +00:00
|
|
|
d.setVar('SBUILDSPEC', cmdsrpm + "\n")
|
|
|
|
d.setVarFlag('SBUILDSPEC', 'func', '1')
|
|
|
|
bb.build.exec_func('SBUILDSPEC', d)
|
2012-08-24 06:06:59 +00:00
|
|
|
cmd = cmd + " -bb " + outspecfile
|
2012-03-26 10:49:23 +00:00
|
|
|
|
2017-02-02 13:20:41 +00:00
|
|
|
# rpm 4 creates various empty directories in _topdir, let's clean them up
|
|
|
|
cleanupcmd = "rm -rf %s/BUILDROOT %s/SOURCES %s/SPECS %s/SRPMS" % (workdir, workdir, workdir, workdir)
|
|
|
|
|
2012-07-11 17:33:43 +00:00
|
|
|
# Build the rpm package!
|
2017-02-02 13:20:41 +00:00
|
|
|
d.setVar('BUILDSPEC', cmd + "\n" + cleanupcmd + "\n")
|
2012-07-11 17:33:43 +00:00
|
|
|
d.setVarFlag('BUILDSPEC', 'func', '1')
|
|
|
|
bb.build.exec_func('BUILDSPEC', d)
|
2015-08-21 14:21:57 +00:00
|
|
|
|
2016-12-14 21:13:04 +00:00
|
|
|
if d.getVar('RPM_SIGN_PACKAGES') == '1':
|
2015-08-21 14:21:57 +00:00
|
|
|
bb.build.exec_func("sign_rpm", d)
|
2005-08-31 10:45:47 +00:00
|
|
|
}
|
2007-08-21 09:37:30 +00:00
|
|
|
|
|
|
|
python () {
|
2016-12-14 21:13:04 +00:00
|
|
|
if d.getVar('PACKAGES') != '':
|
2012-03-03 10:41:41 +00:00
|
|
|
deps = ' rpm-native:do_populate_sysroot virtual/fakeroot-native:do_populate_sysroot'
|
|
|
|
d.appendVarFlag('do_package_write_rpm', 'depends', deps)
|
2015-11-10 09:52:44 +00:00
|
|
|
d.setVarFlag('do_package_write_rpm', 'fakeroot', '1')
|
2007-08-21 09:37:30 +00:00
|
|
|
}
|
|
|
|
|
2010-08-05 09:52:10 +00:00
|
|
|
SSTATETASKS += "do_package_write_rpm"
|
|
|
|
do_package_write_rpm[sstate-inputdirs] = "${PKGWRITEDIRRPM}"
|
|
|
|
do_package_write_rpm[sstate-outputdirs] = "${DEPLOY_DIR_RPM}"
|
2011-03-29 10:58:01 +00:00
|
|
|
# Take a shared lock, we can write multiple packages at the same time...
|
|
|
|
# but we need to stop the rootfs/solver from running while we do...
|
|
|
|
do_package_write_rpm[sstate-lockfile-shared] += "${DEPLOY_DIR_RPM}/rpm.lock"
|
2010-08-05 09:52:10 +00:00
|
|
|
|
|
|
|
python do_package_write_rpm_setscene () {
|
2012-07-11 17:33:43 +00:00
|
|
|
sstate_setscene(d)
|
2010-08-05 09:52:10 +00:00
|
|
|
}
|
2010-09-16 05:55:21 +00:00
|
|
|
addtask do_package_write_rpm_setscene
|
2007-08-21 09:37:30 +00:00
|
|
|
|
|
|
|
python do_package_write_rpm () {
|
2012-07-11 17:33:43 +00:00
|
|
|
bb.build.exec_func("read_subpackage_metadata", d)
|
|
|
|
bb.build.exec_func("do_package_rpm", d)
|
2007-08-21 09:37:30 +00:00
|
|
|
}
|
2010-08-20 16:52:39 +00:00
|
|
|
|
2010-08-05 09:52:10 +00:00
|
|
|
do_package_write_rpm[dirs] = "${PKGWRITEDIRRPM}"
|
2013-01-29 22:04:35 +00:00
|
|
|
do_package_write_rpm[cleandirs] = "${PKGWRITEDIRRPM}"
|
2012-03-10 02:11:57 +00:00
|
|
|
do_package_write_rpm[umask] = "022"
|
2017-01-19 16:49:00 +00:00
|
|
|
do_package_write_rpm[depends] += "${@oe.utils.build_depends_string(d.getVar('PACKAGE_WRITE_DEPS'), 'do_populate_sysroot')}"
|
2014-03-28 11:04:30 +00:00
|
|
|
addtask package_write_rpm after do_packagedata do_package
|
2008-08-18 08:01:41 +00:00
|
|
|
|
package-index.bb: add support for deb and rpm.
[YOCTO #1024]
Currently package-index.bb only supports ipk. This commit adds the support
for rpm and deb, too.
------------------------------
How to generate and use repos:
1) run "bitbake package-index" after building some target,
e.g., core-image-sato-sdk;
2) export ${DEPLOY_DIR_RPM}, ${DEPLOY_DIR_IPK} and ${DEPLOY_DIR_DEB} by a
webserver on the host, assuming the host IP is 192.168.7.1, at
http://192.168.7.1/rpm
http://192.168.7.1/ipk
http://192.168.7.1/deb
3) inside the target, according to the packaging system (rpm, ipk or deb) used
when we generate the target image, we can use different ways to manage
packages:
3.1) RPM
run "zypper addrepo http://192.168.7.1/rpm main; zypper refresh"
to retrieve info about the repo; next, we can use "zypper install/remove"
to manage packages.
3.2) IPK
add the repo info into opkg config file, i.e., in
/etc/opkg/arch.conf, we can add something like
"src i586 http://192.168.7.1/ipk/i586", and next, we run "opkg update" to
make opkg update the list of available packages. And later, we can use
"opkg install/remove" to manage packages.
3.3) DEB
Currently in target, some important config files, like
/var/lib/dpkg/status and /etc/apt/sources.list, for deb/apt are missing. So
we can't install/remove package in target at present.
(From OE-Core rev: 01e34bdb43e0cc27c1cfffd6730c384f40c404c1)
Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-05-18 04:09:01 +00:00
|
|
|
PACKAGEINDEXDEPS += "rpm-native:do_populate_sysroot"
|
2017-01-26 16:28:11 +00:00
|
|
|
PACKAGEINDEXDEPS += "createrepo-c-native:do_populate_sysroot"
|
2014-02-24 16:12:07 +00:00
|
|
|
|
|
|
|
do_build[recrdeptask] += "do_package_write_rpm"
|