projects/guix·blob version-0.10.0 · refs

258 lines · 11.5 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014, 2015, 2016 Eric Bavier <[email protected]>
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19(define-module (gnu packages debug)
20 #:use-module (guix packages)
21 #:use-module (guix licenses)
22 #:use-module (guix download)
23 #:use-module (guix utils)
24 #:use-module (guix build-system gnu)
25 #:use-module (gnu packages bash)
26 #:use-module (gnu packages flex)
27 #:use-module (gnu packages indent)
28 #:use-module (gnu packages llvm)
29 #:use-module (gnu packages perl)
30 #:use-module (gnu packages pretty-print)
31 #:use-module (gnu packages qemu)
32 #:use-module (ice-9 match)
33 #:use-module (srfi srfi-1))
34
35(define-public delta
36 (package
37 (name "delta")
38 (version "2006.08.03")
39 (source
40 (origin
41 (method url-fetch)
42 (uri (list
43 (string-append "http://ftp.de.debian.org/debian/pool/main/d/delta/"
44 "delta_" version ".orig.tar.gz")
45 ;; This uri seems to send guix download into an infinite loop
46 (string-append "http://delta.tigris.org/files/documents/3103/"
47 "33566/delta-" version ".tar.gz")))
48 (sha256
49 (base32
50 "184wh35pf2ddx97319s6sgkzpz48xxkbwzcjpycv009bm53lh61q"))))
51 (build-system gnu-build-system)
52 (inputs ;Installed programs are perl scripts
53 `(("perl" ,perl)))
54 (arguments
55 `(#:phases
56 (alist-replace
57 'install
58 (lambda* (#:key outputs #:allow-other-keys)
59 ;; Makefile contains no install target
60 (let* ((out (assoc-ref outputs "out"))
61 (bin (string-append out "/bin"))
62 (doc (string-append out "/share/doc/delta-" ,version)))
63 (begin
64 (mkdir-p bin)
65 (mkdir-p doc)
66 (for-each (lambda (h)
67 (copy-file h (string-append doc "/" (basename h))))
68 `("License.txt" ,@(find-files "www" ".*\\.html")))
69 (for-each (lambda (b)
70 (copy-file b (string-append bin "/" b)))
71 `("delta" "multidelta" "topformflat")))))
72 (alist-delete 'configure %standard-phases))))
73 (home-page "http://delta.tigris.org/")
74 (synopsis "Heuristical file minimizer")
75 (description
76 "Delta assists you in minimizing \"interesting\" files subject to a test
77of their interestingness. A common such situation is when attempting to
78isolate a small failure-inducing substring of a large input that causes your
79program to exhibit a bug.")
80 ;; See License.txt, which is a bsd-3 license, despite the project's
81 ;; home-page pointing to a bsd-2 license.
82 (license bsd-3)))
83
84(define-public c-reduce
85 (package
86 (name "c-reduce")
87 (version "2.3.0")
88 (source
89 (origin
90 (method url-fetch)
91 (uri (list
92 (string-append "http://embed.cs.utah.edu/creduce/"
93 "creduce-" version ".tar.gz")))
94 (sha256
95 (base32
96 "0r9lvnifjcnsrkrk8k4mha1kmmb93jya7alm523ck59y3173bpi0"))
97 (modules '((guix build utils)))
98 (snippet
99 '(substitute* "clang_delta/TransformationManager.cpp"
100 (("llvm/Config/config.h") "llvm/Config/llvm-config.h")))))
101 (build-system gnu-build-system)
102 (inputs
103 `(("astyle" ,astyle)
104 ("delta" ,delta)
105 ("llvm" ,llvm)
106 ("clang" ,clang)
107 ("flex" ,flex)
108 ("indent" ,indent)
109 ("perl" ,perl)
110 ("benchmark-timer" ,perl-benchmark-timer)
111 ("exporter-lite" ,perl-exporter-lite)
112 ("file-which" ,perl-file-which)
113 ("getopt-tabular" ,perl-getopt-tabular)
114 ("regex-common" ,perl-regexp-common)
115 ("sys-cpu" ,perl-sys-cpu)))
116 (arguments
117 `(#:phases (alist-cons-after
118 'install 'set-load-paths
119 (lambda* (#:key inputs outputs #:allow-other-keys)
120 ;; Tell creduce where to find the perl modules it needs.
121 (let* ((out (assoc-ref outputs "out"))
122 (prog (string-append out "/bin/creduce")))
123 (wrap-program
124 prog
125 `("PERL5LIB" ":" prefix
126 ,(map (lambda (p)
127 (string-append (assoc-ref inputs p)
128 "/lib/perl5/site_perl/"
129 ,(package-version perl)))
130 '("benchmark-timer" "exporter-lite"
131 "file-which" "getopt-tabular"
132 "regex-common" "sys-cpu"))))))
133 %standard-phases)))
134 (home-page "http://embed.cs.utah.edu/creduce")
135 (synopsis "Reducer for interesting code")
136 (description
137 "C-Reduce is a tool that takes a large C or C++ program that has a
138property of interest (such as triggering a compiler bug) and automatically
139produces a much smaller C/C++ program that has the same property. It is
140intended for use by people who discover and report bugs in compilers and other
141tools that process C/C++ code.")
142 (license ncsa)))
143
144(define qemu-2.3.0
145 (package
146 (inherit qemu-minimal)
147 (version "2.3.0")
148 (source (origin
149 (method url-fetch)
150 (uri (string-append
151 "http://wiki.qemu-project.org/download/qemu-"
152 version ".tar.bz2"))
153 (sha256
154 (base32
155 "120m53c3p28qxmfzllicjzr8syjv6v4d9rsyrgkp7gnmcgvvgfmn"))))
156 (arguments
157 ;; XXX: Disable tests because of GTester's rejection of duplicate test
158 ;; names, which wasn't addressed in this version of QEMU.
159 `(#:tests? #f
160 ,@(package-arguments qemu-minimal)))))
161
162(define-public american-fuzzy-lop
163 (let ((machine (match (or (%current-target-system)
164 (%current-system))
165 ("x86_64-linux" "x86_64")
166 ("i686-linux" "i386")
167 ;; Prevent errors when querying this package on unsupported
168 ;; platforms, e.g. when running "guix package --search="
169 (_ "UNSUPPORTED"))))
170 (package
171 (name "american-fuzzy-lop")
172 (version "1.96b") ;It seems all releases have the 'b' suffix
173 (source
174 (origin
175 (method url-fetch)
176 (uri (string-append "http://lcamtuf.coredump.cx/afl/releases/"
177 "afl-" version ".tgz"))
178 (sha256
179 (base32
180 "0z7j231p6v2h1dxxijgdzj1lq1lxr8cxllwf6iyv7p4ki5pv1gh3"))))
181 (build-system gnu-build-system)
182 (inputs
183 `(("custom-qemu"
184 ;; The afl-qemu tool builds qemu 2.3.0 with a few patches applied.
185 ,(package (inherit qemu-2.3.0)
186 (name "afl-qemu")
187 (inputs
188 `(("afl-src" ,source)
189 ,@(package-inputs qemu-2.3.0)))
190 ;; afl only supports using a single afl-qemu-trace executable, so
191 ;; we only build qemu for the native target.
192 (arguments
193 `(#:modules ((srfi srfi-1)
194 ,@%gnu-build-system-modules)
195 ,@(substitute-keyword-arguments (package-arguments qemu-2.3.0)
196 ((#:configure-flags config-flags)
197 ``(,(string-append "--target-list=" ,machine "-linux-user")
198 ,@(remove (λ (f) (string-prefix? "--target-list=" f))
199 ,config-flags)))
200 ((#:phases qemu-phases)
201 `(modify-phases ,qemu-phases
202 (add-after
203 'unpack 'apply-afl-patches
204 (lambda* (#:key inputs #:allow-other-keys)
205 (let* ((afl-dir (string-append "afl-" ,version))
206 (patch-dir
207 (string-append afl-dir
208 "/qemu_mode/patches")))
209 (unless (zero?
210 (system* "tar" "xf"
211 (assoc-ref inputs "afl-src")))
212 (error "tar failed to unpack afl-src"))
213 (copy-file (string-append patch-dir
214 "/afl-qemu-cpu-inl.h")
215 "./afl-qemu-cpu-inl.h")
216 (copy-file (string-append afl-dir "/config.h")
217 "./afl-config.h")
218 (copy-file (string-append afl-dir "/types.h")
219 "./types.h")
220 (substitute* "afl-qemu-cpu-inl.h"
221 (("\\.\\./\\.\\./config.h") "afl-config.h"))
222 (substitute* (string-append patch-dir
223 "/cpu-exec.diff")
224 (("\\.\\./patches/") ""))
225 (every (lambda (patch-file)
226 (zero? (system* "patch" "--force" "-p1"
227 "--input" patch-file)))
228 (find-files patch-dir
229 "\\.diff$"))))))))))))))
230 (arguments
231 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
232 "CC=gcc")
233 #:phases (modify-phases %standard-phases
234 (delete 'configure)
235 (add-after
236 ;; TODO: Build and install the afl-llvm tool.
237 'install 'install-qemu
238 (lambda* (#:key inputs outputs #:allow-other-keys)
239 (let ((qemu (assoc-ref inputs "custom-qemu"))
240 (out (assoc-ref outputs "out")))
241 (symlink (string-append qemu "/bin/qemu-" ,machine)
242 (string-append out "/bin/afl-qemu-trace"))
243 #t)))
244 (delete 'check))))
245 (supported-systems (fold delete
246 %supported-systems
247 '("armhf-linux" "mips64el-linux")))
248 (home-page "http://lcamtuf.coredump.cx/afl")
249 (synopsis "Security-oriented fuzzer")
250 (description
251 "American fuzzy lop is a security-oriented fuzzer that employs a novel
252type of compile-time instrumentation and genetic algorithms to automatically
253discover clean, interesting test cases that trigger new internal states in the
254targeted binary. This substantially improves the functional coverage for the
255fuzzed code. The compact synthesized corpora produced by the tool are also
256useful for seeding other, more labor- or resource-intensive testing regimes
257down the road.")
258 (license asl2.0))))