all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Help with substitute*
@ 2018-11-13 21:29 swedebugia
  2018-11-14  3:07 ` Mark H Weaver
  0 siblings, 1 reply; 2+ messages in thread
From: swedebugia @ 2018-11-13 21:29 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 160 bytes --]

Hi

I refactored my substitute* into that below.
Now it runs without substitute anything :S

Can some of you spot the error causing this?
-- 
Cheers
Swedebugia

[-- Attachment #2: 0001-gnu-Add-ufw.patch --]
[-- Type: text/x-patch, Size: 2808 bytes --]

From ad2a9291cefeed2f2e7294b1608b1e067bdf06f6 Mon Sep 17 00:00:00 2001
From: swedebugia <swedebugia@riseup.net>
Date: Sat, 10 Nov 2018 21:39:04 +0100
Subject: [PATCH] gnu: Add ufw

* gnu/packages/networking.scm: New variable.
---
 gnu/packages/networking.scm | 45 +++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gnu/packages/networking.scm b/gnu/packages/networking.scm
index 5504742fa..5d9110138 100644
--- a/gnu/packages/networking.scm
+++ b/gnu/packages/networking.scm
@@ -2262,3 +2262,48 @@ allow all other machines, without direct access to that network, to be relayed
 through the machine the Dante server is running on.  The external network will
 never see any machines other than the one Dante is running on.")
     (license (license:non-copyleft "file://LICENSE"))))
+
+(define-public ufw
+  ;; Select the branch named "release/0.35":
+  (let* ((commit "fd93d37a782d4f736201df508fb86e72641874d8"))
+    (package
+    (name "ufw")
+    (version "0.35")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://git.launchpad.net/ufw")
+                    (commit commit)))
+              (sha256
+               (base32
+                "10r2ga1w5vmg8m4z5yim01cd0g8cs6ws2h65vaj6ilg8yp8d90f9"))
+              (file-name (git-file-name name version))))
+    (build-system python-build-system)
+    (inputs `(("iptables" ,iptables)))
+    (arguments
+     ;; FIXME: All tests fail with: ModuleNotFoundError: No module named
+     ;; 'ufw'
+     `(#:tests? #f
+       #:use-setuptools? #f
+       #:phases (modify-phases %standard-phases
+         (add-before 'build 'fix-paths
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (iptables (assoc-ref inputs "iptables")))
+               (substitute* "setup.py"
+                (("iptables_exe = ''")
+                 (string-append "iptables_exe = '" iptables "/sbin/iptables'"))
+                (("iptables_dir = ''")
+                 (string-append "iptables_dir = '" iptables  "/sbin/'"))
+                (("real_confdir = os.path.join('/etc')")
+                 (string-append "real_confdir = '" out  "/etc/'"))
+                (("real_statedir = os.path.join('/lib', 'ufw')")
+                 (string-append "real_statedir = '" out "/lib/ufw'"))))
+             #t)))))
+    (home-page "https://launchpad.net/ufw")
+    (synopsis "Uncomplicated firewall")
+    (description "Uncomplicated Firewall (UFW) is a program for managing a
+netfilter firewall designed to be easy to use.  It uses a command-line
+interface consisting of a small number of simple commands, and uses iptables
+for configuration.")
+    (license license:gpl3))))
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: Help with substitute*
  2018-11-13 21:29 Help with substitute* swedebugia
@ 2018-11-14  3:07 ` Mark H Weaver
  0 siblings, 0 replies; 2+ messages in thread
From: Mark H Weaver @ 2018-11-14  3:07 UTC (permalink / raw)
  To: swedebugia; +Cc: guix-devel

Hi,

swedebugia <swedebugia@riseup.net> writes:
> I refactored my substitute* into that below.
> Now it runs without substitute anything :S

Actually, the first two substitutions worked, but not the latter two.
See below.

> +               (substitute* "setup.py"
> +                (("iptables_exe = ''")
> +                 (string-append "iptables_exe = '" iptables "/sbin/iptables'"))
> +                (("iptables_dir = ''")
> +                 (string-append "iptables_dir = '" iptables  "/sbin/'"))
> +                (("real_confdir = os.path.join('/etc')")
> +                 (string-append "real_confdir = '" out  "/etc/'"))
> +                (("real_statedir = os.path.join('/lib', 'ufw')")
> +                 (string-append "real_statedir = '" out "/lib/ufw'"))))

In the latter two substitutions above, the parentheses '(' and ')' are
special characters in regular expression syntax.  In order to avoid
their special meaning, and match actual parentheses, you need to escape
them by preceding each with a backslash.  However, backslash is also a
special character in Scheme string literal syntax, so you need to put
two backslashes to get a single backslash in the actual string.  So, it
should look like this:

--8<---------------cut here---------------start------------->8---
  (substitute* "setup.py"
   (("iptables_exe = ''")
    (string-append "iptables_exe = '" iptables "/sbin/iptables'"))
   (("iptables_dir = ''")
    (string-append "iptables_dir = '" iptables  "/sbin/'"))
   (("real_confdir = os.path.join\\('/etc'\\)")
    (string-append "real_confdir = '" out  "/etc/'"))
   (("real_statedir = os.path.join\\('/lib', 'ufw'\\)")
    (string-append "real_statedir = '" out "/lib/ufw'"))))
--8<---------------cut here---------------end--------------->8---

With this change, the package builds, although I haven't done any
further testing.

      Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-14  3:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-13 21:29 Help with substitute* swedebugia
2018-11-14  3:07 ` Mark H Weaver

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.