guix-devel
[Top][All Lists]
Advanced

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

[PATCH] gnu: Add NetSurf.


From: ericbavier
Subject: [PATCH] gnu: Add NetSurf.
Date: Thu, 11 Aug 2016 07:59:15 -0500

From: Eric Bavier <address@hidden>

* gnu/packages/web.scm (netsurf): New variable.
---
 gnu/packages/web.scm | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 111 insertions(+)

diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
index fa791ff..1d0c97e 100644
--- a/gnu/packages/web.scm
+++ b/gnu/packages/web.scm
@@ -52,12 +52,17 @@
   #:use-module (gnu packages compression)
   #:use-module (gnu packages cyrus-sasl)
   #:use-module (gnu packages databases)
+  #:use-module (gnu packages bison)
+  #:use-module (gnu packages flex)
   #:use-module (gnu packages mit-krb5)
   #:use-module (gnu packages gd)
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages gnome)
+  #:use-module (gnu packages gperf)
+  #:use-module (gnu packages gtk)
   #:use-module (gnu packages icu4c)
+  #:use-module (gnu packages image)
   #:use-module (gnu packages lua)
   #:use-module (gnu packages base)
   #:use-module (gnu packages perl)
@@ -3385,3 +3390,109 @@ playback of HTTP request/response traces.")
 can easily be invoked on a single file.  Your partner can access the file with
 tools they trust (e.g. wget).")
     (license l:gpl2+)))
+
+(define-public netsurf
+  (package
+    (name "netsurf")
+    (version "3.5")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://download.netsurf-browser.org/";
+                           "netsurf/releases/source-full/netsurf-all-"
+                           version ".tar.gz"))
+       (sha256
+        (base32
+         "1vdldzcv42wykajmw8vbql0f1yd44gbx30kywfrrh2x3064ly609"))
+       (modules '((guix build utils)))
+       (snippet
+        '(begin
+           (substitute* "Makefile"
+             ;; Do not clobber PKG_CONFIG_PATH from the environment
+             (("PKG_CONFIG_PATH = \\$")
+              "PKG_CONFIG_PATH := $(PKG_CONFIG_PATH):$")
+             ;; Honor make variables
+             (("shell cc") "shell $(CC)"))))))
+    (build-system glib-or-gtk-build-system)
+    (native-inputs
+     `(("pkg-config" ,pkg-config)
+       ("perl" ,perl)
+       ("perl-html-parser" ,perl-html-parser)
+       ("flex" ,flex)
+       ("bison" ,bison)))
+    (inputs
+     `(("gtk+" ,gtk+-2)
+       ("gperf" ,gperf)
+       ("curl" ,curl)
+       ("openssl" ,openssl)
+       ("libpng" ,libpng)
+       ("libjpeg" ,libjpeg)
+       ("expat" ,expat)))
+    (arguments
+     `(#:make-flags `("CC=gcc" "BUILD_CC=gcc"
+                      ,(string-append "PREFIX=" %output))
+       #:parallel-build? #f             ;parallel builds not supported
+       #:tests? #f                      ;TODO
+       #:phases
+       (modify-phases %standard-phases
+         (replace 'configure
+           (lambda* (#:key outputs #:allow-other-keys)
+             (call-with-output-file "netsurf/Makefile.config"
+               (lambda (port)
+                 (format port "~
+                         NETSURF_GTK_RESOURCES := $(PREFIX)/share/netsurf/~@
+                         ")))
+             #t))
+         (add-after 'build 'adjust-welcome
+           (lambda* _
+             (use-modules (sxml simple))
+             ;; First, fix some unended tags and simple substitutions
+             (substitute* "netsurf/gtk/res/welcome.html"
+               (("<(img|input)([^>]*)>" _ tag contents)
+                (string-append "<" tag contents " />"))
+               (("Licence") "License") ;prefer GNU spelling
+               ((" open source") ", free software")
+               ;; Prefer privacy-respecting default search engine
+               (("www.google.co.uk") "www.duckduckgo.com")
+               (("Google Search") "DuckDuckGo Search"))
+             ;; TODO: Are the search inputs appropriate?
+             ;; Remove default links so it doesn't seem we're endorsing them
+             (with-atomic-file-replacement "netsurf/gtk/res/welcome.html"
+               (lambda (in out)
+                 ;; Leave the DOCTYPE header as is
+                 (display (read-line in 'concat) out)
+                 (sxml->xml
+                  (let rec ((sxml
+                             (xml->sxml in #:entities '((nbsp . "\xa0")))))
+                    ;; We'd like to use sxml-match here, but it can't
+                    ;; match against generic tag symbols...
+                    (match sxml
+                      (('div ('@ ('class "links")) . rest)
+                       '())
+                      ((head tail ...)
+                       (cons (rec head) (map rec tail)))
+                      (x x)))
+                  out)))
+             #t))
+         (add-after 'install 'install-more
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (desktop (string-append out "/share/applications/"
+                                            "netsurf.desktop")))
+               (mkdir-p (dirname desktop))
+               (copy-file "netsurf/gtk/res/netsurf-gtk.desktop"
+                          desktop)
+               (substitute* desktop
+                 (("netsurf-gtk") (string-append out "/bin/netsurf"))
+                 (("netsurf.png") (string-append out "/share/netsurf/"
+                                                 "netsurf.xpm")))
+               (install-file "netsurf/Docs/netsurf-gtk.1"
+                             (string-append out "/share/man/man1/"))
+               #t))))))
+    (home-page "https://www.netsurf-browser.org";)
+    (synopsis "Web browser")
+    (description
+     "NetSurf is a web browser.  NetSurf has its own layout and rendering
+engine entirely written from scratch.  It is small and capable of handling
+many of the web standards in use today.")
+    (license l:gpl2+)))
-- 
2.9.2




reply via email to

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