All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] distribute_license: added class to copy license files
@ 2010-07-29 14:51 Chase Maupin
  2010-07-29 20:55 ` Bernhard Reutner-Fischer
  0 siblings, 1 reply; 7+ messages in thread
From: Chase Maupin @ 2010-07-29 14:51 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Chase Maupin

* 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.

Signed-off-by: Chase Maupin <chase.maupin@ti.com>
---
 classes/distribute_license.bbclass |   56 ++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)
 create mode 100644 classes/distribute_license.bbclass

diff --git a/classes/distribute_license.bbclass b/classes/distribute_license.bbclass
new file mode 100644
index 0000000..795a404
--- /dev/null
+++ b/classes/distribute_license.bbclass
@@ -0,0 +1,56 @@
+# 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() {
+    # Change directory to source directory
+    cd ${S}
+
+    # Turn of globbing so that wildcards are not expanded in for loop
+    set -f
+
+    # Check if LICENSE_FILES exist.  If so copy them to DEPLOY_DIR
+    for lic in ${LICENSE_FILES}
+    do
+        res=""
+        res=`find . -maxdepth ${LICENSE_SEARCH_DEPTH} -name "$lic"`
+        if [ "$res" != "" ]
+        then
+            mkdir -p ${DEPLOY_DIR}/licenses/${PN}
+            cp $res ${DEPLOY_DIR}/licenses/${PN}
+        fi
+    done
+
+    # Turn globbing back on
+    set +f
+
+    # Just to be clean change directory back to where we started from.
+    cd -
+}
+
+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
-- 
1.7.0.4




^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-08-02 14:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-29 14:51 [PATCH 1/1] distribute_license: added class to copy license files Chase Maupin
2010-07-29 20:55 ` Bernhard Reutner-Fischer
2010-07-29 21:46   ` Maupin, Chase
2010-07-30  7:57     ` Bernhard Reutner-Fischer
2010-07-30  8:10       ` David Kozub
2010-07-30  6:48   ` Koen Kooi
2010-08-02 14:11     ` Marc Olzheim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.