Content-Security-Policy: default-src 'none'
Content-Type: text/plain; charset=UTF-8
Content-Length: 8038
Content-Disposition: inline; filename="guix-build.sh"
Last-Modified: Sat, 16 Nov 2024 19:39:12 GMT
Expires: Tue, 14 Nov 2034 19:39:12 GMT
ETag: "7842ce87c62123569dc1b1952f209913b5264f17"

# GNU Guix --- Functional package management for GNU
# Copyright © 2012, 2013, 2014, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
#
# 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/>.

#
# Test the `guix build' command-line utility.
#

guix build --version

# Should fail.
if guix build -e +;
then false; else true; fi

# Source-less packages are accepted; they just return nothing.
guix </td></tr></table>
<table class='tabs'><tr><td>
<a class='active' href='/guix/about/'>about</a><a href='/guix/'>summary</a><a href='/guix/refs/?id=4f6172f1c5c603cd58f85821bf7a80e716b0c67e'>refs</a><a href='/guix/log/'>log</a><a href='/guix/tree/?id=4f6172f1c5c603cd58f85821bf7a80e716b0c67e'>tree</a><a href='/guix/commit/?id=4f6172f1c5c603cd58f85821bf7a80e716b0c67e'>commit</a><a href='/guix/diff/?id=4f6172f1c5c603cd58f85821bf7a80e716b0c67e'>diff</a></td><td class='form'><form class='right' method='get' action='/guix/log/'>
<input type='hidden' name='id' value='4f6172f1c5c603cd58f85821bf7a80e716b0c67e'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='content'><div id='summary'><pre>
# GNU Guix --- Functional package management for GNU
# Copyright © 2018 Chris Marusich &lt;cmmarusich@gmail.com&gt;
# Copyright © 2018, 2019, 2020, 2022, 2023 Ludovic Courtès &lt;ludo@gnu.org&gt;
#
# 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 &lt;http://www.gnu.org/licenses/&gt;.

#
# Test the `guix pack&apos; command-line utility.
#

# A network connection is required to build %bootstrap-coreutils&amp;co,
# which is required to run these tests with the --bootstrap option.
if ! guile -c &apos;(getaddrinfo &quot;www.gnu.org&quot; &quot;80&quot; AI_NUMERICSERV)&apos; 2&gt; /dev/null; then
    exit 77
fi

guix pack --version

# Use --no-substitutes because we need to verify we can do this ourselves.
# Use --no-grafts to avoid interference--e.g., --dry-run passing even when
# given an unsupported package.
GUIX_BUILD_OPTIONS=&quot;--no-substitutes --no-grafts&quot;
export GUIX_BUILD_OPTIONS

test_directory=&quot;`mktemp -d`&quot;
trap &apos;chmod -Rf +w &quot;$test_directory&quot;; rm -rf &quot;$test_directory&quot;&apos; EXIT

# Reject unsuppoted packages.
guix pack intelmetool -s armhf-linux -n &amp;&amp; false

# Compute the derivation of a pack.
drv=&quot;`guix pack coreutils -d --no-grafts`&quot;
guix gc -R &quot;$drv&quot; | grep &quot;`guix build coreutils -d --no-grafts`&quot;

# Compute the derivation of a cross-compiled pack.  Make sure it refers to the
# cross-compiled package and not to the native package.
drv=&quot;`guix pack idutils -d --no-grafts --target=arm-linux-gnueabihf`&quot;
guix gc -R &quot;$drv&quot; | \
    grep &quot;`guix build idutils --target=arm-linux-gnueabihf -d --no-grafts`&quot;
guix gc -R &quot;$drv&quot; | grep &quot;`guix build idutils -d --no-grafts`&quot; &amp;&amp; false

# Build a tarball with no compression.
guix pack --compression=none --bootstrap guile-bootstrap

# Build a tarball (with compression).  Check that &apos;-e&apos; works as well.
out1=&quot;`guix pack --bootstrap guile-bootstrap`&quot;
out2=&quot;`guix pack --bootstrap -e &apos;(@ (gnu packages bootstrap) %bootstrap-guile)&apos;`&quot;
test -n &quot;$out1&quot;
test &quot;$out1&quot; = &quot;$out2&quot;

