#!/bin/bash # This scripts checks that the libraries in src do not use any GPL'd files # and mix LGPL'd and GPL'd files in one library. The script unpacks a tarball, # removes all files under GPL license (*), attempts to build the libraries # in src/, and prints any error messages about "No such file or directory". # # (*) The script uses license_check to identify the GPL'd files and removes # them, with the exception of files/directories contained in an optional file. # There should be a file with default exceptions in the same directory. set -e # see also check_licenses EXTENSIONS="C cpp h xpm gif pcx bmp jpeg png txt html vcproj sln dsp dsw cin cout cmd nef cgal dll lib tex makefile readme" CHECK_PATTERN="\.(`echo $EXTENSIONS | sed -e 's/ /\\|/g'`)" if [ $# -lt 1 -o $# -gt 2 ]; then echo "Usage: ${0##*/} [exceptions]" exit 1 fi DIR=`pwd` if [ "x${1:0:1}" != x/ ]; then FILE="`pwd`/$1" else FILE="$1" fi if [ $# = 2 ]; then if [ "x${2:0:1}" != x/ ]; then EXCEPTIONS="`pwd`/$2" else EXCEPTIONS="$2" fi fi echo -n Extracting tarball $FILE ... TMP_DIR=`mktemp -dq /tmp/${0##*/}.XXXXXX` cd $TMP_DIR tar xzf $FILE DIR=${FILE##*/} DIR=${DIR%.tar.gz} cd $DIR echo " done" echo echo Removing GPLed files ... if [ "x$EXCEPTIONS" != x ]; then licensecheck -r * -c $CHECK_PATTERN | grep "[^L]GPL (v3 or later)" | sed 's/:.*//' | grep -v -f "$EXCEPTIONS" | sort rm `licensecheck -r * -c $CHECK_PATTERN | grep "[^L]GPL (v3 or later)" | sed 's/:.*//' | grep -v -f "$EXCEPTIONS"` else licensecheck -r * -c $CHECK_PATTERN | grep "[^L]GPL (v3 or later)" | sed 's/:.*//' | sort rm `licensecheck -r * -c $CHECK_PATTERN | grep "[^L]GPL (v3 or later)" | sed 's/:.*//'` fi echo Removing GPLed files done echo echo List of exceptions: if [ "x$EXCEPTIONS" != x ]; then cat "$EXCEPTIONS" else echo "(none)" fi echo echo -n Building $1 ... rm -fr demo/[A-Z]* rm -fr examples/[A-Z]* # Somehow -DWITH_CGAL_Core=OFF is not taken into account, hence the CORE files # are listed in the exceptions file. cmake . make | grep -C 10 "No such file" || true echo " done" echo echo -n Cleaning up ... cd .. rm -fr $DIR cd .. rmdir $TMP_DIR echo " done" echo