# Remaining package name validity fixes
return s.lower().replace('_', '-').replace('@', '+').replace(',', '+').replace('/', '-')
-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):
+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):
"""
Used in .bb files to split up dynamically generated subpackages of a
given package, usually plugins or modules.
continue
f = os.path.join(dvar + root, o)
mode = os.lstat(f).st_mode
- if not (stat.S_ISREG(mode) or (allow_dirs and stat.S_ISDIR(mode))):
+ if not (stat.S_ISREG(mode) or (allow_links and stat.S_ISLNK(mode)) or (allow_dirs and stat.S_ISDIR(mode))):
continue
on = legitimize_package_name(m.group(1))
pkg = output_pattern % on
PACKAGE_DEPENDS += "file-native"
+def package_stash_hook(func, name, d):
+ import bb, os.path
+ body = bb.data.getVar(func, d, True)
+ pn = bb.data.getVar('PN', d, True)
+ staging = bb.data.getVar('PKGDATA_DIR', d, True)
+ dirname = os.path.join(staging, 'hooks', name)
+ bb.mkdirhier(dirname)
+ fn = os.path.join(dirname, pn)
+ f = open(fn, 'w')
+ f.write("python () {\n");
+ f.write(body);
+ f.write("}\n");
+ f.close()
+
python () {
import bb
if bb.data.getVar('PACKAGES', d, True) != '':
# If the file is in a .debug directory it was already stripped,
# don't do it again...
if os.path.dirname(file).endswith(".debug"):
- bb.note("Already run strip")
+ bb.note("Already ran strip")
return 0
strip = bb.data.getVar("STRIP", d, 1)
os.system('rm -rf %s' % pkgdest)
seen = []
+ main_is_empty = 1
+ main_pkg = bb.data.getVar('PN', d, 1)
for pkg in package_list:
localdata = bb.data.createCopy(d)
continue
if (not os.path.islink(file)) and (not os.path.exists(file)):
continue
+ if file[-4:] == '.pyo':
+ continue
if file in seen:
continue
seen.append(file)
ret = bb.copyfile(file, fpath)
if ret is False or ret == 0:
raise bb.build.FuncFailed("File population failed")
+ if pkg == main_pkg and main_is_empty:
+ main_is_empty = 0
del localdata
os.chdir(workdir)
dangling_links[pkg].append(os.path.normpath(target))
for pkg in package_list:
- rdepends = explode_deps(bb.data.getVar('RDEPENDS_' + pkg, d, 1) or bb.data.getVar('RDEPENDS', d, 1) or "")
+ rdepends = explode_deps(bb.data.getVar('RDEPENDS_' + pkg, d, 0) or bb.data.getVar('RDEPENDS', d, 0) or "")
+
+ remstr = "${PN} (= ${DEBPV})"
+ if main_is_empty and remstr in rdepends:
+ rdepends.remove(remstr)
for l in dangling_links[pkg]:
found = False
bb.debug(1, "%s contains dangling link %s" % (pkg, l))
if val:
f.write('%s_%s: %s\n' % (var, pkg, encode(val)))
- packages = bb.data.getVar('PACKAGES', d, 1)
+ packages = bb.data.getVar('PACKAGES', d, True)
+ 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))
- data_file = bb.data.expand("${PKGDATA_DIR}/${PN}", d)
+ data_file = pkgdatadir + bb.data.expand("/${PN}" , d)
f = open(data_file, 'w')
f.write("PACKAGES: %s\n" % packages)
f.close()
+ package_stagefile(data_file, d)
workdir = bb.data.getVar('WORKDIR', d, 1)
for pkg in packages.split():
- subdata_file = bb.data.expand("${PKGDATA_DIR}/runtime/%s" % pkg, d)
+ subdata_file = pkgdatadir + "/runtime/%s" % pkg
sf = open(subdata_file, 'w')
+ write_if_exists(sf, pkg, 'PN')
+ write_if_exists(sf, pkg, 'PR')
write_if_exists(sf, pkg, 'DESCRIPTION')
write_if_exists(sf, pkg, 'RDEPENDS')
write_if_exists(sf, pkg, 'RPROVIDES')
write_if_exists(sf, pkg, 'RRECOMMENDS')
write_if_exists(sf, pkg, 'RSUGGESTS')
- write_if_exists(sf, pkg, 'RPROVIDES')
write_if_exists(sf, pkg, 'RREPLACES')
write_if_exists(sf, pkg, 'RCONFLICTS')
write_if_exists(sf, pkg, 'PKG')
write_if_exists(sf, pkg, 'pkg_prerm')
sf.close()
+ package_stagefile(subdata_file, d)
+ #if pkgdatadir2:
+ # bb.copyfile(subdata_file, pkgdatadir2 + "/runtime/%s" % pkg)
+
allow_empty = bb.data.getVar('ALLOW_EMPTY_%s' % pkg, d, 1)
if not allow_empty:
allow_empty = bb.data.getVar('ALLOW_EMPTY', d, 1)
os.chdir(root)
g = glob('*')
if g or allow_empty == "1":
- packagedfile = bb.data.expand('${PKGDATA_DIR}/runtime/%s.packaged' % pkg, d)
+ packagedfile = pkgdatadir + '/runtime/%s.packaged' % pkg
file(packagedfile, 'w').close()
+ package_stagefile(packagedfile, d)
+ if pstageactive == "1":
+ bb.utils.unlockfile(lf)
}
emit_pkgdata[dirs] = "${PKGDATA_DIR}/runtime"
ldconfig_postinst_fragment() {
if [ x"$D" = "x" ]; then
- ldconfig
+ if [ -e /etc/ld.so.conf ] ; then
+ [ -x /sbin/ldconfig ] && /sbin/ldconfig
+ fi
fi
}
-SHLIBSDIR = "${STAGING_DIR}/${HOST_SYS}/shlibs"
+SHLIBSDIR = "${STAGING_DIR_HOST}/shlibs"
python package_do_shlibs() {
import os, re, os.path
shlibs_dir = bb.data.getVar('SHLIBSDIR', d, 1)
bb.mkdirhier(shlibs_dir)
+ pstageactive = bb.data.getVar('PSTAGING_ACTIVE', d, True)
+ if pstageactive == "1":
+ lf = bb.utils.lockfile(bb.data.expand("${STAGING_DIR}/staging.lock", d))
+
+ if bb.data.getVar('PACKAGE_SNAP_LIB_SYMLINKS', d, True) == "1":
+ snap_symlinks = True
+ else:
+ snap_symlinks = False
+
+ if (bb.data.getVar('USE_LDCONFIG', d, True) or "1") == "1":
+ use_ldconfig = True
+ else:
+ use_ldconfig = False
+
needed = {}
private_libs = bb.data.getVar('PRIVATE_LIBS', d, 1)
for pkg in packages.split():
needed[pkg] = []
sonames = list()
top = os.path.join(pkgdest, pkg)
+ renames = []
for root, dirs, files in os.walk(top):
for file in files:
soname = None
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
+ if m:
+ this_soname = m.group(1)
+ if not this_soname 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(this_soname):
+ sonames.append(this_soname)
+ if libdir_re.match(root):
+ needs_ldconfig = True
+ if snap_symlinks and (file != soname):
+ renames.append((path, os.path.join(root, this_soname)))
+ for (old, new) in renames:
+ os.rename(old, new)
shlibs_file = os.path.join(shlibs_dir, pkg + ".list")
if os.path.exists(shlibs_file):
os.remove(shlibs_file)
for s in sonames:
fd.write(s + '\n')
fd.close()
+ package_stagefile(shlibs_file, d)
fd = open(shver_file, 'w')
fd.write(ver + '\n')
fd.close()
- if needs_ldconfig:
+ package_stagefile(shver_file, d)
+ if needs_ldconfig and use_ldconfig:
bb.debug(1, 'adding ldconfig call to postinst for %s' % pkg)
postinst = bb.data.getVar('pkg_postinst_%s' % pkg, d, 1) or bb.data.getVar('pkg_postinst', d, 1)
if not postinst:
postinst += bb.data.getVar('ldconfig_postinst_fragment', d, 1)
bb.data.setVar('pkg_postinst_%s' % pkg, postinst, d)
+ if pstageactive == "1":
+ bb.utils.unlockfile(lf)
+
shlib_provider = {}
list_re = re.compile('^(.*)\.list$')
for dir in [shlibs_dir]:
dep_pkg = dep_pkg[0]
shlib_provider[l] = (dep_pkg, lib_ver)
+ dep_packages = []
for pkg in packages.split():
bb.debug(2, "calculating shlib requirements for %s" % pkg)
dep = dep_pkg
if not dep in deps:
deps.append(dep)
+ if not dep_pkg in dep_packages:
+ dep_packages.append(dep_pkg)
+
else:
bb.note("Couldn't find shared library provider for %s" % n)
if hdr == 'Requires':
pkgconfig_needed[pkg] += exp.replace(',', ' ').split()
+ pstageactive = bb.data.getVar('PSTAGING_ACTIVE', d, True)
+ if pstageactive == "1":
+ lf = bb.utils.lockfile(bb.data.expand("${STAGING_DIR}/staging.lock", d))
+
for pkg in packages.split():
pkgs_file = os.path.join(shlibs_dir, pkg + ".pclist")
if os.path.exists(pkgs_file):
for p in pkgconfig_provided[pkg]:
f.write('%s\n' % p)
f.close()
+ package_stagefile(pkgs_file, d)
for dir in [shlibs_dir]:
if not os.path.exists(dir):
for dep in deps:
fd.write(dep + '\n')
fd.close()
+ package_stagefile(deps_file, d)
+
+ if pstageactive == "1":
+ bb.utils.unlockfile(lf)
}
python read_shlibdeps () {
for suffix in pkgs:
for pkg in pkgs[suffix]:
(base, func) = pkgs[suffix][pkg]
- if suffix == "-dev":
+ if suffix == "-dev" and not pkg.startswith("kernel-module-"):
pkg_adddeprrecs(pkg, base, suffix, func, depends, d)
if len(pkgs[suffix]) == 1:
pkg_addrrecs(pkg, base, suffix, func, rdepends, d)
package_depchains \
emit_pkgdata"
+def package_run_hooks(f, d):
+ import bb, os
+ staging = bb.data.getVar('PKGDATA_DIR', d, True)
+ dn = os.path.join(staging, 'hooks', f)
+ if os.access(dn, os.R_OK):
+ for f in os.listdir(dn):
+ fn = os.path.join(dn, f)
+ fp = open(fn, 'r')
+ line = 0
+ for l in fp.readlines():
+ l = l.rstrip()
+ bb.parse.parse_py.BBHandler.feeder(line, l, fn, os.path.basename(fn), d)
+ line += 1
+ fp.close()
+ anonqueue = bb.data.getVar("__anonqueue", d, 1) or []
+ body = [x['content'] for x in anonqueue]
+ flag = { 'python' : 1, 'func' : 1 }
+ bb.data.setVar("__anonfunc", "\n".join(body), d)
+ bb.data.setVarFlags("__anonfunc", flag, d)
+ try:
+ t = bb.data.getVar('T', d)
+ bb.data.setVar('T', '${TMPDIR}/', d)
+ bb.build.exec_func("__anonfunc", d)
+ bb.data.delVar('T', d)
+ if t:
+ bb.data.setVar('T', t, d)
+ except Exception, e:
+ bb.msg.debug(1, bb.msg.domain.Parsing, "Exception when executing anonymous function: %s" % e)
+ raise
+ bb.data.delVar("__anonqueue", d)
+ bb.data.delVar("__anonfunc", d)
+
python package_do_package () {
packages = (bb.data.getVar('PACKAGES', d, 1) or "").split()
if len(packages) < 1:
for f in (bb.data.getVar('PACKAGEFUNCS', d, 1) or '').split():
bb.build.exec_func(f, d)
+ package_run_hooks(f, d)
}
do_package[dirs] = "${D}"
addtask package before do_build after do_install