From c7ceb8a4e434ec8ab76af04b6ec01e78786a16df Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 3 Dec 2011 16:19:56 +0100 Subject: [PATCH] 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. --- ChangeLog | 9 +++++++++ gnulib-tool | 55 +++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index f21d38ff6..429b80ce6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2011-12-03 Bruno Haible + 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 + sethostname tests: Fix link error on mingw. * tests/test-sethostname1.c: New file, extracted from tests/test-sethostname.c. diff --git a/gnulib-tool b/gnulib-tool index 792bd4993..d9d4526cc 100755 --- a/gnulib-tool +++ b/gnulib-tool @@ -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 -- 2.11.0