3
# Copyright (C) 2012-2014, 2016, 2017, 2019-2021 Etersoft
4
# Copyright (C) 2012-2014, 2016, 2017, 2019-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/>.
20
load_helper epm-sh-altlinux
23
load_helper epm-sh-warmup
24
load_helper epm-sh-install
30
grep -q "is not installed" $1 && return $RPMISNOTINSTALLED
35
# Try remove with low level removing
46
store_output sudocmd rpm -ev $noscripts $nodeps $@
47
# rpm returns number of packages if failed on removing
48
__check_rpm_e_result $RC_STDOUT $?
54
# shellcheck disable=SC2046
55
sudocmd dpkg -P $(subst_option nodeps --force-all) $(print_name "$@")
58
sudocmd pkg_delete -r $@
61
sudocmd pkg delete -R $@
64
sudocmd emerge --unmerge $@
70
sudocmd eopkg $(subst_option nodeps --ignore-dependency) remove $@
73
sudocmd $PMTYPE uninstall $@
76
sudocmd /sbin/removepkg $@
88
local APTOPTIONS="$(subst_option non_interactive -y)"
92
sudocmd apt-get remove --purge $APTOPTIONS $@
95
sudocmd aptitude purge $@
98
sudocmd apt-get remove $APTOPTIONS $@
101
docmd pkcon remove $@
109
pkgsrc) # without dependencies
110
sudocmd pkg_delete $@
113
sudocmd pkg delete -R $@
116
#sudocmd emerge --unmerge $@
117
sudocmd emerge -aC $@
120
sudocmd pacman -Rc $@
123
sudocmd yum remove $@
126
sudocmd dnf remove $@
129
sudocmd snappy uninstall $@
132
sudocmd zypper remove --clean-deps $@
135
sudocmd mpkg remove $@
138
sudocmd eopkg $(subst_option nodeps --ignore-dependency) remove $@
141
sudocmd conary erase $@
144
sudocmd npackdcl remove --package=$1
147
sudocmd nix-env --uninstall $@
153
sudocmd guix package -r $@
156
sudocmd pm uninstall $@
159
sudocmd pkg uninstall $@
162
sudocmd choco uninstall $@
165
sudocmd /usr/sbin/slackpkg remove $@
171
sudocmd apt-cyg remove $@
174
sudocmd xbps remove -R $@
177
sudocmd $PMTYPE uninstall $@
180
# shellcheck disable=SC2046
181
sudocmd opkg $(subst_option force -force-depends) remove $@
184
fatal "Have no suitable command for $PMTYPE"
196
sudocmd apt-get -y --force-yes remove --purge $@
199
sudocmd aptitude -y purge $@
202
sudocmd apt-get -y --force-yes remove $@
205
docmd pkcon remove --noninteractive $@
208
sudocmd urpme --auto $@
211
sudocmd pacman -Rc --noconfirm $@
214
sudocmd yum -y remove $@
217
sudocmd dnf remove --assumeyes $@
220
sudocmd zypper --non-interactive remove --clean-deps $@
223
sudocmd /usr/sbin/slackpkg -batch=on -default_answer=yes remove $@
226
sudocmd pkg delete -y -R $@
229
sudocmd opkg -force-defaults remove $@
232
sudocmd eopkg $(subst_option nodeps --ignore-dependency) --yes-all remove $@
235
sudocmd $PMTYPE uninstall -s $@
238
sudocmd xbps remove -y $@
244
epm_print_remove_command()
248
echo "rpm -ev $nodeps $*"
254
echo "pkcon remove --noninteractive $*"
257
echo "pkg_delete -r $*"
260
echo "pkg delete -R $*"
266
echo "emerge --unmerge $*"
269
echo "/sbin/removepkg $*"
272
echo "opkg remove $*"
275
echo "eopkg remove $*"
278
echo "apt-cyg remove $*"
281
echo "xbps remove -y $*"
284
echo "$PMTYPE uninstall -s $*"
287
fatal "Have no suitable appropriate remove command for $PMTYPE"
295
if [ -n "$show_command_only" ] ; then
296
epm_print_remove_command $pkg_filenames
300
# TODO: add support for --no-scripts to all cases
302
if [ "$BASEDISTRNAME" = "alt" ] ; then
303
load_helper epm-sh-altlinux
304
if tasknumber "$pkg_names" >/dev/null ; then
305
assure_exists apt-repo
306
pkg_names="$(get_task_packages $pkg_names)"
310
# TODO: fix pkg_names override
311
# get full package name(s) from the package file(s)
312
[ -n "$pkg_files" ] && pkg_names="$pkg_names $(epm query $pkg_files)"
315
if [ -z "$pkg_names" ] ; then
316
warning "no package(s) to remove."
319
# remove according current arch (if x86_64) by default
320
pkg_names="$(echo $pkg_names | exp_with_arch_suffix)"
322
if [ -n "$dryrun" ] ; then
323
info "Packages for removing:"
328
APTOPTIONS="--simulate"
332
APTOPTIONS="--simulate"
335
fatal "don't yet support --simulate for $PMTYPE"
341
if [ -n "$skip_missed" ] ; then
342
pkg_names="$(get_only_installed_packages $pkg_names)"
345
epm_remove_low $pkg_names && return
348
if [ -n "$direct" ] || [ -n "$nodeps" ] || [ "$STATUS" = "$RPMISNOTINSTALLED" ]; then
349
[ -n "$force" ] || return $STATUS
352
# get package name for hi level package management command (with version if supported and if possible)
353
pkg_names=$(__epm_get_hilevel_name $pkg_names)
355
if [ -n "$non_interactive" ] ; then
356
epm_remove_nonint $pkg_names
358
# if not separate command, use usual command
359
[ "$RET" = "5" ] || return $RET
362
epm_remove_names $pkg_names