epm-reinstall 2.58 KB
Newer Older
Vitaly Lipatov's avatar
Vitaly Lipatov committed
1 2
#!/bin/sh
#
3 4
# Copyright (C) 2012,2014,2016,2017  Etersoft
# Copyright (C) 2012,2014,2016,2017  Vitaly Lipatov <lav@etersoft.ru>
Vitaly Lipatov's avatar
Vitaly Lipatov committed
5
#
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
load_helper epm-install
21
load_helper epm-sh-warmup
22

Vitaly Lipatov's avatar
Vitaly Lipatov committed
23 24 25 26
# copied from etersoft-build-utils/share/eterbuild/functions/rpmpkg
epm_reinstall_names()
{
	[ -n "$1" ] || return
27

Vitaly Lipatov's avatar
Vitaly Lipatov committed
28 29
	case $PMTYPE in
		apt-rpm|apt-dpkg)
30 31
			local APTOPTIONS="$(subst_option non_interactive -y)"
			sudocmd apt-get --reinstall $APTOPTIONS install $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
32
			return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
33 34 35
		aptitude-dpkg)
			sudocmd aptitude reinstall $@
			return ;;
36
		packagekit)
37 38 39
			warning "Please send me the correct command form for it"
			docmd pkcon install --allow-reinstall $@
			return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
40 41 42
		yum-rpm)
			sudocmd yum reinstall $@
			return ;;
43 44 45
		dnf-rpm)
			sudocmd dnf reinstall $@
			return ;;
46 47 48
		homebrew)
			sudocmd brew reinstall $@
			return ;;
49
		pkgng)
50
			sudocmd pkg install -f $@
51
			return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
52 53
		opkg)
			sudocmd opkg --force-reinstall install $@
54 55 56
			return ;;
		eopkg)
			sudocmd eopkg --reinstall install $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
57
			return ;;
58
		slackpkg)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
59
			sudocmd_foreach "/usr/sbin/slackpkg reinstall" $@
60
			return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
61
	esac
62 63

	# fallback to generic install
Vitaly Lipatov's avatar
Vitaly Lipatov committed
64
	epm_install_names $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
65 66 67 68 69 70
}

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

71 72
    case $PMTYPE in
        apt-rpm)
73 74
            sudocmd rpm -Uvh --force $@ && return
            sudocmd apt-get --reinstall install $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
75
            return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
76
        apt-dpkg|aptitude-dpkg)
77
            sudocmd dpkg -i $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
78
            return ;;
79
        slackpkg)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
80
            sudocmd_foreach "/sbin/installpkg" $@
81
            return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
82 83 84 85 86 87 88 89 90
    esac

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


epm_reinstall()
{
Vitaly Lipatov's avatar
Vitaly Lipatov committed
91
    [ -n "$pkg_filenames" ] || fatal "Reinstall: package name is missed."
Vitaly Lipatov's avatar
Vitaly Lipatov committed
92

93 94
    warmup_lowbase

95 96 97
    # get package name for hi level package management command (with version if supported and if possible)
    pkg_names=$(__epm_get_hilevel_name $pkg_names)

98 99
    warmup_hibase

Vitaly Lipatov's avatar
Vitaly Lipatov committed
100 101 102 103
    epm_reinstall_names $pkg_names
    epm_reinstall_files $pkg_files
}