diff options
Diffstat (limited to 'classes')
-rw-r--r-- | classes/autotools.bbclass | 8 | ||||
-rw-r--r-- | classes/base.bbclass | 134 | ||||
-rw-r--r-- | classes/package.bbclass | 81 | ||||
-rw-r--r-- | classes/packagedata.bbclass | 73 |
4 files changed, 120 insertions, 176 deletions
diff --git a/classes/autotools.bbclass b/classes/autotools.bbclass index 8236a27c76..45b269f4fd 100644 --- a/classes/autotools.bbclass +++ b/classes/autotools.bbclass @@ -1,5 +1,3 @@ -inherit base - # use autotools_stage_all for native packages AUTOTOOLS_NATIVE_STAGE_INSTALL = "1" @@ -115,7 +113,7 @@ autotools_do_configure() { else CONFIGURE_AC=configure.ac fi - if grep "^AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then + if grep "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then if grep "sed.*POTFILES" $CONFIGURE_AC >/dev/null; then : do nothing -- we still have an old unmodified configure.ac else @@ -123,12 +121,12 @@ autotools_do_configure() { echo "no" | glib-gettextize --force --copy fi fi - if grep "^[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then + mkdir -p m4 + if grep "^[[:space:]]*[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then oenote Executing intltoolize --copy --force --automake intltoolize --copy --force --automake fi oenote Executing autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths - mkdir -p m4 autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || oefatal "autoreconf execution failed." cd $olddir fi diff --git a/classes/base.bbclass b/classes/base.bbclass index 89ee917d20..7f24482605 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -49,7 +49,7 @@ def base_path_out(path, d): # for MD5/SHA handling def base_chk_load_parser(config_paths): - import ConfigParser, os, bb + import ConfigParser parser = ConfigParser.ConfigParser() if len(parser.read(config_paths)) < 1: raise ValueError("no ini files could be found") @@ -57,7 +57,6 @@ def base_chk_load_parser(config_paths): return parser def base_chk_file(parser, pn, pv, src_uri, localpath, data): - import os, bb no_checksum = False # Try PN-PV-SRC_URI first and then try PN-SRC_URI # we rely on the get method to create errors @@ -128,7 +127,6 @@ def base_chk_file(parser, pn, pv, src_uri, localpath, data): def base_dep_prepend(d): - import bb # # Ideally this will check a flag so we will operate properly in # the case where host == build == target, for now we don't work in @@ -150,7 +148,6 @@ def base_dep_prepend(d): return deps def base_read_file(filename): - import bb try: f = file( filename, "r" ) except IOError, reason: @@ -166,21 +163,18 @@ def base_ifelse(condition, iftrue = True, iffalse = False): return iffalse def base_conditional(variable, checkvalue, truevalue, falsevalue, d): - import bb if bb.data.getVar(variable,d,1) == checkvalue: return truevalue else: return falsevalue def base_less_or_equal(variable, checkvalue, truevalue, falsevalue, d): - import bb if float(bb.data.getVar(variable,d,1)) <= float(checkvalue): return truevalue else: return falsevalue def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d): - import bb result = bb.vercmp(bb.data.getVar(variable,d,True), checkvalue) if result <= 0: return truevalue @@ -188,7 +182,6 @@ def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d): return falsevalue def base_contains(variable, checkvalues, truevalue, falsevalue, d): - import bb matches = 0 if type(checkvalues).__name__ == "str": checkvalues = [checkvalues] @@ -200,7 +193,6 @@ def base_contains(variable, checkvalues, truevalue, falsevalue, d): return falsevalue def base_both_contain(variable1, variable2, checkvalue, d): - import bb if bb.data.getVar(variable1,d,1).find(checkvalue) != -1 and bb.data.getVar(variable2,d,1).find(checkvalue) != -1: return checkvalue else: @@ -211,8 +203,6 @@ DEPENDS_prepend="${@base_dep_prepend(d)} " # Returns PN with various suffixes removed # or PN if no matching suffix was found. def base_package_name(d): - import bb; - pn = bb.data.getVar('PN', d, 1) if pn.endswith("-native"): pn = pn[0:-7] @@ -229,7 +219,6 @@ def base_package_name(d): return pn def base_set_filespath(path, d): - import os, bb bb.note("base_set_filespath usage is deprecated, %s should be fixed" % d.getVar("P", 1)) filespath = [] # The ":" ensures we have an 'empty' override @@ -448,7 +437,6 @@ oe_libinstall() { } def package_stagefile(file, d): - import bb, os if bb.data.getVar('PSTAGING_ACTIVE', d, True) == "1": destfile = file.replace(bb.data.getVar("TMPDIR", d, 1), bb.data.getVar("PSTAGE_TMPDIR_STAGE", d, 1)) @@ -529,21 +517,11 @@ python do_cleanall() { do_cleanall[recrdeptask] = "do_clean" addtask cleanall after do_clean -#Uncomment this for bitbake 1.8.12 -#addtask rebuild after do_${BB_DEFAULT_TASK} -addtask rebuild +addtask rebuild after do_${BB_DEFAULT_TASK} do_rebuild[dirs] = "${TOPDIR}" do_rebuild[nostamp] = "1" python base_do_rebuild() { """rebuild a package""" - from bb import __version__ - try: - from distutils.version import LooseVersion - except ImportError: - def LooseVersion(v): print "WARNING: sanity.bbclass can't compare versions without python-distutils"; return 1 - if (LooseVersion(__version__) < LooseVersion('1.8.11')): - bb.build.exec_func('do_clean', d) - bb.build.exec_task('do_' + bb.data.getVar('BB_DEFAULT_TASK', d, 1), d) } addtask mrproper @@ -563,7 +541,6 @@ do_distclean[dirs] = "${TOPDIR}" do_distclean[nostamp] = "1" python base_do_distclean() { """clear downloaded sources, build and temp directories""" - import os bb.build.exec_func('do_clean', d) @@ -741,7 +718,7 @@ def subprocess_setup(): signal.signal(signal.SIGPIPE, signal.SIG_DFL) def oe_unpack_file(file, data, url = None): - import bb, os, subprocess + import subprocess if not url: url = "file://%s" % file dots = file.split(".") @@ -819,7 +796,7 @@ def oe_unpack_file(file, data, url = None): addtask unpack after do_fetch do_unpack[dirs] = "${WORKDIR}" python base_do_unpack() { - import re, os + import re localdata = bb.data.createCopy(d) bb.data.update_data(localdata) @@ -846,7 +823,6 @@ METADATA_REVISION = "${@base_get_scm_revision(d)}" METADATA_BRANCH = "${@base_get_scm_branch(d)}" def base_get_scm(d): - import os from bb import which baserepo = os.path.dirname(os.path.dirname(which(d.getVar("BBPATH", 1), "classes/base.bbclass"))) for (scm, scmpath) in {"svn": ".svn", @@ -907,7 +883,6 @@ def base_get_metadata_svn_revision(path, d): return revision def base_get_metadata_git_branch(path, d): - import os branch = os.popen('cd %s; PATH=%s git symbolic-ref HEAD 2>/dev/null' % (path, d.getVar("PATH", 1))).read().rstrip() if len(branch) != 0: @@ -915,7 +890,6 @@ def base_get_metadata_git_branch(path, d): return "<unknown>" def base_get_metadata_git_revision(path, d): - import os rev = os.popen("cd %s; PATH=%s git show-ref HEAD 2>/dev/null" % (path, d.getVar("PATH", 1))).read().split(" ")[0].rstrip() if len(rev) != 0: return rev @@ -926,7 +900,7 @@ addhandler base_eventhandler python base_eventhandler() { from bb import note, error, data from bb.event import Handled, NotHandled, getName - import os + name = getName(e) if name == "TaskCompleted": @@ -1034,6 +1008,8 @@ addtask build after do_populate_staging do_build = "" do_build[func] = "1" +INHERIT =+ "packagedata" + # Functions that update metadata based on files outputted # during the build process. @@ -1054,88 +1030,6 @@ def explode_deps(s): r.append(i) return r -def packaged(pkg, d): - import os, bb - return os.access(get_subpkgedata_fn(pkg, d) + '.packaged', os.R_OK) - -def read_pkgdatafile(fn): - pkgdata = {} - - def decode(str): - import codecs - c = codecs.getdecoder("string_escape") - return c(str)[0] - - import os - if os.access(fn, os.R_OK): - import re - f = file(fn, 'r') - lines = f.readlines() - f.close() - r = re.compile("([^:]+):\s*(.*)") - for l in lines: - m = r.match(l) - if m: - pkgdata[m.group(1)] = decode(m.group(2)) - - return pkgdata - -def get_subpkgedata_fn(pkg, d): - import bb, os - archs = bb.data.expand("${PACKAGE_ARCHS}", d).split(" ") - archs.reverse() - pkgdata = bb.data.expand('${TMPDIR}/pkgdata/', d) - targetdir = bb.data.expand('${TARGET_VENDOR}-${TARGET_OS}/runtime/', d) - for arch in archs: - fn = pkgdata + arch + targetdir + pkg - if os.path.exists(fn): - return fn - return bb.data.expand('${PKGDATA_DIR}/runtime/%s' % pkg, d) - -def has_subpkgdata(pkg, d): - import bb, os - return os.access(get_subpkgedata_fn(pkg, d), os.R_OK) - -def read_subpkgdata(pkg, d): - import bb - return read_pkgdatafile(get_subpkgedata_fn(pkg, d)) - -def has_pkgdata(pn, d): - import bb, os - fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d) - return os.access(fn, os.R_OK) - -def read_pkgdata(pn, d): - import bb - fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d) - return read_pkgdatafile(fn) - -python read_subpackage_metadata () { - import bb - data = read_pkgdata(bb.data.getVar('PN', d, 1), d) - - for key in data.keys(): - bb.data.setVar(key, data[key], d) - - for pkg in bb.data.getVar('PACKAGES', d, 1).split(): - sdata = read_subpkgdata(pkg, d) - for key in sdata.keys(): - bb.data.setVar(key, sdata[key], d) -} - - -# -# Collapse FOO_pkg variables into FOO -# -def read_subpkgdata_dict(pkg, d): - import bb - ret = {} - subd = read_pkgdatafile(get_subpkgedata_fn(pkg, d)) - for var in subd: - newvar = var.replace("_" + pkg, "") - ret[newvar] = subd[var] - return ret - # Make sure MACHINE isn't exported # (breaks binutils at least) MACHINE[unexport] = "1" @@ -1151,7 +1045,7 @@ DISTRO[unexport] = "1" def base_after_parse(d): - import bb, os, exceptions + import exceptions source_mirror_fetch = bb.data.getVar('SOURCE_MIRROR_FETCH', d, 0) if not source_mirror_fetch: @@ -1234,19 +1128,7 @@ def base_after_parse(d): bb.data.setVar('MULTIMACH_ARCH', multiarch, d) python () { - import bb - from bb import __version__ base_after_parse(d) - - # Remove this for bitbake 1.8.12 - try: - from distutils.version import LooseVersion - except ImportError: - def LooseVersion(v): print "WARNING: sanity.bbclass can't compare versions without python-distutils"; return 1 - if (LooseVersion(__version__) >= LooseVersion('1.8.11')): - deps = bb.data.getVarFlag('do_rebuild', 'deps', d) or [] - deps.append('do_' + bb.data.getVar('BB_DEFAULT_TASK', d, 1)) - bb.data.setVarFlag('do_rebuild', 'deps', deps, d) } def check_app_exists(app, d): diff --git a/classes/package.bbclass b/classes/package.bbclass index e7865754eb..1c14908f1a 100644 --- a/classes/package.bbclass +++ b/classes/package.bbclass @@ -2,7 +2,8 @@ # General packaging help functions # -PKGDEST = "${WORKDIR}/install" +PKGD = "${WORKDIR}/package" +PKGDEST = "${WORKDIR}/packages-split" def legitimize_package_name(s): """ @@ -28,10 +29,7 @@ def do_split_packages(d, root, file_regex, output_pattern, description, postinst """ import os, os.path, bb - dvar = bb.data.getVar('D', d, True) - if not dvar: - bb.error("D not defined") - return + dvar = bb.data.getVar('PKGD', d, True) packages = bb.data.getVar('PACKAGES', d, True).split() @@ -302,15 +300,8 @@ python package_do_split_locales() { bb.note("datadir not defined") return - dvar = bb.data.getVar('D', d, True) - if not dvar: - bb.error("D not defined") - return - + dvar = bb.data.getVar('PKGD', d, True) pn = bb.data.getVar('PN', d, True) - if not pn: - bb.error("PN not defined") - return if pn + '-locale' in packages: packages.remove(pn + '-locale') @@ -343,34 +334,29 @@ python package_do_split_locales() { bb.data.setVar('PACKAGES', ' '.join(packages), d) } -python populate_packages () { - import glob, stat, errno, re +python perform_packagecopy () { + import os - workdir = bb.data.getVar('WORKDIR', d, True) - if not workdir: - bb.error("WORKDIR not defined, unable to package") - return + dest = bb.data.getVar('D', d, True) + dvar = bb.data.getVar('PKGD', d, True) - import os # path manipulations - outdir = bb.data.getVar('DEPLOY_DIR', d, True) - if not outdir: - bb.error("DEPLOY_DIR not defined, unable to package") - return - bb.mkdirhier(outdir) - - dvar = bb.data.getVar('D', d, True) - if not dvar: - bb.error("D not defined, unable to package") - return bb.mkdirhier(dvar) - packages = bb.data.getVar('PACKAGES', d, True) + # Start by package population by taking a copy of the installed + # files to operate on + os.system('cp -pPR %s/* %s/' % (dest, dvar)) +} + +python populate_packages () { + import os, glob, stat, errno, re + workdir = bb.data.getVar('WORKDIR', d, True) + outdir = bb.data.getVar('DEPLOY_DIR', d, True) + dvar = bb.data.getVar('PKGD', d, True) + packages = bb.data.getVar('PACKAGES', d, True) pn = bb.data.getVar('PN', d, True) - if not pn: - bb.error("PN not defined") - return + bb.mkdirhier(outdir) os.chdir(dvar) def isexec(path): @@ -542,6 +528,7 @@ python emit_pkgdata() { return packages = bb.data.getVar('PACKAGES', d, True) + pkgdest = bb.data.getVar('PKGDEST', d, 1) pkgdatadir = bb.data.getVar('PKGDATA_DIR', d, True) pstageactive = bb.data.getVar('PSTAGING_ACTIVE', d, True) @@ -585,7 +572,7 @@ python emit_pkgdata() { allow_empty = bb.data.getVar('ALLOW_EMPTY_%s' % pkg, d, True) if not allow_empty: allow_empty = bb.data.getVar('ALLOW_EMPTY', d, True) - root = "%s/install/%s" % (workdir, pkg) + root = "%s/%s" % (pkgdest, pkg) os.chdir(root) g = glob('*') + glob('.[!.]*') if g or allow_empty == "1": @@ -621,9 +608,6 @@ python package_do_shlibs() { packages = bb.data.getVar('PACKAGES', d, True) workdir = bb.data.getVar('WORKDIR', d, True) - if not workdir: - bb.error("WORKDIR not defined") - return ver = bb.data.getVar('PV', d, True) if not ver: @@ -787,12 +771,7 @@ python package_do_pkgconfig () { import re, os packages = bb.data.getVar('PACKAGES', d, True) - workdir = bb.data.getVar('WORKDIR', d, True) - if not workdir: - bb.error("WORKDIR not defined") - return - pkgdest = bb.data.getVar('PKGDEST', d, True) shlibs_dir = bb.data.getVar('SHLIBSDIR', d, True) @@ -1012,8 +991,10 @@ python package_depchains() { pkg_addrrecs(pkg, base, suffix, func, rdeps, d) } - -PACKAGEFUNCS ?= "package_do_split_locales \ +PACKAGE_PREPROCESS_FUNCS ?= "" +PACKAGEFUNCS ?= "perform_packagecopy \ + ${PACKAGE_PREPROCESS_FUNCS} \ + package_do_split_locales \ populate_packages \ package_do_shlibs \ package_do_pkgconfig \ @@ -1059,6 +1040,16 @@ python package_do_package () { bb.debug(1, "No packages to build, skipping do_package") return + workdir = bb.data.getVar('WORKDIR', d, True) + outdir = bb.data.getVar('DEPLOY_DIR', d, True) + dest = bb.data.getVar('D', d, True) + dvar = bb.data.getVar('PKGD', d, True) + pn = bb.data.getVar('PN', d, True) + + 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") + return + for f in (bb.data.getVar('PACKAGEFUNCS', d, True) or '').split(): bb.build.exec_func(f, d) package_run_hooks(f, d) diff --git a/classes/packagedata.bbclass b/classes/packagedata.bbclass new file mode 100644 index 0000000000..86f18a9e96 --- /dev/null +++ b/classes/packagedata.bbclass @@ -0,0 +1,73 @@ +def packaged(pkg, d): + return os.access(get_subpkgedata_fn(pkg, d) + '.packaged', os.R_OK) + +def read_pkgdatafile(fn): + pkgdata = {} + + def decode(str): + import codecs + c = codecs.getdecoder("string_escape") + return c(str)[0] + + if os.access(fn, os.R_OK): + import re + f = file(fn, 'r') + lines = f.readlines() + f.close() + r = re.compile("([^:]+):\s*(.*)") + for l in lines: + m = r.match(l) + if m: + pkgdata[m.group(1)] = decode(m.group(2)) + + return pkgdata + +def get_subpkgedata_fn(pkg, d): + archs = bb.data.expand("${PACKAGE_ARCHS}", d).split(" ") + archs.reverse() + pkgdata = bb.data.expand('${TMPDIR}/pkgdata/', d) + targetdir = bb.data.expand('${TARGET_VENDOR}-${TARGET_OS}/runtime/', d) + for arch in archs: + fn = pkgdata + arch + targetdir + pkg + if os.path.exists(fn): + return fn + return bb.data.expand('${PKGDATA_DIR}/runtime/%s' % pkg, d) + +def has_subpkgdata(pkg, d): + return os.access(get_subpkgedata_fn(pkg, d), os.R_OK) + +def read_subpkgdata(pkg, d): + return read_pkgdatafile(get_subpkgedata_fn(pkg, d)) + +def has_pkgdata(pn, d): + fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d) + return os.access(fn, os.R_OK) + +def read_pkgdata(pn, d): + fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d) + return read_pkgdatafile(fn) + +python read_subpackage_metadata () { + data = read_pkgdata(bb.data.getVar('PN', d, 1), d) + + for key in data.keys(): + bb.data.setVar(key, data[key], d) + + for pkg in bb.data.getVar('PACKAGES', d, 1).split(): + sdata = read_subpkgdata(pkg, d) + for key in sdata.keys(): + bb.data.setVar(key, sdata[key], d) +} + + +# +# Collapse FOO_pkg variables into FOO +# +def read_subpkgdata_dict(pkg, d): + ret = {} + subd = read_pkgdatafile(get_subpkgedata_fn(pkg, d)) + for var in subd: + newvar = var.replace("_" + pkg, "") + ret[newvar] = subd[var] + return ret + |