epm-list_available 3.54 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/bin/sh
#
# Copyright (C) 2023  Etersoft
# Copyright (C) 2023  Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

load_helper epm-sh-warmup

__aptcyg_print_full()
{
    #showcmd apt-cyg show
25
    local VERSION=$(a= apt-cyg show "$1" | grep -m1 "^version: " | sed -e "s|^version: ||g")
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
    echo "$1-$VERSION"
}

__fo_pfn()
{
    grep -v "^$" | grep -- "$pkg_filenames"
}

epm_list_available()
{

    if [ -n "$1" ] ; then
        # list --available with args is the same as search
        load_helper epm-search
        epm_search "$@"
        return
    fi

44 45 46 47 48 49 50 51 52 53 54 55 56
    # use cache we got during epm update
    # TODO: update from this place if obsoleted
    if [ -n "$short" ] ; then
        if [ -s $epm_vardir/available-packages ] ; then
            cat $epm_vardir/available-packages
            return
        elif [ -n "$direct" ] ; then
            # don't go in long retrieving if --direct is used
            return
        fi
    fi


57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
case $PMTYPE in
    apt-*)
        warmup_dpkgbase
        # TODO: use apt list
        if [ -n "$short" ] ; then
            docmd apt-cache search . | sed -e "s| .*||g"
        else
            docmd apt-cache search .
        fi
        ;;
    dnf-*)
        warmup_rpmbase
        if [ -n "$short" ] ; then
            docmd dnf list --available | sed -e "s| .*||g"
        else
            docmd dnf list --available
        fi
        ;;
    yum-*)
        warmup_rpmbase
        if [ -n "$short" ] ; then
78
            docmd yum list available | sed -e "s| .*||g"
79
        else
80
            docmd yum list available
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
        fi
        ;;
    packagekit)
        # see for filter list: pkcon get-filters
        # TODO: implement --short
        docmd pkcon get-packages -p | sed -e "s| (.*||g" -e "s|.* ||"
        ;;
    snappy)
        docmd snappy find .
        ;;
    snap)
        docmd snap find .
        ;;
    appget)
        docmd appget search .
        ;;
    winget)
        docmd winget search .
        ;;
    emerge)
        docmd eix --world
        ;;
    termux-pkg)
        docmd pkg list-all
        ;;
    npackd)
        CMD="npackdcl list"
        ;;
    eopkg)
        CMD="eopkg list-available"
        ;;
112 113
    choco)
        CMD="choco search ."
114 115 116 117 118 119 120 121 122 123 124 125 126
        ;;
    slackpkg)
        CMD="slackpkg search ."
        ;;
    homebrew)
        docmd brew search .
        ;;
    opkg)
        CMD="opkg list-available"
        ;;
    apk)
        CMD="apk list --available"
        ;;
127 128 129
    nix)
        CMD="nix-env -qaP"
        ;;
130 131 132 133 134 135 136 137 138 139 140
    xbps)
        CMD="xbps-query -l -R"
        showcmd $CMD
        if [ -n "$short" ] ; then
            $CMD | sed -e "s|^ii ||g" -e "s| .*||g" -e "s|\(.*\)-.*|\1|g" | __fo_pfn
        else
            $CMD | sed -e "s|^ii ||g" -e "s| .*||g" | __fo_pfn
        fi
        return 0
        ;;
    *)
141
        fatal 'Have no suitable query command for $PMTYPE'
142 143 144
        ;;
esac

145 146 147
if [ -n "$CMD" ] ; then
    docmd $CMD | __fo_pfn
fi
148 149 150
# FIXME: we print empty lines, but will lost error status

}