[oe-commits] Chase Maupin : distribute_license: added class to copy license files

git version control git at git.openembedded.org
Tue Aug 3 07:44:50 UTC 2010


Module: openembedded.git
Branch: org.openembedded.dev
Commit: 5e75fa8c1b28055b610eb47ba5d3368a16810aa4
URL:    http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=5e75fa8c1b28055b610eb47ba5d3368a16810aa4

Author: Chase Maupin <chasemaupin03 at gmail.com>
Date:   Fri Jul 30 03:34:59 2010 +0000

distribute_license: added class to copy license files

* This class can be used to copy license files from package
  sources into the deploy directory so they can be distributed.
* By default it searches the top-level source directory for
  files matching COPYING* or LICENSE*
* Search depth and pattern can be modified using the
  LICENSE_SEARCH_DEPTH and LICENSE_FILES variables
  respectively.
* Thanks to Koen Kooi and Bernhard Reutner-Fischer for their
  inputs and suggestions.

Signed-off-by: Chase Maupin <chase.maupin at ti.com>
Signed-off-by: Koen Kooi <k-kooi at ti.com>

---

 classes/distribute_license.bbclass |   51 ++++++++++++++++++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/classes/distribute_license.bbclass b/classes/distribute_license.bbclass
new file mode 100644
index 0000000..b9bde77
--- /dev/null
+++ b/classes/distribute_license.bbclass
@@ -0,0 +1,51 @@
+# distribute-license.bbclass will search the sources of a package to
+# a given depth looking for a match to the specified pattern and if
+# found will copy the matching file(s) to the deploy directory.
+#
+# This class is used to collect license files such as COPYING or
+# LICENSE where they are found and save them per package.
+#
+# This package uses the following variables to control its operations:
+#   - LICENSE_FILES         = Pattern of license files to be searched for.
+#                             By default this is COPYING* and LICENSE* but
+#                             this can be changed per package.
+#   - LICENSE_SEARCH_DEPTH  = The maximum depth to search in the package
+#                             sources for files matching the LICENSE_FILES
+#                             pattern.
+
+
+# Files to copy for the licensing.  By default this is looking for
+# files following the patters COPYING* or LICENSING* in the top
+# level sources directory.
+LICENSE_FILES ?= "COPYING* LICENSE*"
+
+# Maximum depth to look for license files
+LICENSE_SEARCH_DEPTH ?= "1"
+
+distribute_license_do_copy_license() {
+    # Turn off globbing so that wildcards are not expanded in for loop
+    set -f
+
+    # Check if LICENSE_FILES exist.  If so copy them to DEPLOY_DIR
+    # Keep the relative path of licenses the same in the DEPLOY_DIR
+    for lic in ${LICENSE_FILES}
+    do
+        find ${S} -maxdepth ${LICENSE_SEARCH_DEPTH} -name "$lic" | \
+            while read f
+            do
+                bn=$(basename $f)
+                bd=$(dirname $f | sed -e "s|${S}||")
+                install -D $f ${DEPLOY_DIR}/licenses/${PN}/$bd/$bn
+            done
+    done
+
+    # Turn globbing back on
+    set +f
+}
+
+EXPORT_FUNCTIONS do_copy_license
+
+# Put after do_patch in case a patch adds the license files
+do_copy_license[deptask] = "do_patch"
+
+addtask copy_license after do_patch before do_configure





More information about the Openembedded-commits mailing list