aboutsummaryrefslogtreecommitdiff
# GNU Guix --- Functional package management for GNU
# Copyright © 2013, 2015, 2017, 2018, 2019 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 gc' command-line utility.
#

guix gc --version

trap "rm -f guix-gc-root" EXIT
rm -f guix-gc-root

# Below we are using 'drv' and 'out' to contain store file names.  If 'drv'
# and 'out' are environment variables, 'list-runtime-roots' will "see" them
# and thus prevent $drv and $out from being garbage-collected.  Using 'unset'
# allows us to make sure these are truly local shell variables and not
# environments variables.
unset drv
unset out

# For some operations, passing extra arguments is an error.
for option in "" "-C 500M" "--verify" "--optimize" "--list-roots"
do
    guix gc $option whatever && false
done

# This should fail.
guix gc --verify=foo && false

# Check the references of a .drv.
drv="`guix build guile-bootstrap -d`"
out="`guix build guile-bootstrap`"
test -f "$drv" && test -d "$out"

guix gc --references "$drv" | grep -e -bash
guix gc --references "$out"
guix gc --references "$out/bin/guile"

guix gc --references /dev/null && false

# Check derivers.
guix gc --derivers "$out" | grep "$drv"

# Add then reclaim a .drv file.
drv="`guix build idutils -d`"
test -f "$drv"

guix gc --list-dead | grep "$drv"
guix gc --delete "$drv"
test ! -f "$drv"

# Add a .drv, register it as a root.
drv="`guix build --root=guix-gc-root lsh -d`"
test -f "$drv" && test -L guix-gc-root

guix gc --list-roots | grep "$PWD/guix-gc-root"

guix gc --list-live | grep "$drv"
guix gc --delete "$drv" && false

rm guix-gc-root
guix gc --list-dead | grep "$drv"
guix gc --delete "$drv"
test ! -f "$drv"

# Try a random collection.
guix gc -C 1KiB

# Check trivial error cases.
guix gc --delete /dev/null && false

# Bug #19757
out="`guix build guile-bootstrap`"
test -d "$out"

guix gc --delete "$out"

test ! -d "$out"

out="`guix build guile-bootstrap`"
test -d "$out"

guix gc --delete "$out/"

test ! -d "$out"

out="`guix build guile-bootstrap`"
test -d "$out"

guix gc --delete "$out/bin/guile"
2021-09-14system: Add trailing newline to /etc/timezone....Ludovic Courtès 2021-08-12system: Accept gexps in 'setuid-programs'....Ludovic Courtès 2021-08-12system: Handle 'setuid-programs' deprecation handling as a field sanitizer....Ludovic Courtès 2021-07-29services: Migrate to <setuid-program>....Brice Waegeneire 2021-07-29services: setuid: More configurable setuid support....Chris Lemmer-Webber 2021-07-09system: Provide mg instead of zile....Mathieu Othacehe 2021-05-11Merge branch 'version-1.3.0'Maxim Cournoyer 2021-05-11gnu: Allow services to install kernel-loadable modules....raid5atemyhomework 2021-05-07system: Add wget to %base-packages-networking....Maxim Cournoyer 2021-01-30services: shepherd: Allow custom 'shepherd' package....Maxime Devos 2021-01-22system: Fix typo in docstring....Ludovic Courtès 2020-12-21system: Allow separated /boot and encrypted root....Miguel Ángel Arruga Vivas 2020-11-26mapped-devices: Allow target to be list of strings....Mikhail Tsykalov 2020-11-02system: Change comment wording....Miguel Ángel Arruga Vivas 2020-11-01system: Add store-directory-prefix to boot-parameters....Miguel Ángel Arruga Vivas 2020-10-18system: Provide locale information to the bootloader....Miguel Ángel Arruga Vivas 2020-10-18system: Add locale to boot-parameters....Miguel Ángel Arruga Vivas 2020-10-15install: Deduplicate packages with %base-package sets....Efraim Flashner 2020-10-15system: Add %base-packages-disk-utilities....Efraim Flashner 2020-10-09system: hurd: Add PAM support with shadow and sudo....Jan (janneke) Nieuwenhuizen 2020-10-08system: Include 'guile-3.0-latest' in '%base-packages'....Ludovic Courtès 2020-09-07linux-boot: Handle nfs-root device strings....Stefan 2020-08-24system: Validate sudoers file when building the system....Ludovic Courtès 2020-07-29system: 'operating-system-with-provenance' uses the OS location info....Ludovic Courtès 2020-07-25Use 'formatted-message' instead of '&message' where appropriate....Ludovic Courtès 2020-07-25utils: Move <location> and '&error-location' to (guix diagnostics)....Ludovic Courtès 2020-07-15system: 'operating-system-root-file-system' raises upon missing root....Ludovic Courtès 2020-07-15system: Add 'location' field to <operating-system>....Ludovic Courtès 2020-07-05system: Do not use "hurd-target?"....Mathieu Othacehe 2020-07-03services: system-service-type: Add entries support for the Hurd....Jan (janneke) Nieuwenhuizen 2020-07-03system: 'read-boot-parameters' allow initrd to be missing....Jan (janneke) Nieuwenhuizen 2020-07-03system: 'read-boot-parameters' bugfix for multiboot....Jan (janneke) Nieuwenhuizen 2020-06-21system: Add 'sg' and 'newgrp' to %SETUID-PROGRAMS....Brice Waegeneire 2020-06-19hurd-boot: Use 'setxattr' instead of invoking settrans....Jan (janneke) Nieuwenhuizen 2020-06-09services: etc: Add '/etc/ttys' symlink for the Hurd....Jan (janneke) Nieuwenhuizen 2020-06-09system: Fix typo that breaks grub.cfg generation....Royce Strange 2020-06-08gnu: services: Add %hurd-startup-service....Jan (janneke) Nieuwenhuizen 2020-06-08system: hurd: Populate services....Jan (janneke) Nieuwenhuizen 2020-06-08services: hurd: Populate system profile....Jan (janneke) Nieuwenhuizen