gnu: Add iptables.
[jackhill/guix/guix.git] / gnu / packages / linux.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
4 ;;;
5 ;;; This file is part of GNU Guix.
6 ;;;
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
11 ;;;
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
16 ;;;
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20 (define-module (gnu packages linux)
21 #:use-module (guix licenses)
22 #:use-module (gnu packages)
23 #:use-module ((gnu packages compression)
24 #:renamer (symbol-prefix-proc 'guix:))
25 #:use-module (gnu packages flex)
26 #:use-module (gnu packages libusb)
27 #:use-module (gnu packages ncurses)
28 #:use-module (gnu packages perl)
29 #:use-module (gnu packages pkg-config)
30 #:use-module (guix packages)
31 #:use-module (guix download)
32 #:use-module (guix build-system gnu))
33
34 (define-public (system->linux-architecture arch)
35 "Return the Linux architecture name for ARCH, a Guix system name such as
36 \"x86_64-linux\"."
37 (let ((arch (car (string-split arch #\-))))
38 (cond ((string=? arch "i686") "i386")
39 ((string-prefix? "mips" arch) "mips")
40 ((string-prefix? "arm" arch) "arm")
41 (else arch))))
42
43 (define-public linux-libre-headers
44 (let* ((version* "3.3.8")
45 (build-phase
46 (lambda (arch)
47 `(lambda _
48 (setenv "ARCH" ,(system->linux-architecture arch))
49 (format #t "`ARCH' set to `~a'~%" (getenv "ARCH"))
50
51 (and (zero? (system* "make" "defconfig"))
52 (zero? (system* "make" "mrproper" "headers_check"))))))
53 (install-phase
54 `(lambda* (#:key outputs #:allow-other-keys)
55 (let ((out (assoc-ref outputs "out")))
56 (and (zero? (system* "make"
57 (string-append "INSTALL_HDR_PATH=" out)
58 "headers_install"))
59 (mkdir (string-append out "/include/config"))
60 (call-with-output-file
61 (string-append out
62 "/include/config/kernel.release")
63 (lambda (p)
64 (format p "~a-default~%" ,version*))))))))
65 (package
66 (name "linux-libre-headers")
67 (version version*)
68 (source (origin
69 (method url-fetch)
70 (uri (string-append
71 "http://linux-libre.fsfla.org/pub/linux-libre/releases/3.3.8-gnu/linux-libre-"
72 version "-gnu.tar.xz"))
73 (sha256
74 (base32
75 "0jkfh0z1s6izvdnc3njm39dhzp1cg8i06jv06izwqz9w9qsprvnl"))))
76 (build-system gnu-build-system)
77 (native-inputs `(("perl" ,perl)))
78 (arguments
79 `(#:modules ((guix build gnu-build-system)
80 (guix build utils)
81 (srfi srfi-1)
82 ,@(if (%current-target-system)
83 '((guix build gnu-cross-build))
84 '()))
85 #:phases (alist-replace
86 'build ,(build-phase (%current-system))
87 (alist-replace
88 'install ,install-phase
89 (alist-delete 'configure
90 ,(if (%current-target-system)
91 '%standard-cross-phases
92 '%standard-phases))))
93 #:tests? #f))
94 (synopsis "GNU Linux-Libre kernel headers")
95 (description "Headers of the Linux-Libre kernel.")
96 (license gpl2)
97 (home-page "http://www.gnu.org/software/linux-libre/"))))
98
99 (define-public module-init-tools
100 (package
101 (name "module-init-tools")
102 (version "3.16")
103 (source (origin
104 (method url-fetch)
105 (uri (string-append
106 "mirror://kernel.org/linux/utils/kernel/module-init-tools/module-init-tools-"
107 version ".tar.bz2"))
108 (sha256
109 (base32
110 "0jxnz9ahfic79rp93l5wxcbgh4pkv85mwnjlbv1gz3jawv5cvwp1"))))
111 (build-system gnu-build-system)
112 (inputs
113 ;; The upstream tarball lacks man pages, and building them would require
114 ;; DocBook & co. Thus, use Gentoo's pre-built man pages.
115 `(("man-pages"
116 ,(origin
117 (method url-fetch)
118 (uri (string-append
119 "http://distfiles.gentoo.org/distfiles/module-init-tools-" version
120 "-man.tar.bz2"))
121 (sha256
122 (base32
123 "1j1nzi87kgsh4scl645fhwhjvljxj83cmdasa4n4p5krhasgw358"))))))
124 (arguments
125 '(#:phases (alist-cons-before
126 'unpack 'unpack-man-pages
127 (lambda* (#:key inputs #:allow-other-keys)
128 (let ((man-pages (assoc-ref inputs "man-pages")))
129 (zero? (system* "tar" "xvf" man-pages))))
130 %standard-phases)))
131 (home-page "http://www.kernel.org/pub/linux/utils/kernel/module-init-tools/")
132 (synopsis "Tools for loading and managing Linux kernel modules")
133 (description
134 "Tools for loading and managing Linux kernel modules, such as `modprobe',
135 `insmod', `lsmod', and more.")
136 (license gpl2+)))
137
138 (define-public linux-libre
139 (let* ((version* "3.3.8")
140 (build-phase
141 '(lambda* (#:key system #:allow-other-keys #:rest args)
142 (let ((arch (car (string-split system #\-))))
143 (setenv "ARCH"
144 (cond ((string=? arch "i686") "i386")
145 (else arch)))
146 (format #t "`ARCH' set to `~a'~%" (getenv "ARCH")))
147
148 (let ((build (assoc-ref %standard-phases 'build)))
149 (and (zero? (system* "make" "defconfig"))
150 (begin
151 (format #t "enabling additional modules...~%")
152 (substitute* ".config"
153 (("^# CONFIG_CIFS.*$")
154 "CONFIG_CIFS=m\n"))
155 (zero? (system* "make" "oldconfig")))
156
157 ;; Call the default `build' phase so `-j' is correctly
158 ;; passed.
159 (apply build #:make-flags "all" args)))))
160 (install-phase
161 `(lambda* (#:key inputs outputs #:allow-other-keys)
162 (let* ((out (assoc-ref outputs "out"))
163 (moddir (string-append out "/lib/modules"))
164 (mit (assoc-ref inputs "module-init-tools")))
165 (mkdir-p moddir)
166 (for-each (lambda (file)
167 (copy-file file
168 (string-append out "/" (basename file))))
169 (find-files "." "^(bzImage|System\\.map)$"))
170 (copy-file ".config" (string-append out "/config"))
171 (zero? (system* "make"
172 (string-append "DEPMOD=" mit "/sbin/depmod")
173 (string-append "MODULE_DIR=" moddir)
174 (string-append "INSTALL_PATH=" out)
175 (string-append "INSTALL_MOD_PATH=" out)
176 "modules_install"))))))
177 (package
178 (name "linux-libre")
179 (version version*)
180 (source (origin
181 (method url-fetch)
182 (uri (string-append
183 "http://linux-libre.fsfla.org/pub/linux-libre/releases/3.3.8-gnu/linux-libre-"
184 version "-gnu.tar.xz"))
185 (sha256
186 (base32
187 "0jkfh0z1s6izvdnc3njm39dhzp1cg8i06jv06izwqz9w9qsprvnl"))))
188 (build-system gnu-build-system)
189 (native-inputs `(("perl" ,perl)
190 ("module-init-tools" ,module-init-tools)))
191 (arguments
192 `(#:modules ((guix build gnu-build-system)
193 (guix build utils)
194 (srfi srfi-1)
195 (ice-9 match))
196 #:phases (alist-replace
197 'build ,build-phase
198 (alist-replace
199 'install ,install-phase
200 (alist-delete 'configure %standard-phases)))
201 #:tests? #f))
202 (synopsis "100% free redistribution of a cleaned Linux kernel")
203 (description "Linux-Libre operating system kernel.")
204 (license gpl2)
205 (home-page "http://www.gnu.org/software/linux-libre/"))))
206
207 (define-public linux-pam
208 (package
209 (name "linux-pam")
210 (version "1.1.6")
211 (source
212 (origin
213 (method url-fetch)
214 (uri (list (string-append "http://www.linux-pam.org/library/Linux-PAM-"
215 version ".tar.bz2")
216 (string-append "mirror://kernel.org/linux/libs/pam/library/Linux-PAM-"
217 version ".tar.bz2")))
218 (sha256
219 (base32
220 "1hlz2kqvbjisvwyicdincq7nz897b9rrafyzccwzqiqg53b8gf5s"))))
221 (build-system gnu-build-system)
222 (inputs
223 `(("flex" ,flex)
224
225 ;; TODO: optional dependencies
226 ;; ("libxcrypt" ,libxcrypt)
227 ;; ("cracklib" ,cracklib)
228 ))
229 (arguments
230 ;; XXX: Tests won't run in chroot, presumably because /etc/pam.d
231 ;; isn't available.
232 '(#:tests? #f))
233 (home-page "http://www.linux-pam.org/")
234 (synopsis "Pluggable authentication modules for Linux")
235 (description
236 "A *Free* project to implement OSF's RFC 86.0.
237 Pluggable authentication modules are small shared object files that can
238 be used through the PAM API to perform tasks, like authenticating a user
239 at login. Local and dynamic reconfiguration are its key features")
240 (license bsd-3)))
241
242 (define-public psmisc
243 (package
244 (name "psmisc")
245 (version "22.20")
246 (source
247 (origin
248 (method url-fetch)
249 (uri (string-append "mirror://sourceforge/psmisc/psmisc/psmisc-"
250 version ".tar.gz"))
251 (sha256
252 (base32
253 "052mfraykmxnavpi8s78aljx8w87hyvpx8mvzsgpjsjz73i28wmi"))))
254 (build-system gnu-build-system)
255 (inputs `(("ncurses" ,ncurses)))
256 (home-page "http://psmisc.sourceforge.net/")
257 (synopsis
258 "set of utilities that use the proc filesystem, such as fuser, killall, and pstree")
259 (description
260 "This PSmisc package is a set of some small useful utilities that
261 use the proc filesystem. We're not about changing the world, but
262 providing the system administrator with some help in common tasks.")
263 (license gpl2+)))
264
265 (define-public util-linux
266 (package
267 (name "util-linux")
268 (version "2.21")
269 (source
270 (origin
271 (method url-fetch)
272 (uri (string-append "mirror://kernel.org/linux/utils/"
273 name "/v" version "/"
274 name "-" version ".2" ".tar.xz"))
275 (sha256
276 (base32
277 "1rpgghf7n0zx0cdy8hibr41wvkm2qp1yvd8ab1rxr193l1jmgcir"))))
278 (build-system gnu-build-system)
279 (arguments
280 `(#:configure-flags '("--disable-use-tty-group")
281 #:phases (alist-cons-after
282 'install 'patch-chkdupexe
283 (lambda* (#:key outputs #:allow-other-keys)
284 (let ((out (assoc-ref outputs "out")))
285 (substitute* (string-append out "/bin/chkdupexe")
286 ;; Allow 'patch-shebang' to do its work.
287 (("@PERL@") "/bin/perl"))))
288 %standard-phases)))
289 (inputs `(("zlib" ,guix:zlib)
290 ("ncurses" ,ncurses)
291 ("perl" ,perl)))
292 (home-page "https://www.kernel.org/pub/linux/utils/util-linux/")
293 (synopsis "Collection of utilities for the Linux kernel")
294 (description
295 "util-linux is a random collection of utilities for the Linux kernel.")
296
297 ;; Note that util-linux doesn't use the same license for all the
298 ;; code. GPLv2+ is the default license for a code without an
299 ;; explicitly defined license.
300 (license (list gpl3+ gpl2+ gpl2 lgpl2.0+
301 bsd-4 public-domain))))
302
303 (define-public procps
304 (package
305 (name "procps")
306 (version "3.2.8")
307 (source (origin
308 (method url-fetch)
309 (uri (string-append "http://procps.sourceforge.net/procps-"
310 version ".tar.gz"))
311 (sha256
312 (base32
313 "0d8mki0q4yamnkk4533kx8mc0jd879573srxhg6r2fs3lkc6iv8i"))))
314 (build-system gnu-build-system)
315 (inputs `(("ncurses" ,ncurses)
316 ("patch/make-3.82" ,(search-patch "procps-make-3.82.patch"))))
317 (arguments
318 '(#:patches (list (assoc-ref %build-inputs "patch/make-3.82"))
319 #:phases (alist-replace
320 'configure
321 (lambda* (#:key outputs #:allow-other-keys)
322 ;; No `configure', just a single Makefile.
323 (let ((out (assoc-ref outputs "out")))
324 (substitute* "Makefile"
325 (("/usr/") "/")
326 (("--(owner|group) 0") "")
327 (("ldconfig") "true")
328 (("^LDFLAGS[[:blank:]]*:=(.*)$" _ value)
329 ;; Add libproc to the RPATH.
330 (string-append "LDFLAGS := -Wl,-rpath="
331 out "/lib" value))))
332 (setenv "CC" "gcc"))
333 (alist-replace
334 'install
335 (lambda* (#:key outputs #:allow-other-keys)
336 (let ((out (assoc-ref outputs "out")))
337 (and (zero?
338 (system* "make" "install"
339 (string-append "DESTDIR=" out)))
340
341 ;; Sanity check.
342 (zero?
343 (system* (string-append out "/bin/ps")
344 "--version")))))
345 %standard-phases))
346
347 ;; What did you expect? Tests?
348 #:tests? #f))
349 (home-page "http://procps.sourceforge.net/")
350 (synopsis "Utilities that give information about processes")
351 (description
352 "procps is the package that has a bunch of small useful utilities
353 that give information about processes using the Linux /proc file system.
354 The package includes the programs ps, top, vmstat, w, kill, free,
355 slabtop, and skill.")
356 (license gpl2)))
357
358 (define-public usbutils
359 (package
360 (name "usbutils")
361 (version "006")
362 (source
363 (origin
364 (method url-fetch)
365 (uri (string-append "mirror://kernel.org/linux/utils/usb/usbutils/"
366 "usbutils-" version ".tar.xz"))
367 (sha256
368 (base32
369 "03pd57vv8c6x0hgjqcbrxnzi14h8hcghmapg89p8k5zpwpkvbdfr"))))
370 (build-system gnu-build-system)
371 (inputs
372 `(("libusb" ,libusb) ("pkg-config" ,pkg-config)))
373 (home-page "http://www.linux-usb.org/")
374 (synopsis
375 "Tools for working with USB devices, such as lsusb")
376 (description
377 "Tools for working with USB devices, such as lsusb.")
378 (license gpl2+)))
379
380 (define-public e2fsprogs
381 (package
382 (name "e2fsprogs")
383 (version "1.42.7")
384 (source (origin
385 (method url-fetch)
386 (uri (string-append "mirror://sourceforge/e2fsprogs/e2fsprogs-"
387 version ".tar.gz"))
388 (sha256
389 (base32
390 "0ibkkvp6kan0hn0d1anq4n2md70j5gcm7mwna515w82xwyr02rfw"))))
391 (build-system gnu-build-system)
392 (inputs `(("util-linux" ,util-linux)
393 ("pkg-config" ,pkg-config)))
394 (arguments
395 '(#:phases (alist-cons-before
396 'configure 'patch-shells
397 (lambda _
398 (substitute* "configure"
399 (("/bin/sh (.*)parse-types.sh" _ dir)
400 (string-append (which "sh") " " dir
401 "parse-types.sh")))
402 (substitute* (find-files "." "^Makefile.in$")
403 (("#!/bin/sh")
404 (string-append "#!" (which "sh")))))
405 %standard-phases)
406
407 ;; FIXME: Tests work by comparing the stdout/stderr of programs, that
408 ;; they fail because we get an extra line that says "Can't check if
409 ;; filesystem is mounted due to missing mtab file".
410 #:tests? #f))
411 (home-page "http://e2fsprogs.sourceforge.net/")
412 (synopsis "Creating and checking ext2/ext3/ext4 file systems")
413 (description
414 "This package provides tools for manipulating ext2/ext3/ext4 file systems.")
415 (license (list gpl2 ; programs
416 lgpl2.0 ; libext2fs
417 x11)))) ; libuuid
418
419 (define-public strace
420 (package
421 (name "strace")
422 (version "4.7")
423 (source (origin
424 (method url-fetch)
425 (uri (string-append "mirror://sourceforge/strace/strace-"
426 version ".tar.xz"))
427 (sha256
428 (base32
429 "158iwk0pl2mfw93m1843xb7a2zb8p6lh0qim07rca6f1ff4dk764"))))
430 (build-system gnu-build-system)
431 (inputs `(("perl" ,perl)))
432 (home-page "http://strace.sourceforge.net/")
433 (synopsis "System call tracer for Linux")
434 (description
435 "strace is a system call tracer, i.e. a debugging tool which prints out a
436 trace of all the system calls made by a another process/program.")
437 (license bsd-3)))
438
439 (define-public alsa-lib
440 (package
441 (name "alsa-lib")
442 (version "1.0.27.1")
443 (source (origin
444 (method url-fetch)
445 (uri (string-append
446 "ftp://ftp.alsa-project.org/pub/lib/alsa-lib-"
447 version ".tar.bz2"))
448 (sha256
449 (base32
450 "0fx057746dj7rjdi0jnvx2m9b0y1lgdkh1hks87d8w32xyihf3k9"))))
451 (build-system gnu-build-system)
452 (home-page "http://www.alsa-project.org/")
453 (synopsis "The Advanced Linux Sound Architecture libraries")
454 (description
455 "The Advanced Linux Sound Architecture (ALSA) provides audio and
456 MIDI functionality to the Linux-based operating system.")
457 (license lgpl2.1+)))
458
459 (define-public iptables
460 (package
461 (name "iptables")
462 (version "1.4.16.2")
463 (source (origin
464 (method url-fetch)
465 (uri (string-append
466 "http://www.netfilter.org/projects/iptables/files/iptables-"
467 version ".tar.bz2"))
468 (sha256
469 (base32
470 "0vkg5lzkn4l3i1sm6v3x96zzvnv9g7mi0qgj6279ld383mzcws24"))))
471 (build-system gnu-build-system)
472 (arguments '(#:tests? #f)) ; no test suite
473 (home-page "http://www.netfilter.org/projects/iptables/index.html")
474 (synopsis "Program to configure the Linux IP packet filtering rules")
475 (description
476 "iptables is the userspace command line program used to configure the
477 Linux 2.4.x and later IPv4 packet filtering ruleset. It is targeted towards
478 system administrators. Since Network Address Translation is also configured
479 from the packet filter ruleset, iptables is used for this, too. The iptables
480 package also includes ip6tables. ip6tables is used for configuring the IPv6
481 packet filter.")
482 (license gpl2+)))