epm-repolist 3.63 KB
Newer Older
1 2
#!/bin/sh
#
3 4
# Copyright (C) 2012, 2016, 2019, 2020, 2021  Etersoft
# Copyright (C) 2012, 2016, 2019, 2020, 2021  Vitaly Lipatov <lav@etersoft.ru>
5
#
6 7 8
# 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
9 10 11 12 13
# (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
14
# GNU Affero General Public License for more details.
15
#
16 17
# 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/>.
18 19
#

20 21
load_helper epm-sh-altlinux

22
__print_apt_sources_list()
23
{
24
    local i
25 26
    for i in $@ ; do
        test -r "$i" || continue
27
        grep -v -- "^.*#" $i
28
    done | grep -v -- "^ *\$"
29 30
}

31 32 33 34 35 36 37 38 39 40
__print_apt_sources_list_full()
{
    local i
    for i in $@ ; do
        test -r "$i" || continue
        grep -- "^[[:space:]]*#*[[:space:]]*rpm" $i
    done | grep -v -- "^ *\$"
}

# TODO: remove
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
__print_apt_sources_list_list()
{
    local i
    for i in $@ ; do
        test -r "$i" || continue
        grep -v -- "^.*#" $i | grep -v -- "^ *\$" | grep -q . && echo "$i"
    done
}

__info_cyan()
{
		set_boldcolor $CYAN
		echo "$*" >&2
		restore_color
}

__print_apt_sources_list_verbose()
{
    local i
    for i in $@ ; do
        test -r "$i" || continue
        grep -v -- "^.*#" $i | grep -v -- "^ *\$" | grep -q . && __info_cyan "$i:" || continue
        grep -v -- "^.*#" $i | grep -v -- "^ *\$" | sed -e 's|^|    |'
    done
}

67 68 69 70 71 72 73 74 75 76
__print_apt_sources_list_verbose_full()
{
    local i
    for i in $@ ; do
        test -r "$i" || continue
        grep -- "^[[:space:]]*#*[[:space:]]*rpm" $i | grep -v -- "^ *\$" | grep -q . && echo && __info_cyan "$i:" || continue
        grep -- "^[[:space:]]*#*[[:space:]]*rpm" $i | grep -v -- "^ *\$" | sed -e 's|^|    |' -e "s|\(.*#.*\)|$(set_color $WHITE)\1$(restore_color)|"
    done
}

77 78 79
print_apt_sources_list()
{
    local LISTS='/etc/apt/sources.list /etc/apt/sources.list.d/*.list'
80 81 82 83 84 85 86 87 88 89

    if [ "$1" = "-a" ] || [ "$1" = "--all" ] ; then
        if [ -n "$quiet" ] ; then
            __print_apt_sources_list_full $LISTS
        else
            __print_apt_sources_list_verbose_full $LISTS
        fi
        return
    fi

90 91 92
    if [ -n "$quiet" ] ; then
        __print_apt_sources_list $LISTS
    else
93
        __print_apt_sources_list_verbose $LISTS
94
    fi
95 96 97
}


98 99
epm_repolist()
{
100

101
[ -z "$*" ] || [ "$PMTYPE" = "apt-rpm" ] || fatal "No arguments are allowed here"
102

103
case $PMTYPE in
104
	apt-rpm)
105
		#assure_exists apt-repo
106 107
		if tasknumber "$1" >/dev/null ; then
			get_task_packages "$@"
108
		else
109
			print_apt_sources_list "$@"
110
			#docmd apt-repo list
111
		fi
112
		;;
113 114 115
	deepsolver-rpm)
		docmd ds-conf
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
116
	apt-dpkg|aptitude-dpkg)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
117
		print_apt_sources_list "$@"
118
		;;
119
	yum-rpm)
120
		docmd yum repolist $verbose
121
		[ -n "$verbose" ] || info "Use --verbose if you need detail information."
122
		;;
123
	dnf-rpm)
124
		docmd dnf repolist $verbose
125
		[ -n "$verbose" ] || info "Use --verbose if you need detail information."
126
		;;
127
	urpm-rpm)
128
		docmd urpmq --list-url
129
		;;
130
	zypper-rpm)
131 132
		docmd zypper sl -d
		;;
133
	packagekit)
134 135
		docmd pkcon repo-list
		;;
136
	emerge)
137
		docmd eselect profile list
138
		docmd layman -L
139
		;;
140 141 142
	xbps)
		docmd xbps-query -L
		;;
143 144 145
	winget)
		docmd winget source list
		;;
146 147 148
	eoget)
		docmd eoget list-repo
		;;
149
	pacman)
150
		docmd grep -v -- "^#\|^$" /etc/pacman.conf
151
		;;
152
	slackpkg)
153
		docmd grep -v -- "^#\|^$" /etc/slackpkg/mirrors
154
		;;
155
	*)
156
		fatal "Have no suitable command for $PMTYPE"
157 158 159 160
		;;
esac

}