Commit 88ae5fc6 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm-repofix: rewrite epm repo change

parent 364c7f2b
...@@ -130,7 +130,8 @@ __try_fix_apt_source_list() ...@@ -130,7 +130,8 @@ __try_fix_apt_source_list()
local list="$1" local list="$1"
local br="$(__repofix_filter_vendor "$2")" local br="$(__repofix_filter_vendor "$2")"
local path="$3" local path="$3"
if grep -q -e "^[^#].*$path" $list ; then # FIXME: masked grep: предупреждение: stray \ before /
if grep -q -e "^[^#].*$path" $list 2>/dev/null ; then
if __repofix_check_vendor $br ; then if __repofix_check_vendor $br ; then
regexp_subst "/$path/s/^rpm[[:space:]]*([fhr])/rpm [$br] \1/" $list regexp_subst "/$path/s/^rpm[[:space:]]*([fhr])/rpm [$br] \1/" $list
else else
...@@ -169,29 +170,12 @@ __fix_alt_sources_list() ...@@ -169,29 +170,12 @@ __fix_alt_sources_list()
done done
} }
__subst_with_etersoft_url()
{
local NURL="http://download.etersoft.ru/pub ALTLinux"
echo "$1" | sed \
-e "s|h\?f\?t\?tp://ftp.altlinux.org/pub/distributions/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://ftp.basealt.ru/pub/distributions/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://mirror.yandex.ru/* altlinux|$NURL|" \
-e "s|h\?f\?t\?tp://mirror.eterfund.org/download.etersoft.ru/pub/* ALTLinux|$NURL|"
}
__subst_with_eterfund_url()
{
local NURL="https://mirror.eterfund.org/download.etersoft.ru/pub ALTLinux"
echo "$1" | sed \
-e "s|h\?f\?t\?tp://ftp.altlinux.org/pub/distributions/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://ftp.basealt.ru/pub/distributions/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://mirror.yandex.ru/* altlinux|$NURL|"
}
__subst_with_yandex_url() __subst_with_repo_url()
{ {
local NURL="http://mirror.yandex.ru altlinux" local NURL="$2"
echo "$1" | sed \ echo "$1" | sed \
-e "s|h\?f\?t\?tp://mirror.yandex.ru/* altlinux|$NURL|" \
-e "s|h\?f\?t\?tp://ftp.altlinux.org/pub/distributions/* ALTLinux|$NURL|" \ -e "s|h\?f\?t\?tp://ftp.altlinux.org/pub/distributions/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://ftp.basealt.ru/pub/distributions/* ALTLinux|$NURL|" \ -e "s|h\?f\?t\?tp://ftp.basealt.ru/pub/distributions/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://ftp.etersoft.ru/pub/* ALTLinux|$NURL|" \ -e "s|h\?f\?t\?tp://ftp.etersoft.ru/pub/* ALTLinux|$NURL|" \
...@@ -199,56 +183,15 @@ __subst_with_yandex_url() ...@@ -199,56 +183,15 @@ __subst_with_yandex_url()
-e "s|h\?f\?t\?tp://mirror.eterfund.org/download.etersoft.ru/pub/* ALTLinux|$NURL|" -e "s|h\?f\?t\?tp://mirror.eterfund.org/download.etersoft.ru/pub/* ALTLinux|$NURL|"
} }
__subst_with_basealt_url() __change_repo()
{
local NURL="http://ftp.basealt.ru/pub/distributions ALTLinux"
echo "$1" | sed \
-e "s|h\?f\?t\?tp://mirror.yandex.ru/* altlinux|$NURL|" \
-e "s|h\?f\?t\?tp://ftp.etersoft.ru/pub/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://mirror.eterfund.org/download.etersoft.ru/pub/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://download.etersoft.ru/pub/* ALTLinux|$NURL|"
}
__subst_with_altlinux_url()
{
local NURL="http://ftp.altlinux.org/pub/distributions ALTLinux"
echo "$1" | sed \
-e "s|h\?f\?t\?tp://mirror.yandex.ru/* altlinux|$NURL|" \
-e "s|h\?f\?t\?tp://ftp.etersoft.ru/pub/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://mirror.eterfund.org/download.etersoft.ru/pub/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://download.etersoft.ru/pub/* ALTLinux|$NURL|"
}
__fix_repo_to_etersoft()
{
local NN
a="" apt-repo list | grep -v debuginfo | grep -v etersoft | grep -v "file:/" | while read nn ; do
NN="$(__subst_with_etersoft_url "$nn")"
[ "$NN" = "$nn" ] && continue
epm removerepo "$nn"
epm addrepo "$NN"
done
}
__fix_repo_to_yandex()
{
local NN
a="" apt-repo list | grep -v debuginfo | grep -v mirror\.yandex | grep -v "file:/" | while read nn ; do
NN="$(__subst_with_yandex_url "$nn")"
[ "$NN" = "$nn" ] && continue
epm removerepo "$nn"
epm addrepo "$NN"
done
}
__fix_repo_to_basealt()
{ {
local SHORT="$1"
local REPLTO="$2"
local NN local NN
a="" apt-repo list | grep -v debuginfo | grep -v ftp.basealt | grep -v "file:/" | while read nn ; do a="" apt-repo list | grep -v $SHORT | grep -v "file:/" | while read nn ; do
NN="$(__subst_with_basealt_url "$nn")" NN="$(__subst_with_repo_url "$nn" "$REPLTO")"
[ "$NN" = "$nn" ] && continue [ "$NN" = "$nn" ] && continue
epm removerepo "$nn" epm addrepo "$NN" && epm removerepo "$nn" || return 1
epm addrepo "$NN"
done done
} }
...@@ -264,26 +207,25 @@ case $BASEDISTRNAME in ...@@ -264,26 +207,25 @@ case $BASEDISTRNAME in
__fix_alt_sources_list /etc/apt/sources.list __fix_alt_sources_list /etc/apt/sources.list
__fix_alt_sources_list /etc/apt/sources.list.d/*.list __fix_alt_sources_list /etc/apt/sources.list.d/*.list
# TODO: move to repo change # TODO: move to repo change
if [ "$1" = "etersoft" ] ; then case "$1" in
__fix_repo_to_etersoft /etc/apt/sources.list "etersoft")
__fix_repo_to_etersoft /etc/apt/sources.list.d/*.list __change_repo etersoft "http://download.etersoft.ru/pub ALTLinux"
fi ;;
if [ "$1" = "eterfund.org" ] ; then "eterfund.org")
__fix_repo_to_eterfund /etc/apt/sources.list __change_repo eterfund.org "https://mirror.eterfund.org/download.etersoft.ru/pub ALTLinux"
__fix_repo_to_eterfund /etc/apt/sources.list.d/*.list ;;
fi "yandex")
if [ "$1" = "yandex" ] ; then __change_repo mirror.yandex "http://mirror.yandex.ru altlinux"
__fix_repo_to_yandex /etc/apt/sources.list ;;
__fix_repo_to_yandex /etc/apt/sources.list.d/*.list "basealt")
fi __change_repo ftp.basealt "http://ftp.basealt.ru/pub/distributions ALTLinux"
if [ "$1" = "basealt" ] ; then ;;
__fix_repo_to_basealt /etc/apt/sources.list "altlinux.org")
__fix_repo_to_basealt /etc/apt/sources.list.d/*.list __change_repo ftp.altlinux "http://ftp.altlinux.org/pub/distributions ALTLinux"
fi ;;
if [ "$1" = "altlinux.org" ] ; then *)
__fix_repo_to_altlinux /etc/apt/sources.list fatal "Unsupported change key $1"
__fix_repo_to_altlinux /etc/apt/sources.list.d/*.list esac
fi
docmd apt-repo list docmd apt-repo list
return return
;; ;;
......
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