Commit 07c65a5e authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm-autoremove: big rewrite, add confirm before removing

parent a81a5008
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2012, 2017, 2018 Etersoft # Copyright (C) 2012, 2017, 2018, 2021 Etersoft
# Copyright (C) 2012, 2017, 2018 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2012, 2017, 2018, 2021 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
...@@ -36,15 +36,11 @@ __epm_autoremove_altrpm_pp() ...@@ -36,15 +36,11 @@ __epm_autoremove_altrpm_pp()
local pkgs fullpkgs local pkgs fullpkgs
info "Removing unused python/perl modules..." info "Removing unused python/perl modules..."
#[ -n "$force" ] || info "You can run with --force for more deep removing"
local force=force
local libexclude="$1" local libexclude="$1"
local flag= local flag=
[ -n "$force" ] || libexclude=$libexclude'[^-]*$'
showcmd "apt-cache list-nodeps | grep -E -- \"$libexclude\"" showcmd "apt-cache list-nodeps | grep -E -- \"$libexclude\""
fullpkgs=$(apt-cache list-nodeps | grep -E -- "$libexclude" ) fullpkgs=$(apt-cache list-nodeps | grep -E -- "$libexclude" )
pkgs=$(skip_manually_installed $fullpkgs) pkgs=$(skip_manually_installed $fullpkgs)
...@@ -56,9 +52,16 @@ __epm_autoremove_altrpm_pp() ...@@ -56,9 +52,16 @@ __epm_autoremove_altrpm_pp()
return 0 return 0
fi fi
if [ -n "$pkgs" ] ; then
info "The command we will run:"
showcmd rpm -v -e $pkgs
__epm_print_excluded "$pkgs" "$fullpkgs" __epm_print_excluded "$pkgs" "$fullpkgs"
[ -n "$pkgs" ] && sudocmd rpm -v -e $pkgs && flag=1 confirm_info "We will remove unused (without dependencies) packages above."
sudocmd rpm -v -e $pkgs && flag=1
fi
if [ -n "$flag" ] ; then if [ -n "$flag" ] ; then
info "" info ""
...@@ -107,17 +110,15 @@ __epm_autoremove_altrpm_lib() ...@@ -107,17 +110,15 @@ __epm_autoremove_altrpm_lib()
return 0 return 0
fi fi
if [ -n "$pkgs" ] ; then
info "The command we will run:"
showcmd rpm -v -e $pkgs
__epm_print_excluded "$pkgs" "$fullpkgs" __epm_print_excluded "$pkgs" "$fullpkgs"
confirm_info "We will remove unused (without dependencies) packages above."
# commented, with hi probability user install i586- manually sudocmd rpm -v -e $pkgs && flag=1
# workaround against missed i586- handling in apt-cache list-nodeps
if epmqp i586-lib >/dev/null ; then
info "You can try removing all i586- with follow command"
showcmd rpm -v -e $(epmqp i586-lib)
fi fi
[ -n "$pkgs" ] && sudocmd rpm -v -e $pkgs && flag=1
if [ -n "$flag" ] ; then if [ -n "$flag" ] ; then
info "" info ""
info "call again for next cycle until all libs will be removed" info "call again for next cycle until all libs will be removed"
...@@ -197,10 +198,11 @@ case $DISTRNAME in ...@@ -197,10 +198,11 @@ case $DISTRNAME in
epm_autoremove_print_help epm_autoremove_print_help
return 0 return 0
fi fi
if [ -z "$direct" ] ; then if [ -z "$direct" ] ; then
fatal "Run autoremove without args or with --direct. Check epm autoremove --help to available commands."
sudocmd apt-get $(subst_option non_interactive -y) autoremove $dryrun sudocmd apt-get $(subst_option non_interactive -y) autoremove $dryrun
local RET=$? local RET=$?
info "Also you can run 'epm autoremove --direct' to use epm implementation of autoremove (see --help)"
[ "$RET" = 0 ] || return [ "$RET" = 0 ] || return
else else
__epm_autoremove_altrpm "$@" __epm_autoremove_altrpm "$@"
...@@ -208,6 +210,9 @@ case $DISTRNAME in ...@@ -208,6 +210,9 @@ case $DISTRNAME in
[ -n "$dryrun" ] && return [ -n "$dryrun" ] && return
# remove old kernels only by a default way
[ -n "$@" ] && return
docmd epm remove-old-kernels $(subst_option non_interactive --auto) docmd epm remove-old-kernels $(subst_option non_interactive --auto)
if which nvidia-clean-driver 2>/dev/null ; then if which nvidia-clean-driver 2>/dev/null ; then
...@@ -218,6 +223,11 @@ case $DISTRNAME in ...@@ -218,6 +223,11 @@ case $DISTRNAME in
fi fi
fi fi
if [ -z "$direct" ] ; then
echo
info "Also you can run 'epm autoremove --direct' to use epm implementation of autoremove (see --help)"
fi
return return
;; ;;
*) *)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment