gnulib-tool: Verify that the License field is present and non-empty.
authorBruno Haible <bruno@clisp.org>
Sat, 3 Dec 2011 15:19:56 +0000 (16:19 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 3 Dec 2011 15:19:56 +0000 (16:19 +0100)
* gnulib-tool (func_get_license_raw): New function, extracted from
func_get_license.
(func_get_license): Use it. Warn if the module is not a test module and
has no license.
Suggested by Jim Meyering.

ChangeLog
gnulib-tool

index f21d38f..429b80c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2011-12-03  Bruno Haible  <bruno@clisp.org>
 
+       gnulib-tool: Verify that the License field is present and non-empty.
+       * gnulib-tool (func_get_license_raw): New function, extracted from
+       func_get_license.
+       (func_get_license): Use it. Warn if the module is not a test module and
+       has no license.
+       Suggested by Jim Meyering.
+
+2011-12-03  Bruno Haible  <bruno@clisp.org>
+
        sethostname tests: Fix link error on mingw.
        * tests/test-sethostname1.c: New file, extracted from
        tests/test-sethostname.c.
index 792bd49..d9d4526 100755 (executable)
@@ -2375,31 +2375,50 @@ func_get_link_directive ()
   fi
 }
 
-# func_get_license module
+# func_get_license_raw module
 # Input:
 # - local_gnulib_dir  from --local-dir
 # - modcache          true or false, from --cache-modules/--no-cache-modules
-func_get_license ()
+func_get_license_raw ()
 {
-  {
-    if ! $modcache; then
-      func_lookup_file "modules/$1"
-      sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
+  if ! $modcache; then
+    func_lookup_file "modules/$1"
+    sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
+  else
+    func_cache_lookup_module "$1"
+    # Output the field's value, including the final newline (if any).
+    if $have_associative; then
+      if eval 'test -n "${modcache_license[$1]+set}"'; then
+        eval 'echo "${modcache_license[$1]}"'
+      fi
     else
-      func_cache_lookup_module "$1"
-      # Output the field's value, including the final newline (if any).
-      if $have_associative; then
-        if eval 'test -n "${modcache_license[$1]+set}"'; then
-          eval 'echo "${modcache_license[$1]}"'
-        fi
-      else
-        eval "field_set=\"\$${cachevar}_license_set\""
-        if test -n "$field_set"; then
-          eval "field_value=\"\$${cachevar}_license\""
-          echo "${field_value}"
-        fi
+      eval "field_set=\"\$${cachevar}_license_set\""
+      if test -n "$field_set"; then
+        eval "field_value=\"\$${cachevar}_license\""
+        echo "${field_value}"
       fi
     fi
+  fi
+}
+
+# func_get_license module
+# Input:
+# - local_gnulib_dir  from --local-dir
+# - modcache          true or false, from --cache-modules/--no-cache-modules
+func_get_license ()
+{
+  # Warn if the License field is missing.
+  case "$1" in
+    *-tests ) ;;
+    * )
+      license=`func_get_license_raw "$1"`
+      if test -z "$license"; then
+        func_warning "module $1 lacks a License"
+      fi
+      ;;
+  esac
+  {
+    func_get_license_raw "$1"
     # The default is GPL.
     echo "GPL"
   } | sed -e 's,^ *$,,' | sed -e 1q