Commit 56820c45 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm: add separated release_downgrade command

parent 79847221
......@@ -284,10 +284,14 @@ check_command()
epm_cmd=full_upgrade
direct_args=1
;;
release-upgrade|upgrade-release|upgrade-system|release-switch|release-downgrade) # HELPCMD: upgrade/switch 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
direct_args=1
;;
release-downgrade|downgrade-release|downgrade-system) # HELPCMD: downgrade whole system to the release in arg (default: previuos release)
epm_cmd=release_downgrade
direct_args=1
;;
kernel-update|kernel-upgrade|update-kernel|upgrade-kernel) # HELPCMD: update system kernel to the last repo version
epm_cmd=kernel_update
direct_args=1
......@@ -532,7 +536,7 @@ fi
# Use eatmydata for write specific operations
case $epm_cmd in
update|upgrade|Upgrade|install|reinstall|Install|remove|autoremove|kernel_update|release_upgrade|check)
update|upgrade|Upgrade|install|reinstall|Install|remove|autoremove|kernel_update|release_upgrade|release_downgrade|check)
set_eatmydata
;;
esac
......
#!/bin/sh
#
# Copyright (C) 2013, 2016, 2017, 2019, 2020, 2021 Etersoft
# Copyright (C) 2013, 2016, 2017, 2019, 2020, 2021 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-release_upgrade
get_prev_release()
{
local FROM="$1"
case "$FROM" in
"p8")
echo "p7" ;;
"p9")
echo "p8" ;;
"p10")
echo "p9" ;;
"c7")
echo "c6" ;;
"c8")
echo "c7" ;;
"c8.1")
echo "c8" ;;
"c8.2")
echo "c8.1" ;;
"c9")
echo "c8.2" ;;
*)
echo "$FROM" ;;
esac
}
# FIXME: see epm_release_upgrade
epm_release_downgrade()
{
assure_root
assure_safe_run
info "Starting upgrade/switch whole system to other release"
info "Check also http://wiki.etersoft.ru/Admin/UpdateLinux"
cd /tmp || fatal
# TODO: it is possible eatmydata does not do his work
export EPMNOEATMYDATA=1
case $DISTRNAME in
ALTLinux)
__epm_ru_update || fatal
# try to detect current release by repo
if [ "$DISTRVERSION" = "Sisyphus" ] || [ -z "$DISTRVERSION" ] ; then
local dv
dv="$(__detect_alt_release_by_repo)"
if [ -n "$dv" ] && [ "$dv" != "$DISTRVERSION" ] ; then
DISTRVERSION="$dv"
info "Detected running $DISTRNAME $DISTRVERSION (according to using repos)"
fi
fi
TARGET=""
[ -n "$3" ] && fatal "Too many args: $*"
if [ -n "$2" ] ; then
DISTRVERSION="$1"
info "Force current distro version as $DISTRVERSION"
TARGET="$2"
elif [ -n "$1" ] ; then
TARGET="$1"
fi
[ -n "$TARGET" ] || TARGET="$(get_prev_release $DISTRVERSION)"
__alt_repofix
__switch_alt_to_distro $DISTRVERSION $TARGET && info "Done. The system has been successfully downgraded to the previous release '$TO'."
return 0
;;
*)
;;
esac
case $PMTYPE in
apt-rpm)
#docmd epm update
info "Have no idea how to downgrade $DISTRNAME"
;;
*-dpkg)
assure_exists do-release-upgrade update-manager-core
sudocmd do-release-upgrade
;;
packagekit)
docmd pkcon upgrade-system "$@"
;;
yum-rpm)
docmd epm install rpm yum
sudocmd yum clean all
# TODO
showcmd rpm -Uvh http://mirror.yandex.ru/fedora/linux/releases/16/Fedora/x86_64/os/Packages/fedora-release-16-1.noarch.rpm
showcmd epm Upgrade
;;
dnf-rpm)
info "Check https://fedoraproject.org/wiki/DNF_system_upgrade for an additional info"
docmd epm install dnf
#docmd epm install epel-release yum-utils
sudocmd dnf --refresh upgrade
sudocmd dnf clean all
assure_exists dnf-plugin-system-upgrade
sudocmd dnf upgrade --refresh
local RELEASEVER="$1"
[ -n "$RELEASEVER" ] || RELEASEVER=$(($DISTRVERSION + 1))
#[ -n "$RELEASEVER" ] || fatal "Run me with new version"
confirm_info "Upgrade to $DISTRNAME/$RELEASEVER"
sudocmd dnf system-upgrade download --refresh --releasever=$RELEASEVER
# TODO: from docs:
# dnf system-upgrade reboot
# FIXME: download all packages again
sudocmd dnf distro-sync --releasever=$RELEASEVER
info "Run epm autoorphans to remove orphaned packages"
;;
urpm-rpm)
sudocmd urpmi.removemedia -av
# TODO
showcmd urpmi.addmedia --distrib http://mirror.yandex.ru/mandriva/devel/2010.2/i586/
sudocmd urpmi --auto-update --replacefiles
;;
zypper-rpm)
docmd epm repolist
# TODO
# sudocmd zypper rr <номер_репозитория>
showcmd rr N
showcmd epm ar http://mirror.yandex.ru/opensuse/distribution/11.1/repo/oss 11.1oss
showcmd zypper ref
docmd epm update
docmd epm install rpm zypper
docmd epm upgrade
;;
pacman)
epm Upgrade
;;
conary)
epm Upgrade
;;
emerge)
epm Upgrade
;;
guix)
sudocmd guix pull --verbose
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
......@@ -306,7 +306,6 @@ __switch_alt_to_distro()
local TO="$2"
local FROM="$1"
info
[ -n "$TO" ] || TO="$(get_next_release $FROM)"
__save_alt_repo_lists
trap __restore_alt_repo_lists EXIT
......@@ -454,19 +453,18 @@ __switch_alt_to_distro()
;;
*)
if [ "$FROM" = "$TO" ] ; then
info "It seems your system is already updated to newest $DISTRNAME $TO"
info "It seems your system is already $DISTRNAME $TO"
else
warning "Unknown distro version. Have no idea how to switch from $DISTRNAME $FROM to $DISTRNAME $TO."
fi
info "Try run f.i. # epm release-upgrade p10 or # epm release-upgrade Sisyphus"
info "Also possible you need install altlinux-release-p? package for correct distro version detecting"
trap - EXIT
info "Try run f.i. '# epm release-upgrade p10' or '# epm release-downgrade p9' or '# epm release-upgrade Sisyphus'"
info "Also possible you need install altlinux-release-p? package for correct distro version detecting"
return 1
esac
trap - EXIT
epm clean
info "Note: Also you can try '# epm autoremove' and '# epm autoorphans' commands to remove obsoleted and unused packages."
info "Done. The system has been successfully upgraded to the next release '$TO'."
trap - EXIT
}
epm_release_upgrade()
......@@ -504,11 +502,13 @@ epm_release_upgrade()
TARGET="$1"
fi
[ -n "$TARGET" ] || TARGET="$(get_next_release $DISTRVERSION)"
__alt_repofix
# TODO: ask before upgrade
__switch_alt_to_distro $DISTRVERSION $TARGET
return
__switch_alt_to_distro $DISTRVERSION $TARGET && info "Done. The system has been successfully upgraded to the next release '$TO'."
return 0
;;
*)
;;
......@@ -517,14 +517,14 @@ epm_release_upgrade()
case $PMTYPE in
apt-rpm)
#docmd epm update
info "Have no idea how to upgrade $DISTRNAME"
info "Have no idea how to upgrade $DISTRNAME. It is possible you need use 'release-downgrade'"
;;
*-dpkg)
assure_exists do-release-upgrade update-manager-core
sudocmd do-release-upgrade
;;
packagekit)
docmd pkcon upgrade-system $pkg_filenames
docmd pkcon upgrade-system "$@"
;;
yum-rpm)
docmd epm install rpm yum
......@@ -541,7 +541,7 @@ epm_release_upgrade()
sudocmd dnf clean all
assure_exists dnf-plugin-system-upgrade
sudocmd dnf upgrade --refresh
local RELEASEVER="$pkg_filenames"
local RELEASEVER="$1"
[ -n "$RELEASEVER" ] || RELEASEVER=$(($DISTRVERSION + 1))
#[ -n "$RELEASEVER" ] || fatal "Run me with new version"
confirm_info "Upgrade to $DISTRNAME/$RELEASEVER"
......
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