epm-update 2.93 KB
Newer Older
1 2
#!/bin/sh
#
3 4
# Copyright (C) 2012, 2014, 2016-2017  Etersoft
# Copyright (C) 2012, 2014, 2016-2017  Vitaly Lipatov <lav@etersoft.ru>
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
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.
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/>.
18 19 20 21
#

# copied from korinf/tools/run-script/scripts/update

22 23
load_helper epm-sh-warmup

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
# TODO: restore mirroring
get_latest_version()
{
    URL="https://eepm.ru/app-versions"
    #update_url_if_need_mirrored
    epm tool eget -q -O- "$URL/$1"
}

__check_for_epm_version()
{
    local latest="$(get_latest_version "epm" 2>/dev/null)"
    #[ -z "$latest" ] && return
    local res="$(epm print compare "$EPMVERSION" "$latest")"
    [ "$res" = "-1" ] && info "Latest EPM version in Korinf repository is $latest. You have version $EPMVERSION running."
}

40 41
epm_update()
{
42
	[ -z "$*" ] || fatal "No arguments are allowed here"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
43
	info "Running command for update remote package repository database"
44

45 46
warmup_hibase

47
case $PMTYPE in
48
	apt-rpm)
49 50 51 52 53
		# TODO: hack against cd to cwd in apt-get on ALT
		cd /
		sudocmd apt-get update
		local ret="$?"
		cd - >/dev/null
54
		__check_for_epm_version
55
		return $ret
56
		#sudocmd apt-get -f install || exit
57
		;;
58
	apt-dpkg)
59
		sudocmd apt-get update || return
60 61
		#sudocmd apt-get -f install || exit
		#sudocmd apt-get autoremove
Vitaly Lipatov's avatar
Vitaly Lipatov committed
62
		;;
63
	packagekit)
64 65
		docmd pkcon refresh
		;;
66 67 68
	#snappy)
	#	sudocmd snappy
	#	;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
69
	aptitude-dpkg)
70
		sudocmd aptitude update || return
Vitaly Lipatov's avatar
Vitaly Lipatov committed
71
		;;
72
	yum-rpm)
73
		# just skipped
74
		[ -z "$verbose" ] || info "update command is stubbed for yum"
75 76
		;;
	dnf-rpm)
77
		# just skipped
78
		[ -z "$verbose" ] || info "update command is stubbed for dnf"
79
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
80
	urpm-rpm)
81
		sudocmd urpmi.update -a
82
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
83
	pacman)
84
		sudocmd pacman -S -y
Vitaly Lipatov's avatar
Vitaly Lipatov committed
85
		;;
86 87 88
	aura)
		sudocmd aura -A -y
		;;
89
	zypper-rpm)
90
		sudocmd zypper $(subst_option non_interactive --non-interactive) refresh
91
		;;
92
	emerge)
93
		sudocmd emerge --sync
94
		;;
95
	slackpkg)
96
		sudocmd /usr/sbin/slackpkg -batch=on update
97
		;;
98 99 100
	deepsolver-rpm)
		sudocmd ds-update
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
101 102 103
	npackd)
		sudocmd packdcl detect # get packages from MSI database
		;;
104
	homebrew)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
105
		docmd brew update
106
		;;
107 108
	opkg)
		sudocmd opkg update
109
		;;
110 111 112
	eopkg)
		sudocmd eopkg update-repo
		;;
113 114 115
	apk)
		sudocmd apk update
		;;
116 117 118 119
	pkgsrc)
		# portsnap extract for the first time?
		sudocmd portsnap fetch update
		;;
120 121 122
	aptcyg)
		sudocmd apt-cyg update
		;;
123 124 125
	xbps)
		sudocmd xbps-install -S
		;;
126 127 128
	winget)
		sudocmd winget source update
		;;
129
	*)
130
		fatal "Have no suitable update command for $PMTYPE"
131 132 133 134
		;;
esac

}