# # General packaging help functions # def legitimize_package_name(s): """ Make sure package names are legitimate strings """ 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 , as in glibc locale files. s = re.sub('', fixutf, s) # 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): """ Used in .bb files to split up dynamically generated subpackages of a given package, usually plugins or modules. """ import os, os.path, bb dvar = bb.data.getVar('D', d, 1) if not dvar: bb.error("D not defined") return packages = bb.data.getVar('PACKAGES', d, 1).split() if not packages: # nothing to do return 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: # 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 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 if not (stat.S_ISREG(mode) or (allow_dirs and stat.S_ISDIR(mode))): 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) 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) 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)) bb.data.setVar('FILES_' + pkg, " ".join(the_files), d) if extra_depends != '': the_depends = bb.data.getVar('RDEPENDS_' + pkg, d, 1) 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: oldfiles = bb.data.getVar('FILES_' + pkg, d, 1) if not oldfiles: bb.fatal("Package '%s' exists but has no files" % pkg) 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) #PACKAGE_DEPENDS ?= "file-native" #DEPENDS_prepend =+ "${PACKAGE_DEPENDS} " # file(1) output to match to consider a file an unstripped executable FILE_UNSTRIPPED_MATCH ?= "not stripped" #FIXME: this should be "" when any errors are gone! IGNORE_STRIP_ERRORS ?= "1" runstrip() { # Function to strip a single file, called from RUNSTRIP in populate_packages below # A working 'file' (one which works on the target architecture) # is necessary for this stuff to work, hence the addition to PACKAGES_DEPENDS local ro st st=0 if { file "$1" || { oewarn "file $1: failed (forced strip)" >&2 echo '${FILE_UNSTRIPPED_MATCH}' } } | grep -q '${FILE_UNSTRIPPED_MATCH}' then oenote "${STRIP} $1" ro= test -w "$1" || { ro=1 chmod +w "$1" } mkdir -p $(dirname "$1")/.debug debugfile="$(dirname "$1")/.debug/$(basename "$1")" '${OBJCOPY}' --only-keep-debug "$1" "$debugfile" '${STRIP}' "$1" st=$? '${OBJCOPY}' --add-gnu-debuglink="$debugfile" "$1" test -n "$ro" && chmod -w "$1" if test $st -ne 0 then oewarn "runstrip: ${STRIP} $1: strip failed" >&2 if [ x${IGNORE_STRIP_ERRORS} == x1 ] then #FIXME: remove this, it's for error detection if file "$1" 2>/dev/null >&2 then (oefatal "${STRIP} $1: command failed" >/dev/tty) else (oefatal "file $1: command failed" >/dev/tty) fi st=0 fi fi else oenote "runstrip: skip $1" fi return $st } # # Package data handling routines # STAGING_PKGMAPS_DIR ?= "${STAGING_DIR}/pkgmaps" def add_package_mapping (pkg, new_name, d): import bb, os def encode(str): import codecs c = codecs.getencoder("string_escape") return c(str)[0] pmap_dir = bb.data.getVar('STAGING_PKGMAPS_DIR', d, 1) bb.mkdirhier(pmap_dir) data_file = os.path.join(pmap_dir, pkg) f = open(data_file, 'w') f.write("%s\n" % encode(new_name)) f.close() def get_package_mapping (pkg, d): import bb, os def decode(str): import codecs c = codecs.getdecoder("string_escape") return c(str)[0] data_file = bb.data.expand("${STAGING_PKGMAPS_DIR}/%s" % pkg, d) if os.access(data_file, os.R_OK): f = file(data_file, 'r') lines = f.readlines() f.close() for l in lines: return decode(l).strip() return pkg def runtime_mapping_rename (varname, d): import bb, os #bb.note("%s before: %s" % (varname, bb.data.getVar(varname, d, 1))) new_depends = [] for depend in explode_deps(bb.data.getVar(varname, d, 1) or ""): # Have to be careful with any version component of the depend split_depend = depend.split(' (') new_depend = get_package_mapping(split_depend[0].strip(), d) if len(split_depend) > 1: new_depends.append("%s (%s" % (new_depend, split_depend[1])) else: new_depends.append(new_depend) bb.data.setVar(varname, " ".join(new_depends) or None, d) #bb.note("%s after: %s" % (varname, bb.data.getVar(varname, d, 1))) # # Package functions suitable for inclusion in PACKAGEFUNCS # python package_do_split_locales() { import os if (bb.data.getVar('PACKAGE_NO_LOCALE', d, 1) == '1'): bb.debug(1, "package requested not splitting locales") return packages = (bb.data.getVar('PACKAGES', d, 1) or "").split() if not packages: bb.debug(1, "no packages to build; not splitting locales") return datadir = bb.data.getVar('datadir', d, 1) if not datadir: bb.note("datadir not defined") return dvar = bb.data.getVar('D', d, 1) if not dvar: bb.error("D not defined") return pn = bb.data.getVar('PN', d, 1) if not pn: bb.error("PN not defined") return 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) # 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', '') 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) rdep = (bb.data.getVar('RDEPENDS_%s' % mainpkg, d, 1) or bb.data.getVar('RDEPENDS', d, 1) or "").split() rdep.append('%s-locale*' % pn) bb.data.setVar('RDEPENDS_%s' % mainpkg, ' '.join(rdep), d) } python populate_packages () { import glob, stat, errno, re workdir = bb.data.getVar('WORKDIR', d, 1) if not workdir: bb.error("WORKDIR not defined, unable to package") return import os # path manipulations outdir = bb.data.getVar('DEPLOY_DIR', d, 1) if not outdir: bb.error("DEPLOY_DIR not defined, unable to package") return bb.mkdirhier(outdir) dvar = bb.data.getVar('D', d, 1) if not dvar: bb.error("D not defined, unable to package") return bb.mkdirhier(dvar) packages = bb.data.getVar('PACKAGES', d, 1) if not packages: bb.debug(1, "PACKAGES not defined, nothing to package") return pn = bb.data.getVar('PN', d, 1) if not pn: bb.error("PN not defined") return 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) # Sanity check PACKAGES for duplicates - should be moved to # sanity.bbclass once we have the infrastucture package_list = [] for pkg in packages.split(): if pkg in package_list: bb.error("-------------------") bb.error("%s is listed in PACKAGES mutliple times, this leads to packaging errors." % pkg) bb.error("Please fix the metadata/report this as bug to OE bugtracker.") bb.error("-------------------") else: package_list.append(pkg) if (bb.data.getVar('INHIBIT_PACKAGE_STRIP', d, 1) != '1'): stripfunc = "" for root, dirs, files in os.walk(dvar): for f in files: file = os.path.join(root, f) if not os.path.islink(file) and not os.path.isdir(file) and isexec(file): stripfunc += "\trunstrip %s || st=1\n" % (file) if not stripfunc == "": from bb import build localdata = bb.data.createCopy(d) # strip bb.data.setVar('RUNSTRIP', '\tlocal st\n\tst=0\n%s\treturn $st' % stripfunc, localdata) bb.data.setVarFlag('RUNSTRIP', 'func', 1, localdata) bb.build.exec_func('RUNSTRIP', localdata) for pkg in package_list: localdata = bb.data.createCopy(d) root = os.path.join(workdir, "install", pkg) os.system('rm -rf %s' % root) bb.data.setVar('ROOT', '', localdata) bb.data.setVar('ROOT_%s' % pkg, root, localdata) bb.data.setVar('PKG', pkg, localdata) overrides = bb.data.getVar('OVERRIDES', localdata, 1) if not overrides: raise bb.build.FuncFailed('OVERRIDES not defined') bb.data.setVar('OVERRIDES', overrides+':'+pkg, localdata) bb.data.update_data(localdata) root = bb.data.getVar('ROOT', localdata, 1) bb.mkdirhier(root) filesvar = bb.data.getVar('FILES', localdata, 1) or "" 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 fpath = os.path.join(root,file) dpath = os.path.dirname(fpath) bb.mkdirhier(dpath) ret = bb.movefile(file,fpath) if ret is None or ret == 0: 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) unshipped.append(path) 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) for pkg in package_list: pkgname = bb.data.getVar('PKG_%s' % pkg, d, 1) if pkgname is None: bb.data.setVar('PKG_%s' % pkg, pkg, d) else: add_package_mapping(pkg, pkgname, d) dangling_links = {} pkg_files = {} for pkg in package_list: dangling_links[pkg] = [] pkg_files[pkg] = [] inst_root = os.path.join(workdir, "install", pkg) 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)) for pkg in package_list: rdepends = explode_deps(bb.data.getVar('RDEPENDS_' + pkg, d, 1) or bb.data.getVar('RDEPENDS', d, 1) or "") for l in dangling_links[pkg]: found = False bb.debug(1, "%s contains dangling link %s" % (pkg, l)) for p in package_list: for f in pkg_files[p]: if f == l: found = True bb.debug(1, "target found in %s" % p) if p == pkg: break if not p in rdepends: rdepends.append(p) break if found == False: bb.note("%s contains dangling symlink to %s" % (pkg, l)) bb.data.setVar('RDEPENDS_' + pkg, " " + " ".join(rdepends), d) } populate_packages[dirs] = "${D}" python emit_pkgdata() { def write_if_exists(f, pkg, var): def encode(str): import codecs c = codecs.getencoder("string_escape") return c(str)[0] val = bb.data.getVar('%s_%s' % (var, pkg), d, 1) if val: f.write('%s_%s: %s\n' % (var, pkg, encode(val))) packages = bb.data.getVar('PACKAGES', d, 1) if not packages: return data_file = bb.data.expand("${STAGING_DIR}/pkgdata/${PN}", d) f = open(data_file, 'w') f.write("PACKAGES: %s\n" % packages) f.close() for pkg in packages.split(): subdata_file = bb.data.expand("${STAGING_DIR}/pkgdata/runtime/%s" % pkg, d) sf = open(subdata_file, 'w') 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, '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() } emit_pkgdata[dirs] = "${STAGING_DIR}/pkgdata/runtime" ldconfig_postinst_fragment() { if [ x"$D" = "x" ]; then ldconfig fi } python package_do_shlibs() { import os, re, os.path exclude_shlibs = bb.data.getVar('EXCLUDE_FROM_SHLIBS', d, 0) if exclude_shlibs: bb.note("not generating shlibs") return lib_re = re.compile("^lib.*\.so") libdir_re = re.compile(".*/lib$") packages = bb.data.getVar('PACKAGES', d, 1) if not packages: bb.debug(1, "no packages to build; not calculating shlibs") return workdir = bb.data.getVar('WORKDIR', d, 1) if not workdir: bb.error("WORKDIR not defined") return staging = bb.data.getVar('STAGING_DIR', d, 1) if not staging: bb.error("STAGING_DIR not defined") return ver = bb.data.getVar('PV', d, 1) if not ver: bb.error("PV not defined") return target_sys = bb.data.getVar('TARGET_SYS', d, 1) if not target_sys: bb.error("TARGET_SYS not defined") return shlibs_dir = os.path.join(staging, target_sys, "shlibs") old_shlibs_dir = os.path.join(staging, "shlibs") bb.mkdirhier(shlibs_dir) needed = {} for pkg in packages.split(): needs_ldconfig = False bb.debug(2, "calculating shlib provides for %s" % pkg) needed[pkg] = [] sonames = list() top = os.path.join(workdir, "install", pkg) for root, dirs, files in os.walk(top): for file in files: soname = None path = os.path.join(root, file) if os.access(path, os.X_OK) or lib_re.match(file): cmd = (bb.data.getVar('BUILD_PREFIX', d, 1) or "") + "objdump -p " + path + " 2>/dev/null" 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: sonames.append(m.group(1)) if m and libdir_re.match(root): needs_ldconfig = True shlibs_file = os.path.join(shlibs_dir, pkg + ".list") if os.path.exists(shlibs_file): os.remove(shlibs_file) shver_file = os.path.join(shlibs_dir, pkg + ".ver") 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() fd = open(shver_file, 'w') fd.write(ver + '\n') fd.close() if needs_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 = '#!/bin/sh\n' postinst += bb.data.getVar('ldconfig_postinst_fragment', d, 1) bb.data.setVar('pkg_postinst_%s' % pkg, postinst, d) shlib_provider = {} list_re = re.compile('^(.*)\.list$') for dir in [old_shlibs_dir, shlibs_dir]: 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) 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] if dep_pkg == pkg: 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) deps_file = os.path.join(workdir, "install", pkg + ".shlibdeps") 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 () { import re, os packages = bb.data.getVar('PACKAGES', d, 1) if not packages: bb.debug(1, "no packages to build; not calculating pkgconfig dependencies") return workdir = bb.data.getVar('WORKDIR', d, 1) if not workdir: bb.error("WORKDIR not defined") return staging = bb.data.getVar('STAGING_DIR', d, 1) if not staging: bb.error("STAGING_DIR not defined") return target_sys = bb.data.getVar('TARGET_SYS', d, 1) if not target_sys: bb.error("TARGET_SYS not defined") return shlibs_dir = os.path.join(staging, target_sys, "shlibs") old_shlibs_dir = os.path.join(staging, "shlibs") 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] = [] top = os.path.join(workdir, "install", pkg) 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() for pkg in packages.split(): pkgs_file = os.path.join(shlibs_dir, pkg + ".pclist") 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() for dir in [old_shlibs_dir, shlibs_dir]: 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) deps_file = os.path.join(workdir, "install", pkg + ".pcdeps") 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 read_shlibdeps () { packages = (bb.data.getVar('PACKAGES', d, 1) or "").split() for pkg in packages: rdepends = explode_deps(bb.data.getVar('RDEPENDS_' + pkg, d, 0) or bb.data.getVar('RDEPENDS', d, 0) or "") shlibsfile = bb.data.expand("${WORKDIR}/install/" + pkg + ".shlibdeps", d) if os.access(shlibsfile, os.R_OK): fd = file(shlibsfile) lines = fd.readlines() fd.close() for l in lines: rdepends.append(l.rstrip()) pcfile = bb.data.expand("${WORKDIR}/install/" + pkg + ".pcdeps", d) if os.access(pcfile, os.R_OK): fd = file(pcfile) lines = fd.readlines() fd.close() for l in lines: rdepends.append(l.rstrip()) bb.data.setVar('RDEPENDS_' + pkg, " " + " ".join(rdepends), d) } python package_depchains() { """ For a given set of prefix and postfix modifiers, make those packages RRECOMMENDS on the corresponding packages for its DEPENDS. 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. """ packages = bb.data.getVar('PACKAGES', d, 1) postfixes = (bb.data.getVar('DEPCHAIN_POST', d, 1) or '').split() prefixes = (bb.data.getVar('DEPCHAIN_PRE', d, 1) or '').split() def pkg_addrrecs(pkg, base, func, d): rdepends = explode_deps(bb.data.getVar('RDEPENDS_' + base, d, 1) or bb.data.getVar('RDEPENDS', d, 1) or "") # bb.note('rdepends for %s is %s' % (base, rdepends)) rreclist = explode_deps(bb.data.getVar('RRECOMMENDS_' + pkg, d, 1) or bb.data.getVar('RRECOMMENDS', d, 1) or "") for depend in rdepends: split_depend = depend.split(' (') name = split_depend[0].strip() func(rreclist, name) bb.data.setVar('RRECOMMENDS_%s' % pkg, ' '.join(rreclist), d) def packaged(pkg, d): return os.access(bb.data.expand('${STAGING_DIR}/pkgdata/runtime/%s.packaged' % pkg, d), os.R_OK) for pkg in packages.split(): for postfix in postfixes: def func(list, name): pkg = '%s%s' % (name, postfix) if not pkg in list: if packaged(pkg, d): list.append(pkg) base = pkg[:-len(postfix)] if pkg.endswith(postfix): pkg_addrrecs(pkg, base, func, d) continue for prefix in prefixes: def func(list, name): pkg = '%s%s' % (prefix, name) if not pkg in list: if packaged(pkg, d): list.append(pkg) base = pkg[len(prefix):] if pkg.startswith(prefix): pkg_addrrecs(pkg, base, func, d) } PACKAGEFUNCS ?= "package_do_split_locales \ populate_packages \ package_do_shlibs \ package_do_pkgconfig \ read_shlibdeps \ package_depchains \ emit_pkgdata" python package_do_package () { for f in (bb.data.getVar('PACKAGEFUNCS', d, 1) or '').split(): bb.build.exec_func(f, d) } # shlibs requires any DEPENDS to have already packaged for the *.list files do_package[deptask] = "do_package" do_package[dirs] = "${D}" addtask package before do_build after do_install PACKAGE_WRITE_FUNCS ?= "read_subpackage_metadata" python package_do_package_write () { for f in (bb.data.getVar('PACKAGE_WRITE_FUNCS', d, 1) or '').split(): bb.build.exec_func(f, d) } do_package_write[dirs] = "${D}" addtask package_write before do_build after do_package EXPORT_FUNCTIONS do_package do_package_write # # Helper functions for the package writing classes # python package_mapping_rename_hook () { """ Rewrite variables to account for package renaming in things like debian.bbclass or manual PKG variable name changes """ 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 ='#n656'>656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565