You need to sign in or sign up before continuing.
epm-install-apt-dpkg 2.62 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#!/bin/sh
#
# Copyright (C) 2012-2020  Etersoft
# Copyright (C) 2012-2020  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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

epm_install_files_apt_dpkg()
{
    local files="$*"
    [ -z "$files" ] && return

    # the new version of the conf. file is installed with a .dpkg-dist suffix
    if [ -n "$non_interactive" ] ; then
        DPKGOPTIONS="--force-confdef --force-confold"
    fi

    if __epm_repack_if_needed $files ; then
31
        [ -n "$repacked_pkgs" ] || fatal 'Can'\''t convert $files'
32 33 34 35 36 37 38 39 40
        files="$repacked_pkgs"
    fi

    if [ -n "$save_only" ] ; then
        echo
        cp -v $files "$EPMCURDIR"
        return
    fi

41 42 43 44 45 46 47
    if [ -n "$put_to_repo" ] ; then
        load_helper epm-repopkg
        epm_put_to_repo $files
        return
    fi


48 49
    # TODO: if dpkg can't install due missed deps, trying with apt (as for now, --refuse-depends, --refuse-breaks don't help me)

50 51 52 53 54
    if [ -n "$force_overwrite" ] ; then
        DPKGOPTIONS="$DPKGOPTIONS --force-overwrite"
    fi

    if [ -n "$nodeps" ] || [ -n "$force_overwrite" ] ; then
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
        sudocmd dpkg $DPKGOPTIONS -i $files
        return
    fi

    # for too old apt-get
    # TODO: check apt-get version?
    apt_can_install_files='1'
    if [ "$DISTRNAME" = "Ubuntu" ] ; then
        [ "$DISTRVERSION" = "14.04" ] && apt_can_install_files=''
        [ "$DISTRVERSION" = "12.04" ] && apt_can_install_files=''
    fi

    if [ -n "$apt_can_install_files" ] ; then
        # TODO: don't resolve fuzzy dependencies ()
        # are there apt that don't support dpkg files to install?
        epm_install_names $(make_filepath $files)
        return
    fi

    # old way:

    sudocmd dpkg $DPKGOPTIONS -i $files
    local RES=$?

    # return OK if all is OK
    [ "$RES" = "0" ] && return $RES

    # TODO: workaround with epm-check needed only for very old apt

    # run apt -f install if there are were some errors during install
    load_helper epm-check
    epm_check

    # repeat install for get correct status
    sudocmd dpkg $DPKGOPTIONS -i $files
}