# # old_revision [4c108250ef95743112aee6c23a4f206124025bbb] # # patch "classes/package.bbclass" # from [a4793b3e861b8e79ae72fd8fb897b01aff983b38] # to [6d38d123e9ab2e3f1235b253086a38e70abf8518] # ============================================================ --- classes/package.bbclass a4793b3e861b8e79ae72fd8fb897b01aff983b38 +++ classes/package.bbclass 6d38d123e9ab2e3f1235b253086a38e70abf8518 @@ -120,76 +120,68 @@ python () { python () { import bb - 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(): deps += " %s:do_populate_staging" % dep bb.data.setVarFlag('do_package', 'depends', deps, d) - deps = bb.data.getVarFlag('do_package_write', 'depends', d) or "" - for dep in (bb.data.getVar('PACKAGE_EXTRA_DEPENDS', d, True) or "").split(): - deps += " %s:do_populate_staging" % dep - bb.data.setVarFlag('do_package_write', 'depends', deps, d) - # shlibs requires any DEPENDS to have already packaged for the *.list files bb.data.setVarFlag('do_package', 'deptask', 'do_package', d) } -# 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 do_package[depends] +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] - local ro st + import bb, os, commands, stat - 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 -} + pathprefix = "export PATH=%s; " % bb.data.getVar('PATH', d, 1) + 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 + + strip = bb.data.getVar("STRIP", d, 1) + objcopy = bb.data.getVar("OBJCOPY", d, 1) + + newmode = None + if not os.access(file, os.W_OK): + origmode = os.stat(file)[stat.ST_MODE] + newmode = origmode | stat.S_IWRITE + os.chmod(file, newmode) + + 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" + + bb.mkdirhier(os.path.join(os.path.dirname(file), ".debug")) + debugfile=os.path.join(os.path.dirname(file), ".debug", os.path.basename(file)) + + stripcmd = "'%s' %s '%s'" % (strip, extraflags, file) + bb.debug(1, "runstrip: %s" % stripcmd) + + os.system("%s'%s' --only-keep-debug '%s' '%s'" % (pathprefix, objcopy, file, debugfile)) + ret = os.system("%s%s" % (pathprefix, stripcmd)) + os.system("%s'%s' --add-gnu-debuglink='%s' '%s'" % (pathprefix, objcopy, debugfile, file)) + + if newmode: + os.chmod(file, origmode) + + if ret: + bb.error("runstrip: '%s' strip command failed" % stripcmd) + + return 1 + # # Package data handling routines # @@ -376,19 +368,11 @@ python populate_packages () { 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) + runstrip(file, d) for pkg in package_list: localdata = bb.data.createCopy(d) @@ -513,13 +497,13 @@ python emit_pkgdata() { if not packages: return - data_file = bb.data.expand("${STAGING_DIR}/pkgdata/${PN}", d) + data_file = bb.data.expand("${PKGDATA_DIR}/${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) + subdata_file = bb.data.expand("${PKGDATA_DIR}/runtime/%s" % pkg, d) sf = open(subdata_file, 'w') write_if_exists(sf, pkg, 'DESCRIPTION') write_if_exists(sf, pkg, 'RDEPENDS') @@ -538,7 +522,7 @@ python emit_pkgdata() { write_if_exists(sf, pkg, 'pkg_prerm') sf.close() } -emit_pkgdata[dirs] = "${STAGING_DIR}/pkgdata/runtime" +emit_pkgdata[dirs] = "${PKGDATA_DIR}/runtime" ldconfig_postinst_fragment() { if [ x"$D" = "x" ]; then @@ -840,7 +824,7 @@ python package_depchains() { def pkg_addrrecs(pkg, base, suffix, getname, rdepends, d): def packaged(pkg, d): - return os.access(bb.data.expand('${STAGING_DIR}/pkgdata/runtime/%s.packaged' % pkg, d), os.R_OK) + return os.access(bb.data.expand('${PKGDATA_DIR}/runtime/%s.packaged' % pkg, d), os.R_OK) #bb.note('rdepends for %s is %s' % (base, rdepends)) @@ -916,21 +900,14 @@ addtask package before do_build after do 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) +# Dummy task to mark when all packaging is complete +do_package_write () { + : } -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 #