equo unused

If you are new to Linux or new to Sabayon Linux and just not sure where to post, here ya go. Post without fear of being told to RTFM :-)

Moderator: Moderators

Post Reply
kevinfish
Young Hen
Posts: 29
Joined: Sat Mar 05, 2011 3:12

equo unused

Post by kevinfish » Sun Aug 26, 2018 6:22

what is this function for and (how) can I use it to clean up and/or recover space on my machine?

Many of the results look to be important packages, some I actually DO use all the time, so...

...enquiring minds want to know!

User avatar
sabayonino
Sagely Hen
Posts: 3251
Joined: Sun Sep 21, 2008 1:12
Location: Italy
Contact:

Re: equo unused

Post by sabayonino » Sun Aug 26, 2018 9:53

I never understand this equo option.

To cleanup yoor system by downloaded packages and entropy cache just run

Code: Select all

# equo cleanup
There is an option in /etc/entropy/client.conf that can cleanup entropy cache ; by default

Code: Select all

[...]# Number of days that should pass before package files
# get removed from cache automatically.
# Note that this feature should be disabled in server-environments where
# storing packages cache is subject to different policies.
# The daemon in charge of this is client-updates-daemon available via
# entropy-client-services package. You may consider cleaning up packages cache
# manually by calling "equo cleanup" either inside a cronjob or by hand.
# Valid parameters: <integer, representing number of days>
# Default parameter if unset: <feature disabled>
# NOTE: values <0 or >365 are not tolerated.
packages-autoprune-days = 60[...]
[Che Cos'è Il Calcolo Distribuito (BOINC)

BOINC ready ! Sabayon+BOINC = BILD ,my Sabayon spin :cyclops: - Ready to crunch for the Science everywhere :)

kevinfish
Young Hen
Posts: 29
Joined: Sat Mar 05, 2011 3:12

Re: equo unused

Post by kevinfish » Sun Aug 26, 2018 19:38

well, I don't care so much about cleaning caches as I do about removing packages that I didn't personally install or aren't a direct dependency of something I did.

User avatar
sabayonino
Sagely Hen
Posts: 3251
Joined: Sun Sep 21, 2008 1:12
Location: Italy
Contact:

Re: equo unused

Post by sabayonino » Sun Aug 26, 2018 22:42

All packages on a fresh installation are dependency but you can remove

Example :
You don't need for all xf86-video drivers 'cuase you have nvidia VGA

Code: Select all

equo unused -q | grep xf86-video
x11-drivers/xf86-video-amdgpu-18.0.1
x11-drivers/xf86-video-ast-1.1.5
x11-drivers/xf86-video-dummy-0.3.8
x11-drivers/xf86-video-glint-1.2.9
x11-drivers/xf86-video-intel-2.99.917_p20180214-r1
x11-drivers/xf86-video-nouveau-1.0.15-r1
x11-drivers/xf86-video-openchrome-0.6.0
x11-drivers/xf86-video-qxl-0.1.5
x11-drivers/xf86-video-r128-6.10.2
x11-drivers/xf86-video-siliconmotion-1.7.9
x11-drivers/xf86-video-vboxvideo-1.0.0
You can remove safetely (be sure to pass --nodeps option)

Code: Select all

equo unused -q | grep xf86-video | xargs equo rm --nodeps

