2006-10-20 14:31:06 +00:00
|
|
|
#
|
|
|
|
# General packaging help functions
|
|
|
|
#
|
|
|
|
|
2009-01-25 17:14:57 +00:00
|
|
|
inherit packagedata
|
|
|
|
|
2009-10-29 23:55:43 +00:00
|
|
|
PKGD = "${WORKDIR}/package"
|
|
|
|
PKGDEST = "${WORKDIR}/packages-split"
|
2007-09-03 14:16:12 +00:00
|
|
|
|
2005-08-31 10:45:47 +00:00
|
|
|
def legitimize_package_name(s):
|
2006-10-20 14:31:06 +00:00
|
|
|
"""
|
|
|
|
Make sure package names are legitimate strings
|
|
|
|
"""
|
2006-09-20 16:40:07 +00:00
|
|
|
import re
|
|
|
|
|
|
|
|
def fixutf(m):
|
|
|
|
cp = m.group(1)
|
|
|
|
if cp:
|
|
|
|
return ('\u%s' % cp).decode('unicode_escape').encode('utf-8')
|
|
|
|
|
|
|
|
# Handle unicode codepoints encoded as <U0123>, as in glibc locale files.
|
|
|
|
s = re.sub('<U([0-9A-Fa-f]{1,4})>', fixutf, s)
|
|
|
|
|
|
|
|
# Remaining package name validity fixes
|
2005-08-31 10:45:47 +00:00
|
|
|
return s.lower().replace('_', '-').replace('@', '+').replace(',', '+').replace('/', '-')
|
|
|
|
|
2008-10-06 12:49:05 +00:00
|
|
|
def do_split_packages(d, root, file_regex, output_pattern, description, postinst=None, recursive=False, hook=None, extra_depends=None, aux_files_pattern=None, postrm=None, allow_dirs=False, prepend=False, match_path=False, aux_files_pattern_verbatim=None, allow_links=False):
|
2006-10-20 14:31:06 +00:00
|
|
|
"""
|
|
|
|
Used in .bb files to split up dynamically generated subpackages of a
|
|
|
|
given package, usually plugins or modules.
|
|
|
|
"""
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2009-10-29 23:55:43 +00:00
|
|
|
dvar = bb.data.getVar('PKGD', d, True)
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
packages = bb.data.getVar('PACKAGES', d, True).split()
|
2005-08-31 10:45:47 +00:00
|
|
|
|
|
|
|
if postinst:
|
|
|
|
postinst = '#!/bin/sh\n' + postinst + '\n'
|
|
|
|
if postrm:
|
|
|
|
postrm = '#!/bin/sh\n' + postrm + '\n'
|
|
|
|
if not recursive:
|
|
|
|
objs = os.listdir(dvar + root)
|
|
|
|
else:
|
|
|
|
objs = []
|
|
|
|
for walkroot, dirs, files in os.walk(dvar + root):
|
|
|
|
for file in files:
|
|
|
|
relpath = os.path.join(walkroot, file).replace(dvar + root + '/', '', 1)
|
|
|
|
if relpath:
|
|
|
|
objs.append(relpath)
|
|
|
|
|
|
|
|
if extra_depends == None:
|
2006-10-22 12:06:41 +00:00
|
|
|
# This is *really* broken
|
|
|
|
mainpkg = packages[0]
|
|
|
|
# At least try and patch it up I guess...
|
|
|
|
if mainpkg.find('-dbg'):
|
|
|
|
mainpkg = mainpkg.replace('-dbg', '')
|
|
|
|
if mainpkg.find('-dev'):
|
|
|
|
mainpkg = mainpkg.replace('-dev', '')
|
|
|
|
extra_depends = mainpkg
|
2005-08-31 10:45:47 +00:00
|
|
|
|
|
|
|
for o in objs:
|
|
|
|
import re, stat
|
|
|
|
if match_path:
|
|
|
|
m = re.match(file_regex, o)
|
|
|
|
else:
|
|
|
|
m = re.match(file_regex, os.path.basename(o))
|
|
|
|
|
|
|
|
if not m:
|
|
|
|
continue
|
|
|
|
f = os.path.join(dvar + root, o)
|
|
|
|
mode = os.lstat(f).st_mode
|
2008-10-06 12:49:05 +00:00
|
|
|
if not (stat.S_ISREG(mode) or (allow_links and stat.S_ISLNK(mode)) or (allow_dirs and stat.S_ISDIR(mode))):
|
2005-08-31 10:45:47 +00:00
|
|
|
continue
|
|
|
|
on = legitimize_package_name(m.group(1))
|
|
|
|
pkg = output_pattern % on
|
|
|
|
if not pkg in packages:
|
|
|
|
if prepend:
|
|
|
|
packages = [pkg] + packages
|
|
|
|
else:
|
|
|
|
packages.append(pkg)
|
2009-10-29 23:24:19 +00:00
|
|
|
oldfiles = bb.data.getVar('FILES_' + pkg, d, True)
|
2008-09-10 22:29:43 +00:00
|
|
|
if not oldfiles:
|
2005-08-31 10:45:47 +00:00
|
|
|
the_files = [os.path.join(root, o)]
|
|
|
|
if aux_files_pattern:
|
|
|
|
if type(aux_files_pattern) is list:
|
|
|
|
for fp in aux_files_pattern:
|
|
|
|
the_files.append(fp % on)
|
|
|
|
else:
|
|
|
|
the_files.append(aux_files_pattern % on)
|
2006-03-23 22:31:13 +00:00
|
|
|
if aux_files_pattern_verbatim:
|
|
|
|
if type(aux_files_pattern_verbatim) is list:
|
|
|
|
for fp in aux_files_pattern_verbatim:
|
|
|
|
the_files.append(fp % m.group(1))
|
|
|
|
else:
|
|
|
|
the_files.append(aux_files_pattern_verbatim % m.group(1))
|
2005-08-31 10:45:47 +00:00
|
|
|
bb.data.setVar('FILES_' + pkg, " ".join(the_files), d)
|
|
|
|
if extra_depends != '':
|
2009-10-29 23:24:19 +00:00
|
|
|
the_depends = bb.data.getVar('RDEPENDS_' + pkg, d, True)
|
2005-08-31 10:45:47 +00:00
|
|
|
if the_depends:
|
|
|
|
the_depends = '%s %s' % (the_depends, extra_depends)
|
|
|
|
else:
|
|
|
|
the_depends = extra_depends
|
|
|
|
bb.data.setVar('RDEPENDS_' + pkg, the_depends, d)
|
|
|
|
bb.data.setVar('DESCRIPTION_' + pkg, description % on, d)
|
|
|
|
if postinst:
|
|
|
|
bb.data.setVar('pkg_postinst_' + pkg, postinst, d)
|
|
|
|
if postrm:
|
|
|
|
bb.data.setVar('pkg_postrm_' + pkg, postrm, d)
|
|
|
|
else:
|
|
|
|
bb.data.setVar('FILES_' + pkg, oldfiles + " " + os.path.join(root, o), d)
|
|
|
|
if callable(hook):
|
|
|
|
hook(f, pkg, file_regex, output_pattern, m.group(1))
|
|
|
|
|
|
|
|
bb.data.setVar('PACKAGES', ' '.join(packages), d)
|
|
|
|
|
2007-04-10 11:23:14 +00:00
|
|
|
PACKAGE_DEPENDS += "file-native"
|
|
|
|
|
2007-04-03 11:31:02 +00:00
|
|
|
python () {
|
2007-04-10 11:23:14 +00:00
|
|
|
if bb.data.getVar('PACKAGES', d, True) != '':
|
|
|
|
deps = bb.data.getVarFlag('do_package', 'depends', d) or ""
|
|
|
|
for dep in (bb.data.getVar('PACKAGE_DEPENDS', d, True) or "").split():
|
2009-11-10 14:55:23 +00:00
|
|
|
deps += " %s:do_populate_sysroot" % dep
|
2007-04-10 11:23:14 +00:00
|
|
|
bb.data.setVarFlag('do_package', 'depends', deps, d)
|
2007-04-03 11:31:02 +00:00
|
|
|
|
2007-09-27 11:52:15 +00:00
|
|
|
deps = (bb.data.getVarFlag('do_package', 'deptask', d) or "").split()
|
2007-05-09 09:54:54 +00:00
|
|
|
# shlibs requires any DEPENDS to have already packaged for the *.list files
|
2007-09-27 11:52:15 +00:00
|
|
|
deps.append("do_package")
|
|
|
|
bb.data.setVarFlag('do_package', 'deptask', " ".join(deps), d)
|
2007-04-03 11:31:02 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 08:54:41 +00:00
|
|
|
def runstrip(file, d):
|
|
|
|
# Function to strip a single file, called from populate_packages below
|
|
|
|
# A working 'file' (one which works on the target architecture)
|
|
|
|
# is necessary for this stuff to work, hence the addition to do_package[depends]
|
|
|
|
|
2009-11-08 22:32:43 +00:00
|
|
|
import commands, stat
|
2007-08-06 08:54:41 +00:00
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
pathprefix = "export PATH=%s; " % bb.data.getVar('PATH', d, True)
|
2007-08-06 08:54:41 +00:00
|
|
|
|
|
|
|
ret, result = commands.getstatusoutput("%sfile '%s'" % (pathprefix, file))
|
|
|
|
|
|
|
|
if ret:
|
|
|
|
bb.error("runstrip: 'file %s' failed (forced strip)" % file)
|
|
|
|
|
|
|
|
if "not stripped" not in result:
|
|
|
|
bb.debug(1, "runstrip: skip %s" % file)
|
|
|
|
return 0
|
|
|
|
|
2007-12-19 10:32:12 +00:00
|
|
|
# If the file is in a .debug directory it was already stripped,
|
|
|
|
# don't do it again...
|
|
|
|
if os.path.dirname(file).endswith(".debug"):
|
2008-03-19 16:05:35 +00:00
|
|
|
bb.note("Already ran strip")
|
2007-12-19 10:32:12 +00:00
|
|
|
return 0
|
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
strip = bb.data.getVar("STRIP", d, True)
|
|
|
|
objcopy = bb.data.getVar("OBJCOPY", d, True)
|
2007-08-06 08:54:41 +00:00
|
|
|
|
|
|
|
newmode = None
|
|
|
|
if not os.access(file, os.W_OK):
|
2007-08-06 14:05:51 +00:00
|
|
|
origmode = os.stat(file)[stat.ST_MODE]
|
|
|
|
newmode = origmode | stat.S_IWRITE
|
2007-08-06 08:54:41 +00:00
|
|
|
os.chmod(file, newmode)
|
|
|
|
|
2007-08-06 09:10:08 +00:00
|
|
|
extraflags = ""
|
|
|
|
if ".so" in file and "shared" in result:
|
|
|
|
extraflags = "--remove-section=.comment --remove-section=.note --strip-unneeded"
|
|
|
|
elif "shared" in result or "executable" in result:
|
|
|
|
extraflags = "--remove-section=.comment --remove-section=.note"
|
2007-08-06 08:54:41 +00:00
|
|
|
|
2007-08-06 09:10:08 +00:00
|
|
|
bb.mkdirhier(os.path.join(os.path.dirname(file), ".debug"))
|
2007-08-06 08:54:41 +00:00
|
|
|
debugfile=os.path.join(os.path.dirname(file), ".debug", os.path.basename(file))
|
|
|
|
|
2007-08-06 09:10:08 +00:00
|
|
|
stripcmd = "'%s' %s '%s'" % (strip, extraflags, file)
|
|
|
|
bb.debug(1, "runstrip: %s" % stripcmd)
|
|
|
|
|
2007-08-06 08:54:41 +00:00
|
|
|
os.system("%s'%s' --only-keep-debug '%s' '%s'" % (pathprefix, objcopy, file, debugfile))
|
2007-08-06 09:10:08 +00:00
|
|
|
ret = os.system("%s%s" % (pathprefix, stripcmd))
|
2007-08-06 08:54:41 +00:00
|
|
|
os.system("%s'%s' --add-gnu-debuglink='%s' '%s'" % (pathprefix, objcopy, debugfile, file))
|
|
|
|
|
|
|
|
if newmode:
|
|
|
|
os.chmod(file, origmode)
|
|
|
|
|
|
|
|
if ret:
|
2007-08-06 09:10:08 +00:00
|
|
|
bb.error("runstrip: '%s' strip command failed" % stripcmd)
|
2007-08-06 08:54:41 +00:00
|
|
|
|
|
|
|
return 1
|
2006-10-20 14:31:06 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Package data handling routines
|
|
|
|
#
|
|
|
|
|
|
|
|
def get_package_mapping (pkg, d):
|
2007-11-24 23:06:56 +00:00
|
|
|
data = read_subpkgdata(pkg, d)
|
|
|
|
key = "PKG_%s" % pkg
|
2006-10-20 14:31:06 +00:00
|
|
|
|
2007-11-24 23:06:56 +00:00
|
|
|
if key in data:
|
|
|
|
return data[key]
|
2006-10-20 14:31:06 +00:00
|
|
|
|
|
|
|
return pkg
|
|
|
|
|
|
|
|
def runtime_mapping_rename (varname, d):
|
2009-10-29 23:24:19 +00:00
|
|
|
#bb.note("%s before: %s" % (varname, bb.data.getVar(varname, d, True)))
|
2006-10-20 14:31:06 +00:00
|
|
|
|
|
|
|
new_depends = []
|
2009-11-19 10:13:10 +00:00
|
|
|
deps = bb.utils.explode_dep_versions(bb.data.getVar(varname, d, True) or "")
|
|
|
|
for depend in deps:
|
2006-10-20 14:31:06 +00:00
|
|
|
# Have to be careful with any version component of the depend
|
2009-11-19 10:13:10 +00:00
|
|
|
new_depend = get_package_mapping(depend, d)
|
|
|
|
if deps[depend]:
|
|
|
|
new_depends.append("%s (%s)" % (new_depend, deps[depend]))
|
2006-10-20 14:31:06 +00:00
|
|
|
else:
|
|
|
|
new_depends.append(new_depend)
|
|
|
|
|
|
|
|
bb.data.setVar(varname, " ".join(new_depends) or None, d)
|
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
#bb.note("%s after: %s" % (varname, bb.data.getVar(varname, d, True)))
|
2006-10-20 14:31:06 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Package functions suitable for inclusion in PACKAGEFUNCS
|
|
|
|
#
|
|
|
|
|
|
|
|
python package_do_split_locales() {
|
2009-10-29 23:24:19 +00:00
|
|
|
if (bb.data.getVar('PACKAGE_NO_LOCALE', d, True) == '1'):
|
2006-10-20 14:31:06 +00:00
|
|
|
bb.debug(1, "package requested not splitting locales")
|
|
|
|
return
|
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
packages = (bb.data.getVar('PACKAGES', d, True) or "").split()
|
2006-10-20 14:31:06 +00:00
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
datadir = bb.data.getVar('datadir', d, True)
|
2006-10-20 14:31:06 +00:00
|
|
|
if not datadir:
|
|
|
|
bb.note("datadir not defined")
|
|
|
|
return
|
|
|
|
|
2009-10-29 23:55:43 +00:00
|
|
|
dvar = bb.data.getVar('PKGD', d, True)
|
2009-10-29 23:24:19 +00:00
|
|
|
pn = bb.data.getVar('PN', d, True)
|
2006-10-20 14:31:06 +00:00
|
|
|
|
|
|
|
if pn + '-locale' in packages:
|
|
|
|
packages.remove(pn + '-locale')
|
|
|
|
|
|
|
|
localedir = os.path.join(dvar + datadir, 'locale')
|
|
|
|
|
|
|
|
if not os.path.isdir(localedir):
|
|
|
|
bb.debug(1, "No locale files in this package")
|
|
|
|
return
|
|
|
|
|
|
|
|
locales = os.listdir(localedir)
|
|
|
|
|
2006-10-21 22:03:13 +00:00
|
|
|
# This is *really* broken
|
2006-10-20 14:31:06 +00:00
|
|
|
mainpkg = packages[0]
|
2006-10-21 22:03:13 +00:00
|
|
|
# At least try and patch it up I guess...
|
|
|
|
if mainpkg.find('-dbg'):
|
|
|
|
mainpkg = mainpkg.replace('-dbg', '')
|
|
|
|
if mainpkg.find('-dev'):
|
|
|
|
mainpkg = mainpkg.replace('-dev', '')
|
2006-10-20 14:31:06 +00:00
|
|
|
|
|
|
|
for l in locales:
|
|
|
|
ln = legitimize_package_name(l)
|
|
|
|
pkg = pn + '-locale-' + ln
|
|
|
|
packages.append(pkg)
|
|
|
|
bb.data.setVar('FILES_' + pkg, os.path.join(datadir, 'locale', l), d)
|
|
|
|
bb.data.setVar('RDEPENDS_' + pkg, '%s virtual-locale-%s' % (mainpkg, ln), d)
|
|
|
|
bb.data.setVar('RPROVIDES_' + pkg, '%s-locale %s-translation' % (pn, ln), d)
|
|
|
|
bb.data.setVar('DESCRIPTION_' + pkg, '%s translation for %s' % (l, pn), d)
|
|
|
|
|
|
|
|
bb.data.setVar('PACKAGES', ' '.join(packages), d)
|
|
|
|
|
2007-06-18 11:36:18 +00:00
|
|
|
# Disabled by RP 18/06/07
|
|
|
|
# Wildcards aren't supported in debian
|
|
|
|
# They break with ipkg since glibc-locale* will mean that
|
|
|
|
# glibc-localedata-translit* won't install as a dependency
|
|
|
|
# for some other package which breaks meta-toolchain
|
|
|
|
# Probably breaks since virtual-locale- isn't provided anywhere
|
2009-10-29 23:24:19 +00:00
|
|
|
#rdep = (bb.data.getVar('RDEPENDS_%s' % mainpkg, d, True) or bb.data.getVar('RDEPENDS', d, True) or "").split()
|
2007-06-18 11:36:18 +00:00
|
|
|
#rdep.append('%s-locale*' % pn)
|
|
|
|
#bb.data.setVar('RDEPENDS_%s' % mainpkg, ' '.join(rdep), d)
|
2006-10-20 14:31:06 +00:00
|
|
|
}
|
|
|
|
|
2009-10-29 23:55:43 +00:00
|
|
|
python perform_packagecopy () {
|
|
|
|
dest = bb.data.getVar('D', d, True)
|
|
|
|
dvar = bb.data.getVar('PKGD', d, True)
|
|
|
|
|
|
|
|
bb.mkdirhier(dvar)
|
|
|
|
|
|
|
|
# Start by package population by taking a copy of the installed
|
|
|
|
# files to operate on
|
2009-11-20 17:11:27 +00:00
|
|
|
os.system('rm -rf %s/*' % (dvar))
|
2009-10-29 23:55:43 +00:00
|
|
|
os.system('cp -pPR %s/* %s/' % (dest, dvar))
|
|
|
|
}
|
|
|
|
|
2005-08-31 10:45:47 +00:00
|
|
|
python populate_packages () {
|
2009-11-08 22:32:43 +00:00
|
|
|
import glob, stat, errno, re
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
workdir = bb.data.getVar('WORKDIR', d, True)
|
|
|
|
outdir = bb.data.getVar('DEPLOY_DIR', d, True)
|
2009-10-29 23:55:43 +00:00
|
|
|
dvar = bb.data.getVar('PKGD', d, True)
|
2009-10-29 23:24:19 +00:00
|
|
|
packages = bb.data.getVar('PACKAGES', d, True)
|
|
|
|
pn = bb.data.getVar('PN', d, True)
|
2009-10-29 23:41:24 +00:00
|
|
|
|
|
|
|
bb.mkdirhier(outdir)
|
2005-08-31 10:45:47 +00:00
|
|
|
os.chdir(dvar)
|
|
|
|
|
|
|
|
def isexec(path):
|
|
|
|
try:
|
|
|
|
s = os.stat(path)
|
|
|
|
except (os.error, AttributeError):
|
|
|
|
return 0
|
|
|
|
return (s[stat.ST_MODE] & stat.S_IEXEC)
|
|
|
|
|
2006-05-09 16:10:46 +00:00
|
|
|
# Sanity check PACKAGES for duplicates - should be moved to
|
2006-10-20 16:09:53 +00:00
|
|
|
# sanity.bbclass once we have the infrastucture
|
|
|
|
package_list = []
|
2006-05-09 16:10:46 +00:00
|
|
|
for pkg in packages.split():
|
2006-10-20 16:09:53 +00:00
|
|
|
if pkg in package_list:
|
|
|
|
bb.error("-------------------")
|
2007-03-21 10:11:50 +00:00
|
|
|
bb.error("%s is listed in PACKAGES multiple times, this leads to packaging errors." % pkg)
|
2006-10-20 16:09:53 +00:00
|
|
|
bb.error("Please fix the metadata/report this as bug to OE bugtracker.")
|
|
|
|
bb.error("-------------------")
|
|
|
|
else:
|
|
|
|
package_list.append(pkg)
|
2006-05-09 16:10:46 +00:00
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
if (bb.data.getVar('INHIBIT_PACKAGE_STRIP', d, True) != '1'):
|
2006-07-24 08:35:37 +00:00
|
|
|
for root, dirs, files in os.walk(dvar):
|
|
|
|
for f in files:
|
|
|
|
file = os.path.join(root, f)
|
2006-10-20 16:09:53 +00:00
|
|
|
if not os.path.islink(file) and not os.path.isdir(file) and isexec(file):
|
2007-08-06 08:54:41 +00:00
|
|
|
runstrip(file, d)
|
2006-07-24 08:35:37 +00:00
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
pkgdest = bb.data.getVar('PKGDEST', d, True)
|
2007-09-03 14:16:12 +00:00
|
|
|
os.system('rm -rf %s' % pkgdest)
|
|
|
|
|
2007-10-23 21:57:31 +00:00
|
|
|
seen = []
|
|
|
|
|
2006-10-20 16:09:53 +00:00
|
|
|
for pkg in package_list:
|
2005-08-31 10:45:47 +00:00
|
|
|
localdata = bb.data.createCopy(d)
|
2007-09-03 14:16:12 +00:00
|
|
|
root = os.path.join(pkgdest, pkg)
|
|
|
|
bb.mkdirhier(root)
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2006-09-21 16:29:02 +00:00
|
|
|
bb.data.setVar('PKG', pkg, localdata)
|
2009-10-29 23:24:19 +00:00
|
|
|
overrides = bb.data.getVar('OVERRIDES', localdata, True)
|
2005-08-31 10:45:47 +00:00
|
|
|
if not overrides:
|
|
|
|
raise bb.build.FuncFailed('OVERRIDES not defined')
|
2007-09-03 14:16:12 +00:00
|
|
|
bb.data.setVar('OVERRIDES', overrides + ':' + pkg, localdata)
|
2005-08-31 10:45:47 +00:00
|
|
|
bb.data.update_data(localdata)
|
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
filesvar = bb.data.getVar('FILES', localdata, True) or ""
|
2005-08-31 10:45:47 +00:00
|
|
|
files = filesvar.split()
|
|
|
|
for file in files:
|
|
|
|
if os.path.isabs(file):
|
|
|
|
file = '.' + file
|
|
|
|
if not os.path.islink(file):
|
|
|
|
if os.path.isdir(file):
|
|
|
|
newfiles = [ os.path.join(file,x) for x in os.listdir(file) ]
|
|
|
|
if newfiles:
|
|
|
|
files += newfiles
|
|
|
|
continue
|
|
|
|
globbed = glob.glob(file)
|
|
|
|
if globbed:
|
|
|
|
if [ file ] != globbed:
|
|
|
|
files += globbed
|
|
|
|
continue
|
|
|
|
if (not os.path.islink(file)) and (not os.path.exists(file)):
|
|
|
|
continue
|
2007-10-23 21:57:31 +00:00
|
|
|
if file in seen:
|
|
|
|
continue
|
|
|
|
seen.append(file)
|
2007-12-19 11:07:14 +00:00
|
|
|
if os.path.isdir(file) and not os.path.islink(file):
|
2007-10-23 21:57:31 +00:00
|
|
|
bb.mkdirhier(os.path.join(root,file))
|
2007-12-19 11:07:14 +00:00
|
|
|
os.chmod(os.path.join(root,file), os.stat(file).st_mode)
|
2007-10-23 21:57:31 +00:00
|
|
|
continue
|
2005-08-31 10:45:47 +00:00
|
|
|
fpath = os.path.join(root,file)
|
|
|
|
dpath = os.path.dirname(fpath)
|
|
|
|
bb.mkdirhier(dpath)
|
2007-11-24 14:55:57 +00:00
|
|
|
ret = bb.copyfile(file, fpath)
|
2007-10-23 21:57:31 +00:00
|
|
|
if ret is False or ret == 0:
|
2005-08-31 10:45:47 +00:00
|
|
|
raise bb.build.FuncFailed("File population failed")
|
|
|
|
del localdata
|
|
|
|
os.chdir(workdir)
|
|
|
|
|
|
|
|
unshipped = []
|
|
|
|
for root, dirs, files in os.walk(dvar):
|
|
|
|
for f in files:
|
|
|
|
path = os.path.join(root[len(dvar):], f)
|
2007-10-23 21:57:31 +00:00
|
|
|
if ('.' + path) not in seen:
|
|
|
|
unshipped.append(path)
|
2005-08-31 10:45:47 +00:00
|
|
|
|
|
|
|
if unshipped != []:
|
|
|
|
bb.note("the following files were installed but not shipped in any package:")
|
|
|
|
for f in unshipped:
|
|
|
|
bb.note(" " + f)
|
|
|
|
|
|
|
|
bb.build.exec_func("package_name_hook", d)
|
|
|
|
|
2006-10-20 16:09:53 +00:00
|
|
|
for pkg in package_list:
|
2009-10-29 23:24:19 +00:00
|
|
|
pkgname = bb.data.getVar('PKG_%s' % pkg, d, True)
|
2006-02-27 13:18:52 +00:00
|
|
|
if pkgname is None:
|
2005-08-31 10:45:47 +00:00
|
|
|
bb.data.setVar('PKG_%s' % pkg, pkg, d)
|
|
|
|
|
|
|
|
dangling_links = {}
|
|
|
|
pkg_files = {}
|
2006-10-20 16:09:53 +00:00
|
|
|
for pkg in package_list:
|
2005-08-31 10:45:47 +00:00
|
|
|
dangling_links[pkg] = []
|
|
|
|
pkg_files[pkg] = []
|
2007-09-03 14:16:12 +00:00
|
|
|
inst_root = os.path.join(pkgdest, pkg)
|
2005-08-31 10:45:47 +00:00
|
|
|
for root, dirs, files in os.walk(inst_root):
|
|
|
|
for f in files:
|
|
|
|
path = os.path.join(root, f)
|
|
|
|
rpath = path[len(inst_root):]
|
|
|
|
pkg_files[pkg].append(rpath)
|
|
|
|
try:
|
|
|
|
s = os.stat(path)
|
|
|
|
except OSError, (err, strerror):
|
|
|
|
if err != errno.ENOENT:
|
|
|
|
raise
|
|
|
|
target = os.readlink(path)
|
|
|
|
if target[0] != '/':
|
|
|
|
target = os.path.join(root[len(inst_root):], target)
|
|
|
|
dangling_links[pkg].append(os.path.normpath(target))
|
|
|
|
|
2006-10-20 16:09:53 +00:00
|
|
|
for pkg in package_list:
|
2009-10-29 23:24:19 +00:00
|
|
|
rdepends = bb.utils.explode_deps(bb.data.getVar('RDEPENDS_' + pkg, d, True) or bb.data.getVar('RDEPENDS', d, True) or "")
|
2005-08-31 10:45:47 +00:00
|
|
|
for l in dangling_links[pkg]:
|
|
|
|
found = False
|
|
|
|
bb.debug(1, "%s contains dangling link %s" % (pkg, l))
|
2006-10-20 16:09:53 +00:00
|
|
|
for p in package_list:
|
2005-08-31 10:45:47 +00:00
|
|
|
for f in pkg_files[p]:
|
|
|
|
if f == l:
|
|
|
|
found = True
|
|
|
|
bb.debug(1, "target found in %s" % p)
|
|
|
|
if p == pkg:
|
|
|
|
break
|
2006-09-21 16:29:02 +00:00
|
|
|
if not p in rdepends:
|
|
|
|
rdepends.append(p)
|
2005-08-31 10:45:47 +00:00
|
|
|
break
|
|
|
|
if found == False:
|
|
|
|
bb.note("%s contains dangling symlink to %s" % (pkg, l))
|
|
|
|
bb.data.setVar('RDEPENDS_' + pkg, " " + " ".join(rdepends), d)
|
2006-09-21 16:29:02 +00:00
|
|
|
}
|
2006-10-20 14:31:06 +00:00
|
|
|
populate_packages[dirs] = "${D}"
|
2006-09-21 16:29:02 +00:00
|
|
|
|
|
|
|
python emit_pkgdata() {
|
2007-09-27 11:52:15 +00:00
|
|
|
from glob import glob
|
|
|
|
|
2005-08-31 10:45:47 +00:00
|
|
|
def write_if_exists(f, pkg, var):
|
|
|
|
def encode(str):
|
|
|
|
import codecs
|
|
|
|
c = codecs.getencoder("string_escape")
|
|
|
|
return c(str)[0]
|
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
val = bb.data.getVar('%s_%s' % (var, pkg), d, True)
|
2005-08-31 10:45:47 +00:00
|
|
|
if val:
|
|
|
|
f.write('%s_%s: %s\n' % (var, pkg, encode(val)))
|
2008-10-02 19:56:19 +00:00
|
|
|
return
|
2009-10-29 23:24:19 +00:00
|
|
|
val = bb.data.getVar('%s' % (var), d, True)
|
2008-10-02 19:56:19 +00:00
|
|
|
if val:
|
|
|
|
f.write('%s: %s\n' % (var, encode(val)))
|
|
|
|
return
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2008-03-19 16:05:35 +00:00
|
|
|
packages = bb.data.getVar('PACKAGES', d, True)
|
2009-10-29 23:41:48 +00:00
|
|
|
pkgdest = bb.data.getVar('PKGDEST', d, 1)
|
2008-03-19 16:05:35 +00:00
|
|
|
pkgdatadir = bb.data.getVar('PKGDATA_DIR', d, True)
|
|
|
|
|
|
|
|
pstageactive = bb.data.getVar('PSTAGING_ACTIVE', d, True)
|
|
|
|
if pstageactive == "1":
|
|
|
|
lf = bb.utils.lockfile(bb.data.expand("${STAGING_DIR}/staging.lock", d))
|
2006-09-21 16:29:02 +00:00
|
|
|
|
2008-03-19 16:05:35 +00:00
|
|
|
data_file = pkgdatadir + bb.data.expand("/${PN}" , d)
|
2005-08-31 10:45:47 +00:00
|
|
|
f = open(data_file, 'w')
|
|
|
|
f.write("PACKAGES: %s\n" % packages)
|
|
|
|
f.close()
|
2008-03-19 16:05:35 +00:00
|
|
|
package_stagefile(data_file, d)
|
2006-09-21 16:29:02 +00:00
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
workdir = bb.data.getVar('WORKDIR', d, True)
|
2007-09-27 11:52:15 +00:00
|
|
|
|
2006-09-21 16:29:02 +00:00
|
|
|
for pkg in packages.split():
|
2008-03-19 16:05:35 +00:00
|
|
|
subdata_file = pkgdatadir + "/runtime/%s" % pkg
|
2006-09-21 16:29:02 +00:00
|
|
|
sf = open(subdata_file, 'w')
|
2008-01-09 13:50:38 +00:00
|
|
|
write_if_exists(sf, pkg, 'PN')
|
2008-10-02 19:56:19 +00:00
|
|
|
write_if_exists(sf, pkg, 'PV')
|
2008-03-19 16:05:35 +00:00
|
|
|
write_if_exists(sf, pkg, 'PR')
|
2006-09-21 16:29:02 +00:00
|
|
|
write_if_exists(sf, pkg, 'DESCRIPTION')
|
|
|
|
write_if_exists(sf, pkg, 'RDEPENDS')
|
|
|
|
write_if_exists(sf, pkg, 'RPROVIDES')
|
2006-10-20 16:09:05 +00:00
|
|
|
write_if_exists(sf, pkg, 'RRECOMMENDS')
|
|
|
|
write_if_exists(sf, pkg, 'RSUGGESTS')
|
|
|
|
write_if_exists(sf, pkg, 'RREPLACES')
|
|
|
|
write_if_exists(sf, pkg, 'RCONFLICTS')
|
2006-09-21 16:29:02 +00:00
|
|
|
write_if_exists(sf, pkg, 'PKG')
|
|
|
|
write_if_exists(sf, pkg, 'ALLOW_EMPTY')
|
|
|
|
write_if_exists(sf, pkg, 'FILES')
|
|
|
|
write_if_exists(sf, pkg, 'pkg_postinst')
|
|
|
|
write_if_exists(sf, pkg, 'pkg_postrm')
|
|
|
|
write_if_exists(sf, pkg, 'pkg_preinst')
|
|
|
|
write_if_exists(sf, pkg, 'pkg_prerm')
|
|
|
|
sf.close()
|
2007-09-27 11:52:15 +00:00
|
|
|
|
2008-03-19 16:05:35 +00:00
|
|
|
package_stagefile(subdata_file, d)
|
|
|
|
#if pkgdatadir2:
|
|
|
|
# bb.copyfile(subdata_file, pkgdatadir2 + "/runtime/%s" % pkg)
|
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
allow_empty = bb.data.getVar('ALLOW_EMPTY_%s' % pkg, d, True)
|
2007-12-19 11:07:14 +00:00
|
|
|
if not allow_empty:
|
2009-10-29 23:24:19 +00:00
|
|
|
allow_empty = bb.data.getVar('ALLOW_EMPTY', d, True)
|
2009-10-29 23:41:48 +00:00
|
|
|
root = "%s/%s" % (pkgdest, pkg)
|
2007-09-27 11:52:15 +00:00
|
|
|
os.chdir(root)
|
|
|
|
g = glob('*')
|
|
|
|
if g or allow_empty == "1":
|
2008-03-19 16:05:35 +00:00
|
|
|
packagedfile = pkgdatadir + '/runtime/%s.packaged' % pkg
|
2007-12-19 11:07:14 +00:00
|
|
|
file(packagedfile, 'w').close()
|
2008-03-19 16:05:35 +00:00
|
|
|
package_stagefile(packagedfile, d)
|
|
|
|
if pstageactive == "1":
|
|
|
|
bb.utils.unlockfile(lf)
|
2005-08-31 10:45:47 +00:00
|
|
|
}
|
2007-08-21 11:51:25 +00:00
|
|
|
emit_pkgdata[dirs] = "${PKGDATA_DIR}/runtime"
|
2005-08-31 10:45:47 +00:00
|
|
|
|
|
|
|
ldconfig_postinst_fragment() {
|
|
|
|
if [ x"$D" = "x" ]; then
|
2008-03-19 16:05:35 +00:00
|
|
|
[ -x /sbin/ldconfig ] && /sbin/ldconfig
|
2005-08-31 10:45:47 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-03-19 16:05:35 +00:00
|
|
|
SHLIBSDIR = "${STAGING_DIR_HOST}/shlibs"
|
2008-01-23 21:03:26 +00:00
|
|
|
|
2005-08-31 10:45:47 +00:00
|
|
|
python package_do_shlibs() {
|
2009-11-08 22:32:43 +00:00
|
|
|
import re
|
2005-08-31 10:45:47 +00:00
|
|
|
|
|
|
|
exclude_shlibs = bb.data.getVar('EXCLUDE_FROM_SHLIBS', d, 0)
|
|
|
|
if exclude_shlibs:
|
|
|
|
bb.note("not generating shlibs")
|
|
|
|
return
|
|
|
|
|
2008-06-18 08:37:33 +00:00
|
|
|
lib_re = re.compile("^.*\.so")
|
2005-08-31 10:45:47 +00:00
|
|
|
libdir_re = re.compile(".*/lib$")
|
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
packages = bb.data.getVar('PACKAGES', d, True)
|
|
|
|
targetos = bb.data.getVar('TARGET_OS', d, True)
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
workdir = bb.data.getVar('WORKDIR', d, True)
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
ver = bb.data.getVar('PV', d, True)
|
2005-08-31 10:45:47 +00:00
|
|
|
if not ver:
|
|
|
|
bb.error("PV not defined")
|
|
|
|
return
|
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
pkgdest = bb.data.getVar('PKGDEST', d, True)
|
2007-09-03 14:16:12 +00:00
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
shlibs_dir = bb.data.getVar('SHLIBSDIR', d, True)
|
2005-08-31 10:45:47 +00:00
|
|
|
bb.mkdirhier(shlibs_dir)
|
|
|
|
|
2008-03-19 16:05:35 +00:00
|
|
|
pstageactive = bb.data.getVar('PSTAGING_ACTIVE', d, True)
|
|
|
|
if pstageactive == "1":
|
|
|
|
lf = bb.utils.lockfile(bb.data.expand("${STAGING_DIR}/staging.lock", d))
|
|
|
|
|
2008-04-11 15:19:45 +00:00
|
|
|
def linux_so(root, path, file):
|
2009-10-29 23:24:19 +00:00
|
|
|
cmd = bb.data.getVar('OBJDUMP', d, True) + " -p " + os.path.join(root, file) + " 2>/dev/null"
|
|
|
|
cmd = "PATH=\"%s\" %s" % (bb.data.getVar('PATH', d, True), cmd)
|
2008-04-11 15:19:45 +00:00
|
|
|
fd = os.popen(cmd)
|
|
|
|
lines = fd.readlines()
|
|
|
|
fd.close()
|
|
|
|
for l in lines:
|
|
|
|
m = re.match("\s+NEEDED\s+([^\s]*)", l)
|
|
|
|
if m:
|
|
|
|
needed[pkg].append(m.group(1))
|
|
|
|
m = re.match("\s+SONAME\s+([^\s]*)", l)
|
|
|
|
if m and not m.group(1) in sonames:
|
|
|
|
# if library is private (only used by package) then do not build shlib for it
|
|
|
|
if not private_libs or -1 == private_libs.find(m.group(1)):
|
|
|
|
sonames.append(m.group(1))
|
|
|
|
if m and libdir_re.match(root):
|
|
|
|
needs_ldconfig = True
|
|
|
|
def darwin_so(root, path, file):
|
|
|
|
fullpath = os.path.join(root, file)
|
|
|
|
if not os.path.exists(fullpath):
|
|
|
|
return
|
|
|
|
|
|
|
|
def get_combinations(base):
|
|
|
|
#
|
|
|
|
# Given a base library name, find all combinations of this split by "." and "-"
|
|
|
|
#
|
|
|
|
combos = []
|
|
|
|
options = base.split(".")
|
|
|
|
for i in range(1, len(options) + 1):
|
|
|
|
combos.append(".".join(options[0:i]))
|
|
|
|
options = base.split("-")
|
|
|
|
for i in range(1, len(options) + 1):
|
|
|
|
combos.append("-".join(options[0:i]))
|
|
|
|
return combos
|
|
|
|
|
|
|
|
if (file.endswith('.dylib') or file.endswith('.so')) and not pkg.endswith('-dev') and not pkg.endswith('-dbg'):
|
|
|
|
# Drop suffix
|
|
|
|
name = file.rsplit(".",1)[0]
|
|
|
|
# Find all combinations
|
|
|
|
combos = get_combinations(name)
|
|
|
|
for combo in combos:
|
|
|
|
if not combo in sonames:
|
|
|
|
sonames.append(combo)
|
|
|
|
if file.endswith('.dylib') or file.endswith('.so'):
|
2009-10-29 23:55:43 +00:00
|
|
|
lafile = fullpath.replace(os.path.join(pkgdest, pkg), bb.data.getVar('PKGD', d, True))
|
2008-04-11 15:19:45 +00:00
|
|
|
# Drop suffix
|
|
|
|
lafile = lafile.rsplit(".",1)[0]
|
|
|
|
lapath = os.path.dirname(lafile)
|
|
|
|
lafile = os.path.basename(lafile)
|
|
|
|
# Find all combinations
|
|
|
|
combos = get_combinations(lafile)
|
|
|
|
for combo in combos:
|
|
|
|
if os.path.exists(lapath + '/' + combo + '.la'):
|
|
|
|
break
|
|
|
|
lafile = lapath + '/' + combo + '.la'
|
|
|
|
|
|
|
|
#bb.note("Foo2: %s" % lafile)
|
|
|
|
#bb.note("Foo %s %s" % (file, fullpath))
|
2008-05-05 22:19:28 +00:00
|
|
|
if os.path.exists(lafile):
|
|
|
|
fd = open(lafile, 'r')
|
|
|
|
lines = fd.readlines()
|
|
|
|
fd.close()
|
|
|
|
for l in lines:
|
|
|
|
m = re.match("\s*dependency_libs=\s*'(.*)'", l)
|
|
|
|
if m:
|
|
|
|
deps = m.group(1).split(" ")
|
|
|
|
for dep in deps:
|
|
|
|
#bb.note("Trying %s for %s" % (dep, pkg))
|
|
|
|
name = None
|
|
|
|
if dep.endswith(".la"):
|
|
|
|
name = os.path.basename(dep).replace(".la", "")
|
|
|
|
elif dep.startswith("-l"):
|
|
|
|
name = dep.replace("-l", "lib")
|
|
|
|
if pkg not in needed:
|
|
|
|
needed[pkg] = []
|
|
|
|
if name:
|
|
|
|
needed[pkg].append(name)
|
|
|
|
#bb.note("Adding %s for %s" % (name, pkg))
|
2005-08-31 10:45:47 +00:00
|
|
|
needed = {}
|
2009-10-29 23:24:19 +00:00
|
|
|
private_libs = bb.data.getVar('PRIVATE_LIBS', d, True)
|
2005-08-31 10:45:47 +00:00
|
|
|
for pkg in packages.split():
|
|
|
|
needs_ldconfig = False
|
|
|
|
bb.debug(2, "calculating shlib provides for %s" % pkg)
|
|
|
|
|
|
|
|
needed[pkg] = []
|
|
|
|
sonames = list()
|
2007-09-03 14:16:12 +00:00
|
|
|
top = os.path.join(pkgdest, pkg)
|
2005-08-31 10:45:47 +00:00
|
|
|
for root, dirs, files in os.walk(top):
|
|
|
|
for file in files:
|
|
|
|
soname = None
|
2008-04-11 20:37:51 +00:00
|
|
|
path = os.path.join(root, file)
|
2008-07-15 10:56:56 +00:00
|
|
|
if os.path.islink(path):
|
|
|
|
continue
|
2008-05-05 22:19:28 +00:00
|
|
|
if targetos == "darwin" or targetos == "darwin8":
|
2008-04-11 15:19:45 +00:00
|
|
|
darwin_so(root, dirs, file)
|
|
|
|
elif os.access(path, os.X_OK) or lib_re.match(file):
|
|
|
|
linux_so(root, dirs, file)
|
2006-09-21 16:29:02 +00:00
|
|
|
shlibs_file = os.path.join(shlibs_dir, pkg + ".list")
|
2005-08-31 10:45:47 +00:00
|
|
|
if os.path.exists(shlibs_file):
|
|
|
|
os.remove(shlibs_file)
|
2006-09-21 16:29:02 +00:00
|
|
|
shver_file = os.path.join(shlibs_dir, pkg + ".ver")
|
2005-08-31 10:45:47 +00:00
|
|
|
if os.path.exists(shver_file):
|
|
|
|
os.remove(shver_file)
|
|
|
|
if len(sonames):
|
|
|
|
fd = open(shlibs_file, 'w')
|
|
|
|
for s in sonames:
|
|
|
|
fd.write(s + '\n')
|
|
|
|
fd.close()
|
2008-03-19 16:05:35 +00:00
|
|
|
package_stagefile(shlibs_file, d)
|
2005-08-31 10:45:47 +00:00
|
|
|
fd = open(shver_file, 'w')
|
|
|
|
fd.write(ver + '\n')
|
|
|
|
fd.close()
|
2008-03-19 16:05:35 +00:00
|
|
|
package_stagefile(shver_file, d)
|
2005-08-31 10:45:47 +00:00
|
|
|
if needs_ldconfig:
|
|
|
|
bb.debug(1, 'adding ldconfig call to postinst for %s' % pkg)
|
2009-10-29 23:24:19 +00:00
|
|
|
postinst = bb.data.getVar('pkg_postinst_%s' % pkg, d, True) or bb.data.getVar('pkg_postinst', d, True)
|
2005-08-31 10:45:47 +00:00
|
|
|
if not postinst:
|
|
|
|
postinst = '#!/bin/sh\n'
|
2009-10-29 23:24:19 +00:00
|
|
|
postinst += bb.data.getVar('ldconfig_postinst_fragment', d, True)
|
2005-08-31 10:45:47 +00:00
|
|
|
bb.data.setVar('pkg_postinst_%s' % pkg, postinst, d)
|
|
|
|
|
2008-03-19 16:05:35 +00:00
|
|
|
if pstageactive == "1":
|
|
|
|
bb.utils.unlockfile(lf)
|
|
|
|
|
2005-08-31 10:45:47 +00:00
|
|
|
shlib_provider = {}
|
|
|
|
list_re = re.compile('^(.*)\.list$')
|
2008-01-17 21:51:05 +00:00
|
|
|
for dir in [shlibs_dir]:
|
2005-08-31 10:45:47 +00:00
|
|
|
if not os.path.exists(dir):
|
|
|
|
continue
|
|
|
|
for file in os.listdir(dir):
|
|
|
|
m = list_re.match(file)
|
|
|
|
if m:
|
|
|
|
dep_pkg = m.group(1)
|
|
|
|
fd = open(os.path.join(dir, file))
|
|
|
|
lines = fd.readlines()
|
|
|
|
fd.close()
|
|
|
|
ver_file = os.path.join(dir, dep_pkg + '.ver')
|
|
|
|
lib_ver = None
|
|
|
|
if os.path.exists(ver_file):
|
|
|
|
fd = open(ver_file)
|
|
|
|
lib_ver = fd.readline().rstrip()
|
|
|
|
fd.close()
|
|
|
|
for l in lines:
|
|
|
|
shlib_provider[l.rstrip()] = (dep_pkg, lib_ver)
|
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
assumed_libs = bb.data.getVar('ASSUME_SHLIBS', d, True)
|
2008-03-19 16:05:35 +00:00
|
|
|
if assumed_libs:
|
|
|
|
for e in assumed_libs.split():
|
|
|
|
l, dep_pkg = e.split(":")
|
|
|
|
lib_ver = None
|
|
|
|
dep_pkg = dep_pkg.rsplit("_", 1)
|
|
|
|
if len(dep_pkg) == 2:
|
|
|
|
lib_ver = dep_pkg[1]
|
|
|
|
dep_pkg = dep_pkg[0]
|
|
|
|
shlib_provider[l] = (dep_pkg, lib_ver)
|
2005-08-31 10:45:47 +00:00
|
|
|
|
|
|
|
for pkg in packages.split():
|
|
|
|
bb.debug(2, "calculating shlib requirements for %s" % pkg)
|
|
|
|
|
|
|
|
deps = list()
|
|
|
|
for n in needed[pkg]:
|
|
|
|
if n in shlib_provider.keys():
|
|
|
|
(dep_pkg, ver_needed) = shlib_provider[n]
|
|
|
|
|
2006-09-21 16:29:02 +00:00
|
|
|
if dep_pkg == pkg:
|
2005-08-31 10:45:47 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
if ver_needed:
|
|
|
|
dep = "%s (>= %s)" % (dep_pkg, ver_needed)
|
|
|
|
else:
|
|
|
|
dep = dep_pkg
|
|
|
|
if not dep in deps:
|
|
|
|
deps.append(dep)
|
|
|
|
else:
|
|
|
|
bb.note("Couldn't find shared library provider for %s" % n)
|
|
|
|
|
2007-09-03 14:16:12 +00:00
|
|
|
deps_file = os.path.join(pkgdest, pkg + ".shlibdeps")
|
2005-08-31 10:45:47 +00:00
|
|
|
if os.path.exists(deps_file):
|
|
|
|
os.remove(deps_file)
|
|
|
|
if len(deps):
|
|
|
|
fd = open(deps_file, 'w')
|
|
|
|
for dep in deps:
|
|
|
|
fd.write(dep + '\n')
|
|
|
|
fd.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
python package_do_pkgconfig () {
|
2009-11-08 22:32:43 +00:00
|
|
|
import re
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
packages = bb.data.getVar('PACKAGES', d, True)
|
|
|
|
workdir = bb.data.getVar('WORKDIR', d, True)
|
|
|
|
pkgdest = bb.data.getVar('PKGDEST', d, True)
|
2007-09-03 14:16:12 +00:00
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
shlibs_dir = bb.data.getVar('SHLIBSDIR', d, True)
|
2005-08-31 10:45:47 +00:00
|
|
|
bb.mkdirhier(shlibs_dir)
|
|
|
|
|
|
|
|
pc_re = re.compile('(.*)\.pc$')
|
|
|
|
var_re = re.compile('(.*)=(.*)')
|
|
|
|
field_re = re.compile('(.*): (.*)')
|
|
|
|
|
|
|
|
pkgconfig_provided = {}
|
|
|
|
pkgconfig_needed = {}
|
|
|
|
for pkg in packages.split():
|
|
|
|
pkgconfig_provided[pkg] = []
|
|
|
|
pkgconfig_needed[pkg] = []
|
2007-09-03 14:16:12 +00:00
|
|
|
top = os.path.join(pkgdest, pkg)
|
2005-08-31 10:45:47 +00:00
|
|
|
for root, dirs, files in os.walk(top):
|
|
|
|
for file in files:
|
|
|
|
m = pc_re.match(file)
|
|
|
|
if m:
|
|
|
|
pd = bb.data.init()
|
|
|
|
name = m.group(1)
|
|
|
|
pkgconfig_provided[pkg].append(name)
|
|
|
|
path = os.path.join(root, file)
|
|
|
|
if not os.access(path, os.R_OK):
|
|
|
|
continue
|
|
|
|
f = open(path, 'r')
|
|
|
|
lines = f.readlines()
|
|
|
|
f.close()
|
|
|
|
for l in lines:
|
|
|
|
m = var_re.match(l)
|
|
|
|
if m:
|
|
|
|
name = m.group(1)
|
|
|
|
val = m.group(2)
|
|
|
|
bb.data.setVar(name, bb.data.expand(val, pd), pd)
|
|
|
|
continue
|
|
|
|
m = field_re.match(l)
|
|
|
|
if m:
|
|
|
|
hdr = m.group(1)
|
|
|
|
exp = bb.data.expand(m.group(2), pd)
|
|
|
|
if hdr == 'Requires':
|
|
|
|
pkgconfig_needed[pkg] += exp.replace(',', ' ').split()
|
|
|
|
|
2008-03-19 16:05:35 +00:00
|
|
|
pstageactive = bb.data.getVar('PSTAGING_ACTIVE', d, True)
|
|
|
|
if pstageactive == "1":
|
|
|
|
lf = bb.utils.lockfile(bb.data.expand("${STAGING_DIR}/staging.lock", d))
|
|
|
|
|
2005-08-31 10:45:47 +00:00
|
|
|
for pkg in packages.split():
|
2006-09-21 16:29:02 +00:00
|
|
|
pkgs_file = os.path.join(shlibs_dir, pkg + ".pclist")
|
2005-08-31 10:45:47 +00:00
|
|
|
if os.path.exists(pkgs_file):
|
|
|
|
os.remove(pkgs_file)
|
|
|
|
if pkgconfig_provided[pkg] != []:
|
|
|
|
f = open(pkgs_file, 'w')
|
|
|
|
for p in pkgconfig_provided[pkg]:
|
|
|
|
f.write('%s\n' % p)
|
|
|
|
f.close()
|
2008-03-19 16:05:35 +00:00
|
|
|
package_stagefile(pkgs_file, d)
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2008-01-17 21:51:05 +00:00
|
|
|
for dir in [shlibs_dir]:
|
2005-08-31 10:45:47 +00:00
|
|
|
if not os.path.exists(dir):
|
|
|
|
continue
|
|
|
|
for file in os.listdir(dir):
|
|
|
|
m = re.match('^(.*)\.pclist$', file)
|
|
|
|
if m:
|
|
|
|
pkg = m.group(1)
|
|
|
|
fd = open(os.path.join(dir, file))
|
|
|
|
lines = fd.readlines()
|
|
|
|
fd.close()
|
|
|
|
pkgconfig_provided[pkg] = []
|
|
|
|
for l in lines:
|
|
|
|
pkgconfig_provided[pkg].append(l.rstrip())
|
|
|
|
|
|
|
|
for pkg in packages.split():
|
|
|
|
deps = []
|
|
|
|
for n in pkgconfig_needed[pkg]:
|
|
|
|
found = False
|
|
|
|
for k in pkgconfig_provided.keys():
|
|
|
|
if n in pkgconfig_provided[k]:
|
|
|
|
if k != pkg and not (k in deps):
|
|
|
|
deps.append(k)
|
|
|
|
found = True
|
|
|
|
if found == False:
|
|
|
|
bb.note("couldn't find pkgconfig module '%s' in any package" % n)
|
2007-09-03 14:16:12 +00:00
|
|
|
deps_file = os.path.join(pkgdest, pkg + ".pcdeps")
|
2005-08-31 10:45:47 +00:00
|
|
|
if os.path.exists(deps_file):
|
|
|
|
os.remove(deps_file)
|
|
|
|
if len(deps):
|
|
|
|
fd = open(deps_file, 'w')
|
|
|
|
for dep in deps:
|
|
|
|
fd.write(dep + '\n')
|
|
|
|
fd.close()
|
2008-03-19 16:05:35 +00:00
|
|
|
package_stagefile(deps_file, d)
|
|
|
|
|
|
|
|
if pstageactive == "1":
|
|
|
|
bb.utils.unlockfile(lf)
|
2005-08-31 10:45:47 +00:00
|
|
|
}
|
|
|
|
|
2006-10-20 14:31:06 +00:00
|
|
|
python read_shlibdeps () {
|
2009-10-29 23:24:19 +00:00
|
|
|
packages = bb.data.getVar('PACKAGES', d, True).split()
|
2006-10-20 14:31:06 +00:00
|
|
|
for pkg in packages:
|
2009-01-25 17:20:05 +00:00
|
|
|
rdepends = bb.utils.explode_deps(bb.data.getVar('RDEPENDS_' + pkg, d, 0) or bb.data.getVar('RDEPENDS', d, 0) or "")
|
2007-12-19 11:07:14 +00:00
|
|
|
for extension in ".shlibdeps", ".pcdeps", ".clilibdeps":
|
|
|
|
depsfile = bb.data.expand("${PKGDEST}/" + pkg + extension, d)
|
|
|
|
if os.access(depsfile, os.R_OK):
|
|
|
|
fd = file(depsfile)
|
|
|
|
lines = fd.readlines()
|
|
|
|
fd.close()
|
|
|
|
for l in lines:
|
|
|
|
rdepends.append(l.rstrip())
|
2006-10-20 14:31:06 +00:00
|
|
|
bb.data.setVar('RDEPENDS_' + pkg, " " + " ".join(rdepends), d)
|
|
|
|
}
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2006-10-20 14:31:06 +00:00
|
|
|
python package_depchains() {
|
2006-10-20 16:09:53 +00:00
|
|
|
"""
|
|
|
|
For a given set of prefix and postfix modifiers, make those packages
|
2007-04-04 11:06:37 +00:00
|
|
|
RRECOMMENDS on the corresponding packages for its RDEPENDS.
|
2006-10-20 16:09:53 +00:00
|
|
|
|
|
|
|
Example: If package A depends upon package B, and A's .bb emits an
|
|
|
|
A-dev package, this would make A-dev Recommends: B-dev.
|
2007-04-04 11:06:37 +00:00
|
|
|
|
|
|
|
If only one of a given suffix is specified, it will take the RRECOMMENDS
|
|
|
|
based on the RDEPENDS of *all* other packages. If more than one of a given
|
|
|
|
suffix is specified, its will only use the RDEPENDS of the single parent
|
|
|
|
package.
|
2006-10-20 16:09:53 +00:00
|
|
|
"""
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
packages = bb.data.getVar('PACKAGES', d, True)
|
|
|
|
postfixes = (bb.data.getVar('DEPCHAIN_POST', d, True) or '').split()
|
|
|
|
prefixes = (bb.data.getVar('DEPCHAIN_PRE', d, True) or '').split()
|
2006-10-20 16:09:53 +00:00
|
|
|
|
2008-01-09 13:50:38 +00:00
|
|
|
def pkg_adddeprrecs(pkg, base, suffix, getname, depends, d):
|
|
|
|
|
|
|
|
#bb.note('depends for %s is %s' % (base, depends))
|
2009-10-29 23:24:19 +00:00
|
|
|
rreclist = bb.utils.explode_deps(bb.data.getVar('RRECOMMENDS_' + pkg, d, True) or bb.data.getVar('RRECOMMENDS', d, True) or "")
|
2008-01-09 13:50:38 +00:00
|
|
|
|
|
|
|
for depend in depends:
|
|
|
|
if depend.find('-native') != -1 or depend.find('-cross') != -1 or depend.startswith('virtual/'):
|
|
|
|
#bb.note("Skipping %s" % depend)
|
|
|
|
continue
|
2008-02-07 20:20:34 +00:00
|
|
|
if depend.endswith('-dev'):
|
|
|
|
depend = depend.replace('-dev', '')
|
|
|
|
if depend.endswith('-dbg'):
|
|
|
|
depend = depend.replace('-dbg', '')
|
2008-01-09 13:50:38 +00:00
|
|
|
pkgname = getname(depend, suffix)
|
|
|
|
#bb.note("Adding %s for %s" % (pkgname, depend))
|
|
|
|
if not pkgname in rreclist:
|
|
|
|
rreclist.append(pkgname)
|
|
|
|
|
|
|
|
#bb.note('setting: RRECOMMENDS_%s=%s' % (pkg, ' '.join(rreclist)))
|
|
|
|
bb.data.setVar('RRECOMMENDS_%s' % pkg, ' '.join(rreclist), d)
|
|
|
|
|
2007-04-04 11:06:37 +00:00
|
|
|
def pkg_addrrecs(pkg, base, suffix, getname, rdepends, d):
|
|
|
|
|
2008-01-09 13:50:38 +00:00
|
|
|
#bb.note('rdepends for %s is %s' % (base, rdepends))
|
2009-10-29 23:24:19 +00:00
|
|
|
rreclist = bb.utils.explode_deps(bb.data.getVar('RRECOMMENDS_' + pkg, d, True) or bb.data.getVar('RRECOMMENDS', d, True) or "")
|
2006-10-20 16:09:53 +00:00
|
|
|
|
|
|
|
for depend in rdepends:
|
2008-10-02 22:05:09 +00:00
|
|
|
if depend.find('virtual-locale-') != -1:
|
|
|
|
#bb.note("Skipping %s" % depend)
|
|
|
|
continue
|
2008-02-07 20:20:34 +00:00
|
|
|
if depend.endswith('-dev'):
|
|
|
|
depend = depend.replace('-dev', '')
|
|
|
|
if depend.endswith('-dbg'):
|
|
|
|
depend = depend.replace('-dbg', '')
|
2007-04-04 11:06:37 +00:00
|
|
|
pkgname = getname(depend, suffix)
|
2008-10-02 22:05:09 +00:00
|
|
|
#bb.note("Adding %s for %s" % (pkgname, depend))
|
2007-10-02 14:19:54 +00:00
|
|
|
if not pkgname in rreclist:
|
2007-03-29 09:49:07 +00:00
|
|
|
rreclist.append(pkgname)
|
2006-10-20 16:09:53 +00:00
|
|
|
|
2007-03-29 09:49:07 +00:00
|
|
|
#bb.note('setting: RRECOMMENDS_%s=%s' % (pkg, ' '.join(rreclist)))
|
2006-10-20 16:09:53 +00:00
|
|
|
bb.data.setVar('RRECOMMENDS_%s' % pkg, ' '.join(rreclist), d)
|
|
|
|
|
2007-03-29 09:49:07 +00:00
|
|
|
def add_dep(list, dep):
|
|
|
|
dep = dep.split(' (')[0].strip()
|
|
|
|
if dep not in list:
|
|
|
|
list.append(dep)
|
|
|
|
|
2008-01-09 13:50:38 +00:00
|
|
|
depends = []
|
2009-10-29 23:24:19 +00:00
|
|
|
for dep in bb.utils.explode_deps(bb.data.getVar('DEPENDS', d, True) or ""):
|
2008-01-09 13:50:38 +00:00
|
|
|
add_dep(depends, dep)
|
|
|
|
|
2007-03-29 09:49:07 +00:00
|
|
|
rdepends = []
|
2009-10-29 23:24:19 +00:00
|
|
|
for dep in bb.utils.explode_deps(bb.data.getVar('RDEPENDS', d, True) or ""):
|
2007-03-29 09:49:07 +00:00
|
|
|
add_dep(rdepends, dep)
|
|
|
|
|
|
|
|
for pkg in packages.split():
|
2009-10-29 23:24:19 +00:00
|
|
|
for dep in bb.utils.explode_deps(bb.data.getVar('RDEPENDS_' + pkg, d, True) or ""):
|
2007-03-29 09:49:07 +00:00
|
|
|
add_dep(rdepends, dep)
|
|
|
|
|
|
|
|
#bb.note('rdepends is %s' % rdepends)
|
2006-10-20 16:09:53 +00:00
|
|
|
|
2007-04-04 11:06:37 +00:00
|
|
|
def post_getname(name, suffix):
|
|
|
|
return '%s%s' % (name, suffix)
|
|
|
|
def pre_getname(name, suffix):
|
|
|
|
return '%s%s' % (suffix, name)
|
|
|
|
|
|
|
|
pkgs = {}
|
2006-10-20 16:09:53 +00:00
|
|
|
for pkg in packages.split():
|
|
|
|
for postfix in postfixes:
|
|
|
|
if pkg.endswith(postfix):
|
2007-04-04 11:06:37 +00:00
|
|
|
if not postfix in pkgs:
|
|
|
|
pkgs[postfix] = {}
|
|
|
|
pkgs[postfix][pkg] = (pkg[:-len(postfix)], post_getname)
|
2006-10-20 16:09:53 +00:00
|
|
|
|
|
|
|
for prefix in prefixes:
|
|
|
|
if pkg.startswith(prefix):
|
2007-04-04 11:06:37 +00:00
|
|
|
if not prefix in pkgs:
|
|
|
|
pkgs[prefix] = {}
|
|
|
|
pkgs[prefix][pkg] = (pkg[:-len(prefix)], pre_getname)
|
|
|
|
|
|
|
|
for suffix in pkgs:
|
|
|
|
for pkg in pkgs[suffix]:
|
|
|
|
(base, func) = pkgs[suffix][pkg]
|
2008-01-09 13:50:38 +00:00
|
|
|
if suffix == "-dev":
|
|
|
|
pkg_adddeprrecs(pkg, base, suffix, func, depends, d)
|
2007-04-04 11:06:37 +00:00
|
|
|
if len(pkgs[suffix]) == 1:
|
|
|
|
pkg_addrrecs(pkg, base, suffix, func, rdepends, d)
|
|
|
|
else:
|
|
|
|
rdeps = []
|
2009-10-29 23:24:19 +00:00
|
|
|
for dep in bb.utils.explode_deps(bb.data.getVar('RDEPENDS_' + base, d, True) or bb.data.getVar('RDEPENDS', d, True) or ""):
|
2007-04-04 11:06:37 +00:00
|
|
|
add_dep(rdeps, dep)
|
|
|
|
pkg_addrrecs(pkg, base, suffix, func, rdeps, d)
|
2006-10-20 16:09:53 +00:00
|
|
|
}
|
2006-10-20 14:31:06 +00:00
|
|
|
|
2009-10-30 00:31:30 +00:00
|
|
|
PACKAGE_PREPROCESS_FUNCS ?= ""
|
2009-10-29 23:55:43 +00:00
|
|
|
PACKAGEFUNCS ?= "perform_packagecopy \
|
2009-10-30 00:31:30 +00:00
|
|
|
${PACKAGE_PREPROCESS_FUNCS} \
|
2009-10-29 23:55:43 +00:00
|
|
|
package_do_split_locales \
|
2006-10-20 14:31:06 +00:00
|
|
|
populate_packages \
|
|
|
|
package_do_shlibs \
|
|
|
|
package_do_pkgconfig \
|
|
|
|
read_shlibdeps \
|
2006-10-20 16:09:05 +00:00
|
|
|
package_depchains \
|
|
|
|
emit_pkgdata"
|
2006-10-20 14:31:06 +00:00
|
|
|
|
2005-08-31 10:45:47 +00:00
|
|
|
python package_do_package () {
|
2009-10-29 23:24:19 +00:00
|
|
|
packages = (bb.data.getVar('PACKAGES', d, True) or "").split()
|
2007-09-27 11:52:15 +00:00
|
|
|
if len(packages) < 1:
|
|
|
|
bb.debug(1, "No packages to build, skipping do_package")
|
|
|
|
return
|
|
|
|
|
2009-10-29 23:41:24 +00:00
|
|
|
workdir = bb.data.getVar('WORKDIR', d, True)
|
|
|
|
outdir = bb.data.getVar('DEPLOY_DIR', d, True)
|
2009-10-29 23:55:43 +00:00
|
|
|
dest = bb.data.getVar('D', d, True)
|
|
|
|
dvar = bb.data.getVar('PKGD', d, True)
|
2009-10-29 23:41:24 +00:00
|
|
|
pn = bb.data.getVar('PN', d, True)
|
|
|
|
|
2009-10-29 23:55:43 +00:00
|
|
|
if not workdir or not outdir or not dest or not dvar or not pn or not packages:
|
|
|
|
bb.error("WORKDIR, DEPLOY_DIR, D, PN and PKGD all must be defined, unable to package")
|
2009-10-29 23:41:24 +00:00
|
|
|
return
|
|
|
|
|
2009-10-29 23:24:19 +00:00
|
|
|
for f in (bb.data.getVar('PACKAGEFUNCS', d, True) or '').split():
|
2005-08-31 10:45:47 +00:00
|
|
|
bb.build.exec_func(f, d)
|
|
|
|
}
|
2006-10-20 16:09:05 +00:00
|
|
|
do_package[dirs] = "${D}"
|
2006-09-18 20:31:39 +00:00
|
|
|
addtask package before do_build after do_install
|
2006-10-20 14:31:06 +00:00
|
|
|
|
2007-08-21 22:39:57 +00:00
|
|
|
# Dummy task to mark when all packaging is complete
|
|
|
|
do_package_write () {
|
|
|
|
:
|
|
|
|
}
|
2007-08-24 10:59:50 +00:00
|
|
|
addtask package_write before do_build after do_package
|
2006-10-20 16:09:05 +00:00
|
|
|
|
2007-08-21 22:39:57 +00:00
|
|
|
EXPORT_FUNCTIONS do_package do_package_write
|
2006-10-20 16:09:05 +00:00
|
|
|
|
2006-10-20 14:31:06 +00:00
|
|
|
#
|
|
|
|
# Helper functions for the package writing classes
|
|
|
|
#
|
|
|
|
|
|
|
|
python package_mapping_rename_hook () {
|
2006-10-20 16:09:05 +00:00
|
|
|
"""
|
|
|
|
Rewrite variables to account for package renaming in things
|
|
|
|
like debian.bbclass or manual PKG variable name changes
|
|
|
|
"""
|
2006-10-20 14:31:06 +00:00
|
|
|
runtime_mapping_rename("RDEPENDS", d)
|
|
|
|
runtime_mapping_rename("RRECOMMENDS", d)
|
|
|
|
runtime_mapping_rename("RSUGGESTS", d)
|
|
|
|
runtime_mapping_rename("RPROVIDES", d)
|
|
|
|
runtime_mapping_rename("RREPLACES", d)
|
|
|
|
runtime_mapping_rename("RCONFLICTS", d)
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_FUNCTIONS mapping_rename_hook
|