summaryrefslogtreecommitdiffstats
path: root/meta/classes/copyleft_compliance.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/copyleft_compliance.bbclass')
-rw-r--r--meta/classes/copyleft_compliance.bbclass64
1 files changed, 64 insertions, 0 deletions
diff --git a/meta/classes/copyleft_compliance.bbclass b/meta/classes/copyleft_compliance.bbclass
new file mode 100644
index 0000000000..907c1836b3
--- /dev/null
+++ b/meta/classes/copyleft_compliance.bbclass
@@ -0,0 +1,64 @@
1# Deploy sources for recipes for compliance with copyleft-style licenses
2# Defaults to using symlinks, as it's a quick operation, and one can easily
3# follow the links when making use of the files (e.g. tar with the -h arg).
4#
5# vi:sts=4:sw=4:et
6
7inherit copyleft_filter
8
9COPYLEFT_SOURCES_DIR ?= '${DEPLOY_DIR}/copyleft_sources'
10
11python do_prepare_copyleft_sources () {
12 """Populate a tree of the recipe sources and emit patch series files"""
13 import os.path
14 import shutil
15
16 p = d.getVar('P', True)
17 included, reason = copyleft_should_include(d)
18 if not included:
19 bb.debug(1, 'copyleft: %s is excluded: %s' % (p, reason))
20 return
21 else:
22 bb.debug(1, 'copyleft: %s is included: %s' % (p, reason))
23
24 sources_dir = d.getVar('COPYLEFT_SOURCES_DIR', True)
25 dl_dir = d.getVar('DL_DIR', True)
26 src_uri = d.getVar('SRC_URI', True).split()
27 fetch = bb.fetch2.Fetch(src_uri, d)
28 ud = fetch.ud
29
30 pf = d.getVar('PF', True)
31 dest = os.path.join(sources_dir, pf)
32 shutil.rmtree(dest, ignore_errors=True)
33 bb.utils.mkdirhier(dest)
34
35 for u in ud.values():
36 local = os.path.normpath(fetch.localpath(u.url))
37 if local.endswith('.bb'):
38 continue
39 elif local.endswith('/'):
40 local = local[:-1]
41
42 if u.mirrortarball:
43 tarball_path = os.path.join(dl_dir, u.mirrortarball)
44 if os.path.exists(tarball_path):
45 local = tarball_path
46
47 oe.path.symlink(local, os.path.join(dest, os.path.basename(local)), force=True)
48
49 patches = src_patches(d)
50 for patch in patches:
51 _, _, local, _, _, parm = bb.fetch.decodeurl(patch)
52 patchdir = parm.get('patchdir')
53 if patchdir:
54 series = os.path.join(dest, 'series.subdir.%s' % patchdir.replace('/', '_'))
55 else:
56 series = os.path.join(dest, 'series')
57
58 with open(series, 'a') as s:
59 s.write('%s -p%s\n' % (os.path.basename(local), parm['striplevel']))
60}
61
62addtask prepare_copyleft_sources after do_fetch before do_build
63do_prepare_copyleft_sources[dirs] = "${WORKDIR}"
64do_build[recrdeptask] += 'do_prepare_copyleft_sources'