guix-devel
[Top][All Lists]
Advanced

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

Re: [PATCH]: gnu: shogun: Remove non-free source files.


From: Ricardo Wurmus
Subject: Re: [PATCH]: gnu: shogun: Remove non-free source files.
Date: Thu, 21 May 2015 11:59:00 +0200

Attached is a patch to remove non-free source files as well as anything
in a "#ifdef USE_SVMLIGHT ... #endif" block.

>From d409756bd2fc2db396d6257cfed42a213f6f43f6 Mon Sep 17 00:00:00 2001
From: Ricardo Wurmus <address@hidden>
Date: Fri, 8 May 2015 16:53:28 +0200
Subject: [PATCH] gnu: shogun: Remove non-free source files.

* gnu/packages/bioinformatics.scm (shogun)[source]: Add snippet to remove
  non-free sources.
---
 gnu/packages/bioinformatics.scm | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/bioinformatics.scm b/gnu/packages/bioinformatics.scm
index fa7ff4c..e1dfda1 100644
--- a/gnu/packages/bioinformatics.scm
+++ b/gnu/packages/bioinformatics.scm
@@ -1605,7 +1605,41 @@ 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.
+           (for-each
+            (lambda (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?)))))))
+            (find-files "src/shogun/kernel/"
+                        "^Kernel\\.(cpp|h)"))))))
     (build-system cmake-build-system)
     (arguments
      '(#:tests? #f ;no check target
-- 
2.1.0


reply via email to

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