Commit 4cc5729d authored by Vitaly Lipatov's avatar Vitaly Lipatov

rewrite release-upgrade

parent a7829414
......@@ -268,7 +268,7 @@ check_command()
full-upgrade) # HELPCMD: update all system packages and kernel
epm_cmd=full_upgrade
;;
release-upgrade|upgrade-release|upgrade-system) # HELPCMD: update whole system to the release in arg (default: next (latest) release)
release-upgrade|upgrade-release|upgrade-system|release-switch) # HELPCMD: upgrade/switch whole system to the release in arg (default: next (latest) release)
epm_cmd=release_upgrade
;;
kernel-update|kernel-upgrade|update-kernel|upgrade-kernel) # HELPCMD: update system kernel to the last repo version
......
......@@ -18,6 +18,7 @@
#
load_helper epm-query
load_helper epm-repofix
confirm_info()
{
......@@ -46,8 +47,8 @@ __detect_alt_release_by_repo()
{
local BRD=$(cat /etc/apt/sources.list /etc/apt/sources.list.d/*.list \
| grep -v "^#" \
| grep "[tp][5-9]/branch/" \
| sed -e "s|.*\([tp][5-9]\)/branch.*|\1|g" \
| grep "[tpc][5-9]\.?[0-9]?/branch/" \
| sed -e "s|.*\([tpc][5-9]\.?[0-9]?\)/branch.*|\1|g" \
| sort -u )
if [ "$(__wcount $BRD)" = "1" ] ; then
echo "$BRD"
......@@ -83,15 +84,16 @@ __replace_alt_version_in_repo()
__alt_repofix()
{
local TO="$1"
load_helper epm-repofix
showcmd epm repofix
(quiet=1 pkg_filenames='' epm_repofix >/dev/null)
epm --quiet repo fix >/dev/null
# TODO: switch it in repo code
TO="$(__repofix_filter_vendor "$TO")"
# replace sign name
if [ -n "$TO" ] ; then
__replace_text_in_alt_repo "/^ *#/! s!\[alt\]![$TO]!g"
__replace_text_in_alt_repo "/^ *#/! s!\[sisyphus\]![$TO]!g"
__replace_text_in_alt_repo "/^ *#/! s!\[updates\]![$TO]!g"
__replace_text_in_alt_repo "/^ *#/! s!\[[tpc][6-9]\]![$TO]!g"
__replace_text_in_alt_repo "/^ *#/! s!\[[tpc][6-9]\.?[0-9]?\]![$TO]!g"
fi
}
......@@ -116,6 +118,7 @@ get_fix_release_pkg()
TO="sisyphus"
echo "apt-conf-$TO"
else
# will it update /etc/altlinux-release
echo "apt-conf-branch"
fi
......@@ -124,11 +127,17 @@ get_fix_release_pkg()
TOINSTALL="altlinux-release-$TO"
else
# just assure we have /etc/altlinux-release and switched from sisyphus
if [ ! -s /etc/altlinux-release ] || epmqf /etc/altlinux-release | grep -q sisyphus ; then
if [ ! -s /etc/altlinux-release ] || epm qf /etc/altlinux-release | grep -q sisyphus ; then
TOINSTALL="altlinux-release-$TO"
fi
fi
#local AR="$(epm --short qf /etc/altlinux-release)"
#if [ -n "$AR" ] && [ "$AR" != "$TOINSTALL" ] ; then
# echo "$AR-"
#fi
# TODO: add bug?
# workaround against obsoleted altlinux-release-sisyphus package from 2008 year
[ "$TOINSTALL" = "altlinux-release-sisyphus" ] && TOINSTALL="branding-alt-sisyphus-release"
......@@ -145,139 +154,180 @@ get_fix_release_pkg()
# workaround against
# file /etc/fedora-release from install of altlinux-release-p8-20160414-alt1 conflicts with file from package branding-simply-linux-release-8.2.0-alt1
# problem
if __get_conflict_release_pkg | grep -q -v "^altlinux-release" && [ "$TOINSTALL" != "$(__get_conflict_release_pkg)" ] ; then
echo $(__get_conflict_release_pkg)-
local AR="$(__get_conflict_release_pkg)"
if [ -n "$AR" ] && [ "$TOINSTALL" != "$AR" ] ; then
echo $AR-
fi
fi
}
__update_to_the_distro()
__switch_repo_to()
{
local TO="$1"
case "$TO" in
p7)
__alt_repofix
docmd epm update || fatal
docmd epm install rpm apt "$(get_fix_release_pkg --force "$TO")" || fatal "Check an error and run epm release-upgrade again"
__alt_repofix $TO
docmd epm update || fatal
docmd epm upgrade || fatal "Check an error and run epm release-upgrade again"
;;
p8)
__alt_repofix
docmd epm update || fatal
docmd epm install rpm apt "$(get_fix_release_pkg --force "$TO")" || fatal "Check an error and run epm release-upgrade again"
__alt_repofix $TO
docmd epm update || fatal
# sure we have systemd if systemd is running
if is_installed systemd && is_active_systemd systemd ; then
docmd epm install systemd || fatal
fi
docmd epm upgrade || fatal "Check an error and run epm release-upgrade again"
;;
p9)
#docmd epm update || fatal
#docmd epm install rpm apt "$(get_fix_release_pkg --force "$TO")" || fatal "Check an error and run epm release-upgrade again"
__alt_repofix $TO
docmd epm update || fatal
# sure we have systemd if systemd is running
#if is_installed systemd && is_active_systemd systemd ; then
# docmd epm install systemd || fatal
#fi
docmd epm upgrade || fatal "Check an error and run epm release-upgrade again"
;;
Sisyphus)
__alt_repofix
docmd epm update || fatal
#local ADDPKG
#ADDPKG=$(epm -q --short make-initrd sssd-ad 2>/dev/null)
#docmd epm install librpm7 librpm rpm apt $ADDPKG "$(get_fix_release_pkg --force "$TO")" ConsoleKit2- || fatal "Check an error and run again"
docmd epm upgrade || fatal "Check an error and run epm release-upgrade or just epm upgrade again"
;;
*)
esac
__replace_alt_version_in_repo "Sisyphus/" "$TO/branch/"
__replace_alt_version_in_repo "[tpc][5-9]\.?[0-9]?/branch/" "$TO/branch/"
__alt_repofix $TO
}
__check_system()
{
# sure we have systemd if systemd is running
if is_installed systemd && is_active_systemd systemd ; then
docmd epm install systemd || fatal
fi
}
__update_alt_to_next_distro()
get_next_release()
{
local FROM="$1"
case "$FROM" in
"p6")
echo "p7" ;;
"p7")
echo "p8" ;;
"p8")
echo "p9" ;;
"c6")
echo "c7" ;;
"c7")
echo "c8" ;;
"c8")
echo "c8.1" ;;
"c8.1")
echo "c8.2" ;;
"c8.2")
echo "c9" ;;
*)
echo "$FROM" ;;
esac
}
# TODO: install new conf without signs?
__switch_alt_to_distro()
{
local TO="$2"
local FROM="$1"
info
case "$*" in
[ -n "$TO" ] || TO="$(get_next_release $FROM)"
case "$*" in
"p6"|"p6 p7"|"t6 p7"|"c6 c7")
[ -n "$TO" ] || TO="p7"
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install rpm apt "$(get_fix_release_pkg "$FROM")" || fatal
__replace_alt_version_in_repo "Sisyphus/" "$TO/branch/"
__replace_alt_version_in_repo "$FROM/branch/" "$TO/branch/"
__update_to_the_distro "$TO"
__switch_repo_to $TO
docmd epm update || fatal
docmd epm install rpm apt "$(get_fix_release_pkg --force "$TO")" || fatal "Check an error and run epm release-upgrade again"
docmd epm upgrade || fatal "Check an error and run epm release-upgrade again"
docmd epm update-kernel
info "Done."
info "Run epm release-upgrade again for update to p8"
;;
"p7"|"p7 p8"|"t7 p8"|"c7 c8"|"p8 p8")
[ -n "$TO" ] || TO="p8"
"p7"|"p7 p8"|"t7 p8"|"c7 c8")
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install rpm apt "$(get_fix_release_pkg "$FROM")" || fatal
__replace_alt_version_in_repo "Sisyphus/" "$TO/branch/"
__replace_alt_version_in_repo $FROM/branch/ $TO/branch/
__update_to_the_distro $TO
__switch_repo_to $TO
docmd epm update || fatal
docmd epm install rpm apt "$(get_fix_release_pkg --force "$TO")" || fatal "Check an error and run epm release-upgrade again"
__check_system
docmd epm upgrade || fatal "Check an error and run epm release-upgrade again"
docmd epm update-kernel || fatal
info "Done."
;;
"p8"|"p8 p9"|"t8 p9"|"c8 c9"|"p9 p9")
[ -n "$TO" ] || TO="p9"
"c8"|"c8.1"|"c8.2"|"c8 c8.1"|"c8.1 c8.2"|"c8 c8.2")
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install rpm apt "$(get_fix_release_pkg "$FROM")" || fatal
__replace_alt_version_in_repo "Sisyphus/" "$TO/branch/"
__replace_alt_version_in_repo $FROM/branch/ $TO/branch/
__update_to_the_distro $TO
__switch_repo_to $TO
docmd epm update || fatal
docmd epm install rpm apt "$(get_fix_release_pkg --force "$TO")" || fatal "Check an error and run epm release-upgrade again"
__check_system
docmd epm upgrade || fatal "Check an error and run epm release-upgrade again"
docmd epm update-kernel || fatal
info "Done."
;;
"p9 c8"|"p9 c8.1"|"Sisyphus c8"|"Sisyphus c8.1")
"p8 c8"|"p8 c8.1"|"p8 c8.2")
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install rpm apt "$(get_fix_release_pkg "$FROM")" || fatal
__switch_repo_to $TO
docmd epm update || fatal
docmd epm install rpm apt "$(get_fix_release_pkg --force "$TO")" || fatal "Check an error and run epm release-upgrade again"
__check_system
if epm installed libcrypt >/dev/null ; then
# glibc-core coflicts libcrypt
docmd epm downgrade apt pam pam0_passwdqc glibc-core libcrypt- || fatal
fi
docmd epm downgrade
docmd epm upgrade || fatal "Check an error and run epm release-upgrade again"
docmd epm update-kernel || fatal
info "Done."
;;
"p8"|"p8 p9"|"t8 p9"|"c8 c9"|"c8 p9"|"c8.1 p9"|"c8.2 p9"|"p9 p9")
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install rpm apt "$(get_fix_release_pkg "$FROM")" || fatal
__switch_repo_to $TO
docmd epm update || fatal
__check_system
docmd epm upgrade || fatal "Check an error and run epm release-upgrade again"
docmd epm install rpm apt "$(get_fix_release_pkg --force "$TO")" || fatal "Check an error and run epm release-upgrade again"
docmd epm update-kernel || fatal
info "Done."
;;
"p9 p8"|"c8.1 c8"|"c8.1 p8"|"p8 p8")
confirm_info "Downgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install "$(get_fix_release_pkg "$FROM")" || fatal
__replace_alt_version_in_repo "$FROM/" "$TO/branch/"
#__replace_text_in_alt_repo "/^ *#/! s!\[alt\]![$TO]!g"
__update_to_the_distro $TO
docmd epm downgrade || fatal
__switch_repo_to $TO
docmd epm update || fatal
docmd epm downgrade rpm apt "$(get_fix_release_pkg --force "$TO")" || fatal "Check an error and run epm release-upgrade again"
__check_system
if epm installed libcrypt >/dev/null ; then
# glibc-core coflicts libcrypt
docmd epm downgrade apt rpm pam pam0_passwdqc glibc-core libcrypt- || fatal
fi
docmd epm downgrade
docmd epm upgrade || fatal
info "Done."
;;
"Sisyphus p8")
TO="p8"
"p9 c8"|"p9 c8.1"|"p9 c8.2")
confirm_info "Downgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install "$(get_fix_release_pkg "$FROM")" || fatal
__replace_alt_version_in_repo "$FROM/" "$TO/branch/"
#__replace_text_in_alt_repo "/^ *#/! s!\[alt\]![$TO]!g"
__update_to_the_distro $TO
docmd epm downgrade || fatal
__switch_repo_to $TO
docmd epm update || fatal
docmd epm downgrade rpm apt "$(get_fix_release_pkg --force "$TO")" || fatal "Check an error and run epm release-upgrade again"
__check_system
#if epm installed libcrypt >/dev/null ; then
# # glibc-core coflicts libcrypt
# docmd epm downgrade apt rpm pam pam0_passwdqc glibc-core libcrypt- || fatal
#fi
docmd epm downgrade
docmd epm upgrade || fatal
info "Done."
;;
"Sisyphus p9")
TO="p9"
"Sisyphus p8"|"Sisyphus p9"|"Sisyphus c8"|"Sisyphus c8.1")
confirm_info "Downgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install "$(get_fix_release_pkg "$FROM")" || fatal
__replace_alt_version_in_repo "$FROM/" "$TO/branch/"
#__replace_text_in_alt_repo "/^ *#/! s!\[alt\]![$TO]!g"
__update_to_the_distro $TO
docmd epm downgrade || fatal
__switch_repo_to $TO
docmd epm update || fatal
docmd epm install rpm apt "$(get_fix_release_pkg --force "$TO")" || fatal "Check an error and run epm release-upgrade again"
__check_system
docmd epm downgrade
docmd epm upgrade || fatal
info "Done."
;;
"p8 Sisyphus"|"p9 Sisyphus"|"Sisyphus Sisyphus")
TO="Sisyphus"
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install rpm apt "$(get_fix_release_pkg "$FROM")" || fatal
docmd epm upgrade || fatal
__replace_alt_version_in_repo "$FROM/branch/" "$TO/"
__alt_repofix "sisyphus"
__update_to_the_distro $TO
docmd epm update || fatal
docmd epm install rpm apt "$(get_fix_release_pkg --force "$TO")" || fatal "Check an error and run epm release-upgrade again"
#local ADDPKG
#ADDPKG=$(epm -q --short make-initrd sssd-ad 2>/dev/null)
#docmd epm install librpm7 librpm rpm apt $ADDPKG "$(get_fix_release_pkg --force "$TO")" ConsoleKit2- || fatal "Check an error and run again"
docmd epm upgrade || fatal "Check an error and run epm release-upgrade or just epm upgrade again"
__check_system
docmd epm update-kernel || fatal
info "Done."
;;
*)
[ -n "$TO" ] || TO="$FROM"
if [ "$FROM" = "$TO" ] ; then
info "It seems your system is already updated to newest $DISTRNAME $TO"
else
......@@ -324,7 +374,7 @@ epm_release_upgrade()
# TODO: ask before upgrade
__update_alt_to_next_distro $DISTRVERSION $TARGET
__switch_alt_to_distro $DISTRVERSION $TARGET
return
;;
*)
......
......@@ -29,12 +29,27 @@ __repofix_check_vendor()
return 1
}
__repofix_filter_vendor()
{
local br="$1"
br="$(echo "$br" | sed -e "s|\..*||")"
case $br in
c8)
br="cert8"
;;
c9)
br="cert9"
;;
esac
echo "$br"
}
# source-list vendor path
# example: /etc/apt/source.list p7 ALTLinux\/Sisyphus
__try_fix_apt_source_list()
{
local list="$1"
local br="$2"
local br="$(__repofix_filter_vendor "$2")"
local path="$3"
if grep -q -e "^[^#].*$path" $list ; then
if __repofix_check_vendor $br ; then
......@@ -49,8 +64,8 @@ __try_fix_apt_source_list()
__fix_alt_sources_list()
{
# for beauty spaces
local SUBST_ALT_RULE1='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ]*(Sisyphus)[/ ](x86_64|i586|x86_64-i586|noarch) !\1 \2/\3/\4 !gi'
local SUBST_ALT_RULE2='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ]*([tcp][6-9][/ ]branch|[tcp]1[012][/ ]branch)[/ ](x86_64|i586|x86_64-i586|noarch) !\1 \2/\3/\4 !gi'
local SUBST_ALT_RULE1='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ]*(Sisyphus)[/ ](x86_64|i586|x86_64-i586|noarch|aarch64) !\1 \2/\3/\4 !gi'
local SUBST_ALT_RULE2='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ]*([tcp][6-9]\.?[0-9]?[/ ]branch|[tcp]1[012][/ ]branch)[/ ](x86_64|i586|x86_64-i586|noarch|aarch64) !\1 \2/\3/\4 !gi'
local i
assure_root
for i in "$@" ; do
......
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