╠  ## [sabayonlinux.org] x11-drivers/xf86-video-amdgpu-18.0.1 [233.0kB]
╠  ## [sabayonlinux.org] x11-drivers/xf86-video-ast-1.1.5 [142.1kB]
╠  ## [sabayonlinux.org] x11-drivers/xf86-video-dummy-0.3.8 [36.0kB]
╠  ## [sabayonlinux.org] x11-drivers/xf86-video-glint-1.2.9 [176.5kB]
╠  ## [sabayonlinux.org] x11-drivers/xf86-video-intel-2.99.917_p20180214-r1 [2.5MB]
╠  ## [sabayonlinux.org] x11-drivers/xf86-video-nouveau-1.0.15-r1 [418.0kB]
╠  ## [sabayonlinux.org] x11-drivers/xf86-video-openchrome-0.6.0 [595.9kB]
╠  ## [sabayonlinux.org] x11-drivers/xf86-video-qxl-0.1.5 [288.3kB]
╠  ## [sabayonlinux.org] x11-drivers/xf86-video-r128-6.10.2 [245.9kB]
╠  ## [sabayonlinux.org] x11-drivers/xf86-video-siliconmotion-1.7.9 [171.3kB]
╠  ## [sabayonlinux.org] x11-drivers/xf86-video-vboxvideo-1.0.0 [58.2kB]
Try to install xorg-drivers package and check if these packages will be reinstalled

Code: Select all

# equo i xorg-drivers

Code: Select all

# equo unused -q | grep xf86-video
...nothing to show ...
[Che Cos'è Il Calcolo Distribuito (BOINC)

BOINC ready ! Sabayon+BOINC = BILD ,my Sabayon spin :cyclops: - Ready to crunch for the Science everywhere :)

User avatar
Fitzcarraldo
Sagely Hen
Posts: 8113
Joined: Sat Mar 10, 2007 5:40
Location: United Kingdom
Contact:

Re: equo unused

Post by Fitzcarraldo » Sun Aug 26, 2018 22:49

Haha... sabayonino beat me to it! Anyway...

I wonder if the equo unusedpackages [unused] command looks at the Accessed timestamp of an installed application or library to see when it was used, and, if it has not been used since installation, offers you the option of removing (uninstalling) the associated package.

Code: Select all

fitzcarraldo-pc /home/fitzcarraldo # equo unused --help
usage: equo unusedpackages [-h] [--quiet] [--sortbysize] [--spm-wanted]

show unused packages (pay attention)

optional arguments:
  -h, --help    show this help message and exit
  --quiet, -q   show less details (useful for scripting)
  --sortbysize  sort packages by size
  --spm-wanted  consider packages installed with a Source Package Manager to
                be wanted
For example:

Code: Select all

