Commit 2b200d6f authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm-repo: fixes and improvements

parent 616bb37d
...@@ -217,7 +217,7 @@ __epm_addrepo_apt() ...@@ -217,7 +217,7 @@ __epm_addrepo_apt()
{ {
local repo="$*" local repo="$*"
epm repo list --quiet 2>/dev/null | grep -q -F "$repo" && return 0 epm --quiet repo list | grep -q -F "$repo" && return 0
if [ -n "$dryrun" ] ; then if [ -n "$dryrun" ] ; then
echo "$repo" echo "$repo"
...@@ -428,7 +428,7 @@ __epm_addrepo_alpine() ...@@ -428,7 +428,7 @@ __epm_addrepo_alpine()
{ {
local repo="$1" local repo="$1"
is_url "$repo" || fatal "Only URL is supported" is_url "$repo" || fatal "Only URL is supported"
epm repo list --quiet | grep -q -F "$repo" && return 0 epm --quiet repo list | grep -q -F "$repo" && return 0
echo "$repo" | sudocmd tee -a /etc/apk/repositories echo "$repo" | sudocmd tee -a /etc/apk/repositories
} }
......
...@@ -38,8 +38,8 @@ __epm_removerepo_apt() ...@@ -38,8 +38,8 @@ __epm_removerepo_apt()
for i in /etc/apt/sources.list /etc/apt/sources.list.d/*.list ; do for i in /etc/apt/sources.list /etc/apt/sources.list.d/*.list ; do
[ -s "$i" ] || continue [ -s "$i" ] || continue
# touch file only when it is needed # touch file only when it is needed
grep -q -E "$repo" $i || continue grep -q -F "$repo" $i || continue
$sc sed -i -e "s|.*$repo.*||" $i $sc sed -i -e "s|.*$(sed_escape "$repo").*||" $i
done done
} }
...@@ -47,7 +47,7 @@ __epm_removerepo_apt() ...@@ -47,7 +47,7 @@ __epm_removerepo_apt()
__epm_grep_repo_list() __epm_grep_repo_list()
{ {
while [ -n "$1" ] ; do while [ -n "$1" ] ; do
epm --quiet repo list | grep -E "$1" epm --quiet repo list "$1"
shift shift
done done
} }
...@@ -55,17 +55,17 @@ __epm_grep_repo_list() ...@@ -55,17 +55,17 @@ __epm_grep_repo_list()
# remove grepped lines # remove grepped lines
__epm_removerepo_alt_grepremove() __epm_removerepo_alt_grepremove()
{ {
local rl="$1" local rl="$*"
if [ "$rl" = "all" ] ; then if [ "$rl" = "all" ] ; then
rl=".*" rl="*"
fi fi
# ^rpm means full string # ^rpm means full string
if !rhas "$1" "^rpm" ; then if ! rhas "$rl" "^rpm" ; then
rl="$(__epm_grep_repo_list "$@" 2>/dev/null)" rl="$(__epm_grep_repo_list "$rl" 2>/dev/null)"
if [ -z "$rl" ] ; then if [ -z "$rl" ] ; then
[ -n "$verbose" ] && warning 'Can'\''t find '$*' in the repos (see # epm repolist output)' [ -n "$verbose" ] && warning 'Can'\''t find '$rl' in the repos (see # epm repolist output)'
return 1 return 1
fi fi
fi fi
...@@ -124,7 +124,7 @@ __epm_removerepo_alt() ...@@ -124,7 +124,7 @@ __epm_removerepo_alt()
if echo "$*" | grep -q "^rpm" ; then if echo "$*" | grep -q "^rpm" ; then
__epm_removerepo_apt "$*" __epm_removerepo_apt "$*"
else else
info "removing source.list entries by mask '$*'" info "removing all source.list"
__epm_removerepo_alt_grepremove "$*" __epm_removerepo_alt_grepremove "$*"
fi fi
;; ;;
......
...@@ -32,6 +32,7 @@ __epm_repodisable_alt() ...@@ -32,6 +32,7 @@ __epm_repodisable_alt()
else else
rl="$( (epm --quiet repolist) 2>/dev/null | grep -F "$1" | head -n1 )" rl="$( (epm --quiet repolist) 2>/dev/null | grep -F "$1" | head -n1 )"
[ -z "$rl" ] && warning 'Can'\''t find $1 entries in the repos (see # epm repolist output)' && return 1 [ -z "$rl" ] && warning 'Can'\''t find $1 entries in the repos (see # epm repolist output)' && return 1
[ -z "$rl" ] && warning "Can't find '" $1 "' entries in the repos (see # epm repolist output)" && return 1
fi fi
echo "$rl" | while read rp ; do echo "$rl" | while read rp ; do
[ -n "$dryrun" ] && message 'will comment $rp' && continue [ -n "$dryrun" ] && message 'will comment $rp' && continue
......
...@@ -30,8 +30,9 @@ __epm_repoenable_alt() ...@@ -30,8 +30,9 @@ __epm_repoenable_alt()
if rhas "$1" "\^rpm" ; then if rhas "$1" "\^rpm" ; then
rl="$(echo "$1" | sed -e 's|\^||')" rl="$(echo "$1" | sed -e 's|\^||')"
else else
rl="$( epm --quiet --all repolist 2>/dev/null | grep -F "$1" | head -n1 | sed -e 's|[[:space:]]*#[[:space:]]*||' )" rl="$( epm --quiet repolist --all 2>/dev/null | grep -F "$1" | head -n1 | sed -e 's|[[:space:]]*#[[:space:]]*||' )"
[ -z "$rl" ] && warning 'Can'\''t find commented $1 in the repos (see # epm repolist output)' && return 1 [ -z "$rl" ] && warning 'Can'\''t find commented $1 in the repos (see # epm repolist output)' && return 1
[ -z "$rl" ] && warning "Can't find commented '"$1"' in the repos (see # epm repolist output)" && return 1
fi fi
echo "$rl" | while read rp ; do echo "$rl" | while read rp ; do
[ -n "$dryrun" ] && message 'will uncomment $rp' && continue [ -n "$dryrun" ] && message 'will uncomment $rp' && continue
......
...@@ -69,7 +69,7 @@ __replace_alt_version_in_repo() ...@@ -69,7 +69,7 @@ __replace_alt_version_in_repo()
#echo "Upgrading $DISTRNAME from $1 to $2 ..." #echo "Upgrading $DISTRNAME from $1 to $2 ..."
epm --quiet repo list | sed -E -e "s|($1)|{\1}->{$2}|g" | grep -E --color -- "$1" epm --quiet repo list | sed -E -e "s|($1)|{\1}->{$2}|g" | grep -E --color -- "$1"
# ask and replace only we will have changes # ask and replace only we will have changes
if epm --quiet repo list | grep -E -q -- "$1" ; then if epm --quiet repo list "$1" ; then
__replace_text_in_alt_repo "/^ *#/! s!$1!$2!g" __replace_text_in_alt_repo "/^ *#/! s!$1!$2!g"
fi fi
} }
......
...@@ -91,6 +91,8 @@ print_apt_sources_list() ...@@ -91,6 +91,8 @@ print_apt_sources_list()
{ {
local LISTS='/etc/apt/sources.list /etc/apt/sources.list.d/*.list' local LISTS='/etc/apt/sources.list /etc/apt/sources.list.d/*.list'
[ -n "$1" ] && echo "$*" | grep -q "\.[*?]" && warning "Only glob symbols * and ? are supported. Don't use regexp here!"
if [ "$1" = "-a" ] || [ "$1" = "--all" ] ; then if [ "$1" = "-a" ] || [ "$1" = "--all" ] ; then
shift shift
local wc=$(__convert_glob__to_regexp "$*") local wc=$(__convert_glob__to_regexp "$*")
......
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