NBash

Форк
0
68 строк · 2.5 Кб
1
#!/bin/sh
2
#
3
# Copyright (C) 2019  Etersoft
4
# Copyright (C) 2019  Vitaly Lipatov <lav@etersoft.ru>
5
#
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.
10
#
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.
15
#
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/>.
18
#
19

20
# remove duplicates
21
try_fix_apt_rpm_dupls()
22
{
23
    info "Check for duplicates (internal implementation) ..."
24
    local TESTPKG="ignoreflock"
25
    local has_testpkg=""
26
    if epm --quiet installed $TESTPKG ; then
27
        has_testpkg=1
28
        sudocmd epm remove --auto $TESTPKG || return
29
    fi
30
    local PKGLIST
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|')
33
    local TODEL
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
41
        fi
42
                # first use older package
43
                [ "$(rpmevrcmp "$todel" "$todel2")" = "1" ] && todel="$todel2"
44
        sudocmd rpm -e "$todel" || TODEL="$TODEL $todel"
45
    done
46
    [ -n "$TODEL" ] && sudocmd rpm -e $TODEL
47
    [ -n "$has_testpkg" ] && epm install $TESTPKG
48
}
49

50
epm_dedup()
51
{
52
case "$BASEDISTRNAME" in
53
    "alt")
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)"
57
            sudocmd apt-get dedup
58
        else
59
            info "You can use dedup from apt-scripts package"
60
            try_fix_apt_rpm_dupls
61
        fi
62
        ;;
63
    *)
64
        fatal "Have no suitable command for $PMTYPE"
65
        ;;
66
esac
67

68
}
69

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.