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

rewrite release-upgrade

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