Content-Security-Policy: default-src 'none'
Content-Type: text/plain; charset=UTF-8
Content-Length: 10595
Content-Disposition: inline; filename="guix-package.sh"
Last-Modified: Mon, 14 Oct 2024 15:05:25 GMT
Expires: Thu, 12 Oct 2034 15:05:25 GMT
ETag: "f4e091a5a2c565a832ef91c199cb8e32d98b3e6c"

# GNU Guix --- Functional package management for GNU
# Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
# Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.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 package' command-line utility.
#

guix package --version

readlink_base ()
{
    basename `readlink "$1"`
}

module_dir="t-guix-package-$$"
profile="t-profile-$$"
rm -f "$profile"
</td></tr></table>
<table class='tabs'><tr><td>
<a href='/guix/about/'>about</a><a href='/guix/'>summary</a><a href='/guix/refs/?id=fa0c9b086ce2826a9724b1b71d675daa94b35f50'>refs</a><a href='/guix/log/tests/guix-graph.sh'>log</a><a href='/guix/tree/tests/guix-graph.sh?id=fa0c9b086ce2826a9724b1b71d675daa94b35f50'>tree</a><a class='active' href='/guix/commit/tests/guix-graph.sh?id=fa0c9b086ce2826a9724b1b71d675daa94b35f50'>commit</a><a href='/guix/diff/tests/guix-graph.sh?id=fa0c9b086ce2826a9724b1b71d675daa94b35f50'>diff</a></td><td class='form'><form class='right' method='get' action='/guix/log/tests/guix-graph.sh'>
<input type='hidden' name='id' value='fa0c9b086ce2826a9724b1b71d675daa94b35f50'/><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='path'>path: <a href='/guix/commit/?id=fa0c9b086ce2826a9724b1b71d675daa94b35f50'>root</a>/<a href='/guix/commit/tests?id=fa0c9b086ce2826a9724b1b71d675daa94b35f50'>tests</a>/<a href='/guix/commit/tests/guix-graph.sh?id=fa0c9b086ce2826a9724b1b71d675daa94b35f50'>guix-graph.sh</a></div><div class='content'><div class='cgit-panel'><b>diff options</b><form method='get'><input type='hidden' name='id' value='fa0c9b086ce2826a9724b1b71d675daa94b35f50'/><table><tr><td colspan='2'/></tr><tr><td class='label'>context:</td><td class='ctrl'><select name='context' onchange='this.form.submit();'><option value='1'>1</option><option value='2'>2</option><option value='3' selected='selected'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='15'>15</option><option value='20'>20</option><option value='25'>25</option><option value='30'>30</option><option value='35'>35</option><option value='40'>40</option></select></td></tr><tr><td class='label'>space:</td><td class='ctrl'><select name='ignorews' onchange='this.form.submit();'><option value='0' selected='selected'>include</option><option value='1'>ignore</option></select></td></tr><tr><td class='label'>mode:</td><td class='ctrl'><select name='dt' onchange='this.form.submit();'><option value='0' selected='selected'>unified</option><option value='1'>ssdiff</option><option value='2'>stat only</option></select></td></tr><tr><td/><td class='ctrl'><noscript><input type='submit' value='reload'/></noscript></td></tr></table></form></div><table summary='commit info' class='commit-info'>
<tr><th>author</th><td>Tobias Geerinckx-Rice &lt;me@tobias.gr&gt;</td><td class='right'>2022-08-07 02:00:01 +0200</td></tr>
<tr><th>committer</th><td>Tobias Geerinckx-Rice &lt;me@tobias.gr&gt;</td><td class='right'>2022-08-07 02:00:00 +0200</td></tr>
<tr><th>commit</th><td colspan='2' class='oid'><a href='/guix/commit/tests/guix-graph.sh?id=fa0c9b086ce2826a9724b1b71d675daa94b35f50'>fa0c9b086ce2826a9724b1b71d675daa94b35f50</a> (<a href='/guix/patch/tests/guix-graph.sh?id=fa0c9b086ce2826a9724b1b71d675daa94b35f50'>patch</a>)</td></tr>
<tr><th>tree</th><td colspan='2' class='oid'><a href='/guix/tree/?id=fa0c9b086ce2826a9724b1b71d675daa94b35f50'>3468e22ade5c415c7d248d8f5d6df56340dcc9de</a> /<a href='/guix/tree/tests/guix-graph.sh?id=fa0c9b086ce2826a9724b1b71d675daa94b35f50'>tests/guix-graph.sh</a></td></tr>
<tr><th>parent</th><td colspan='2' class='oid'><a href='/guix/commit/tests/guix-graph.sh?id=dda3a760ab4b1e8dce9797cecd09fefa9c25cb68'>dda3a760ab4b1e8dce9797cecd09fefa9c25cb68</a> (<a href='/guix/diff/tests/guix-graph.sh?id=fa0c9b086ce2826a9724b1b71d675daa94b35f50&amp;id2=dda3a760ab4b1e8dce9797cecd09fefa9c25cb68'>diff</a>)</td></tr><tr><th>download</th><td colspan='2' class='oid'><a href='/guix/snapshot/guix-fa0c9b086ce2826a9724b1b71d675daa94b35f50.tar.gz'>guix-fa0c9b086ce2826a9724b1b71d675daa94b35f50.tar.gz</a><br/><a href='/guix/snapshot/guix-fa0c9b086ce2826a9724b1b71d675daa94b35f50.zip'>guix-fa0c9b086ce2826a9724b1b71d675daa94b35f50.zip</a><br/></td></tr></table>
<div class='commit-subject'>gnu: Add fstransform.</div><div class='commit-msg'>* gnu/packages/file-systems.scm (fstransform): New public variable.
</div><div class='diffstat-header'><a href='/guix/diff/?id=fa0c9b086ce2826a9724b1b71d675daa94b35f50'>Diffstat</a> (limited to 'tests/guix-graph.sh')</div><table summary='diffstat' class='diffstat'></table><div class='diffstat-summary'>0 files changed, 0 insertions, 0 deletions</div><table summary='diff' class='diff'><tr><td></td></tr></table></div> <!-- class=content -->
                         <div class=footer>generated by
                             <a href="https://git.zx2c4.com/cgit/about/">
                                 cgit
                             </a>
                         </div>
                        </div> <!-- id=cgit -->
