Commit c2ad5f20 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm-repolist: add regexp support

parent 437d2b29
#!/bin/sh
#
# Copyright (C) 2012, 2016, 2019, 2020, 2021 Etersoft
# Copyright (C) 2012, 2016, 2019, 2020, 2021 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2016, 2019, 2020, 2021, 2025 Etersoft
# Copyright (C) 2012, 2016, 2019, 2020, 2021, 2025 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
......@@ -21,23 +21,28 @@ load_helper epm-sh-altlinux
__print_apt_sources_list()
{
local regexp="$1"
shift
local i
for i in $@ ; do
test -r "$i" || continue
grep -v -- "^.*#" $i
done | grep -v -- "^ *\$"
done | grep -v -- "^ *\$" | grep -E "$regexp"
}
__print_apt_sources_list_full()
{
local regexp="$1"
shift
local i
for i in $@ ; do
test -r "$i" || continue
grep -- "^[[:space:]]*#*[[:space:]]*rpm" $i
done | grep -v -- "^ *\$"
done | grep -v -- "^ *\$" | grep -E "$regexp"
}
# TODO: remove
# print lists with active values
__print_apt_sources_list_list()
{
local i
......@@ -56,21 +61,25 @@ __info_cyan()
__print_apt_sources_list_verbose()
{
local regexp="$1"
shift
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|^| |'
grep -v -- "^.*#" $i | grep -v -- "^ *\$" | sed -e 's|^| |' | grep -E --color "$regexp"
done
}
__print_apt_sources_list_verbose_full()
{
local regexp="$1"
shift
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)|"
grep -- "^[[:space:]]*#*[[:space:]]*rpm" $i | grep -v -- "^ *\$" | sed -e 's|^| |' -e "s|\(.*#.*\)|$(set_color $WHITE)\1$(restore_color)|" | grep -E --color "$regexp"
done
}
......@@ -79,18 +88,19 @@ print_apt_sources_list()
local LISTS='/etc/apt/sources.list /etc/apt/sources.list.d/*.list'
if [ "$1" = "-a" ] || [ "$1" = "--all" ] ; then
shift
if [ -n "$quiet" ] ; then
__print_apt_sources_list_full $LISTS
__print_apt_sources_list_full "$*" $LISTS
else
__print_apt_sources_list_verbose_full $LISTS
__print_apt_sources_list_verbose_full "$*" $LISTS
fi
return
fi
if [ -n "$quiet" ] ; then
__print_apt_sources_list $LISTS
__print_apt_sources_list "$*" $LISTS
else
__print_apt_sources_list_verbose $LISTS
__print_apt_sources_list_verbose "$*" $LISTS
fi
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment