1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2012, 2013, 2014, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
4 # This file is part of GNU Guix.
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.
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.
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/>.
20 # Test the `guix build' command-line utility.
27 then false
; else true
; fi
29 # Source-less packages are accepted; they just return nothing.
30 guix build
-e '(@ (gnu packages bootstrap) %bootstrap-glibc)' -S
31 test "`guix build -e '(@ (gnu packages bootstrap) %bootstrap-glibc)' -S`" = ""
34 guix build
-e '(@@ (gnu packages bootstrap) %bootstrap-guile)' | \
36 guix build hello
-d | \
37 grep -e '-hello-[0-9\.]\+\.drv$'
40 GUIX_DAEMON_SOCKET
="file://$NIX_STATE_DIR/daemon-socket/socket" \
41 guix build
-e '(@@ (gnu packages bootstrap) %bootstrap-guile)'
43 ( if GUIX_DAEMON_SOCKET
="weird://uri" \
44 guix build
-e '(@@ (gnu packages bootstrap) %bootstrap-guile)'; \
47 # Check --sources option with its arguments
48 module_dir
="t-guix-build-$$"
50 trap "rm -rf $module_dir" EXIT
52 cat > "$module_dir/foo.scm"<<EOF
54 #:use-module (guix tests)
55 #:use-module (guix packages)
56 #:use-module (guix download)
57 #:use-module (guix build-system trivial))
65 (uri "http://www.example.com/foo.tar.gz")
68 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"))))
69 (build-system trivial-build-system)
71 (quasiquote (("bar" ,bar))))
72 (home-page "www.example.com")
73 (synopsis "Dummy package")
74 (description "foo is a dummy package for testing.")
83 (uri "http://www.example.com/bar.tar.gz")
86 "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"))))
87 (build-system trivial-build-system)
92 (uri "http://www.example.com/bar.dat")
95 "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz")))))))
96 (home-page "www.example.com")
97 (synopsis "Dummy package")
98 (description "bar is a dummy package for testing.")
102 (dummy-package "baz" (replacement foo)))
104 (define-public superseded
105 (deprecated-package "superseded" bar))
109 GUIX_PACKAGE_PATH
="$module_dir"
110 export GUIX_PACKAGE_PATH
114 guix build
-d -S foo |
grep -e 'foo\.tar\.gz'
116 # 'baz' has a replacement so we should be getting the replacement's source.
117 (unset GUIX_BUILD_OPTIONS
;
118 test "`guix build -d -S baz`" = "`guix build -d -S foo`")
120 guix build
-d --sources=package foo
121 guix build
-d --sources=package foo |
grep -e 'foo\.tar\.gz'
123 # bar.tar.gz and bar.dat
124 guix build
-d --sources bar
125 test `guix build -d --sources bar \
126 | grep -e 'bar\.tar\.gz' -e 'bar\.dat' \
129 # bar.tar.gz and bar.dat
130 guix build
-d --sources=all bar
131 test `guix build -d --sources bar \
132 | grep -e 'bar\.tar\.gz' -e 'bar\.dat' \
135 # Should include foo.tar.gz, bar.tar.gz, and bar.dat
136 guix build
-d --sources=transitive foo
137 test `guix build -d --sources=transitive foo \
138 | grep -e 'foo\.tar\.gz' -e 'bar\.tar\.gz' -e 'bar\.dat' \
143 cat > "$module_dir/foo.scm"<<EOF
145 #:use-module (guix tests)
146 #:use-module (guix build-system trivial))
149 (dummy-package "package-with-something-wrong"
150 (build-system trivial-build-system)
151 (inputs (quasiquote (("sed" ,sed)))))) ;unbound variable
154 if guix build package-with-something-wrong
-n; then false
; else true
; fi
155 guix build package-with-something-wrong
-n 2> "$module_dir/err" || true
156 grep "unbound" "$module_dir/err" # actual error
157 grep "forget.*(gnu packages base)" "$module_dir/err" # hint
158 rm -f "$module_dir"/*
160 # Should all return valid log files.
161 drv
="`guix build -d -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'`"
162 out
="`guix build -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'`"
163 log
="`guix build --log-file $drv`"
164 echo "$log" |
grep log
/.
*guile.
*drv
166 test "`guix build -e '(@@ (gnu packages bootstrap) %bootstrap-guile)' --log-file`" \
168 test "`guix build --log-file guile-bootstrap`" = "$log"
169 test "`guix build --log-file $out`" = "$log"
171 # Should fail because the name/version combination could not be found.
172 if guix build hello-0.0
.1 -n; then false
; else true
; fi
174 # Keep a symlink to the result, registered as a root.
176 guix build
-r "$result" \
177 -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'
178 test -x "$result/bin/guile"
180 # Should fail, because $result already exists.
181 if guix build
-r "$result" -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'
182 then false
; else true
; fi
187 guix build coreutils
--target=mips64el-linux-gnu
--dry-run --no-substitutes
190 drv1
=`guix build guix --with-input=guile@2.0=guile@2.2 -d`
191 drv2
=`guix build guix -d`
192 test "$drv1" != "$drv2"
194 drv1
=`guix build guile -d`
195 drv2
=`guix build guile --with-input=gimp=ruby -d`
196 test "$drv1" = "$drv2"
198 if guix build guile
--with-input=libunistring
=something-really-silly
199 then false
; else true
; fi
201 # Deprecated/superseded packages.
202 test "`guix build superseded -d`" = "`guix build bar -d`"
204 # Parsing package names and versions.
205 guix build
-n time # PASS
206 guix build
-n time@
1.9 # PASS, version found
207 if guix build
-n time@
3.2; # FAIL, version not found
208 then false
; else true
; fi
209 if guix build
-n something-that-will-never-exist
; # FAIL
210 then false
; else true
; fi
212 # Invoking a monadic procedure.
213 guix build
-e "(begin
214 (use-modules (guix gexp))
216 (gexp->derivation \"test\"
217 (gexp (mkdir (ungexp output))))))" \
221 guix build
-e '#~(mkdir #$output)' -d
222 guix build
-e '#~(mkdir #$output)' -d |
grep 'gexp\.drv'
224 # Building from a package file.
225 cat > "$module_dir/package.scm"<<EOF
227 (use-package-modules bootstrap)
231 guix build
--file="$module_dir/package.scm"
233 # Building from a monadic procedure file.
234 cat > "$module_dir/proc.scm"<<EOF
235 (use-modules (guix gexp))
237 (gexp->derivation "test"
238 (gexp (mkdir (ungexp output)))))
240 guix build
--file="$module_dir/proc.scm" --dry-run
242 # Building from a gexp file.
243 cat > "$module_dir/gexp.scm"<<EOF
244 (use-modules (guix gexp))
246 (gexp (mkdir (ungexp output)))
248 guix build
--file="$module_dir/gexp.scm" -d
249 guix build
--file="$module_dir/gexp.scm" -d |
grep 'gexp\.drv'
251 # Using 'GUIX_BUILD_OPTIONS'.
252 GUIX_BUILD_OPTIONS
="--dry-run --no-grafts"
253 export GUIX_BUILD_OPTIONS
257 GUIX_BUILD_OPTIONS
="--something-completely-crazy"
259 then false
; else true
; fi