1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2012, 2013, 2014, 2016 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 # Should fail because this is a source-less package.
30 if guix build
-e '(@ (gnu packages bootstrap) %bootstrap-glibc)' -S
31 then false
; else true
; fi
34 guix build
-e '(@@ (gnu packages bootstrap) %bootstrap-guile)' | \
36 guix build hello
-d | \
37 grep -e '-hello-[0-9\.]\+\.drv$'
39 # Check --sources option with its arguments
40 module_dir
="t-guix-build-$$"
42 trap "rm -rf $module_dir" EXIT
44 cat > "$module_dir/foo.scm"<<EOF
46 #:use-module (guix tests)
47 #:use-module (guix packages)
48 #:use-module (guix download)
49 #:use-module (guix build-system trivial))
57 (uri "http://www.example.com/foo.tar.gz")
60 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"))))
61 (build-system trivial-build-system)
63 (quasiquote (("bar" ,bar))))
64 (home-page "www.example.com")
65 (synopsis "Dummy package")
66 (description "foo is a dummy package for testing.")
75 (uri "http://www.example.com/bar.tar.gz")
78 "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"))))
79 (build-system trivial-build-system)
84 (uri "http://www.example.com/bar.dat")
87 "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz")))))))
88 (home-page "www.example.com")
89 (synopsis "Dummy package")
90 (description "bar is a dummy package for testing.")
94 (dummy-package "baz" (replacement foo)))
96 (define-public superseded
97 (deprecated-package "superseded" bar))
101 GUIX_PACKAGE_PATH
="$module_dir"
102 export GUIX_PACKAGE_PATH
106 guix build
-d -S foo |
grep -e 'foo\.tar\.gz'
108 # 'baz' has a replacement so we should be getting the replacement's source.
109 (unset GUIX_BUILD_OPTIONS
;
110 test "`guix build -d -S baz`" = "`guix build -d -S foo`")
112 guix build
-d --sources=package foo
113 guix build
-d --sources=package foo |
grep -e 'foo\.tar\.gz'
115 # bar.tar.gz and bar.dat
116 guix build
-d --sources bar
117 test `guix build -d --sources bar \
118 | grep -e 'bar\.tar\.gz' -e 'bar\.dat' \
121 # bar.tar.gz and bar.dat
122 guix build
-d --sources=all bar
123 test `guix build -d --sources bar \
124 | grep -e 'bar\.tar\.gz' -e 'bar\.dat' \
127 # Should include foo.tar.gz, bar.tar.gz, and bar.dat
128 guix build
-d --sources=transitive foo
129 test `guix build -d --sources=transitive foo \
130 | grep -e 'foo\.tar\.gz' -e 'bar\.tar\.gz' -e 'bar\.dat' \
133 # Should all return valid log files.
134 drv
="`guix build -d -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'`"
135 out
="`guix build -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'`"
136 log
="`guix build --log-file $drv`"
137 echo "$log" |
grep log
/.
*guile.
*drv
139 test "`guix build -e '(@@ (gnu packages bootstrap) %bootstrap-guile)' --log-file`" \
141 test "`guix build --log-file guile-bootstrap`" = "$log"
142 test "`guix build --log-file $out`" = "$log"
144 # Should fail because the name/version combination could not be found.
145 if guix build hello-0.0
.1 -n; then false
; else true
; fi
147 # Keep a symlink to the result, registered as a root.
149 guix build
-r "$result" \
150 -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'
151 test -x "$result/bin/guile"
153 # Should fail, because $result already exists.
154 if guix build
-r "$result" -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'
155 then false
; else true
; fi
160 guix build coreutils
--target=mips64el-linux-gnu
--dry-run --no-substitutes
163 drv1
=`guix build guix --with-input=guile=guile-next -d`
164 drv2
=`guix build guix -d`
165 test "$drv1" != "$drv2"
167 drv1
=`guix build guile -d`
168 drv2
=`guix build guile --with-input=gimp=ruby -d`
169 test "$drv1" = "$drv2"
171 if guix build guile
--with-input=libunistring
=something-really-silly
172 then false
; else true
; fi
174 # Deprecated/superseded packages.
175 test "`guix build superseded -d`" = "`guix build bar -d`"
177 # Parsing package names and versions.
178 guix build
-n time # PASS
179 guix build
-n time@
1.7 # PASS, version found
180 guix build
-n time-1.7
# PASS, deprecated version syntax
181 if guix build
-n time@
3.2; # FAIL, version not found
182 then false
; else true
; fi
183 if guix build
-n something-that-will-never-exist
; # FAIL
184 then false
; else true
; fi
186 # Invoking a monadic procedure.
187 guix build
-e "(begin
188 (use-modules (guix gexp))
190 (gexp->derivation \"test\"
191 (gexp (mkdir (ungexp output))))))" \
195 guix build
-e '#~(mkdir #$output)' -d
196 guix build
-e '#~(mkdir #$output)' -d |
grep 'gexp\.drv'
198 # Building from a package file.
199 cat > "$module_dir/package.scm"<<EOF
201 (use-package-modules bootstrap)
205 guix build
--file="$module_dir/package.scm"
207 # Building from a monadic procedure file.
208 cat > "$module_dir/proc.scm"<<EOF
209 (use-modules (guix gexp))
211 (gexp->derivation "test"
212 (gexp (mkdir (ungexp output)))))
214 guix build
--file="$module_dir/proc.scm" --dry-run
216 # Building from a gexp file.
217 cat > "$module_dir/gexp.scm"<<EOF
218 (use-modules (guix gexp))
220 (gexp (mkdir (ungexp output)))
222 guix build
--file="$module_dir/gexp.scm" -d
223 guix build
--file="$module_dir/gexp.scm" -d |
grep 'gexp\.drv'
225 # Using 'GUIX_BUILD_OPTIONS'.
226 GUIX_BUILD_OPTIONS
="--dry-run --no-grafts"
227 export GUIX_BUILD_OPTIONS
231 GUIX_BUILD_OPTIONS
="--something-completely-crazy"
233 then false
; else true
; fi