linux-omap 2.6.29: add support for the omap3-touchbook
[openembedded.git] / classes / src_distribute.bbclass
blob7d75c9e16f1f44454493767086cdd234258caf79
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         import os, re, bb
8         bb.build.exec_func("do_fetch", d)
10         l = bb.data.createCopy(d)
11         bb.data.update_data(l)
13         licenses = (bb.data.getVar('LICENSE', d, 1) or "unknown").split()
14         for license in licenses:
15                 for entry in license.split("|"):
16                         for url in ((bb.data.getVar('SRC_URI', d, 1) or '').split()):
17                                 bb.fetch.init([url], d)
18                                 s = bb.fetch.localpath(url, d)
19                                 s = re.sub(';.*$', '', s)
21                                 try:
22                                         dlonly = int(d.getVar("SRC_DISTRIBUTE_DLONLY", 1))
23                                 except ValueError:
24                                         raise bb.build.FuncFailed("Invalid value for SRC_DISTRIBUTE_DLONLY: expected integer.")
25                                 if dlonly:
26                                         dldir = os.path.realpath(d.getVar("DL_DIR", 1) or "")
27                                         if dldir and not \
28                                            os.path.realpath(s).startswith(dldir + os.path.sep):
29                                                         continue
31                                 cmd = bb.data.getVar('SRC_DISTRIBUTECOMMAND', d, 1)
32                                 if not cmd:
33                                         raise bb.build.FuncFailed("Unable to distribute sources, SRC_DISTRIBUTECOMMAND not set")
34                                 bb.debug(2, "srcdist: running %s" % cmd)
35                                 bb.data.setVar('SRC', os.path.normpath(s), l)
36                                 bb.data.setVar('LIC', entry, l)
37                                 bb.build.exec_func('SRC_DISTRIBUTECOMMAND', l)
40 addtask distribute_sources_all after do_distribute_sources
41 do_distribute_sources_all[recrdeptask] = "do_distribute_sources"
42 do_distribute_sources_all[nostamp] = "1"
44 # compatability wrapper
45 addtask distsrcall after do_distribute_sources_all
46 do_distsrcall[nostamp] = "1"