3
# Copyright (C) 2012,2014,2016 Etersoft
4
# Copyright (C) 2012,2014,2016 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/>.
20
load_helper epm-check_updated_repo
22
__epm_add_alt_apt_downgrade_preferences()
24
[ -r /etc/apt/preferences ] && fatal "/etc/apt/preferences already exists"
25
cat <<EOF | sudocmd tee /etc/apt/preferences
31
# overload with addon repo
41
# overload with test (task) repo
48
# See https://wiki.debian.org/ru/AptPreferences
49
__epm_add_deb_apt_downgrade_preferences()
51
[ -r /etc/apt/preferences ] && fatal "/etc/apt/preferences already exists"
52
info "Running with /etc/apt/preferences:"
53
cat <<EOF | sudorun tee /etc/apt/preferences
63
Pin: release a=unstable
68
__epm_remove_apt_downgrade_preferences()
70
sudocmd rm -f /etc/apt/preferences
77
# it is useful for first time running
80
# if possible, it will put pkg_urls into pkg_files and reconstruct pkg_filenames
81
if [ -n "$pkg_urls" ] ; then
82
info "Downloading packages assigned to downgrade ..."
83
load_helper epm-download
84
__handle_pkg_urls_to_install
87
info "Running command for downgrade packages"
89
case $BASEDISTRNAME in
91
# pass pkg_filenames too
92
if [ -n "$pkg_names" ] ; then
93
__epm_add_alt_apt_downgrade_preferences || return
94
load_helper epm-install
95
(pkg_names=$(get_only_installed_packages $pkg_names) epm_install)
96
__epm_remove_apt_downgrade_preferences
97
elif [ -n "$pkg_files" ] ; then
98
load_helper epm-install
101
for i in $pkg_files ; do
102
local pkgname="$(epm print name for package $i)"
103
is_installed $pkgname || continue
106
(force="$force --oldpackage" epm_install_files $pkgs)
108
__epm_add_alt_apt_downgrade_preferences || return
109
load_helper epm-upgrade
111
__epm_remove_apt_downgrade_preferences
121
local APTOPTIONS="$(subst_option non_interactive -y) $force_yes"
122
__epm_add_deb_apt_downgrade_preferences || return
123
if [ -n "$pkg_filenames" ] ; then
124
sudocmd apt-get $APTOPTIONS install $pkg_filenames
126
sudocmd apt-get $APTOPTIONS dist-upgrade
128
__epm_remove_apt_downgrade_preferences
131
# can do update repobase automagically
132
if [ -n "$pkg_filenames" ] ; then
133
sudocmd yum downgrade $pkg_filenames
135
sudocmd yum distro-sync
139
if [ -n "$pkg_filenames" ] ; then
140
sudocmd dnf downgrade $pkg_filenames
142
sudocmd dnf distro-sync
146
assure_exists urpm-reposync urpm-tools
147
sudocmd urpm-reposync -v
150
fatal "Have no suitable command for $PMTYPE"