3
# Copyright (C) 2013, 2016, 2017, 2019, 2020, 2021 Etersoft
4
# Copyright (C) 2013, 2016, 2017, 2019, 2020, 2021 Vitaly Lipatov <lav@etersoft.ru>
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU Affero General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU Affero General Public License for more details.
16
# You should have received a copy of the GNU Affero General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
load_helper epm-repofix
22
load_helper epm-reposave
26
if [ "$TERM" = "linux" ] ; then
27
echo "You have the best choise to run the '# epm release-upgrade' from text console."
30
if [ "$TERM" != "screen" ] ; then
31
if [ -n "$force" ] ; then
32
echo "You force me running not under screen (TERM=$TERM now)! You can lost your system!"
35
warning "It is very dangerous to upgrade to next release from a GUI (your TERM=$TERM)."
36
if is_installed screen ; then
37
warning "You have 'screen' already installed, just run upgrade via screen (check https://losst.ru/komanda-screen-linux if needed)."
39
warning "It is recommended install 'screen' and run upgrade via screen (check https://losst.ru/komanda-screen-linux if needed)."
41
fatal "or run me with --force if you understand the risk."
45
# run under screen, check if systemd will not kill our processes
47
if ! is_active_systemd ; then
51
res="$(busctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager KillUserProcesses)"
52
if [ "$res" = "b false" ] ; then
53
echo "Good news: systemd-logind will not kill your screen processes (KillUserProcesses=false)"
56
if [ -n "$force" ] ; then
57
warning "You force runnning even if systemd-logind kills screen on disconnect"
59
if ! epm installed systemd-settings-disable-kill-user-processes ; then
60
docmd epm install systemd-settings-disable-kill-user-processes || fatal "Can't install the package above. Fix it or run with --force."
62
# commented, will kick off the user from the system (ALT issue 50580)
63
#docmd serv systemd-logind restart || fatal "Can't restart systemd-logind service. Fix it or run with --force."
64
fatal "Now you need relogin to the system. In this session your screen still will be killed."
68
# check too: KillExcludeUsers
79
# TODO: remove it or move to distro_info
80
__detect_alt_release_by_repo()
82
local BRD=$(cat /etc/apt/sources.list /etc/apt/sources.list.d/*.list \
84
| grep -E "[tpc][5-9]\.?[0-9]?/branch/" \
85
| sed -e "s|.*\([tpc][5-9]\.\?[0-9]\?\)/branch.*|\1|g" \
87
if [ "$(__wcount $BRD)" = "1" ] ; then
92
local BRD=$(cat /etc/apt/sources.list /etc/apt/sources.list.d/*.list \
95
| sed -e "s|.*\(Sisyphus\).*|\1|g" \
97
if [ "$(__wcount $BRD)" = "1" ] ; then
106
__get_conflict_release_pkg()
108
epm qf --quiet --short /etc/fedora-release | head -n1
116
if [ "$1" = "--force" ] ; then
123
if [ "$TO" = "Sisyphus" ] ; then
126
# apt-conf-sisyphus and apt-conf-branch conflicts
127
epm installed apt-conf-branch && echo "apt-conf-branch-"
128
#for i in apt apt-rsync libapt libpackagekit-glib librpm7 packagekit rpm synaptic realmd libldap2 ; do
129
# epm installed $i && echo "$i"
133
epm installed apt-conf-branch && echo "apt-conf-branch" && epm installed apt-conf-sisyphus && echo "apt-conf-sisyphus-"
136
if [ "$FORCE" = "--force" ] ; then
137
# assure we have set needed release
138
TOINSTALL="altlinux-release-$TO"
140
# just assure we have /etc/altlinux-release and switched from sisyphus
141
if [ ! -s /etc/altlinux-release ] || epm qf /etc/altlinux-release | grep -q sisyphus ; then
142
TOINSTALL="altlinux-release-$TO"
146
#local AR="$(epm --short qf /etc/altlinux-release)"
147
#if [ -n "$AR" ] && [ "$AR" != "$TOINSTALL" ] ; then
152
# workaround against obsoleted altlinux-release-sisyphus package from 2008 year
153
[ "$TOINSTALL" = "altlinux-release-sisyphus" ] && TOINSTALL="branding-alt-sisyphus-release"
155
if epm installed etersoft-gpgkeys ; then
156
# TODO: we don't support LINUX@Etersoft for now
157
# leave etersoft-gpgkeys only if we have LINUX@Etersoft repo
158
#epm repo list | grep -q "LINUX@Etersoft" && echo "etersoft-gpgkeys" || echo "alt-gpgkeys"
159
epm --quiet repo comment "LINUX@Etersoft"
162
# update if installed (just print package name here to include in the install list)
163
epm query --short alt-gpgkeys 2>/dev/null
166
if [ -n "$TOINSTALL" ] ; then
170
# 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
172
local AR="$(__get_conflict_release_pkg)"
173
if [ -n "$AR" ] && [ "$TOINSTALL" != "$AR" ] ; then
175
# remove conflicts package right here to workaround against asking 'Yes, do as I say!' later
176
epm remove --nodeps $AR >/dev/null
186
# sure we have systemd if systemd is running
187
if is_active_systemd ; then
188
docmd epm --skip-installed install systemd || fatal
191
if [ "$TO" != "Sisyphus" ] ; then
192
# note: we get --base-version directy to get new version
193
if [ "$(DISTRVENDOR --base-version)" != "$TO" ] || epm installed altlinux-release-sisyphus >/dev/null ; then
194
warning "Current distro still is not $TO, or altlinux-release-sisyphus package is installed."
195
warning "Trying to fix with altlinux-release-$TO"
196
docmd epm install altlinux-release-$TO
200
# switch from prefdm: https://bugzilla.altlinux.org/show_bug.cgi?id=26405#c47
201
if is_active_systemd ; then
202
if serv display-manager exists || serv prefdm exists ; then
203
# don't stop running X server!
205
docmd serv disable prefdm
206
docmd serv disable display-manager
207
docmd serv enable display-manager
210
# xinitrc: /lib/systemd/system/dm.service
211
# gdm: /lib/systemd/system/gdm.service
212
# lightdm: /lib/systemd/system/lightdm.service
213
# lxde-lxdm: /lib/systemd/system/lxdm.service
214
# xinitrc: /lib/systemd/system/prefdm.service
215
# sddm: /lib/systemd/system/sddm.service
216
# enable first available DM
217
for i in lightdm sddm lxde-lxdm gdm ; do
218
serv $i exists && docmd serv enable $i && break
227
docmd epm update && return
228
# TODO: there can be errors due obsoleted alt-gpgkeys
229
epm update 2>&1 | grep "E: Unknown vendor ID" || return
230
info "Drop vendor signs"
231
__alt_replace_sign_name ""
238
__epm_ru_update || fatal
272
docmd epm $non_interactive $force_yes upgrade || fatal "Check the errors and run '# $0' again"
275
# TODO: install new conf without signs?
276
__switch_alt_to_distro()
285
"p6"|"p6 p7"|"t6 p7"|"c6 c7")
286
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
287
docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal
289
docmd epm install rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
292
docmd epm update-kernel
293
info "Run epm release-upgrade again for update to p8"
295
"p7"|"p7 p8"|"t7 p8"|"c7 c8")
296
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
297
docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal
299
docmd epm install rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
303
docmd epm update-kernel || fatal
304
info "Run epm release-upgrade again for update to p9"
306
"c8"|"c8.1"|"c8.2"|"c8 c8.1"|"c8.1 c8.2"|"c8 c8.2")
307
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
308
docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal
310
docmd epm install rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
314
docmd epm update-kernel || fatal
316
"p8 c8"|"p8 c8.1"|"p8 c8.2")
317
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
318
docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal
320
docmd epm install rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
321
if epm installed libcrypt ; then
322
# glibc-core coflicts libcrypt
323
docmd epm downgrade apt pam pam0_passwdqc glibc-core libcrypt- || fatal
325
docmd epm $non_interactive $force_yes downgrade || fatal
329
docmd epm update-kernel || fatal
331
"p8"|"p8 p9"|"t8 p9"|"c8 c9"|"c8 p9"|"c8.1 p9"|"c8.2 p9"|"p9 p9"|"p9 c9f2")
332
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
333
docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal
334
info "Workaround for https://bugzilla.altlinux.org/show_bug.cgi?id=35492 ..."
335
if epm installed gdb >/dev/null ; then
336
docmd epm remove gdb || fatal
341
docmd epm install rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
343
docmd epm update-kernel || fatal
344
info "Run epm release-upgrade again for update to p10"
346
"p9"|"p9 p10"|"p10 p10")
347
info "Upgrade all packages to current $FROM repository"
349
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
350
docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal
354
docmd epm install rpm apt $(get_fix_release_pkg "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
356
docmd epm update-kernel -t std-def || fatal
358
"p9 p8"|"c8.1 c8"|"c8.1 p8"|"p8 p8")
359
confirm_info "Downgrade $DISTRNAME from $FROM to $TO ..."
360
docmd epm install $(get_fix_release_pkg "$FROM")
362
docmd epm downgrade rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
363
if epm installed libcrypt >/dev/null ; then
364
# glibc-core coflicts libcrypt
365
docmd epm downgrade apt rpm pam pam0_passwdqc glibc-core libcrypt- || fatal
367
docmd epm $force_yes $non_interactive downgrade || fatal "Check the error and run '# epm downgrade'"
370
docmd epm upgrade || fatal
372
"p9 c8"|"p9 c8.1"|"p9 c8.2")
373
confirm_info "Downgrade $DISTRNAME from $FROM to $TO ..."
374
docmd epm install $(get_fix_release_pkg "$FROM")
376
docmd epm downgrade rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
377
#if epm installed libcrypt >/dev/null ; then
378
# # glibc-core coflicts libcrypt
379
# docmd epm downgrade apt rpm pam pam0_passwdqc glibc-core libcrypt- || fatal
381
docmd epm $force_yes $non_interactive downgrade || fatal "Check the error and run '# epm downgrade'"
384
docmd epm upgrade || fatal
387
confirm_info "Downgrade $DISTRNAME from $FROM to $TO ..."
388
docmd epm install $(get_fix_release_pkg "$FROM")
390
docmd epm downgrade rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
391
docmd epm $force_yes $non_interactive downgrade || fatal "Check the error and run '# epm downgrade'"
394
docmd epm upgrade || fatal
396
"Sisyphus p8"|"Sisyphus p9"|"Sisyphus p10"|"Sisyphus c8"|"Sisyphus c8.1"|"Sisyphus c9f2")
397
confirm_info "Downgrade $DISTRNAME from $FROM to $TO ..."
398
docmd epm install $(get_fix_release_pkg "$FROM")
400
docmd epm install rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
401
docmd epm $force_yes $non_interactive downgrade || fatal "Check the error and run '# epm downgrade'"
404
docmd epm upgrade || fatal
406
"p8 Sisyphus"|"p9 Sisyphus"|"p10 Sisyphus"|"10 Sisyphus"|"Sisyphus Sisyphus")
407
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
408
docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal
409
docmd epm upgrade || fatal
410
# TODO: epm_reposwitch??
411
__replace_alt_version_in_repo "$FROM/branch/" "$TO/"
413
[ -s /etc/rpm/macros.d/p10 ] && rm -fv /etc/rpm/macros.d/p10
414
__epm_ru_update || fatal
415
docmd epm fix || fatal
416
docmd epm install $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
418
#ADDPKG=$(epm -q --short make-initrd sssd-ad 2>/dev/null)
419
#docmd epm install librpm7 librpm rpm apt $ADDPKG $(get_fix_release_pkg --force "$TO") ConsoleKit2- || fatal "Check an error and run again"
421
docmd epm $force_yes $non_interactive upgrade || fatal "Check the error and run '# epm release-upgrade' again or just '# epm upgrade'"
422
docmd epm $force_yes $non_interactive downgrade || fatal "Check the error and run '# epm downgrade'"
424
docmd epm update-kernel || fatal
427
if [ "$FROM" = "$TO" ] ; then
428
info "It seems your system is already $DISTRNAME $TO"
430
warning "Unknown distro version. Have no idea how to switch from $DISTRNAME $FROM to $DISTRNAME $TO."
433
info "Try run f.i. '# epm release-upgrade p10' or '# epm release-downgrade p9' or '# epm release-upgrade Sisyphus'"
434
info "Also possible you need install altlinux-release-p? package for correct distro version detecting"
445
info "Starting upgrade/switch whole system to other release"
446
info "Check also http://wiki.etersoft.ru/Admin/UpdateLinux"
449
# TODO: it is possible eatmydata does not do his work
450
export EPMNOEATMYDATA=1
452
case $BASEDISTRNAME in
454
__epm_ru_update || fatal
456
# TODO: remove this hack (or move it to distro_info)
457
# try to detect current release by repo
458
if [ "$DISTRVERSION" = "Sisyphus" ] || [ -z "$DISTRVERSION" ] ; then
460
dv="$(__detect_alt_release_by_repo)"
461
if [ -n "$dv" ] && [ "$dv" != "$DISTRVERSION" ] ; then
463
info "Detected running $DISTRNAME $DISTRVERSION (according to using repos)"
468
[ -n "$3" ] && fatal "Too many args: $*"
469
if [ -n "$2" ] ; then
471
info "Force current distro version as $DISTRVERSION"
473
elif [ -n "$1" ] ; then
477
[ "$TARGET" = "Sisyphus" ] && info "Check also https://www.altlinux.org/Update/Sisyphus"
479
[ -n "$TARGET" ] || TARGET="$(get_next_release $DISTRVERSION)"
483
__switch_alt_to_distro $DISTRVERSION $TARGET && info "Done. The system has been successfully upgraded to the next release '$TO'."
494
sudocmd urpmi.addmedia --distrib --mirrorlist 'http://mirrors.mageia.org/api/mageia.8.$DISTRARCH.list'
495
sudocmd urpmi --auto-update $non_interactive $force
499
# TODO: move to distro related upgrade
502
#epm repo add "http://mirror.rosalinux.ru/rosa/rosa2021.1/repository/$DISTRARCH"
503
#showcmd urpmi.addmedia --distrib http://mirror.yandex.ru/mandriva/devel/2010.2/i586/
504
#sudocmd urpmi --auto-update --replacefiles
514
info "Have no idea how to upgrade $DISTRNAME. It is possible you need use 'release-downgrade'"
517
assure_exists do-release-upgrade update-manager-core
518
sudocmd do-release-upgrade
521
docmd pkcon upgrade-system "$@"
524
docmd epm install rpm yum
525
sudocmd yum clean all
526
info "Try do manually:"
527
showcmd rpm -Uvh http://mirror.yandex.ru/fedora/linux/releases/16/Fedora/x86_64/os/Packages/fedora-release-16-1.noarch.rpm
531
if [ "$DISTRNAME/$DISTRVERSION" = "CentOS/8" ] ; then
532
if [ "$1" = "RockyLinux" ] ; then
533
info "https://github.com/rocky-linux/rocky-tools/tree/main/migrate2rocky/"
534
confirm_info "Switch to Rocky Linux 8.x"
536
docmd epm install git
537
sudocmd git clone https://github.com/rocky-linux/rocky-tools.git || fatal
538
sudocmd bash rocky-tools/migrate2rocky/migrate2rocky.sh -r
542
if [ "$1" = "OracleLinux" ] ; then
543
info "Check https://t.me/srv_admin/1630"
544
confirm_info "Switch to Oracle Linux 8.x"
546
docmd epm install git
548
-e 's!^mirrorlist=!#mirrorlist=!' \
549
-e 's!^#?baseurl=http://(mirror|vault).centos.org/\$contentdir/\$releasever/!baseurl=https://dl.rockylinux.org/vault/centos/8.5.2111/!i' \
550
/etc/yum.repos.d/CentOS-*.repo
551
sudocmd git clone https://github.com/oracle/centos2ol.git || fatal
552
a= bash centos2ol/centos2ol.sh
556
info "Check https://www.cyberciti.biz/howto/upgrade-migrate-from-centos-8-to-centos-stream-conversion/"
557
confirm_info "Switch to CentOS Stream?"
559
-e 's!^mirrorlist=!#mirrorlist=!' \
560
-e 's!^#?baseurl=http://(mirror|vault).centos.org/\$contentdir/\$releasever/!baseurl=https://dl.rockylinux.org/vault/centos/8.5.2111/!i' \
561
/etc/yum.repos.d/CentOS-*.repo
562
docmd epm install centos-release-stream
563
sudocmd dnf swap centos-{linux,stream}-repos
564
sudocmd dnf distro-sync
565
info "You can run '# epm autoorphans' to remove orphaned packages"
569
if [ "$DISTRNAME" = "RockyLinux" ] ; then
570
sudocmd dnf --refresh upgrade || fatal
571
sudocmd dnf clean all
572
info "Check https://www.centlinux.com/2022/07/upgrade-your-servers-from-rocky-linux-8-to-9.html"
573
info "For upgrading your yum repositories from Rocky Linux 8 to 9 ..."
574
epm install "https://download.rockylinux.org/pub/rocky/9/BaseOS/x86_64/os/Packages/r/rocky-gpg-keys*.rpm" || fatal
575
epm install "https://download.rockylinux.org/pub/rocky/9/BaseOS/x86_64/os/Packages/r/rocky-repos*.rpm" "https://download.rockylinux.org/pub/rocky/9/BaseOS/x86_64/os/Packages/r/rocky-release*.rpm" || fatal
578
DV=$(echo "$DISTRVERSION" | sed -e "s|\..*||")
579
local RELEASEVER="$1"
580
[ -n "$RELEASEVER" ] || RELEASEVER=$(($DV + 1))
581
confirm_info "Upgrade to $DISTRNAME/$RELEASEVER"
583
sudocmd dnf -y --releasever=$RELEASEVER --allowerasing --setopt=deltarpm=false distro-sync
584
sudocmd rpm --rebuilddb
586
info "You can run '# epm autoorphans' to remove orphaned packages"
587
info "Use # dnf module reset <module> to resolve 'nothing provides module' error"
591
info "Check https://fedoraproject.org/wiki/DNF_system_upgrade for an additional info"
592
#docmd epm install epel-release yum-utils
593
sudocmd dnf --refresh upgrade || fatal
594
sudocmd dnf clean all
595
assure_exists dnf-plugin-system-upgrade
596
sudocmd dnf upgrade --refresh
597
local RELEASEVER="$1"
598
[ -n "$RELEASEVER" ] || RELEASEVER=$(($DISTRVERSION + 1))
599
#[ -n "$RELEASEVER" ] || fatal "Run me with new version"
600
confirm_info "Upgrade to $DISTRNAME/$RELEASEVER"
601
sudocmd dnf system-upgrade download --refresh --releasever=$RELEASEVER
603
# dnf system-upgrade reboot
604
# FIXME: download all packages again
605
sudocmd dnf distro-sync --releasever=$RELEASEVER
606
info "You can run '# epm autoorphans' to remove orphaned packages"
610
# TODO: move to distro related upgrade
611
# sudocmd zypper rr <номер_репозитория>
613
showcmd epm ar http://mirror.yandex.ru/opensuse/distribution/11.1/repo/oss 11.1oss
616
docmd epm install rpm zypper
629
sudocmd guix pull --verbose
632
fatal "Have no suitable command for $PMTYPE"