1 # distribute-license.bbclass will search the sources of a package to
2 # a given depth looking for a match to the specified pattern and if
3 # found will copy the matching file(s) to the deploy directory.
5 # This class is used to collect license files such as COPYING or
6 # LICENSE where they are found and save them per package.
8 # This package uses the following variables to control its operations:
9 # - LICENSE_FILES = Pattern of license files to be searched for.
10 # By default this is COPYING* and LICENSE* but
11 # this can be changed per package.
12 # - LICENSE_SEARCH_DEPTH = The maximum depth to search in the package
13 # sources for files matching the LICENSE_FILES
17 # Files to copy for the licensing. By default this is looking for
18 # files following the patters COPYING* or LICENSING* in the top
19 # level sources directory.
20 LICENSE_FILES ?= "COPYING* LICENSE*"
22 # Maximum depth to look for license files
23 LICENSE_SEARCH_DEPTH ?= "1"
25 distribute_license_do_copy_license() {
26 # Turn off globbing so that wildcards are not expanded in for loop
29 # Check if LICENSE_FILES exist. If so copy them to DEPLOY_DIR
30 # Keep the relative path of licenses the same in the DEPLOY_DIR
31 for lic in ${LICENSE_FILES}
33 find ${S} -maxdepth ${LICENSE_SEARCH_DEPTH} -name "$lic" | \
37 bd=$(dirname $f | sed -e "s|${S}||")
38 install -D $f ${DEPLOY_DIR}/licenses/${PN}/$bd/$bn
42 # Turn globbing back on
46 EXPORT_FUNCTIONS do_copy_license
48 # Put after do_patch in case a patch adds the license files
49 do_copy_license[deptask] = "do_patch"
51 addtask copy_license after do_patch before do_configure