epm-reinstall 1.96 KB
Newer Older
Vitaly Lipatov's avatar
Vitaly Lipatov committed
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
#!/bin/sh
#
# Copyright (C) 2012  Etersoft
# Copyright (C) 2012  Vitaly Lipatov <lav@etersoft.ru>
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#

# copied from etersoft-build-utils/share/eterbuild/functions/rpmpkg
epm_reinstall_names()
{
	[ -n "$1" ] || return
	case $PMTYPE in
		apt-rpm|apt-dpkg)
27
			sudocmd apt-get --reinstall install $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
28 29
			return ;;
		yum-rpm)
30
			sudocmd yum install $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
31 32
			return ;;
		urpm-rpm)
33
			sudocmd urpmi $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
34 35
			return ;;
		zypper-rpm)
36
			sudocmd zypper install $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
37 38
			return ;;
		pkg_add)
39
			sudocmd pkg_add -r $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
40
			return ;;
41
		pacman)
42
			sudocmd pacman -U $@
43
			return ;;
44
		slackpkg)
45
			sudocmd slackpkg reinstall $@
46
			return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
47 48 49 50 51 52 53 54 55 56
		*)
			fatal "Do not known install command for $PMTYPE"
			;;
	esac
}

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

57 58
    case $PMTYPE in
        apt-rpm)
59 60
            sudocmd rpm -Uvh --force $@ && return
            sudocmd apt-get --reinstall install $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
61
            return ;;
62
        apt-pkg)
63
            sudocmd dpkg -i $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
64
            return ;;
65
        slackpkg)
66
            sudocmd installpkg $@
67
            return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
    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
}