3
# Copyright (C) 2012-2020 Etersoft
4
# Copyright (C) 2012-2020 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
epm_install_files_alt()
23
[ -z "$files" ] && return
25
# TODO: check read permissions
27
# do not fallback to install_names if we have no permissions
29
__epm_print_warning_for_nonalt_packages $files
32
if __epm_repack_if_needed $files ; then
33
[ -n "$repacked_pkgs" ] || fatal "Can't convert $files"
34
files="$repacked_pkgs"
37
if [ -n "$save_only" ] ; then
39
cp -v $files "$EPMCURDIR"
43
if [ -n "$put_to_repo" ] ; then
44
load_helper epm-repopkg
45
epm_put_to_repo $files
49
__epm_check_if_src_rpm $files
51
if [ -z "$repacked_pkgs" ] ; then
52
__epm_check_vendor $files
53
__epm_check_if_needed_repack $files
56
# --replacepkgs: Install the Package Even If Already Installed
57
local replacepkgs="$(__epm_get_replacepkgs $files)"
58
sudocmd rpm -Uvh $replacepkgs $(subst_option dryrun --test) $force $noscripts $nodeps $files && save_installed_packages $files && return
60
# TODO: check rpm result code and convert it to compatible format if possible
61
__epm_check_if_rpm_already_installed $force $replacepkgs $noscripts $nodeps $files && return
63
# if run with --nodeps, do not fallback on hi level
64
[ -n "$nodeps" ] && return $RES
66
# separate second output
69
# try install via apt if we could't install package file via rpm (we guess we need install requirements firsly)
71
if [ -z "$noscripts" ] ; then
72
epm_install_names $files
76
# TODO: use it always (apt can install version from repo instead of a file package)
77
info "Workaround for install packages via apt with --noscripts (see https://bugzilla.altlinux.org/44670)"
78
info "Firstly install package requrements …"
79
# names of packages to be installed
80
local fl="$(epm print name for package $files)"
81
local req="$(docmd epm req --short $files)" || return
82
# exclude package names from requires (req - fl)
83
req="$(estrlist exclude "$fl" "$req")"
84
# TODO: can we install only requires via apt?
85
docmd epm install --skip-installed $req || return
88
# --replacepkgs: Install the Package Even If Already Installed
89
local replacepkgs="$(__epm_get_replacepkgs $files)"
90
sudocmd rpm -Uvh $replacepkgs $(subst_option dryrun --test) $force $noscripts $nodeps $files && save_installed_packages $files
93
get_current_kernel_flavour()
101
# std-def 1.2.3-alt1 -> 1.2.3-std-def-alt1
104
echo "$2" | sed -e "s|-|-$1-|"
107
# return latest installed kernel in a form like 5.15.109-un-def-alt1
108
get_latest_kernel_rel()
110
local kernel_flavour="$1"
115
# copied and modified from update-kernel
116
# get the maximum available kernel package version
120
comparever="$(rpmevrcmp "$kmaxver" "$version")"
121
[ "$comparever" -lt 0 ] && kmaxver="$version" ||:
122
done <<<"$(epm print version-release for package kernel-image-$kernel_flavour)"
123
[ -z "$kmaxver" ] && echo "$rrel" && return
125
make_kernel_release "$kernel_flavour" "$kmaxver"
128
# install <module-name>-std-def
129
epm_install_alt_kernel_module()
131
[ -n "$1" ] || return 0
137
# fill kernel flavour list
139
km="$(echo "$kmf" | cut -d- -f1)"
140
kf="$(echo "$kmf" | cut -d- -f2,3)"
141
# use current flavour as default
142
[ "$km" = "$kf" ] && kf="$(get_current_kernel_flavour)"
146
# firstly, update all needed kernels (by flavour)
147
for kf in $(estrlist uniq $kflist) ; do
149
docmd epm update-kernel -t $kf || exit
152
# skip install modules if there are no installed kernels (may be, a container)
153
epm installed "kernel-image-$kf" || return 0
155
# make list for install kernel modules
157
km="$(echo "$kmf" | cut -d- -f1)"
158
kf="$(echo "$kmf" | cut -d- -f2,3)"
159
# use current flavour as default
160
[ "$km" = "$kf" ] && kf="$(get_current_kernel_flavour)"
161
kvf="$(get_latest_kernel_rel $kf)"
162
#kmplist="$kmplist kernel-modules-$km-$kf"
163
# install kernel module for latest installed kernel
164
kmplist="$kmplist kernel-modules-$km-$kvf"
167
# secondly, install module(s)
168
epm_install_names $kmplist
172
epm_install_alt_names()
175
local installnames=''
177
while [ -n "$1" ] ; do
180
if echo "$pkgname" | grep -v "#" | grep -q "^kernel-modules*-" ; then
181
# virtualbox[-std-def]
182
local kmn="$(echo $pkgname | sed -e 's|kernel-modules*-||')"
183
local kf1="$(echo "$kmn" | cut -d- -f2)"
184
local kf2="$(echo "$kmn" | cut -d- -f4)"
185
# pass install with full pkgnames
186
if [ "$kf1" != "$kf2" ] && [ -n "$kf2" ] || echo "$kf1" | grep -q "^[0-9]" ; then
187
installnames="$installnames $pkgname"
189
kmlist="$kmlist $kmn"
192
installnames="$installnames $pkgname"
197
epm_install_names $installnames || return
198
epm_install_alt_kernel_module $kmlist || return
202
# apt-repo with non_interactive support
205
assure_exists apt-repo
206
[ -n "$non_interactive" ] || return
209
trap "$SUDO rm /etc/apt/apt.conf.d/eepm-apt-noninteractive.conf 2>/dev/null" EXIT
210
echo 'APT::Get::Assume-Yes "true";' | $SUDO tee /etc/apt/apt.conf.d/eepm-apt-noninteractive.conf >/dev/null
215
[ -n "$non_interactive" ] || return
217
$SUDO rm /etc/apt/apt.conf.d/eepm-apt-noninteractive.conf 2>/dev/null
221
epm_install_alt_tasks()
224
# TODO: don't use apt-repo
227
sudocmd_foreach "apt-repo test" $(tasknumber "$@")