epm-repolist 2.62 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
__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
}

print_apt_sources_list()
{
    local LISTS='/etc/apt/sources.list /etc/apt/sources.list.d/*.list'
60 61 62
    if [ -n "$quiet" ] ; then
        __print_apt_sources_list $LISTS
    else
63
        __print_apt_sources_list_verbose $LISTS
64
    fi
65 66 67
}


68 69
epm_repolist()
{
70

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

73
case $PMTYPE in
74
	apt-rpm)
75
		#assure_exists apt-repo
76 77
		if tasknumber "$1" >/dev/null ; then
			get_task_packages "$@"
78
		else
79 80
			print_apt_sources_list
			#docmd apt-repo list
81
		fi
82
		;;
83 84 85
	deepsolver-rpm)
		docmd ds-conf
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
86
	apt-dpkg|aptitude-dpkg)
87
		print_apt_sources_list
88
		;;
89
	yum-rpm)
90
		docmd yum repolist $verbose
91
		;;
92
	dnf-rpm)
93
		docmd dnf repolist $verbose
94
		;;
95
	urpm-rpm)
96
		docmd urpmq --list-url
97
		;;
98
	zypper-rpm)
99 100
		docmd zypper sl -d
		;;
101
	packagekit)
102 103
		docmd pkcon repo-list
		;;
104
	emerge)
105
		docmd eselect profile list
106
		docmd layman -L
107
		;;
108 109 110
	xbps)
		docmd xbps-query -L
		;;
111 112 113
	winget)
		docmd winget source list
		;;
114
	pacman)
115
		docmd grep -v -- "^#\|^$" /etc/pacman.conf
116
		;;
117
	slackpkg)
118
		docmd grep -v -- "^#\|^$" /etc/slackpkg/mirrors
119
		;;
120
	*)
121
		fatal "Have no suitable command for $PMTYPE"
122 123 124 125
		;;
esac

}