3
# Copyright (C) 2019 Etersoft
4
# Copyright (C) 2019 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/>.
21
try_fix_apt_rpm_dupls()
23
info "Check for duplicates (internal implementation) ..."
24
local TESTPKG="ignoreflock"
26
if epm --quiet installed $TESTPKG ; then
28
sudocmd epm remove --auto $TESTPKG || return
31
PKGLIST=$(LC_ALL=C sudorun apt-get install $TESTPKG 2>&1 | grep "W: There are multiple versions of" | \
32
sed -e 's|W: There are multiple versions of "\(.*\)" in your system.|\1|')
34
for i in $PKGLIST ; do
35
local pkg=${i/.32bit/}
36
local todel="$(rpm -q $pkg | head -n1)"
37
local todel2="$(rpm -q $pkg | head -n2 | tail -n1)"
38
if [ "$todel" = "$todel2" ] ; then
39
echo "Fix the same name duplicates for $pkg..."
40
sudocmd rpm -e "$todel" --allmatches --nodeps --justdb && epm install $pkg && continue
42
# first use older package
43
[ "$(rpmevrcmp "$todel" "$todel2")" = "1" ] && todel="$todel2"
44
sudocmd rpm -e "$todel" || TODEL="$TODEL $todel"
46
[ -n "$TODEL" ] && sudocmd rpm -e $TODEL
47
[ -n "$has_testpkg" ] && epm install $TESTPKG
52
case "$BASEDISTRNAME" in
54
assure_exists /usr/share/apt/scripts/dedup.lua apt-scripts
55
if [ -z "$direct" ] && [ -f /usr/share/apt/scripts/dedup.lua ] ; then
56
info "Check for duplicates via apt-get dedup from apt-scripts (also you can use internal EPM dedup implementation with --direct option)"
59
info "You can use dedup from apt-scripts package"
64
fatal "Have no suitable command for $PMTYPE"