generic-poky/meta/classes/archiver.bbclass

471 lines
19 KiB
Plaintext
Raw Normal View History

# ex:ts=4:sw=4:sts=4:et
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
#
# This bbclass is used for creating archive for:
# 1) original (or unpacked) source: ARCHIVER_MODE[src] = "original"
# 2) patched source: ARCHIVER_MODE[src] = "patched" (default)
# 3) configured source: ARCHIVER_MODE[src] = "configured"
# 4) The patches between do_unpack and do_patch:
# ARCHIVER_MODE[diff] = "1"
# And you can set the one that you'd like to exclude from the diff:
# ARCHIVER_MODE[diff-exclude] ?= ".pc autom4te.cache patches"
# 5) The environment data, similar to 'bitbake -e recipe':
# ARCHIVER_MODE[dumpdata] = "1"
# 6) The recipe (.bb and .inc): ARCHIVER_MODE[recipe] = "1"
# 7) Whether output the .src.rpm package:
# ARCHIVER_MODE[srpm] = "1"
# 8) Filter the license, the recipe whose license in
# COPYLEFT_LICENSE_INCLUDE will be included, and in
# COPYLEFT_LICENSE_EXCLUDE will be excluded.
# COPYLEFT_LICENSE_INCLUDE = 'GPL* LGPL*'
# COPYLEFT_LICENSE_EXCLUDE = 'CLOSED Proprietary'
# 9) The recipe type that will be archived:
# COPYLEFT_RECIPE_TYPES = 'target'
#
# Don't filter the license by default
COPYLEFT_LICENSE_INCLUDE ?= ''
COPYLEFT_LICENSE_EXCLUDE ?= ''
# Create archive for all the recipe types
COPYLEFT_RECIPE_TYPES ?= 'target native nativesdk cross crosssdk cross-canadian'
inherit copyleft_filter
ARCHIVER_MODE[srpm] ?= "0"
ARCHIVER_MODE[src] ?= "patched"
ARCHIVER_MODE[diff] ?= "0"
ARCHIVER_MODE[diff-exclude] ?= ".pc autom4te.cache patches"
ARCHIVER_MODE[dumpdata] ?= "0"
ARCHIVER_MODE[recipe] ?= "0"
DEPLOY_DIR_SRC ?= "${DEPLOY_DIR}/sources"
ARCHIVER_TOPDIR ?= "${WORKDIR}/deploy-sources"
ARCHIVER_OUTDIR = "${ARCHIVER_TOPDIR}/${TARGET_SYS}/${PF}/"
ARCHIVER_WORKDIR = "${WORKDIR}/archiver-work/"
do_dumpdata[dirs] = "${ARCHIVER_OUTDIR}"
do_ar_recipe[dirs] = "${ARCHIVER_OUTDIR}"
do_ar_original[dirs] = "${ARCHIVER_OUTDIR} ${ARCHIVER_WORKDIR}"
do_deploy_archives[dirs] = "${WORKDIR}"
do_deploy_all_archives[dirs] = "${WORKDIR}"
# This is a convenience for the shell script to use it
python () {
pn = d.getVar('PN')
assume_provided = (d.getVar("ASSUME_PROVIDED") or "").split()
if pn in assume_provided:
for p in d.getVar("PROVIDES").split():
if p != pn:
pn = p
break
included, reason = copyleft_should_include(d)
if not included:
bb.debug(1, 'archiver: %s is excluded: %s' % (pn, reason))
return
else:
bb.debug(1, 'archiver: %s is included: %s' % (pn, reason))
# glibc-locale: do_fetch, do_unpack and do_patch tasks have been deleted,
# so avoid archiving source here.
if pn.startswith('glibc-locale'):
return
# We just archive gcc-source for all the gcc related recipes
if d.getVar('BPN') in ['gcc', 'libgcc'] \
and not pn.startswith('gcc-source'):
bb.debug(1, 'archiver: %s is excluded, covered by gcc-source' % pn)
return
ar_src = d.getVarFlag('ARCHIVER_MODE', 'src')
ar_dumpdata = d.getVarFlag('ARCHIVER_MODE', 'dumpdata')
ar_recipe = d.getVarFlag('ARCHIVER_MODE', 'recipe')
if ar_src == "original":
d.appendVarFlag('do_deploy_archives', 'depends', ' %s:do_ar_original' % pn)
# 'patched' and 'configured' invoke do_unpack_and_patch because
# do_ar_patched resp. do_ar_configured depend on it, but for 'original'
# we have to add it explicitly.
if d.getVarFlag('ARCHIVER_MODE', 'diff') == '1':
d.appendVarFlag('do_deploy_archives', 'depends', ' %s:do_unpack_and_patch' % pn)
elif ar_src == "patched":
d.appendVarFlag('do_deploy_archives', 'depends', ' %s:do_ar_patched' % pn)
elif ar_src == "configured":
# We can't use "addtask do_ar_configured after do_configure" since it
# will cause the deptask of do_populate_sysroot to run not matter what
# archives we need, so we add the depends here.
# There is a corner case with "gcc-source-${PV}" recipes, they don't have
# the "do_configure" task, so we need to use "do_preconfigure"
if pn.startswith("gcc-source-"):
d.appendVarFlag('do_ar_configured', 'depends', ' %s:do_preconfigure' % pn)
else:
d.appendVarFlag('do_ar_configured', 'depends', ' %s:do_configure' % pn)
d.appendVarFlag('do_deploy_archives', 'depends', ' %s:do_ar_configured' % pn)
elif ar_src:
bb.fatal("Invalid ARCHIVER_MODE[src]: %s" % ar_src)
if ar_dumpdata == "1":
d.appendVarFlag('do_deploy_archives', 'depends', ' %s:do_dumpdata' % pn)
if ar_recipe == "1":
d.appendVarFlag('do_deploy_archives', 'depends', ' %s:do_ar_recipe' % pn)
# Output the srpm package
ar_srpm = d.getVarFlag('ARCHIVER_MODE', 'srpm')
if ar_srpm == "1":
if d.getVar('PACKAGES') != '' and d.getVar('IMAGE_PKGTYPE') == 'rpm':
d.appendVarFlag('do_deploy_archives', 'depends', ' %s:do_package_write_rpm' % pn)
if ar_dumpdata == "1":
d.appendVarFlag('do_package_write_rpm', 'depends', ' %s:do_dumpdata' % pn)
if ar_recipe == "1":
d.appendVarFlag('do_package_write_rpm', 'depends', ' %s:do_ar_recipe' % pn)
if ar_src == "original":
d.appendVarFlag('do_package_write_rpm', 'depends', ' %s:do_ar_original' % pn)
elif ar_src == "patched":
d.appendVarFlag('do_package_write_rpm', 'depends', ' %s:do_ar_patched' % pn)
elif ar_src == "configured":
d.appendVarFlag('do_package_write_rpm', 'depends', ' %s:do_ar_configured' % pn)
}
# Take all the sources for a recipe and puts them in WORKDIR/archiver-work/.
# Files in SRC_URI are copied directly, anything that's a directory
# (e.g. git repositories) is "unpacked" and then put into a tarball.
python do_ar_original() {
import shutil, tempfile
if d.getVarFlag('ARCHIVER_MODE', 'src') != "original":
return
ar_outdir = d.getVar('ARCHIVER_OUTDIR')
bb.note('Archiving the original source...')
urls = d.getVar("SRC_URI").split()
# destsuffix (git fetcher) and subdir (everything else) are allowed to be
# absolute paths (for example, destsuffix=${S}/foobar).
# That messes with unpacking inside our tmpdir below, because the fetchers
# will then unpack in that directory and completely ignore the tmpdir.
# That breaks parallel tasks relying on ${S}, like do_compile.
#
# To solve this, we remove these parameters from all URLs.
# We do this even for relative paths because it makes the content of the
# archives more useful (no extra paths that are only used during
# compilation).
for i, url in enumerate(urls):
decoded = bb.fetch2.decodeurl(url)
for param in ('destsuffix', 'subdir'):
if param in decoded[5]:
del decoded[5][param]
encoded = bb.fetch2.encodeurl(decoded)
urls[i] = encoded
fetch = bb.fetch2.Fetch(urls, d)
archive.bbclass: fix do_ar_original archiving of multiple source repos When a recipe uses more than one source which isn't a plain file (for example, multiple git repos), then do_ar_original created the source archives using the same filename and thus only archived one source. The "name" parameter is used as file suffix to create unique names for each source, leading to archives following this pattern: deploy/${TARGET_SYS}/${PF}/${PF}[-<name>].tar.gz. The ${PF} part is a bit redundant, which may or may not be desirable. The patch is more localized this way (no need to modify create_tarball()). For example, meta-oic's iotivity_1.1.1.bb uses: url_iotivity = "git://github.com/iotivity/iotivity.git" branch_iotivity = "1.1-rel" SRC_URI = "${url_iotivity};destsuffix=${S};branch=${branch_iotivity};protocol=http;" url_tinycbor = "git://github.com/01org/tinycbor.git" SRC_URI += "${url_tinycbor};name=tinycbor;destsuffix=${S}/extlibs/tinycbor/tinycbor;protocol=http" url_hippomocks = "git://github.com/dascandy/hippomocks.git" SRC_URI += "${url_hippomocks};name=hippomocks;destsuffix=${S}/extlibs/hippomocks-master;protocol=http" SRC_URI += "file://hippomocks_mips_patch" url_gtest = "http://pkgs.fedoraproject.org/repo/pkgs/gtest/gtest-1.7.0.zip/2d6ec8ccdf5c46b05ba54a9fd1d130d7/gtest-1.7.0.zip" SRC_URI += "${url_gtest};name=gtest;subdir=${BP}/extlibs/gtest" url_sqlite = "http://www.sqlite.org/2015/sqlite-amalgamation-3081101.zip" SRC_URI += "${url_sqlite};name=sqlite3;subdir=${BP}/extlibs/sqlite3;unpack=false" These now get archived in deploy/sources/*/iotivity-1.1.1-r2/ as: gtest-1.7.0.zip iotivity-1.1.1-r2-recipe.tar.gz sqlite-amalgamation-3081101.zip hippomocks_mips_patch iotivity-1.1.1-r2.tar.gz iotivity-1.1.1-r2-hippomocks.tar.gz iotivity-1.1.1-r2-tinycbor.tar.gz (From OE-Core rev: 5c63ffc706c0fff8cfb797a238f4f0e73ee2813d) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-09-26 09:55:16 +00:00
tarball_suffix = {}
for url in fetch.urls:
local = fetch.localpath(url).rstrip("/");
if os.path.isfile(local):
shutil.copy(local, ar_outdir)
elif os.path.isdir(local):
tmpdir = tempfile.mkdtemp(dir=d.getVar('ARCHIVER_WORKDIR'))
fetch.unpack(tmpdir, (url,))
archive.bbclass: fix do_ar_original archiving of multiple source repos When a recipe uses more than one source which isn't a plain file (for example, multiple git repos), then do_ar_original created the source archives using the same filename and thus only archived one source. The "name" parameter is used as file suffix to create unique names for each source, leading to archives following this pattern: deploy/${TARGET_SYS}/${PF}/${PF}[-<name>].tar.gz. The ${PF} part is a bit redundant, which may or may not be desirable. The patch is more localized this way (no need to modify create_tarball()). For example, meta-oic's iotivity_1.1.1.bb uses: url_iotivity = "git://github.com/iotivity/iotivity.git" branch_iotivity = "1.1-rel" SRC_URI = "${url_iotivity};destsuffix=${S};branch=${branch_iotivity};protocol=http;" url_tinycbor = "git://github.com/01org/tinycbor.git" SRC_URI += "${url_tinycbor};name=tinycbor;destsuffix=${S}/extlibs/tinycbor/tinycbor;protocol=http" url_hippomocks = "git://github.com/dascandy/hippomocks.git" SRC_URI += "${url_hippomocks};name=hippomocks;destsuffix=${S}/extlibs/hippomocks-master;protocol=http" SRC_URI += "file://hippomocks_mips_patch" url_gtest = "http://pkgs.fedoraproject.org/repo/pkgs/gtest/gtest-1.7.0.zip/2d6ec8ccdf5c46b05ba54a9fd1d130d7/gtest-1.7.0.zip" SRC_URI += "${url_gtest};name=gtest;subdir=${BP}/extlibs/gtest" url_sqlite = "http://www.sqlite.org/2015/sqlite-amalgamation-3081101.zip" SRC_URI += "${url_sqlite};name=sqlite3;subdir=${BP}/extlibs/sqlite3;unpack=false" These now get archived in deploy/sources/*/iotivity-1.1.1-r2/ as: gtest-1.7.0.zip iotivity-1.1.1-r2-recipe.tar.gz sqlite-amalgamation-3081101.zip hippomocks_mips_patch iotivity-1.1.1-r2.tar.gz iotivity-1.1.1-r2-hippomocks.tar.gz iotivity-1.1.1-r2-tinycbor.tar.gz (From OE-Core rev: 5c63ffc706c0fff8cfb797a238f4f0e73ee2813d) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-09-26 09:55:16 +00:00
# To handle recipes with more than one source, we add the "name"
# URL parameter as suffix. We treat it as an error when
# there's more than one URL without a name, or a name gets reused.
# This is an additional safety net, in practice the name has
# to be set when using the git fetcher, otherwise SRCREV cannot
# be set separately for each URL.
params = bb.fetch2.decodeurl(url)[5]
archiver.bbclass: fix do_ar_original error for matchbox-desktop Error: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ERROR: matchbox-desktop-2.1-r0 do_ar_original: Can not determine archive names for original source because 'name' URL parameter is unset in more than one URL. Add it to at least one of these: git://git.yoctoproject.org/matchbox-desktop-2 file://vfolders/%2A ERROR: matchbox-desktop-2.1-r0 do_ar_original: Function failed: do_ar_original ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In function do_ar_original, when recipes have more than one source, it added the "name" URL parameter as suffix to identify the created tarball. But the URL type "file://" that we always used to represent a series of patches, it didn't have "name" parameter, so it failed. So set "name" to the folder name to identify the created tarball, for example: In matchbox-desktop bb file, the SRC_URI contains: file://vfloders/* We set "name" to "vfolders" to identify the created tarball. In connman-gnome bb file, the SRC_URI contains: file://images/* We set "name" to "images" to identify the created tarball. (From OE-Core rev: 0af636c635391b30c987dedeffe597ef4f8a1ed8) (From OE-Core rev: 9dd945d083ee742dcb75d24d4be40468121008a6) (From OE-Core rev: 113de7ab1e61997147b4b292b7de162d44296d59) Signed-off-by: Dengke Du <dengke.du@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-11-28 12:37:35 +00:00
type = bb.fetch2.decodeurl(url)[0]
location = bb.fetch2.decodeurl(url)[2]
archive.bbclass: fix do_ar_original archiving of multiple source repos When a recipe uses more than one source which isn't a plain file (for example, multiple git repos), then do_ar_original created the source archives using the same filename and thus only archived one source. The "name" parameter is used as file suffix to create unique names for each source, leading to archives following this pattern: deploy/${TARGET_SYS}/${PF}/${PF}[-<name>].tar.gz. The ${PF} part is a bit redundant, which may or may not be desirable. The patch is more localized this way (no need to modify create_tarball()). For example, meta-oic's iotivity_1.1.1.bb uses: url_iotivity = "git://github.com/iotivity/iotivity.git" branch_iotivity = "1.1-rel" SRC_URI = "${url_iotivity};destsuffix=${S};branch=${branch_iotivity};protocol=http;" url_tinycbor = "git://github.com/01org/tinycbor.git" SRC_URI += "${url_tinycbor};name=tinycbor;destsuffix=${S}/extlibs/tinycbor/tinycbor;protocol=http" url_hippomocks = "git://github.com/dascandy/hippomocks.git" SRC_URI += "${url_hippomocks};name=hippomocks;destsuffix=${S}/extlibs/hippomocks-master;protocol=http" SRC_URI += "file://hippomocks_mips_patch" url_gtest = "http://pkgs.fedoraproject.org/repo/pkgs/gtest/gtest-1.7.0.zip/2d6ec8ccdf5c46b05ba54a9fd1d130d7/gtest-1.7.0.zip" SRC_URI += "${url_gtest};name=gtest;subdir=${BP}/extlibs/gtest" url_sqlite = "http://www.sqlite.org/2015/sqlite-amalgamation-3081101.zip" SRC_URI += "${url_sqlite};name=sqlite3;subdir=${BP}/extlibs/sqlite3;unpack=false" These now get archived in deploy/sources/*/iotivity-1.1.1-r2/ as: gtest-1.7.0.zip iotivity-1.1.1-r2-recipe.tar.gz sqlite-amalgamation-3081101.zip hippomocks_mips_patch iotivity-1.1.1-r2.tar.gz iotivity-1.1.1-r2-hippomocks.tar.gz iotivity-1.1.1-r2-tinycbor.tar.gz (From OE-Core rev: 5c63ffc706c0fff8cfb797a238f4f0e73ee2813d) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-09-26 09:55:16 +00:00
name = params.get('name', '')
archiver.bbclass: fix do_ar_original error for matchbox-desktop Error: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ERROR: matchbox-desktop-2.1-r0 do_ar_original: Can not determine archive names for original source because 'name' URL parameter is unset in more than one URL. Add it to at least one of these: git://git.yoctoproject.org/matchbox-desktop-2 file://vfolders/%2A ERROR: matchbox-desktop-2.1-r0 do_ar_original: Function failed: do_ar_original ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In function do_ar_original, when recipes have more than one source, it added the "name" URL parameter as suffix to identify the created tarball. But the URL type "file://" that we always used to represent a series of patches, it didn't have "name" parameter, so it failed. So set "name" to the folder name to identify the created tarball, for example: In matchbox-desktop bb file, the SRC_URI contains: file://vfloders/* We set "name" to "vfolders" to identify the created tarball. In connman-gnome bb file, the SRC_URI contains: file://images/* We set "name" to "images" to identify the created tarball. (From OE-Core rev: 0af636c635391b30c987dedeffe597ef4f8a1ed8) (From OE-Core rev: 9dd945d083ee742dcb75d24d4be40468121008a6) (From OE-Core rev: 113de7ab1e61997147b4b292b7de162d44296d59) Signed-off-by: Dengke Du <dengke.du@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-11-28 12:37:35 +00:00
if type.lower() == 'file':
name_tmp = location.rstrip("*").rstrip("/")
name = os.path.basename(name_tmp)
else:
if name in tarball_suffix:
if not name:
bb.fatal("Cannot determine archive names for original source because 'name' URL parameter is unset in more than one URL. Add it to at least one of these: %s %s" % (tarball_suffix[name], url))
else:
bb.fatal("Cannot determine archive names for original source because 'name=' URL parameter '%s' is used twice. Make it unique in: %s %s" % (tarball_suffix[name], url))
archive.bbclass: fix do_ar_original archiving of multiple source repos When a recipe uses more than one source which isn't a plain file (for example, multiple git repos), then do_ar_original created the source archives using the same filename and thus only archived one source. The "name" parameter is used as file suffix to create unique names for each source, leading to archives following this pattern: deploy/${TARGET_SYS}/${PF}/${PF}[-<name>].tar.gz. The ${PF} part is a bit redundant, which may or may not be desirable. The patch is more localized this way (no need to modify create_tarball()). For example, meta-oic's iotivity_1.1.1.bb uses: url_iotivity = "git://github.com/iotivity/iotivity.git" branch_iotivity = "1.1-rel" SRC_URI = "${url_iotivity};destsuffix=${S};branch=${branch_iotivity};protocol=http;" url_tinycbor = "git://github.com/01org/tinycbor.git" SRC_URI += "${url_tinycbor};name=tinycbor;destsuffix=${S}/extlibs/tinycbor/tinycbor;protocol=http" url_hippomocks = "git://github.com/dascandy/hippomocks.git" SRC_URI += "${url_hippomocks};name=hippomocks;destsuffix=${S}/extlibs/hippomocks-master;protocol=http" SRC_URI += "file://hippomocks_mips_patch" url_gtest = "http://pkgs.fedoraproject.org/repo/pkgs/gtest/gtest-1.7.0.zip/2d6ec8ccdf5c46b05ba54a9fd1d130d7/gtest-1.7.0.zip" SRC_URI += "${url_gtest};name=gtest;subdir=${BP}/extlibs/gtest" url_sqlite = "http://www.sqlite.org/2015/sqlite-amalgamation-3081101.zip" SRC_URI += "${url_sqlite};name=sqlite3;subdir=${BP}/extlibs/sqlite3;unpack=false" These now get archived in deploy/sources/*/iotivity-1.1.1-r2/ as: gtest-1.7.0.zip iotivity-1.1.1-r2-recipe.tar.gz sqlite-amalgamation-3081101.zip hippomocks_mips_patch iotivity-1.1.1-r2.tar.gz iotivity-1.1.1-r2-hippomocks.tar.gz iotivity-1.1.1-r2-tinycbor.tar.gz (From OE-Core rev: 5c63ffc706c0fff8cfb797a238f4f0e73ee2813d) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-09-26 09:55:16 +00:00
tarball_suffix[name] = url
create_tarball(d, tmpdir + '/.', name, ar_outdir)
# Emit patch series files for 'original'
bb.note('Writing patch series files...')
for patch in src_patches(d):
_, _, local, _, _, parm = bb.fetch.decodeurl(patch)
patchdir = parm.get('patchdir')
if patchdir:
series = os.path.join(ar_outdir, 'series.subdir.%s' % patchdir.replace('/', '_'))
else:
series = os.path.join(ar_outdir, 'series')
with open(series, 'a') as s:
s.write('%s -p%s\n' % (os.path.basename(local), parm['striplevel']))
}
python do_ar_patched() {
if d.getVarFlag('ARCHIVER_MODE', 'src') != 'patched':
return
# Get the ARCHIVER_OUTDIR before we reset the WORKDIR
ar_outdir = d.getVar('ARCHIVER_OUTDIR')
ar_workdir = d.getVar('ARCHIVER_WORKDIR')
bb.note('Archiving the patched source...')
d.setVar('WORKDIR', ar_workdir)
create_tarball(d, d.getVar('S'), 'patched', ar_outdir)
}
python do_ar_configured() {
import shutil
# Forcibly expand the sysroot paths as we're about to change WORKDIR
d.setVar('RECIPE_SYSROOT', d.getVar('RECIPE_SYSROOT'))
d.setVar('RECIPE_SYSROOT_NATIVE', d.getVar('RECIPE_SYSROOT_NATIVE'))
ar_outdir = d.getVar('ARCHIVER_OUTDIR')
if d.getVarFlag('ARCHIVER_MODE', 'src') == 'configured':
bb.note('Archiving the configured source...')
pn = d.getVar('PN')
# "gcc-source-${PV}" recipes don't have "do_configure"
# task, so we need to run "do_preconfigure" instead
if pn.startswith("gcc-source-"):
d.setVar('WORKDIR', d.getVar('ARCHIVER_WORKDIR'))
bb.build.exec_func('do_preconfigure', d)
# The libtool-native's do_configure will remove the
# ${STAGING_DATADIR}/aclocal/libtool.m4, so we can't re-run the
# do_configure, we archive the already configured ${S} to
# instead of.
elif pn != 'libtool-native':
# Change the WORKDIR to make do_configure run in another dir.
d.setVar('WORKDIR', d.getVar('ARCHIVER_WORKDIR'))
if bb.data.inherits_class('kernel-yocto', d):
bb.build.exec_func('do_kernel_configme', d)
if bb.data.inherits_class('cmake', d):
bb.build.exec_func('do_generate_toolchain_file', d)
prefuncs = d.getVarFlag('do_configure', 'prefuncs')
for func in (prefuncs or '').split():
if func != "sysroot_cleansstate":
bb.build.exec_func(func, d)
bb.build.exec_func('do_configure', d)
postfuncs = d.getVarFlag('do_configure', 'postfuncs')
for func in (postfuncs or '').split():
if func != "do_qa_configure":
bb.build.exec_func(func, d)
srcdir = d.getVar('S')
builddir = d.getVar('B')
if srcdir != builddir:
if os.path.exists(builddir):
oe.path.copytree(builddir, os.path.join(srcdir, \
'build.%s.ar_configured' % d.getVar('PF')))
create_tarball(d, srcdir, 'configured', ar_outdir)
}
def create_tarball(d, srcdir, suffix, ar_outdir):
"""
create the tarball from srcdir
"""
import tarfile
archiver.bbclass: Fixes and improves archiver class for kernel and gcc packages gcc packages use a shared source directory, this causes an issue since the archiver will try to patch the same source several times (one for each gcc package), producing an error, the archiver class used stamp-base to check this, nonetheless our gcc packages no longer use stamp-base, they use gcc-shared instead, which is what broke this functionality. This patch adds a check to see whether or not the source should be patched, avoiding patching the source when it shouldn't. Also, we dont need to create multiple identical tarballs for all gcc packages, this patch fixes this and creates a single source tarball for gcc. When requesting patched sources, a race condition is created for linux-yocto tasks, unpack_and_patch is executed along with kernel_configme, which most of the time causes errors during configure, since kernel_configme task is specific to the kernel, simply modifying the tasks order by creating a dependency to kernel_configme was impossible, causing errors on all other packages that didnt use kernel_configme, this is fixed by creating a special case for the kernel, adding tasks with correct dependencies, avoiding the race condition and behaving the way it should for all other packages as well. [YOCTO #8378] (From OE-Core rev: aecaa0e8739db1c228a6db78225a717d9f348a5b) Signed-off-by: Alejandro Hernandez <alejandro.hernandez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-10-06 23:05:09 +00:00
# Make sure we are only creating a single tarball for gcc sources
if (d.getVar('SRC_URI') == ""):
archiver.bbclass: Fixes and improves archiver class for kernel and gcc packages gcc packages use a shared source directory, this causes an issue since the archiver will try to patch the same source several times (one for each gcc package), producing an error, the archiver class used stamp-base to check this, nonetheless our gcc packages no longer use stamp-base, they use gcc-shared instead, which is what broke this functionality. This patch adds a check to see whether or not the source should be patched, avoiding patching the source when it shouldn't. Also, we dont need to create multiple identical tarballs for all gcc packages, this patch fixes this and creates a single source tarball for gcc. When requesting patched sources, a race condition is created for linux-yocto tasks, unpack_and_patch is executed along with kernel_configme, which most of the time causes errors during configure, since kernel_configme task is specific to the kernel, simply modifying the tasks order by creating a dependency to kernel_configme was impossible, causing errors on all other packages that didnt use kernel_configme, this is fixed by creating a special case for the kernel, adding tasks with correct dependencies, avoiding the race condition and behaving the way it should for all other packages as well. [YOCTO #8378] (From OE-Core rev: aecaa0e8739db1c228a6db78225a717d9f348a5b) Signed-off-by: Alejandro Hernandez <alejandro.hernandez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-10-06 23:05:09 +00:00
return
bb.utils.mkdirhier(ar_outdir)
if suffix:
filename = '%s-%s.tar.gz' % (d.getVar('PF'), suffix)
else:
filename = '%s.tar.gz' % d.getVar('PF')
tarname = os.path.join(ar_outdir, filename)
bb.note('Creating %s' % tarname)
tar = tarfile.open(tarname, 'w:gz')
tar.add(srcdir, arcname=os.path.basename(srcdir))
tar.close()
# creating .diff.gz between source.orig and source
def create_diff_gz(d, src_orig, src, ar_outdir):
import subprocess
if not os.path.isdir(src) or not os.path.isdir(src_orig):
return
# The diff --exclude can't exclude the file with path, so we copy
# the patched source, and remove the files that we'd like to
# exclude.
src_patched = src + '.patched'
oe.path.copyhardlinktree(src, src_patched)
for i in d.getVarFlag('ARCHIVER_MODE', 'diff-exclude').split():
bb.utils.remove(os.path.join(src_orig, i), recurse=True)
bb.utils.remove(os.path.join(src_patched, i), recurse=True)
dirname = os.path.dirname(src)
basename = os.path.basename(src)
bb.utils.mkdirhier(ar_outdir)
cwd = os.getcwd()
try:
os.chdir(dirname)
out_file = os.path.join(ar_outdir, '%s-diff.gz' % d.getVar('PF'))
diff_cmd = 'diff -Naur %s.orig %s.patched | gzip -c > %s' % (basename, basename, out_file)
subprocess.check_call(diff_cmd, shell=True)
bb.utils.remove(src_patched, recurse=True)
finally:
os.chdir(cwd)
# Run do_unpack and do_patch
python do_unpack_and_patch() {
if d.getVarFlag('ARCHIVER_MODE', 'src') not in \
[ 'patched', 'configured'] and \
d.getVarFlag('ARCHIVER_MODE', 'diff') != '1':
return
ar_outdir = d.getVar('ARCHIVER_OUTDIR')
ar_workdir = d.getVar('ARCHIVER_WORKDIR')
ar_sysroot_native = d.getVar('STAGING_DIR_NATIVE')
pn = d.getVar('PN')
# The kernel class functions require it to be on work-shared, so we dont change WORKDIR
if not (bb.data.inherits_class('kernel-yocto', d) or pn.startswith('gcc-source')):
# Change the WORKDIR to make do_unpack do_patch run in another dir.
d.setVar('WORKDIR', ar_workdir)
# Restore the original path to recipe's native sysroot (it's relative to WORKDIR).
d.setVar('STAGING_DIR_NATIVE', ar_sysroot_native)
# The changed 'WORKDIR' also caused 'B' changed, create dir 'B' for the
# possibly requiring of the following tasks (such as some recipes's
# do_patch required 'B' existed).
bb.utils.mkdirhier(d.getVar('B'))
bb.build.exec_func('do_unpack', d)
# Save the original source for creating the patches
if d.getVarFlag('ARCHIVER_MODE', 'diff') == '1':
src = d.getVar('S').rstrip('/')
src_orig = '%s.orig' % src
oe.path.copytree(src, src_orig)
archiver.bbclass: Fixes and improves archiver class for kernel and gcc packages gcc packages use a shared source directory, this causes an issue since the archiver will try to patch the same source several times (one for each gcc package), producing an error, the archiver class used stamp-base to check this, nonetheless our gcc packages no longer use stamp-base, they use gcc-shared instead, which is what broke this functionality. This patch adds a check to see whether or not the source should be patched, avoiding patching the source when it shouldn't. Also, we dont need to create multiple identical tarballs for all gcc packages, this patch fixes this and creates a single source tarball for gcc. When requesting patched sources, a race condition is created for linux-yocto tasks, unpack_and_patch is executed along with kernel_configme, which most of the time causes errors during configure, since kernel_configme task is specific to the kernel, simply modifying the tasks order by creating a dependency to kernel_configme was impossible, causing errors on all other packages that didnt use kernel_configme, this is fixed by creating a special case for the kernel, adding tasks with correct dependencies, avoiding the race condition and behaving the way it should for all other packages as well. [YOCTO #8378] (From OE-Core rev: aecaa0e8739db1c228a6db78225a717d9f348a5b) Signed-off-by: Alejandro Hernandez <alejandro.hernandez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-10-06 23:05:09 +00:00
# Make sure gcc and kernel sources are patched only once
if not (d.getVar('SRC_URI') == "" or (bb.data.inherits_class('kernel-yocto', d) or pn.startswith('gcc-source'))):
archiver.bbclass: Fixes and improves archiver class for kernel and gcc packages gcc packages use a shared source directory, this causes an issue since the archiver will try to patch the same source several times (one for each gcc package), producing an error, the archiver class used stamp-base to check this, nonetheless our gcc packages no longer use stamp-base, they use gcc-shared instead, which is what broke this functionality. This patch adds a check to see whether or not the source should be patched, avoiding patching the source when it shouldn't. Also, we dont need to create multiple identical tarballs for all gcc packages, this patch fixes this and creates a single source tarball for gcc. When requesting patched sources, a race condition is created for linux-yocto tasks, unpack_and_patch is executed along with kernel_configme, which most of the time causes errors during configure, since kernel_configme task is specific to the kernel, simply modifying the tasks order by creating a dependency to kernel_configme was impossible, causing errors on all other packages that didnt use kernel_configme, this is fixed by creating a special case for the kernel, adding tasks with correct dependencies, avoiding the race condition and behaving the way it should for all other packages as well. [YOCTO #8378] (From OE-Core rev: aecaa0e8739db1c228a6db78225a717d9f348a5b) Signed-off-by: Alejandro Hernandez <alejandro.hernandez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-10-06 23:05:09 +00:00
bb.build.exec_func('do_patch', d)
# Create the patches
if d.getVarFlag('ARCHIVER_MODE', 'diff') == '1':
bb.note('Creating diff gz...')
create_diff_gz(d, src_orig, src, ar_outdir)
bb.utils.remove(src_orig, recurse=True)
}
# BBINCLUDED is special (excluded from basehash signature
# calculation). Using it in a task signature can cause "basehash
# changed" errors.
#
# Depending on BBINCLUDED also causes do_ar_recipe to run again
# for unrelated changes, like adding or removing buildhistory.bbclass.
#
# For these reasons we ignore the dependency completely. The versioning
# of the output file ensures that we create it each time the recipe
# gets rebuilt, at least as long as a PR server is used. We also rely
# on that mechanism to catch changes in the file content, because the
# file content is not part of of the task signature either.
do_ar_recipe[vardepsexclude] += "BBINCLUDED"
python do_ar_recipe () {
"""
archive the recipe, including .bb and .inc.
"""
import re
import shutil
require_re = re.compile( r"require\s+(.+)" )
include_re = re.compile( r"include\s+(.+)" )
bbfile = d.getVar('FILE')
outdir = os.path.join(d.getVar('WORKDIR'), \
'%s-recipe' % d.getVar('PF'))
bb.utils.mkdirhier(outdir)
shutil.copy(bbfile, outdir)
pn = d.getVar('PN')
bbappend_files = d.getVar('BBINCLUDED').split()
# If recipe name is aa, we need to match files like aa.bbappend and aa_1.1.bbappend
# Files like aa1.bbappend or aa1_1.1.bbappend must be excluded.
bbappend_re = re.compile( r".*/%s_[^/]*\.bbappend$" % re.escape(pn))
bbappend_re1 = re.compile( r".*/%s\.bbappend$" % re.escape(pn))
for file in bbappend_files:
if bbappend_re.match(file) or bbappend_re1.match(file):
shutil.copy(file, outdir)
dirname = os.path.dirname(bbfile)
bbpath = '%s:%s' % (dirname, d.getVar('BBPATH'))
f = open(bbfile, 'r')
for line in f.readlines():
incfile = None
if require_re.match(line):
incfile = require_re.match(line).group(1)
elif include_re.match(line):
incfile = include_re.match(line).group(1)
if incfile:
incfile = d.expand(incfile)
incfile = bb.utils.which(bbpath, incfile)
if incfile:
shutil.copy(incfile, outdir)
create_tarball(d, outdir, 'recipe', d.getVar('ARCHIVER_OUTDIR'))
bb.utils.remove(outdir, recurse=True)
}
python do_dumpdata () {
"""
dump environment data to ${PF}-showdata.dump
"""
dumpfile = os.path.join(d.getVar('ARCHIVER_OUTDIR'), \
'%s-showdata.dump' % d.getVar('PF'))
bb.note('Dumping metadata into %s' % dumpfile)
with open(dumpfile, "w") as f:
# emit variables and shell functions
bb.data.emit_env(f, d, True)
# emit the metadata which isn't valid shell
for e in d.keys():
if d.getVarFlag(e, "python", False):
f.write("\npython %s () {\n%s}\n" % (e, d.getVar(e, False)))
}
SSTATETASKS += "do_deploy_archives"
do_deploy_archives () {
echo "Deploying source archive files from ${ARCHIVER_TOPDIR} to ${DEPLOY_DIR_SRC}."
}
python do_deploy_archives_setscene () {
sstate_setscene(d)
}
do_deploy_archives[dirs] = "${ARCHIVER_TOPDIR}"
do_deploy_archives[sstate-inputdirs] = "${ARCHIVER_TOPDIR}"
do_deploy_archives[sstate-outputdirs] = "${DEPLOY_DIR_SRC}"
addtask do_deploy_archives_setscene
addtask do_ar_original after do_unpack
addtask do_unpack_and_patch after do_patch
addtask do_ar_patched after do_unpack_and_patch
addtask do_ar_configured after do_unpack_and_patch
addtask do_dumpdata
addtask do_ar_recipe
addtask do_deploy_archives before do_build
addtask do_deploy_all_archives after do_deploy_archives
do_deploy_all_archives[recrdeptask] = "do_deploy_archives"
do_deploy_all_archives[recideptask] = "do_${BB_DEFAULT_TASK}"
do_deploy_all_archives() {
:
}
archiver.bbclass: Fixes and improves archiver class for kernel and gcc packages gcc packages use a shared source directory, this causes an issue since the archiver will try to patch the same source several times (one for each gcc package), producing an error, the archiver class used stamp-base to check this, nonetheless our gcc packages no longer use stamp-base, they use gcc-shared instead, which is what broke this functionality. This patch adds a check to see whether or not the source should be patched, avoiding patching the source when it shouldn't. Also, we dont need to create multiple identical tarballs for all gcc packages, this patch fixes this and creates a single source tarball for gcc. When requesting patched sources, a race condition is created for linux-yocto tasks, unpack_and_patch is executed along with kernel_configme, which most of the time causes errors during configure, since kernel_configme task is specific to the kernel, simply modifying the tasks order by creating a dependency to kernel_configme was impossible, causing errors on all other packages that didnt use kernel_configme, this is fixed by creating a special case for the kernel, adding tasks with correct dependencies, avoiding the race condition and behaving the way it should for all other packages as well. [YOCTO #8378] (From OE-Core rev: aecaa0e8739db1c228a6db78225a717d9f348a5b) Signed-off-by: Alejandro Hernandez <alejandro.hernandez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-10-06 23:05:09 +00:00
python () {
# Add tasks in the correct order, specifically for linux-yocto to avoid race condition.
# sstatesig.py:sstate_rundepfilter has special support that excludes this dependency
# so that do_kernel_configme does not need to run again when do_unpack_and_patch
# gets added or removed (by adding or removing archiver.bbclass).
archiver.bbclass: Fixes and improves archiver class for kernel and gcc packages gcc packages use a shared source directory, this causes an issue since the archiver will try to patch the same source several times (one for each gcc package), producing an error, the archiver class used stamp-base to check this, nonetheless our gcc packages no longer use stamp-base, they use gcc-shared instead, which is what broke this functionality. This patch adds a check to see whether or not the source should be patched, avoiding patching the source when it shouldn't. Also, we dont need to create multiple identical tarballs for all gcc packages, this patch fixes this and creates a single source tarball for gcc. When requesting patched sources, a race condition is created for linux-yocto tasks, unpack_and_patch is executed along with kernel_configme, which most of the time causes errors during configure, since kernel_configme task is specific to the kernel, simply modifying the tasks order by creating a dependency to kernel_configme was impossible, causing errors on all other packages that didnt use kernel_configme, this is fixed by creating a special case for the kernel, adding tasks with correct dependencies, avoiding the race condition and behaving the way it should for all other packages as well. [YOCTO #8378] (From OE-Core rev: aecaa0e8739db1c228a6db78225a717d9f348a5b) Signed-off-by: Alejandro Hernandez <alejandro.hernandez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-10-06 23:05:09 +00:00
if bb.data.inherits_class('kernel-yocto', d):
bb.build.addtask('do_kernel_configme', 'do_configure', 'do_unpack_and_patch', d)
}