Commit a113dde9 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm autoremove: skip manually installed packages on ALT

parent 1720f2c7
#!/bin/sh
#
# Copyright (C) 2012, 2017 Etersoft
# Copyright (C) 2012, 2017 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2017, 2018 Etersoft
# Copyright (C) 2012, 2017, 2018 Vitaly Lipatov <lav@etersoft.ru>
#
# 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
......@@ -17,9 +17,23 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-check_updated_repo
__epm_print_excluded()
{
local pkgs="$1"
local fullpkgs="$2"
local excluded
excluded="$(estrlist exclude "$pkgs" "$fullpkgs")"
if [ -n "$excluded" ] ; then
echo "Skipped manually installed:"
estrlist union $excluded
fi
}
__epm_autoremove_altrpm_pp()
{
local pkgs
local pkgs fullpkgs
info "Removing unused python/perl modules..."
#[ -n "$force" ] || info "You can run with --force for more deep removing"
......@@ -32,14 +46,18 @@ __epm_autoremove_altrpm_pp()
[ -n "$force" ] || libexclude=$libexclude'[^-]*$'
showcmd "apt-cache list-nodeps | grep -E -- \"$libexclude\""
pkgs=$(apt-cache list-nodeps | grep -E -- "$libexclude" )
fullpkgs=$(apt-cache list-nodeps | grep -E -- "$libexclude" )
pkgs=$(skip_manually_installed $fullpkgs)
if [ -n "$dryrun" ] ; then
info "Packages for autoremoving:"
echo "$pkgs"
__epm_print_excluded "$pkgs" "$fullpkgs"
return 0
fi
__epm_print_excluded "$pkgs" "$fullpkgs"
[ -n "$pkgs" ] && sudocmd rpm -v -e $pkgs && flag=1
if [ -n "$flag" ] ; then
......@@ -53,7 +71,7 @@ __epm_autoremove_altrpm_pp()
__epm_autoremove_altrpm_lib()
{
local pkgs
local pkgs fullpkgs
local nodevel="$1"
......@@ -74,23 +92,27 @@ __epm_autoremove_altrpm_lib()
# https://www.altlinux.org/APT_в_ALT_Linux/Советы_по_использованию#apt-cache_list-nodeps
showcmd "apt-cache list-nodeps | grep -E -- \"$libgrep\""
pkgs=$(apt-cache list-nodeps | grep -E -- "$libgrep" \
fullpkgs=$(apt-cache list-nodeps | grep -E -- "$libgrep" \
| sed -e "s/[-\.]32bit$//g" \
| grep -E -v -- "$develrule" \
| grep -E -v -- "-(debuginfo)$" \
| grep -E -v -- "-(util|utils|tool|tools|plugin|daemon|help)$" \
| grep -E -v -- "^(libsystemd|libreoffice|libnss|libvirt-client|libvirt-daemon|libsasl2-plugin|eepm)" )
pkgs=$(skip_manually_installed $fullpkgs)
if [ -n "$dryrun" ] ; then
info "Packages for autoremoving:"
echo "$pkgs"
__epm_print_excluded "$pkgs" "$fullpkgs"
return 0
fi
__epm_print_excluded "$pkgs" "$fullpkgs"
# commented, with hi probability user install i586- manually
# workaround against missed i586- handling in apt-cache list-nodeps
if epmqp i586-lib >/dev/null ; then
info "You can try removing i586- with follow command"
info "You can try removing all i586- with follow command"
showcmd rpm -v -e $(epmqp i586-lib)
fi
......
......@@ -66,3 +66,25 @@ update_repo_if_needed()
cd - >/dev/null || fatal
}
# save manually installed packages
save_installed_packages()
{
[ -d /var/lib/rpm ] || return 0
estrlist list "$@" | $SUDO tee /var/lib/rpm/EPM-installed >/dev/null
}
check_manually_installed()
{
[ -r /var/lib/rpm/EPM-installed ] || return 1
grep -q -- "^$1\$" /var/lib/rpm/EPM-installed
}
skip_manually_installed()
{
local i
for i in "$@" ; do
check_manually_installed "$i" && continue
echo "$i"
done
}
......@@ -118,7 +118,7 @@ epm_install_names()
case $PMTYPE in
apt-rpm|apt-dpkg)
APTOPTIONS="$APTOPTIONS $(subst_option verbose "-o Debug::pkgMarkInstall=1 -o Debug::pkgProblemResolver=1")"
sudocmd apt-get $APTOPTIONS $noremove install $@
sudocmd apt-get $APTOPTIONS $noremove install $@ && save_installed_packages $@
return ;;
aptitude-dpkg)
sudocmd aptitude install $@
......@@ -323,7 +323,7 @@ epm_install_files()
# do not using low-level for install by file path (FIXME: reasons?)
if ! is_dirpath "$@" || [ "$(get_package_type "$@")" = "rpm" ] ; then
sudocmd rpm -Uvh $force $nodeps $@ && return
sudocmd rpm -Uvh $force $nodeps $@ && save_installed_packages $@ && return
local RES=$?
# TODO: check rpm result code and convert it to compatible format if possible
__epm_check_if_rpm_already_installed $@ && 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