shogun: remove non-distributable SVMlight code
SVMlight uses a non-standard license [0] that doesn't allow distribution without the author's permission: > The software must not be modified and distributed without prior permission of the author. So remove all code related to it when building the binary package. Use upstream's own script to do it (which they use to create and distribute their own Debian package), with a few fixes. There is still the option of building from source with SVMlight enabled with an override that sets the withSvmLight parameter. If SVMlight is enabled set the license to unfree. Also fix the deprecated gpl3 license to gpl3Plus. [0]: https://github.com/shogun-toolbox/shogun/blob/shogun_6.1.4/doc/license/LICENSE_SVMlight.md
This commit is contained in:
parent
d3677c2220
commit
e810fad47a
@ -8,6 +8,7 @@
|
||||
# extra support
|
||||
, pythonSupport ? true, pythonPackages ? null
|
||||
, opencvSupport ? false, opencv ? null
|
||||
, withSvmLight ? false
|
||||
}:
|
||||
|
||||
assert pythonSupport -> pythonPackages != null;
|
||||
@ -60,7 +61,7 @@ stdenv.mkDerivation rec {
|
||||
url = "https://github.com/awild82/shogun/commit/365ce4c4c700736d2eec8ba6c975327a5ac2cd9b.patch";
|
||||
sha256 = "158hqv4xzw648pmjbwrhxjp7qcppqa7kvriif87gn3zdn711c49s";
|
||||
})
|
||||
];
|
||||
] ++ lib.optional (!withSvmLight) ./svmlight-scrubber.patch;
|
||||
|
||||
CCACHE_DISABLE="1";
|
||||
CCACHE_DIR=".ccache";
|
||||
@ -86,12 +87,29 @@ stdenv.mkDerivation rec {
|
||||
(flag "CMAKE_VERBOSE_MAKEFILE:BOOL" doCheck)
|
||||
(flag "PythonModular" pythonSupport)
|
||||
(flag "OpenCV" opencvSupport)
|
||||
(flag "USE_SVMLIGHT" withSvmLight)
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
# Fix preprocessing SVMlight code
|
||||
sed -i \
|
||||
-e 's@#ifdef SVMLIGHT@#ifdef USE_SVMLIGHT@' \
|
||||
-e '/^#ifdef USE_SVMLIGHT/,/^#endif/ s@#endif@#endif //USE_SVMLIGHT@' \
|
||||
src/shogun/kernel/string/CommUlongStringKernel.cpp
|
||||
sed -i -e 's/#if USE_SVMLIGHT/#ifdef USE_SVMLIGHT/' src/interfaces/swig/Machine.i
|
||||
sed -i -e 's@// USE_SVMLIGHT@//USE_SVMLIGHT@' src/interfaces/swig/Transfer.i
|
||||
sed -i -e 's@/\* USE_SVMLIGHT \*/@//USE_SVMLIGHT@' src/interfaces/swig/Transfer_includes.i
|
||||
'' + lib.optionalString (!withSvmLight) ''
|
||||
# Run SVMlight scrubber
|
||||
patchShebangs scripts/light-scrubber.sh
|
||||
echo "removing SVMlight code"
|
||||
./scripts/light-scrubber.sh
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "A toolbox which offers a wide range of efficient and unified machine learning methods";
|
||||
homepage = "http://shogun-toolbox.org/";
|
||||
license = licenses.gpl3;
|
||||
license = if withSvmLight then licenses.unfree else licenses.gpl3Plus;
|
||||
maintainers = with maintainers; [ edwtjo ];
|
||||
};
|
||||
}
|
||||
|
@ -0,0 +1,76 @@
|
||||
From: Sebastián Mancilla <smancill@smancill.dev>
|
||||
Subject: Update SVMlight scrubber script
|
||||
|
||||
This requires previously fixing a few wrong preprocessor directives that
|
||||
are supposed to fence code using SVMlight.
|
||||
|
||||
- The script was too eager and removing *.light files in SVMlight format
|
||||
that are used by other tests. The code reading those files doesn't use
|
||||
any SVMlight code so it should be fine to keep it and run the tests.
|
||||
|
||||
- The Python test *domainadaptationsvm.py was not removed because of
|
||||
wrong globbing.
|
||||
|
||||
- Remove a couple of examples using SVMlight that were missed.
|
||||
|
||||
- The script is actually modifying (and breaking) itself because the
|
||||
grep for the USE_SVMLIGHT macro is too eager again and matches itself
|
||||
(and the version stored in upstream's Debian package control tarball
|
||||
is broken because of it). Just fix it by grepping for preprocessor
|
||||
directives only.
|
||||
|
||||
- No need to fix the Transfer_includes.i file in the script with a final
|
||||
%} when its preprocessor directives have been fixed.
|
||||
|
||||
- The Swig files were moved to a new directory at some point but the
|
||||
script was not updated accordingly.
|
||||
---
|
||||
scripts/light-scrubber.sh | 16 ++++++----------
|
||||
1 file changed, 6 insertions(+), 10 deletions(-)
|
||||
|
||||
diff a/scripts/light-scrubber.sh b/scripts/light-scrubber.sh
|
||||
--- a/scripts/light-scrubber.sh
|
||||
+++ b/scripts/light-scrubber.sh
|
||||
@@ -26,14 +26,16 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
-rm -rf examples/*/*/{*light*,*_domainadaptationsvm_*} \
|
||||
+rm -rf examples/*/*/{*light*.*,*domainadaptationsvm*} \
|
||||
examples/undocumented/matlab_and_octave/tests/*light* \
|
||||
+ examples/undocumented/python/serialization_string_kernels.py \
|
||||
+ examples/undocumented/python/mkl_binclass.py \
|
||||
src/shogun/classifier/svm/SVMLight.* \
|
||||
src/shogun/classifier/svm/SVMLightOneClass.* \
|
||||
src/shogun/regression/svr/SVRLight.* \
|
||||
doc/md/LICENSE_SVMlight*
|
||||
|
||||
-for _file in `grep -rl USE_SVMLIGHT .`
|
||||
+grep -rl '^#ifdef USE_SVMLIGHT' . | while read -r _file
|
||||
do
|
||||
sed -i.orig -e \
|
||||
'/\#ifdef USE_SVMLIGHT/,/\#endif \/\/USE_SVMLIGHT/c \\' ${_file} && \
|
||||
@@ -41,7 +43,7 @@ do
|
||||
rm -rf ${_file}.orig
|
||||
done
|
||||
|
||||
-for _file in `find . -depth -name 'CMakeLists.txt'`
|
||||
+find . -depth -name 'CMakeLists.txt' | while read -r _file
|
||||
do
|
||||
sed -i.orig -e 's!.*_sv[mr]light_.*!!g' ${_file} && \
|
||||
touch -r ${_file}.orig ${_file} && \
|
||||
@@ -56,13 +58,7 @@ do
|
||||
rm -rf ${_file}.orig
|
||||
done
|
||||
|
||||
-_file="src/interfaces/modular/Transfer_includes.i" && \
|
||||
-cp -a ${_file} ${_file}.orig && \
|
||||
-echo '%}' >> ${_file} && \
|
||||
-touch -r ${_file}.orig ${_file} && \
|
||||
-rm -rf ${_file}.orig
|
||||
-
|
||||
-_file="src/interfaces/modular/Machine.i" && \
|
||||
+_file="src/interfaces/swig/Machine.i" && \
|
||||
sed -i.orig -e '/.*CSVRLight.*/d' ${_file} && \
|
||||
touch -r ${_file}.orig ${_file} && \
|
||||
rm -rf ${_file}.orig
|
Loading…
Reference in New Issue
Block a user