angstrom: prefer the git version of tslib
[openembedded.git] / classes / src_distribute.bbclass
blobf3d3cbacd1abe875fbce7e2b9dbabfee2b6aa08f
1 SRC_DISTRIBUTE_DLONLY ?= "0"
2 SRC_DISTRIBUTECOMMAND[func] = "1"
4 addtask distribute_sources before do_build after do_fetch
5 python do_distribute_sources () {
6         bb.build.exec_func("do_fetch", d)
8         cmd = bb.data.getVar('SRC_DISTRIBUTECOMMAND', d, 1)
9         if not cmd:
10                 raise bb.build.FuncFailed("Unable to distribute sources, SRC_DISTRIBUTECOMMAND not set")
12         try:
13                 dlonly = int(d.getVar("SRC_DISTRIBUTE_DLONLY", 1))
14         except ValueError:
15                 raise bb.build.FuncFailed("Invalid value for SRC_DISTRIBUTE_DLONLY: expected integer.")
16         dldir = os.path.realpath(d.getVar("DL_DIR", 1) or "")
18         licenses = (bb.data.getVar('LICENSE', d, 1) or "unknown").split()
19         distribute_licenses = (bb.data.getVar('SRC_DISTRIBUTE_LICENSES', d, 1) or "All").split()
20         urldatadict = bb.fetch.init(d.getVar("SRC_URI", True).split(), d, True)
21         src_uri = oe.data.typed_value("SRC_URI", d)
22         if not src_uri:
23                 return
24         for url in src_uri:
25                 urldata = urldatadict[url]
26                 if not urldata.setup:
27                         urldata.setup_localpath(d)
29                 local = urldata.localpath
30                 if dlonly and dldir and not \
31                    os.path.realpath(local).startswith(dldir + os.path.sep):
32                         continue
34                 bb.data.setVar('SRC', os.path.abspath(local), d)
35                 for license in licenses:
36                         for entry in license.split("|"):
37                                 if entry in distribute_licenses or "All" in distribute_licenses:
38                                         bb.data.setVar('LIC', entry, d)
39                                         bb.build.exec_func('SRC_DISTRIBUTECOMMAND', d)
42 addtask distribute_sources_all after do_distribute_sources
43 do_distribute_sources_all[recrdeptask] = "do_distribute_sources"
44 do_distribute_sources_all[nostamp] = "1"
46 # compatability wrapper
47 addtask distsrcall after do_distribute_sources_all
48 do_distsrcall[nostamp] = "1"