fitzcarraldo-pc /home/fitzcarraldo # equo unused
╠  @@ Running unused packages test...
╠ # [3.2MB] app-admin/sudo-1.8.23
╠ # [408.3kB] app-crypt/sbsigntools-0.6-r1
╠ # [1.3MB] dev-cpp/yaml-cpp-0.6.2
╠ # [172.2MB] dev-db/mariadb-10.3.7
╠ # [1.1MB] dev-db/mariadb-connector-c-3.0.4
╠ # [1.8MB] dev-db/unixODBC-2.3.6
╠ # [7.8MB] dev-games/irrlicht-1.8.4
╠ # [390.5kB] dev-lang/jimtcl-0.76
╠ # [528.1kB] dev-libs/cloog-0.18.4
╠ # [171.3kB] dev-libs/jansson-2.11
╠ # [2.3MB] dev-libs/libevent-2.1.8
╠ # [1.3MB] dev-libs/libx86emu-1.1
╠ # [48.4kB] dev-perl/TermReadKey-2.370.0
╠ # [1.2kB] dev-python/namespace-google-1
╠ # [13.0MB] dev-python/protobuf-python-3.5.2-r1
╠ # [1.0MB] dev-qt/qtpositioning-5.11.1
╠ # [258.4kB] dev-qt/qtwebchannel-5.11.1
╠ # [179.0MB] dev-qt/qtwebengine-5.11.1
╠ # [497.6kB] dev-util/dialog-1.3.20171209
╠ # [20.7MB] games-action/minetest-0.4.17
╠ # [1.4MB] media-libs/libmp4v2-2.0.0
╠ # [45.2kB] media-libs/libtxc_dxtn-1.0.1-r3
╠ # [357.2kB] net-libs/libnet-1.2_rc3-r1
╠ # [851.9kB] net-libs/libpcap-1.8.1
╠ # [448.6kB] net-libs/libsrtp-1.6.0
╠ # [705.7kB] net-libs/libupnp-1.6.21
╠ # [1.3MB] net-misc/networkmanager-openvpn-1.8.2
╠ # [4.8MB] net-misc/ntp-4.2.8_p11
╠ # [1.1MB] net-vpn/openvpn-2.4.6
╠ # [97.4kB] sys-apps/dmapi-2.2.12-r1
╠ # [220.4kB] sys-apps/hdparm-9.56
╠ # [3.2MB] sys-apps/hwinfo-21.23
╠ # [9.0kB] sys-apps/keyboard-configuration-helpers-2.6-r3
╠ # [209.2kB] sys-apps/usb_modeswitch-2.5.2
╠ # [321.9kB] sys-apps/usbutils-010
╠ # [266.0kB] sys-auth/nss-mdns-0.13
╠ # [80.7kB] sys-boot/efibootmgr-0.12
╠ # [58.7MB] sys-boot/grub-2.02_beta3-r1
╠ # [67.4kB] sys-boot/os-prober-1.71
╠ # [137.9MB] sys-devel/clang-4.0.1
╠ # [0.0b] sys-devel/clang-runtime-4.0.1
╠ # [0.0b] sys-devel/clang-runtime-5.0.1
╠ # [217.6kB] sys-fs/dosfstools-4.1
╠ # [1.6MB] sys-fs/jfsutils-1.1.15
╠ # [2.1MB] sys-fs/ntfs3g-2017.3.23-r1
╠ # [358.7kB] sys-fs/squashfs-tools-4.3-r2
╠ # [904.1kB] sys-fs/xfsdump-3.1.8
╠ # [7.2MB] sys-fs/zfs-0.7.8
╠ # [353.9kB] sys-libs/compiler-rt-4.0.1
╠ # [356.6kB] sys-libs/compiler-rt-5.0.1
╠ # [151.9MB] sys-libs/compiler-rt-sanitizers-4.0.1
╠ # [116.3MB] sys-libs/compiler-rt-sanitizers-5.0.1
╠ # [231.5kB] sys-libs/efivar-0.21
╠ # [150.5kB] sys-power/acpid-2.0.29-r1
╠ # [4.9kB] sys-process/cronbase-0.3.7-r6
╠ # [133.8kB] sys-process/cronie-1.5.1-r1
╠ # [450.7kB] sys-process/psmisc-23.1-r1
╠ # [0.0b] virtual/cron-0-r1
╠ # [0.0b] virtual/mysql-5.6-r12
╠ # [184.8MB] www-client/google-chrome-67.0.3396.99
╠ # [29.9kB] x11-apps/sessreg-1.1.1
╠ # [40.2kB] x11-apps/xconsole-1.0.7
╠ # [393.3kB] x11-apps/xdm-1.1.11-r3
╠ # [27.9kB] x11-apps/xrefresh-1.0.6
╠ # [377.1MB] x11-drivers/nvidia-userspace-396.24
╠ # [80.8kB] x11-drivers/xf86-input-joystick-1.6.3
╠ # [146.7kB] x11-drivers/xf86-input-libinput-0.27.1
╠ # [78.2kB] x11-drivers/xf86-input-mtrack-0.5.0
╠ # [278.9kB] x11-drivers/xf86-input-synaptics-1.9.1
╠ # [59.2kB] x11-drivers/xf86-input-vmmouse-13.1.0-r1
╠ # [429.2kB] x11-drivers/xf86-input-wacom-0.36.0-r2
╠ # [233.0kB] x11-drivers/xf86-video-amdgpu-18.0.1
╠ # [142.1kB] x11-drivers/xf86-video-ast-1.1.5
╠ # [36.0kB] x11-drivers/xf86-video-dummy-0.3.8
╠ # [176.5kB] x11-drivers/xf86-video-glint-1.2.9
╠ # [2.5MB] x11-drivers/xf86-video-intel-2.99.917_p20180214-r1
╠ # [418.0kB] x11-drivers/xf86-video-nouveau-1.0.15-r1
╠ # [244.5kB] x11-drivers/xf86-video-nv-2.1.21
╠ # [595.9kB] x11-drivers/xf86-video-openchrome-0.6.0
╠ # [288.3kB] x11-drivers/xf86-video-qxl-0.1.5
╠ # [245.9kB] x11-drivers/xf86-video-r128-6.10.2
╠ # [171.3kB] x11-drivers/xf86-video-siliconmotion-1.7.9
╠ # [97.1kB] x11-drivers/xf86-video-tdfx-1.4.7
╠ # [58.2kB] x11-drivers/xf86-video-vboxvideo-1.0.0
╠ # [261.0kB] x11-drivers/xf86-video-vmware-13.3.0
╠ # [45.8kB] x11-drivers/xf86-video-voodoo-1.2.5
╠ # [811.6kB] x11-libs/libXaw3d-1.6.2
╠ # [27.2kB] x11-libs/libXxf86misc-1.0.3-r2
╠ # [322.1kB] x11-misc/xvkbd-3.9
╠ # [0.0b] x11-proto/fontsproto-2.1.3-r1
╠ # [0.0b] x11-proto/xf86miscproto-0.9.3-r1
╠ # [253.8kB] x11-wm/twm-1.0.10
From the list returned by equo unused, I can see many installed packages that have indeed not been used to date in this particular installation. For example, the Sabayon Linux Installer installed x11-drivers/xf86-video-siliconmotion-1.7.9 but this machine does not have a Silicon Motion GPU. Therefore I can remove (uninstall) that package:

