summary refs log tree commit diff
path: root/gnu
diff options
context:
space:
mode:
authorRicardo Wurmus <ricardo.wurmus@mdc-berlin.de>2015-05-08 16:53:28 +0200
committerRicardo Wurmus <ricardo.wurmus@mdc-berlin.de>2015-05-27 10:56:27 +0200
commit628bd9b8a7877ffe7b53328c1d161ba543f0b0b8 (patch)
tree7941462e108aa316bca47f231c2840a43a391fbd /gnu
parentb734996f9cf395705860703422d5e92565dd3a13 (diff)
downloadguix-628bd9b8a7877ffe7b53328c1d161ba543f0b0b8.tar.gz
gnu: shogun: Remove non-free source files.
* gnu/packages/bioinformatics.scm (shogun)[source]: Add snippet to remove
  non-free sources.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/packages/bioinformatics.scm35
1 files changed, 34 insertions, 1 deletions
diff --git a/gnu/packages/bioinformatics.scm b/gnu/packages/bioinformatics.scm
index b29ca67dbd..c076736da4 100644
--- a/gnu/packages/bioinformatics.scm
+++ b/gnu/packages/bioinformatics.scm
@@ -1628,7 +1628,40 @@ against local background noises.")
              "/sources/shogun-" version ".tar.bz2"))
        (sha256
         (base32
-         "159nlijnb7mnrv9za80wnm1shwvy45hgrqzn51hxy7gw4z6d6fdb"))))
+         "159nlijnb7mnrv9za80wnm1shwvy45hgrqzn51hxy7gw4z6d6fdb"))
+       (modules '((guix build utils)
+                  (ice-9 rdelim)))
+       (snippet
+        '(begin
+           ;; Remove non-free sources and files referencing them
+           (for-each delete-file
+                     (find-files "src/shogun/classifier/svm/"
+                                 "SVMLight\\.(cpp|h)"))
+           (for-each delete-file
+                     (find-files "examples/undocumented/libshogun/"
+                                 (string-append
+                                  "(classifier_.*svmlight.*|"
+                                  "evaluation_cross_validation_locked_comparison).cpp")))
+           ;; Remove non-free functions.
+           (define (delete-ifdefs file)
+             (with-atomic-file-replacement file
+               (lambda (in out)
+                 (let loop ((line (read-line in 'concat))
+                            (skipping? #f))
+                   (if (eof-object? line)
+                       #t
+                       (let ((skip-next?
+                              (or (and skipping?
+                                       (not (string-prefix?
+                                             "#endif //USE_SVMLIGHT" line)))
+                                  (string-prefix?
+                                   "#ifdef USE_SVMLIGHT" line))))
+                         (when (or (not skipping?)
+                                   (and skipping? (not skip-next?)))
+                           (display line out))
+                         (loop (read-line in 'concat) skip-next?)))))))
+           (for-each delete-ifdefs (find-files "src/shogun/kernel/"
+                                               "^Kernel\\.(cpp|h)"))))))
     (build-system cmake-build-system)
     (arguments
      '(#:tests? #f ;no check target