3
# Copyright (C) 2012-2015, 2018 Etersoft
4
# Copyright (C) 2012-2015, 2018 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-install
23
# for zypper before SUSE/11.0
26
a='' zypper install --help 2>&1 | grep -q -- "--dry-run" && echo "--dry-run"
31
a='' yum --help 2>&1 | grep -q -- "--assumeno"
37
grep -q "^No package" $1 && return 1
38
grep -q "^Complete!" $1 && return 0
39
grep -q "Exiting on user [Cc]ommand" $1 && return 0
41
grep -q "^Operation aborted." $1 && return 0
42
# return default result by default
46
__check_pacman_result()
48
grep -q "^error: target not found:" $1 && return 1
49
grep -q "^Total Installed Size:" $1 && return 0
50
grep -q "^Total Download Size:" $1 && return 0
51
# return default result by default
64
CMD="apt-get --simulate install"
67
CMD="aptitude -s install"
70
if __use_yum_assumeno ; then
71
store_output sudocmd yum --assumeno install $filenames
72
__check_yum_result $RC_STDOUT $?
74
store_output sudocmd yum install $filenames <<EOF
77
__check_yum_result $RC_STDOUT $?
83
store_output sudocmd dnf --assumeno install $filenames
84
__check_yum_result $RC_STDOUT $?
89
CMD="urpmi --test --auto"
92
CMD="eopkg --dry-run install"
95
if ! __use_zypper_dry_run >/dev/null ; then
96
fatal "zypper is too old: does not support --dry-run"
98
CMD="zypper --non-interactive install --dry-run"
102
for pkg in $filenames ; do
103
is_installed $pkg && continue
104
docmd emerge --pretend $pkg && continue
110
docmd --noaction install $filenames
113
store_output sudocmd pacman -v -S $filenames <<EOF
116
__check_pacman_result $RC_STDOUT $?
121
#docmd /usr/sbin/slackpkg -batch=on -default_answer=yes download
122
# just try search every package
123
# FIXME: epm_search have to return false status code if the package does not found
126
for pkg in $filenames ; do
127
# FIXME: -[0-0] does not work in search!
128
# FIXME: we need strict search here (not find gst-plugins-base if search for gst-plugins
130
# use verbose for get package status
131
#pkg_filenames="$pkg-[0-9]" verbose=--verbose __epm_search_internal | grep -E "(installed|upgrade)" && continue
132
#pkg_filenames="$pkg" verbose=--verbose __epm_search_internal | grep -E "(installed|upgrade)" && continue
133
__epm_search_internal "$pkg" | grep -q "^$pkg-[0-9]" && continue
135
info "Package '$pkg' does not found in repository."
139
fatal "Have no suitable simulate command for $PMTYPE"
143
sudocmd $CMD $filenames
148
[ -z "$pkg_filenames" ] && info "Simulate: Skip empty list" && return 22
150
local filenames="$(echo $pkg_filenames | filter_out_installed_packages)"
152
[ -z "$filenames" ] && info "Simulate: All packages are already installed" && return 0
154
_epm_do_simulate $filenames
156
if [ -z "$quiet" ] ; then
157
if [ "$RES" = 0 ] ; then
158
info "Simulate result: $filenames package(s) CAN BE installed"
160
info "Simulate result: There are PROBLEMS with install some package(s)"