summary refs log tree commit diff
path: root/gnu/packages/wicd.scm
blob: c66e4b0ed3807d02cb8743ef5294af3c8b3c607a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2015 Pierre-Antoine Rault <par@rigelk.eu>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages wicd)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix build-system python)
  #:use-module (guix licenses)
  #:use-module (guix utils)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages admin)
  #:use-module (gnu packages python))

(define-public wicd
  (package
    (name "wicd")
    (version "1.7.3")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://launchpad.net/wicd/"
                           (version-major+minor version) "/" version
                           "/+download/wicd-" version ".tar.gz"))
       (sha256
        (base32 "00c4rq753bhg64rv1v9yl834ssq7igyy7cz3swp287b5n5bqiqwi"))))
    (build-system python-build-system)
    (native-inputs `(("gettext" ,gnu-gettext)))
    (inputs `(("dbus" ,dbus)
              ("dbus-glib" ,dbus-glib)
              ("python2-dbus" ,python2-dbus)
              ("python2-pygtk" ,python2-pygtk)
              ("python2-urwid" ,python2-urwid)
              ("python2-babel" ,python2-babel)
              ("wireless-tools" ,wireless-tools)
              ("wpa-supplicant" ,wpa-supplicant)
              ("net-tools" ,net-tools)
              ("isc-dhcp" ,isc-dhcp)
              ("iproute" ,iproute)))
    (arguments
     `(#:python ,python-2
       #:tests? #f                      ; test suite requires networking
       #:phases
       (alist-cons-before
        'build 'configure
        (lambda* (#:key inputs outputs #:allow-other-keys)
          (let ((out (assoc-ref outputs "out"))
                (python (assoc-ref inputs "python")))
            (define (which* cmd)
              (cond ((string=? cmd "ping")
                     "/run/setuid-programs/ping")
                    ((which cmd)
                     => identity)
                    (else
                     (format (current-error-port)
                             "WARNING: Unable to find absolute path for ~s~%"
                             cmd)
                     #f)))
            (substitute* "setup.py"
              ;; The handling of unrecognized distros in setup.py is
              ;; broken.  Work around the problem.
              (("\\('init=', " all)
               (string-append "#" all))
              ;; Inhibit attempts to install in /var or /etc.
              (("\\(wpath\\.(log|etc|networks|.*scripts), " all)
               (string-append "#" all)))

            ;; Patch references to subprograms with absolute pathnames.
            (substitute* "wicd/wnettools.py"
              (("(misc\\.Run\\(\\[?[\"'])([^\"' ]*)" all pre cmd)
               (string-append pre (which* cmd)))
              (("(self\\._find_program_path|misc\\.find_path)\\([\"']([^\"']*)[\"']\\)"
                all dummy cmd)
               (let ((pathname (which* cmd)))
                 (if pathname
                     (string-append "'" pathname "'")
                     "None")))
              (("([\"'])(ifconfig|route|wpa_cli|wpa_supplicant|iwconfig|iwpriv|iwlist|ping)"
                all open-quote cmd)
               (string-append open-quote (which* cmd))))

            ;; setup.py cannot cope without LANG
            (setenv "LANG" "C")

            (let ((params
                   (list
                    (string-append "--python=" python "/bin/python")
                    "--no-install-init"
                    "--no-install-docs"
                    "--no-install-acpi"
                    "--no-install-pmutils"
                    "--no-install-kde"
                    "--no-install-gnome-shell-extensions"

                    "--distro=guixsd"
                    "--wicdgroup=netdev"
                    "--loggroup=root"
                    "--logperms=0640"

                    ;; XXX setup.py configure asks us to pass --init=,
                    ;; but if we do it says "no such option 'init'".
                    ;; (string-append "--init=" out "/etc/init.d")

                    (string-append "--initfile=" out "/etc/init.d/wicd")
                    (string-append "--lib=" out "/lib/wicd")
                    (string-append "--share=" out "/share/wicd")

                    "--etc=/etc/wicd"
                    "--scripts=/etc/wicd/scripts"
                    "--pmutils=/etc/pm-utils/sleep.d"

                    (string-append "--encryption="
                                   out "/etc/encryption/templates")
                    (string-append "--bin=" out "/bin")
                    (string-append "--sbin=" out "/sbin")
                    (string-append "--daemon=" out "/share/wicd/daemon")
                    (string-append "--backends=" out "/share/wicd/backends")
                    (string-append "--curses=" out "/share/wicd/curses")
                    (string-append "--gtk=" out "/share/wicd/gtk")
                    (string-append "--cli=" out "/share/wicd/cli")
                    (string-append "--gnome-shell-extensions="
                                   out "/share/gnome-shell-extensions")
                    (string-append "--icons=" out "/share/icons/hicolor")
                    (string-append "--pixmaps=" out "/share/pixmaps")
                    (string-append "--images=" out "/share/wicd/icons")
                    (string-append "--dbus=" out "/etc/dbus-1/system.d")
                    (string-append "--dbus-service="
                                   out "/share/dbus-1/system-services")
                    (string-append "--systemd=" out "/lib/systemd/system")
                    (string-append "--logrotate=" out "/etc/logrotate.d")
                    (string-append "--desktop=" out "/share/applications")
                    (string-append "--translations=" out "/share/locale")
                    (string-append "--autostart=" out "/etc/xdg/autostart")
                    (string-append "--docdir=" out "/share/doc/wicd")
                    (string-append "--mandir=" out "/share/man")
                    (string-append "--kdedir=" out "/share/autostart"))))
              (format #t
                      "running ~s with command ~s and parameters ~s~%"
                      "python setup.py" "configure" params)
              (zero? (apply system* "python" "setup.py" "configure" params)))))
        (alist-cons-after
         'install 'install-dhclient.conf.template.default
         (lambda* (#:key outputs #:allow-other-keys)
           ;; wicd's installer tries to put dhclient.conf.template.default
           ;; in /etc/wicd/other, which is not available in the build
           ;; environment, so here we install it manually in the output
           ;; directory.
           (let* ((out (assoc-ref outputs "out"))
                  (dest-dir (string-append out "/etc/wicd"))
                  (name "dhclient.conf.template.default"))
             (mkdir-p dest-dir)
             (copy-file (string-append "other/" name)
                        (string-append dest-dir "/" name))
             #t))
         %standard-phases))))
    (synopsis "Network connection manager")
    (description "Wicd is a network manager that aims to simplify wired and
wireless networking.")
    (home-page "https://launchpad.net/wicd")
    (license gpl2+)))