# Test &apos;--root&apos;.
guix pack -r &quot;$test_directory/my-guile&quot; --bootstrap guile-bootstrap
test &quot;`readlink &quot;$test_directory/my-guile&quot;`&quot; = &quot;$out1&quot;
guix gc --list-roots | grep &quot;^$test_directory/my-guile$&quot;
rm &quot;$test_directory/my-guile&quot;

# Build a tarball with a symlink.
the_pack=&quot;`guix pack --bootstrap -S /opt/gnu/bin=bin guile-bootstrap`&quot;

# Try to extract it.  Note: we cannot test whether /opt/gnu/bin/guile itself
# exists because /opt/gnu/bin may be an absolute symlink to a store item that
# has been GC&apos;d.
cd &quot;$test_directory&quot;
tar -xf &quot;$the_pack&quot;
test -L opt/gnu/bin

is_available () {
    # Use the &quot;type&quot; shell builtin to see if the program is on PATH.
    type &quot;$1&quot; &gt; /dev/null
}

if is_available chroot &amp;&amp; is_available unshare &amp;&amp; unshare -r true; then
    # Verify we can use what we built.
    unshare -r chroot . /opt/gnu/bin/guile --version
    cd -
else
    echo &quot;warning: skipped some verification because chroot or unshare is unavailable&quot; &gt;&amp;2
fi

# For the tests that build Docker images below, we currently have to use
# --dry-run because if we don&apos;t, there are only two possible cases:
#
#     Case 1: We do not use --bootstrap, and the build takes hours to finish
#             because it needs to build tar etc.
#
#     Case 2: We use --bootstrap, and the build fails because the bootstrap
#             Guile cannot dlopen shared libraries.  Not to mention the fact
#             that we would still have to build many non-bootstrap inputs
#             (e.g., guile-json) in order to create the Docker image.

# Build a Docker image.
guix pack --dry-run --bootstrap -f docker guile-bootstrap

# Build a Docker image with a symlink.
guix pack --dry-run --bootstrap -f docker -S /opt/gnu= guile-bootstrap

# Build a tarball pack of cross-compiled software.  Use coreutils because
# guile-bootstrap is not intended to be cross-compiled.
guix pack --dry-run --bootstrap --target=arm-linux-gnueabihf coreutils

# Likewise, &apos;guix pack -R&apos; requires a full-blown toolchain (because
# &apos;glibc-bootstrap&apos; lacks &apos;libc.a&apos;), hence &apos;--dry-run&apos;.
guix pack -R --dry-run --bootstrap -S /mybin=bin guile-bootstrap

# Make sure package transformation options are honored.
chmod -Rf +w &quot;$test_directory&quot;; rm -r &quot;$test_directory&quot;
mkdir -p &quot;$test_directory&quot; -m 755
drv1=&quot;`guix pack --no-grafts -n guile 2&gt;&amp;1 | grep pack.*\.drv`&quot;
drv2=&quot;`guix pack --no-grafts -n --with-source=guile=$test_directory guile 2&gt;&amp;1 | grep pack.*\.drv`&quot;
test -n &quot;$drv1&quot;
test &quot;$drv1&quot; != &quot;$drv2&quot;

# Try &apos;--manifest&apos; options.
cat &gt; &quot;$test_directory/manifest1.scm&quot; &lt;&lt;EOF
(specifications-&gt;manifest &apos;(&quot;guile&quot;))
EOF
cat &gt; &quot;$test_directory/manifest2.scm&quot; &lt;&lt;EOF
(specifications-&gt;manifest &apos;(&quot;emacs&quot;))
EOF
drv=&quot;`guix pack --no-grafts -d -m &quot;$test_directory/manifest1.scm&quot; -m &quot;$test_directory/manifest2.scm&quot;`&quot;
guix gc -R &quot;$drv&quot; | grep `guix build guile -d --no-grafts`
guix gc -R &quot;$drv&quot; | grep `guix build emacs -d --no-grafts`
</pre>
</div></div> <!-- class=content -->
                         <div class=footer>generated by
                             <a href="https://git.zx2c4.com/cgit/about/">
                                 cgit
                             </a>
                         </div>
                        </div> <!-- id=cgit -->
</body>
</html>