Code: Select all

fitzcarraldo-pc /home/fitzcarraldo # equo remove x11-drivers/xf86-video-siliconmotion-1.7.9
╠ / Calculating inverse dependencies for x11-drivers/xf86-vide╠  @@ These are the packages that would be removed:
╠  ## [sabayon-weekly] x11-drivers/xf86-video-siliconmotion-1.7.9 [171.3kB]                                                 
╠  @@ Packages that would be removed: 1
╠  @@ Freed disk space: 171.3kB
╠  @@ Total bandwidth wasted: 119.9kB
╠  --- >>>  (1/1) x11-drivers/xf86-video-siliconmotion-1.7.9
╠    ## Removing: x11-drivers/xf86-video-siliconmotion-1.7.9
╠    ## Removing from Entropy: x11-drivers/xf86-video-siliconmotion-1.7.9                                                   
>>> Regenerating /etc/ld.so.cache...
╠    ## Package phase: postremove
╠  @@ All done.
╠  @@ No configuration files to update.

User avatar
sabayonino
Sagely Hen
Posts: 3251
Joined: Sun Sep 21, 2008 1:12
Location: Italy
Contact:

Re: equo unused

Post by sabayonino » Sun Aug 26, 2018 23:04

Fitzcarraldo wrote:
Sun Aug 26, 2018 22:49

I wonder if the equo unusedpackages [unused] command looks at the Accessed timestamp of an installed application or library to see when it was used, and, if it has not been used since installation, offers you the option of removing (uninstalling) the associated package.
I can't understand how "unused" works.

For me , Digikam is in "unused" list but I run Digikam every day but timestamp/access time application/libraries is/are newer

Code: Select all

equo unused | grep digikam
╠ # [164.7MB] media-gfx/digikam-5.9.0
If you run "unused" be sure what you're removing. Run --pretend/--ask and --nodeps options always
[Che Cos'è Il Calcolo Distribuito (BOINC)

BOINC ready ! Sabayon+BOINC = BILD ,my Sabayon spin :cyclops: - Ready to crunch for the Science everywhere :)