</body>
</html>
i

    # Exit with 0 when trying to delete the zeroth generation.
    guix package -p "$profile" --delete-generations=0
fi

# Make sure multiple arguments to -i works.
guix package --bootstrap -i guile gcc -p "$profile" -n

# Make sure the `:' syntax works.
guix package --bootstrap -i "glibc:debug" -p "$profile" -n

# Make sure nonexistent outputs are reported.
guix package --bootstrap -i "guile-bootstrap:out" -p "$profile" -n
if guix package --bootstrap -i "guile-bootstrap:does-not-exist" -p "$profile" -n;
then false; else true; fi
if guix package --bootstrap -i "guile-bootstrap:does-not-exist" -p "$profile";
then false; else true; fi

# Check whether `--list-available' returns something sensible.
guix package -p "$profile" -A 'gui.*e' | grep guile

# Check whether `--show' returns something sensible.
guix package --show=guile | grep "^name: guile"

# Ensure `--show' doesn't fail for packages with non-package inputs.
guix package --show=texlive

# Search.
LC_MESSAGES=C
export LC_MESSAGES
test "`guix package -s "An example GNU package" | grep ^name:`" = \
    "name: hello"
test -z "`guix package -s "n0t4r341p4ck4g3"`"

# Make sure `--search' can display all the packages.
guix package --search="" > /dev/null

# There's no generation older than 12 months, so the following command should
# have no effect.
generation="`readlink_base "$profile"`"
if guix package -p "$profile" --delete-generations=12m;
then false; else true; fi
test "`readlink_base "$profile"`" = "$generation"

#
# Try with the default profile.
#

XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
export XDG_CACHE_HOME
HOME="$PWD/t-home-$$"
export HOME

mkdir -p "$HOME"

# Get the canonical directory name so that 'guix package' recognizes it.
HOME="`cd $HOME; pwd -P`"

guix package --bootstrap -i guile-bootstrap
test -L "$HOME/.guix-profile"
test -f "$HOME/.guix-profile/bin/guile"

if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null
then
    guix package --bootstrap -e "$boot_make"
    test -f "$HOME/.guix-profile/bin/make"
    first_environment="`cd $HOME/.guix-profile ; pwd`"

    guix package --bootstrap --roll-back
    test -f "$HOME/.guix-profile/bin/guile"
    ! test -f "$HOME/.guix-profile/bin/make"
    test "`cd $HOME/.guix-profile ; pwd`" = "$first_environment"
fi

# Move to the empty profile.
default_profile="`readlink "$HOME/.guix-profile"`"
for i in `seq 1 3`
do
    # Make sure the current generation is a GC root.
    profile_link="`readlink "$default_profile"`"
    guix gc --list-live | grep "`readlink "$profile_link"`"

    guix package --bootstrap --roll-back
    ! test -f "$HOME/.guix-profile/bin"
    ! test -f "$HOME/.guix-profile/lib"
    test "`readlink "$default_profile"`" = "$default_profile-0-link"
done

# Check whether '-p ~/.guix-profile' makes any difference.
# See <http://bugs.gnu.org/17939>.
if test -e "$HOME/.guix-profile-0-link"; then false; fi
if test -e "$HOME/.guix-profile-1-link"; then false; fi
guix package --bootstrap -p "$HOME/.guix-profile" -i guile-bootstrap
if test -e "$HOME/.guix-profile-1-link"; then false; fi
guix package --bootstrap --roll-back -p "$HOME/.guix-profile"
if test -e "$HOME/.guix-profile-0-link"; then false; fi

# Extraneous argument.
if guix package install foo-bar;
then false; else true; fi

# Make sure the "broken pipe" doesn't yield an error.
# Note: 'pipefail' is a Bash-specific option.
set -o pipefail || true
guix package -A g | head -1 2> "$HOME/err1"
guix package -I | head -1 2> "$HOME/err2"
test "`cat "$HOME/err1" "$HOME/err2"`" = ""

# Make sure '-L' extends the package module search path.
mkdir "$module_dir"

cat > "$module_dir/foo.scm"<<EOF
(define-module (foo)
  #:use-module (guix packages)
  #:use-module (gnu packages emacs))

(define-public x
  (package (inherit emacs)
    (name "emacs-foo-bar")
    (version "42")))
EOF

guix package -A emacs-foo-bar -L "$module_dir" | grep 42
guix package -i emacs-foo-bar-42 -n -L "$module_dir"

# Same thing using the 'GUIX_PACKAGE_PATH' environment variable.
GUIX_PACKAGE_PATH="$module_dir"
export GUIX_PACKAGE_PATH
guix package -A emacs-foo-bar | grep 42
guix package -i emacs-foo-bar-42 -n
unset GUIX_PACKAGE_PATH

# Using 'GUIX_BUILD_OPTIONS'.

available="`guix package -A | sort`"
GUIX_BUILD_OPTIONS="--dry-run"
export GUIX_BUILD_OPTIONS

# Make sure $GUIX_BUILD_OPTIONS is not simply appended to the command-line,
# which would break 'guix package -A' and similar.
available2="`guix package -A | sort`"
test "$available2" = "$available"
guix package -I
