NBash

Форк
0
/
epm-release_downgrade 
171 строка · 4.9 Кб
1
#!/bin/sh
2
#
3
# Copyright (C) 2013, 2016, 2017, 2019, 2020, 2021  Etersoft
4
# Copyright (C) 2013, 2016, 2017, 2019, 2020, 2021  Vitaly Lipatov <lav@etersoft.ru>
5
#
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.
10
#
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.
15
#
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/>.
18
#
19

20
load_helper epm-release_upgrade
21

22
get_prev_release()
23
{
24
    local FROM="$1"
25
    case "$FROM" in
26
    "p8")
27
        echo "p7" ;;
28
    "p9")
29
        echo "p8" ;;
30
    "p10")
31
        echo "p9" ;;
32
    "c7")
33
        echo "c6" ;;
34
    "c8")
35
        echo "c7" ;;
36
    "c8.1")
37
        echo "c8" ;;
38
    "c8.2")
39
        echo "c8.1" ;;
40
    "c9f1")
41
        echo "c8" ;;
42
    "c9f2")
43
        echo "c9f1" ;;
44
    "10")
45
        echo "9" ;;
46
    *)
47
        echo "$FROM" ;;
48
    esac
49
}
50

51
# FIXME: see epm_release_upgrade
52
epm_release_downgrade()
53
{
54
    assure_root
55
    assure_safe_run
56
    info "Starting upgrade/switch whole system to other release"
57
    info "Check also http://wiki.etersoft.ru/Admin/UpdateLinux"
58

59
    cd /tmp || fatal
60
    # TODO: it is possible eatmydata does not do his work
61
    export EPMNOEATMYDATA=1
62

63
    case $BASEDISTRNAME in
64
    "alt")
65
        __epm_ru_update || fatal
66

67
        # try to detect current release by repo
68
        if [ "$DISTRVERSION" = "Sisyphus" ] || [ -z "$DISTRVERSION" ] ; then
69
            local dv
70
            dv="$(__detect_alt_release_by_repo)"
71
            if [ -n "$dv" ] && [ "$dv" != "$DISTRVERSION" ] ; then
72
                DISTRVERSION="$dv"
73
                info "Detected running $DISTRNAME $DISTRVERSION (according to using repos)"
74
            fi
75
        fi
76

77
        TARGET=""
78
        [ -n "$3" ] && fatal "Too many args: $*"
79
        if [ -n "$2" ] ; then
80
            DISTRVERSION="$1"
81
            info "Force current distro version as $DISTRVERSION"
82
            TARGET="$2"
83
        elif [ -n "$1" ] ; then
84
            TARGET="$1"
85
        fi
86

87
        [ -n "$TARGET" ] || TARGET="$(get_prev_release $DISTRVERSION)"
88

89
        __alt_repofix
90

91
        __switch_alt_to_distro $DISTRVERSION $TARGET && info "Done. The system has been successfully downgraded to the previous release '$TARGET'."
92

93
        return 0
94
        ;;
95
    *)
96
        ;;
97
    esac
98

99
    case $PMTYPE in
100
    apt-rpm)
101
        #docmd epm update
102
        info "Have no idea how to downgrade $DISTRNAME"
103
        ;;
104
    *-dpkg)
105
        assure_exists do-release-upgrade update-manager-core
106
        sudocmd do-release-upgrade
107
        ;;
108
    packagekit)
109
        docmd pkcon upgrade-system "$@"
110
        ;;
111
    yum-rpm)
112
        docmd epm install rpm yum
113
        sudocmd yum clean all
114
        info "Try manually:"
115
        showcmd rpm -Uvh http://mirror.yandex.ru/fedora/linux/releases/16/Fedora/x86_64/os/Packages/fedora-release-16-1.noarch.rpm
116
        showcmd epm Upgrade
117
        ;;
118
    dnf-rpm)
119
        info "Check https://fedoraproject.org/wiki/DNF_system_upgrade for an additional info"
120
        docmd epm install dnf
121
        #docmd epm install epel-release yum-utils
122
        sudocmd dnf --refresh upgrade
123
        sudocmd dnf clean all
124
        assure_exists dnf-plugin-system-upgrade
125
        sudocmd dnf upgrade --refresh
126
        local RELEASEVER="$1"
127
        [ -n "$RELEASEVER" ] || RELEASEVER=$(($DISTRVERSION + 1))
128
        #[ -n "$RELEASEVER" ] || fatal "Run me with new version"
129
        confirm_info "Upgrade to $DISTRNAME/$RELEASEVER"
130
        sudocmd dnf system-upgrade download --refresh --releasever=$RELEASEVER
131
        # TODO: from docs:
132
        # dnf system-upgrade reboot
133
        # FIXME: download all packages again
134
        sudocmd dnf distro-sync --releasever=$RELEASEVER
135
        info "Run epm autoorphans to remove orphaned packages"
136
        ;;
137
    urpm-rpm)
138
        sudocmd urpmi.removemedia -av
139
        info "Try do manually:"
140
        showcmd urpmi.addmedia --distrib http://mirror.yandex.ru/mandriva/devel/2010.2/i586/
141
        sudocmd urpmi --auto-update --replacefiles
142
        ;;
143
    zypper-rpm)
144
        docmd epm repolist
145
        # TODO
146
        # sudocmd zypper rr <номер_репозитория>
147
        showcmd rr N
148
        showcmd epm ar http://mirror.yandex.ru/opensuse/distribution/11.1/repo/oss 11.1oss
149
        showcmd zypper ref
150
        docmd epm update
151
        docmd epm install rpm zypper
152
        docmd epm upgrade
153
        ;;
154
    pacman)
155
        epm Upgrade
156
        ;;
157
    conary)
158
        epm Upgrade
159
        ;;
160
    emerge)
161
        epm Upgrade
162
        ;;
163
    guix)
164
        sudocmd guix pull --verbose
165
        ;;
166
    *)
167
        fatal "Have no suitable command for $PMTYPE"
168
        ;;
169
    esac
170

171
}
172

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.