bash library for gentoo utils
Go to file
2024-10-03 16:33:07 +02:00
assets prettify README 2024-09-15 20:30:45 +02:00
config.sh add etools_get_version 2024-09-29 17:23:05 +02:00
etools minor bug fix 2024-10-03 16:32:35 +02:00
etools.conf minor bug fixes + major performance updates 2024-10-01 22:58:13 +02:00
helper.sh saved helper.sh 2024-10-03 16:33:07 +02:00
LICENSE Initial commit 2024-09-09 15:18:53 +02:00
README.md add function to get current version 2024-09-30 22:53:20 +02:00

etools

bash library for gentoo utils

How to use

Just source it!

source etools

What it does

provided function are the following:

einfo <info>
ewarn <warning>
eerror <error>
etools_configure
etools_unset
etools_smart_find <package name> [repo]
# repo can be a path relative to /var/db/repos/ or a full path
# default will be /var/db/repos/ so all repos will be searched
eools_get_version <package name> [offset]
# offset will output the <offset> latest version
# eg.: when 1.2.3 is latest offset 1 will result in a version 1 beneath 1.2.2-r2 for example
etools_current_version <package> [index]
# get currently installed version of a package
# it'll show all version, by specifying the index the n'th version starting at 0 will be displayed
# btw feel free to time all of them ;)

Configuration

etools searches for a configuration file at the following locations:

/etc/etools/etools.conf
$HOME/.config/etools.conf
$HOME/.config/etools/etools.conf

Look at the exmaple configuration file for an example with all configuration options.

For the default values take a look at config.sh.

NOTE: Letting already set options fallback to defaults will not work, as defaults only get set when the relative variables are undefined. To force reload:

etools_unset
source etools

Motivation

They say "A picture is worth a thousand words", so here ya go:

Test it

This script reads all packages in your world file and runs etools_smart_find with the name of the package

while IFS= read -r line; do
    if [[ ${line%% *} == ${line##* }  ]]; then
        echo -e "${line%% *} \e[32mpassed\e[0m";
    else
        echo -e "${line%% *} \e[31mFAILED\e[0m";
    fi;
done <<< $(
    for pkg in $(cat /var/lib/portage/world); do
        echo -n "$pkg ";
        etools_smart_find $(echo $pkg | awk -F'/' '{print $2}');
    done
);