User avatar
Fitzcarraldo
Sagely Hen
Posts: 8113
Joined: Sat Mar 10, 2007 5:40
Location: United Kingdom
Contact:

Re: equo unused

Post by Fitzcarraldo » Sun Aug 26, 2018 23:19

How is your Python? Here is the current source-code file /entropy-master/client/solo/commands/unused.py from the Git repository:

Code: Select all

# -*- coding: utf-8 -*-
"""

    @author: Fabio Erculiani <[email protected]>
    @author: Slawomir Nizio <[email protected]>
    @contact: [email protected]
    @copyright: Fabio Erculiani, Slawomir Nizio
    @license: GPL-2

    B{Entropy Command Line Client}.

"""
import sys
import argparse

from entropy.i18n import _
from entropy.const import etpConst
from entropy.misc import Lifo
from entropy.output import red, blue, brown, darkgreen

import entropy.tools

from solo.commands.descriptor import SoloCommandDescriptor
from solo.commands.command import SoloCommand, sharedlock


class SoloUnused(SoloCommand):
    """
    Main Solo Unused command.
    """

    NAME = "unusedpackages"
    ALIASES = ["unused"]
    ALLOW_UNPRIVILEGED = True

    INTRODUCTION = """\
Report unused packages that could be removed.
"""
    SEE_ALSO = ""

    def __init__(self, args):
        SoloCommand.__init__(self, args)
        self._quiet = False
        self._sortbysize = False
        self._spm_wanted = False
        self._commands = []

    def man(self):
        """
        Overridden from SoloCommand.
        """
        return self._man()

    def _get_parser(self):
        """
        Overridden from SoloCommand.
        """
        _commands = []
        descriptor = SoloCommandDescriptor.obtain_descriptor(
            SoloUnused.NAME)
        parser = argparse.ArgumentParser(
            description=descriptor.get_description(),
            formatter_class=argparse.RawDescriptionHelpFormatter,
            prog="%s %s" % (sys.argv[0], SoloUnused.NAME))

        parser.add_argument("--quiet", "-q", action="store_true",
                            default=self._quiet,
                            help=_("show less details (useful for scripting)"))
        _commands.append("--quiet")
        _commands.append("-q")

        parser.add_argument("--sortbysize", action="store_true",
                            default=self._sortbysize,
                            help=_("sort packages by size"))
        _commands.append("--sortbysize")

        parser.add_argument("--spm-wanted", action="store_true",
                            default=self._spm_wanted,
                            help=_("consider packages installed with" \
                                   " a Source Package Manager to be wanted"))
        _commands.append("--spm-wanted")

        self._commands = _commands
        return parser

    def parse(self):
        """
        Parse command
        """
        parser = self._get_parser()
        try:
            nsargs = parser.parse_args(self._args)
        except IOError as err:
            sys.stderr.write("%s\n" % (err,))
            return parser.print_help, []

        self._quiet = nsargs.quiet
        self._sortbysize = nsargs.sortbysize
        self._spm_wanted = nsargs.spm_wanted

        return self._call_shared, [self._unused]

    def bashcomp(self, last_arg):
        """
        Overridden from SoloCommand.
        """
        import sys

        self._get_parser()
        return self._bashcomp(sys.stdout, last_arg, self._commands)

    def _filter_user_packages(self, inst_repo, pkg_ids):
        """
        For a given repository and package IDs, return only
        the IDs of packages that are marked as being installed
        by user, and optionally also packages installed using
        SPM.
        """
        def _filter_user(pkg_id):
            source = inst_repo.getInstalledPackageSource(pkg_id)
            return source == etpConst['install_sources']['user']

        def _filter_user_or_by_SPM(pkg_id):
            if _filter_user(pkg_id):
                return True

            repo = inst_repo.getInstalledPackageRepository(x)
            if repo is None:
                # sensible default
                return False
            else:
                return repo == etpConst['spmdbid']

        if self._spm_wanted:
            filter_func = _filter_user_or_by_SPM
        else:
            filter_func = _filter_user

        return frozenset([x for x in pkg_ids if filter_func(x)])

    def _get_flat_deps(self, ids_to_check, get_deps_func):
        """
        Return a set (frozenset) of package IDs that are dependencies
        of provided packages, recursively.
        """
        stack = Lifo()

        result_deps = set()

        for pkg_id in ids_to_check:
            stack.push(pkg_id)

        while stack.is_filled():
            pkg_id = stack.pop()
            if pkg_id in result_deps:
                continue

            result_deps.add(pkg_id)

            for dep_id in get_deps_func(pkg_id):
                if dep_id not in result_deps:
                    stack.push(dep_id)

        return frozenset(result_deps)

    def _get_dep_ids(self, inst_repo):
        """
        Return a function that returns dependencies (frozenset of package IDs)
        of a given package.
        """
        def _get(pkg_id):
            dep_ids = []
            deps = inst_repo.retrieveDependencies(pkg_id)

            for dep in deps:
                package_id, pkg_rc = inst_repo.atomMatch(dep)
                if pkg_rc == 0:
                    dep_ids.append(package_id)

            return frozenset(dep_ids)

        return _get

    @sharedlock
    def _unused(self, entropy_client, inst_repo):
        """
        Command implementation.
        """
        if not self._quiet:
            entropy_client.output(
                "%s..." % (
                    blue(_("Running unused packages test")),),
                header=red(" @@ "))

        all_ids = inst_repo.listAllPackageIds()
        user_packages = self._filter_user_packages(inst_repo, all_ids)
        wanted_ids = self._get_flat_deps(user_packages,
                                         self._get_dep_ids(inst_repo))
        not_needed = all_ids - wanted_ids

        def _sort_key(x):
            sort_index = 1 if self._sortbysize else 0
            return x[sort_index]

        not_needed_pkgs_data = sorted(
            [(inst_repo.retrieveAtom(x), inst_repo.retrieveOnDiskSize(x))
             for x in not_needed],
            key=_sort_key)

        if self._quiet:
            entropy_client.output(
                '\n'.join([x[0] for x in not_needed_pkgs_data]),
                level="generic")
        else:
            for atom, disk_size in not_needed_pkgs_data:
                disk_size = entropy.tools.bytes_into_human(disk_size)
                entropy_client.output(
                    "# %s%s%s %s" % (
                        blue("["), brown(disk_size),
                        blue("]"), darkgreen(atom),))

