epm-reinstall 1.75 KB
Newer Older
Vitaly Lipatov's avatar
Vitaly Lipatov committed
1 2 3 4 5
#!/bin/sh
#
# Copyright (C) 2012  Etersoft
# Copyright (C) 2012  Vitaly Lipatov <lav@etersoft.ru>
#
6 7 8
# 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
Vitaly Lipatov's avatar
Vitaly Lipatov committed
9 10 11 12 13
# (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
14
# GNU Affero General Public License for more details.
Vitaly Lipatov's avatar
Vitaly Lipatov committed
15
#
16 17
# 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/>.
Vitaly Lipatov's avatar
Vitaly Lipatov committed
18 19
#

20 21
load_helper epm-install

Vitaly Lipatov's avatar
Vitaly Lipatov committed
22 23 24 25 26 27
# copied from etersoft-build-utils/share/eterbuild/functions/rpmpkg
epm_reinstall_names()
{
	[ -n "$1" ] || return
	case $PMTYPE in
		apt-rpm|apt-dpkg)
28
			sudocmd apt-get --reinstall install $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
29
			return ;;
30 31 32
		dnf-rpm)
			sudocmd dnf reinstall $@
			return ;;
33
		slackpkg)
34
			sudocmd /usr/sbin/slackpkg reinstall $@
35
			return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
36
	esac
37 38 39

	# fallback to generic install
	epm_install_names
Vitaly Lipatov's avatar
Vitaly Lipatov committed
40 41 42 43 44 45
}

epm_reinstall_files()
{
    [ -z "$1" ] && return

46 47
    case $PMTYPE in
        apt-rpm)
48 49
            sudocmd rpm -Uvh --force $@ && return
            sudocmd apt-get --reinstall install $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
50
            return ;;
51
        apt-pkg)
52
            sudocmd dpkg -i $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
53
            return ;;
54
        slackpkg)
55
            sudocmd /sbin/installpkg $@
56
            return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
    esac

    # other systems can install file package via ordinary command
    epm_reinstall_names $@
}


epm_reinstall()
{
    [ -n "$pkg_filenames" ] || fatal "Run install without packages"

    epm_reinstall_names $pkg_names
    epm_reinstall_files $pkg_files
}