bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Friendlier gnulib-tool error messages with multiple incompatible modules


From: Derek Price
Subject: Friendlier gnulib-tool error messages with multiple incompatible modules
Date: Wed, 24 Sep 2008 18:11:27 -0400
User-agent: Thunderbird 2.0.0.16 (Windows/20080708)

Hey all,

Anyone mind if I commit the attached patch?  It makes `gnulib-tool
--update --lgpl' list all incompatible modules instead of breaking after
the first one, like so:

$ ../gnulib/gnulib-tool --update --lgpl
gnulib-tool: *** incompatible license on modules:
gnulib-tool: *** areadlink-with-size/GPL, canonicalize/GPL, chdir-long/GPL,
gnulib-tool: *** chown/GPL, clock-time/GPL, close-stream/GPL, closeout/GPL,
gnulib-tool: *** d-ino/GPL, dirname/GPL, exit/GPL, exitfail/GPL,
gnulib-tool: *** fcntl-safer/GPL, file-set/GPL, filenamecat/GPL,
fpending/GPL,
gnulib-tool: *** ftruncate/GPL, getcwd/GPL, getdate/GPL, getnline/GPL,
gnulib-tool: *** gettime/GPL, hash/GPL, hash-pjw/GPL, hash-triple/GPL,
gnulib-tool: *** lchmod/GPL, lchown/GPL, longlong/GPL, mkancesdirs/GPL,
gnulib-tool: *** mkdir-p/GPL, nanosleep/GPL, openat/GPL, openat-die/GPL,
gnulib-tool: *** quote/GPL, quotearg/GPL, rename/GPL, rpmatch/GPL, same/GPL,
gnulib-tool: *** save-cwd/GPL, savewd/GPL, stat-macros/GPL, strtoimax/GPL,
gnulib-tool: *** strtoumax/GPL, timespec/GPL, tzset/GPL, unistd-safer/GPL,
gnulib-tool: *** unlocked-io/GPL, xalloc/GPL, xalloc-die/GPL, xgetcwd/GPL,
gnulib-tool: *** xgethostname/GPL, xstrndup/GPL,
gnulib-tool: *** yesno/GPL
gnulib-tool: *** Stop.
$

Cheers,

Derek
-- 
Derek R. Price
Solutions Architect
Ximbiot, LLC <http://ximbiot.com>
Get CVS and Subversion Support from Ximbiot!

v: +1 248.835.1260
f: +1 248.246.1176
--- gnulib-tool.orig    2008-09-24 17:48:53.000000000 -0400
+++ gnulib-tool 2008-09-24 18:02:27.000000000 -0400
@@ -396,11 +396,67 @@
   }
 fi
 
+# Treat the shell variable with name $1 like a space delimited stack and
+# append the rest of $@
+func_push ()
+{
+  var=$1
+  shift
+  for e in ${1+"$@"}; do
+    if eval "test -n \"\$$1\""; then
+      func_append $var " "
+    fi
+    func_append $var "$e"
+  done
+}
+
+# Using $1 as a separator, join the rest of $@, then echo the result.
+#
+# e.g. `join ", " a b c d e f' yields:
+#
+#       a, b, c, d, e, f
+func_join ()
+{
+  sep=$1
+  out=$2
+  shift
+  shift
+  for e in ${1+"$@"}; do
+    func_append out "$sep"
+    func_append out "$e"
+  done
+  echo $out
+}
+
+# Wrap $1 at $3 characters, prefixing each line with $2, then echo it.
+#
+# $3 (wrap length) defaults to 80.
+#
+# e.g. `wrap "a b c d e f g h i j k xxxxxxxxxxxxxxxxxx" "gnulib: " 14' yields:
+#
+#      gnulib: a b c 
+#      gnulib: d e f 
+#      gnulib: g h i 
+#      gnulib: j k 
+#      gnulib: 
+#      xxxxxxxxxxxxxxxxxx
+func_wrap ()
+{
+  prefix=$2
+  plen=`echo "$prefix" |wc -c`
+  if test -z "$3"; then
+    len=80
+  fi
+  len=`expr $len - $plen`
+  echo "$1" |sed -e "s#.\\{1,$len\\} #&\\n$prefix#g" -e "s#^#$prefix&#"
+}
+
+
 # func_fatal_error message
 # outputs to stderr a fatal error message, and terminates the program.
 func_fatal_error ()
 {
-  echo "gnulib-tool: *** $1" 1>&2
+  func_wrap "$1" "gnulib-tool: *** " 1>&2
   echo "gnulib-tool: *** Stop." 1>&2
   func_exit 1
 }
@@ -2477,6 +2533,7 @@
 
   # If --lgpl, verify that the licenses of modules are compatible.
   if test -n "$lgpl"; then
+    incompatible_modules=
     for module in $main_modules; do
       license=`func_get_license $module`
       case $license in
@@ -2487,13 +2544,13 @@
             yes | 3)
               case $license in
                 LGPL | LGPLv2+) ;;
-                *) func_fatal_error "incompatible license on module $module: 
$license" ;;
+                *) func_push incompatible_modules $module/$license ;;
               esac
               ;;
             2)
               case $license in
                 LGPLv2+) ;;
-                *) func_fatal_error "incompatible license on module $module: 
$license" ;;
+                *) func_push incompatible_modules $module/$license ;;
               esac
               ;;
             *) func_fatal_error "invalid value lgpl=$lgpl" ;;
@@ -2501,6 +2558,10 @@
           ;;
       esac
     done
+    if test -n "$incompatible_modules"; then
+       list=`func_join ", " $incompatible_modules`
+       func_fatal_error "incompatible license on modules: $list"
+    fi
   fi
 
   # Show banner notice of every module.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]