Commit c538750f authored by Vitaly Lipatov's avatar Vitaly Lipatov

autoremove: add support for autoremove [libs|python|perl|libs-devel]

parent 54756d39
...@@ -4,8 +4,6 @@ packages list таск ...@@ -4,8 +4,6 @@ packages list таск
аналог epm purge: запоминаем список файлов, удаляем пакеты и по возможности всё, от чего зависит (рекурсивно). аналог epm purge: запоминаем список файлов, удаляем пакеты и по возможности всё, от чего зависит (рекурсивно).
epm autoremove [libs|python|perl|libs-devel]
--interactive --interactive
встроить вычисление зависимость сюда rpmreqs встроить вычисление зависимость сюда rpmreqs
......
...@@ -256,7 +256,7 @@ check_command() ...@@ -256,7 +256,7 @@ check_command()
clean) # HELPCMD: clean local package cache clean) # HELPCMD: clean local package cache
epm_cmd=clean epm_cmd=clean
;; ;;
autoremove|package-cleanup) # HELPCMD: auto remove unneeded package(s) autoremove|package-cleanup) # HELPCMD: auto remove unneeded package(s) Supports args for ALT: [libs|python|perl|libs-devel]
epm_cmd=autoremove epm_cmd=autoremove
;; ;;
autoorphans|--orphans) # HELPCMD: remove all packages not from the repository autoorphans|--orphans) # HELPCMD: remove all packages not from the repository
......
...@@ -25,11 +25,12 @@ __epm_autoremove_altrpm_pp() ...@@ -25,11 +25,12 @@ __epm_autoremove_altrpm_pp()
#[ -n "$force" ] || info "You can run with --force for more deep removing" #[ -n "$force" ] || info "You can run with --force for more deep removing"
local force=force local force=force
local libexclude="$1"
local flag= local flag=
[ -n "$force" ] || libexclude=$libexclude'[^-]*$'
libexclude='^(python-module-|python3-module-|python-modules-|python3-modules|perl-)'
[ -n "$force" ] || libexclude=$libexclude'[^-]*$' [ -n "$force" ] || libexclude=$libexclude'[^-]*$'
showcmd "apt-cache list-nodeps | grep -E -- \"$libexclude\"" showcmd "apt-cache list-nodeps | grep -E -- \"$libexclude\""
pkgs=$(apt-cache list-nodeps | grep -E -- "$libexclude" ) pkgs=$(apt-cache list-nodeps | grep -E -- "$libexclude" )
...@@ -44,7 +45,7 @@ __epm_autoremove_altrpm_pp() ...@@ -44,7 +45,7 @@ __epm_autoremove_altrpm_pp()
if [ -n "$flag" ] ; then if [ -n "$flag" ] ; then
info "" info ""
info "call again for next cycle until all modules will be removed" info "call again for next cycle until all modules will be removed"
__epm_autoremove_altrpm_pp __epm_autoremove_altrpm_pp "$libexclude"
fi fi
return 0 return 0
...@@ -54,8 +55,16 @@ __epm_autoremove_altrpm_lib() ...@@ -54,8 +55,16 @@ __epm_autoremove_altrpm_lib()
{ {
local pkgs local pkgs
local nodevel="$1"
info info
if [ "$nodevel" = "nodevel" ] ; then
info "Removing all non -devel/-debuginfo libs packages not need by anything..." info "Removing all non -devel/-debuginfo libs packages not need by anything..."
local develrule='-(devel|devel-static)$'
else
info "Removing all non -debuginfo libs packages (-devel too) not need by anything..."
local develrule='-(NONONO)$'
fi
#[ -n "$force" ] || info "You can run with --force for more deep removing" #[ -n "$force" ] || info "You can run with --force for more deep removing"
local force=force local force=force
...@@ -67,7 +76,8 @@ __epm_autoremove_altrpm_lib() ...@@ -67,7 +76,8 @@ __epm_autoremove_altrpm_lib()
showcmd "apt-cache list-nodeps | grep -- \"$libexclude\"" showcmd "apt-cache list-nodeps | grep -- \"$libexclude\""
pkgs=$(apt-cache list-nodeps | grep -E -- "$libexclude" \ pkgs=$(apt-cache list-nodeps | grep -E -- "$libexclude" \
| sed -e "s/[-\.]32bit$//g" \ | sed -e "s/[-\.]32bit$//g" \
| grep -E -v -- "-(devel|devel-static|debuginfo)$" \ | grep -E -v -- "$develrule" \
| grep -E -v -- "-(debuginfo)$" \
| grep -E -v -- "-(util|utils|tool|tools|plugin|daemon|help)$" \ | grep -E -v -- "-(util|utils|tool|tools|plugin|daemon|help)$" \
| grep -E -v -- "^(libsystemd|libreoffice|libnss|libvirt-client|libvirt-daemon|libsasl2-plugin|eepm)" ) | grep -E -v -- "^(libsystemd|libreoffice|libnss|libvirt-client|libvirt-daemon|libsasl2-plugin|eepm)" )
...@@ -82,7 +92,7 @@ __epm_autoremove_altrpm_lib() ...@@ -82,7 +92,7 @@ __epm_autoremove_altrpm_lib()
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"
__epm_autoremove_altrpm_lib __epm_autoremove_altrpm_lib $nodevel
fi fi
return 0 return 0
...@@ -91,12 +101,35 @@ __epm_autoremove_altrpm_lib() ...@@ -91,12 +101,35 @@ __epm_autoremove_altrpm_lib()
__epm_autoremove_altrpm() __epm_autoremove_altrpm()
{ {
local pkg local i
load_helper epm-packages load_helper epm-packages
assure_exists /etc/buildreqs/files/ignore.d/apt-scripts apt-scripts assure_exists /etc/buildreqs/files/ignore.d/apt-scripts apt-scripts
__epm_autoremove_altrpm_pp if [ -z "$pkg_names" ] ; then
__epm_autoremove_altrpm_pp '^(python-module-|python3-module-|python-modules-|python3-modules|perl-)'
__epm_autoremove_altrpm_lib nodevel
return 0
fi
for i in $pkg_names ; do
case $i in
libs)
__epm_autoremove_altrpm_lib nodevel
;;
python)
__epm_autoremove_altrpm_pp '^(python-module-|python3-module-|python-modules-|python3-modules)'
;;
perl)
__epm_autoremove_altrpm_pp '^(perl-)'
;;
libs-devel)
__epm_autoremove_altrpm_lib __epm_autoremove_altrpm_lib
;;
*)
fatal "autoremove: unsupported '$i'. Use libs, python, perl, libs-devel."
;;
esac
done
return 0 return 0
} }
...@@ -105,8 +138,6 @@ __epm_autoremove_altrpm() ...@@ -105,8 +138,6 @@ __epm_autoremove_altrpm()
epm_autoremove() epm_autoremove()
{ {
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $DISTRNAME in case $DISTRNAME in
ALTLinux) ALTLinux)
__epm_autoremove_altrpm __epm_autoremove_altrpm
...@@ -125,6 +156,8 @@ case $DISTRNAME in ...@@ -125,6 +156,8 @@ case $DISTRNAME in
;; ;;
esac esac
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in case $PMTYPE in
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
sudocmd apt-get autoremove $dryrun sudocmd apt-get autoremove $dryrun
......
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