SoloCommandDescriptor.register(
    SoloCommandDescriptor(
        SoloUnused,
        SoloUnused.NAME,
        _("show unused packages (pay attention)"))
    )

joost
Sagely Hen
Posts: 2694
Joined: Fri Nov 17, 2006 12:11
Location: The Netherlands
Contact:

Re: equo unused

Post by joost » Mon Aug 27, 2018 7:38

If I recall correctly it only checks for atoms with no reverse dependencies. So really pay attention what you remove from the list that it produces. It might actually be something you need.
Image
My blog | Twitter | Please support Sabayon: Image

User avatar
Fitzcarraldo
Sagely Hen
Posts: 8113
Joined: Sat Mar 10, 2007 5:40
Location: United Kingdom
Contact:

Re: equo unused

Post by Fitzcarraldo » Mon Aug 27, 2018 10:01

joost wrote:
Mon Aug 27, 2018 7:38
If I recall correctly it only checks for atoms with no reverse dependencies. So really pay attention what you remove from the list that it produces. It might actually be something you need.
In that case I think 'unusedpackages [unused]' is not a particularly good name for the option. Something along the lines of 'norevdeps' would perhaps have made its purpose more obvious. I think that typing 'equo norevdeps' would probably be more likely to be understood by some users than typing 'equo unused'.

Post Reply