epm-upgrade 3.44 KB
Newer Older
1 2
#!/bin/sh
#
3 4
# Copyright (C) 2012, 2014, 2016, 2019  Etersoft
# Copyright (C) 2012, 2014, 2016, 2019  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
load_helper epm-check_updated_repo
21
load_helper epm-sh-warmup
22

23
epm_upgrade()
24
{
25
	local CMD
26

27
	#[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
28

29 30 31
	# it is useful for first time running
	update_repo_if_needed

32
	warmup_bases
33 34 35 36 37 38 39

	if [ "$DISTRNAME" = "ALTLinux" ] ; then
		load_helper epm-sh-altlinux
		if tasknumber "$pkg_names" >/dev/null ; then
			load_helper epm-addrepo
			load_helper epm-removerepo
			load_helper epm-Install
40
			epm_addrepo "$pkg_names"
41
			local installlist="$(get_task_packages $pkg_names)"
42 43
			# hack: drop -devel packages to avoid package provided by multiple packages
			installlist="$(estrlist reg_exclude ".*-devel .*-devel-static" "$installlist")"
44 45
			[ -n "$verbose" ] && info "Packages from task(s): $installlist"
			# install only installed packages (simulate upgrade packages)
46
			installlist="$(get_only_installed_packages "$installlist")"
47 48
			[ -n "$verbose" ] && info "Packages to upgrade: $installlist"
			(pkg_names="$installlist" epm_Install)
49
			epm_removerepo "$pkg_names"
50 51 52 53
			return
		fi
	fi

Vitaly Lipatov's avatar
Vitaly Lipatov committed
54
	info "Running command for upgrade packages"
55 56

	case $PMTYPE in
57
	apt-rpm|apt-dpkg)
58
		local APTOPTIONS="$(subst_option non_interactive -y) $(subst_option verbose "-o Debug::pkgMarkInstall=1 -o Debug::pkgProblemResolver=1")"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
59
		# Функцию добавления параметра при условии
60
		CMD="apt-get $APTOPTIONS dist-upgrade $noremove"
61
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
62 63 64
	aptitude-dpkg)
		CMD="aptitude dist-upgrade"
		;;
65
	packagekit)
66 67 68
		docmd pkcon update
		return
		;;
69
	yum-rpm)
70
		local OPTIONS="$(subst_option non_interactive -y)"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
71
		# can do update repobase automagically
72
		CMD="yum $OPTIONS update $pkg_filenames"
73
		;;
74
	dnf-rpm)
75
		local OPTIONS="$(subst_option non_interactive -y)"
76
		CMD="dnf $OPTIONS distro-sync $pkg_filenames"
77
		;;
78 79 80
	snappy)
		CMD="snappy update"
		;;
81
	urpm-rpm)
82
		# or --auto-select --replace-files
83
		CMD="urpmi --update --auto-select $pkg_filenames"
84 85
		;;
	zypper-rpm)
86
		CMD="zypper dist-upgrade"
87
		;;
88
	pacman)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
89
		CMD="pacman -S -u $force"
90
		;;
91 92 93
	aura)
		CMD="aura -A -u"
		;;
94 95 96
	emerge)
		CMD="emerge -NuDa world"
		;;
97 98 99
	conary)
		CMD="conary updateall"
		;;
100
	pkgsrc)
101 102
		CMD="freebsd-update fetch install"
		;;
103 104 105
	pkgng)
		CMD="pkg upgrade"
		;;
106 107 108
	chocolatey)
		CMD="chocolatey update all"
		;;
109
	homebrew)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
110
		#CMD="brew upgrade"
111
		docmd "brew upgrade $(brew outdated)"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
112
		return
113
		;;
114 115
	opkg)
		CMD="opkg upgrade"
116
		;;
117
	slackpkg)
118
		CMD="/usr/sbin/slackpkg upgrade-all"
119
		;;
120 121 122
	guix)
		CMD="guix package -u"
		;;
123 124 125
	appget|winget)
		CMD="$PMTYPE update-all"
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
126
	aptcyg)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
127
		# shellcheck disable=SC2046
Vitaly Lipatov's avatar
Vitaly Lipatov committed
128 129 130
		docmd_foreach "epm install" $(short=1 epm packages)
		return
		;;
131 132 133
	xbps)
		CMD="xbps-install -Su"
		;;
134
	*)
135
		fatal "Have no suitable command for $PMTYPE"
136
		;;
137
	esac
138

139
	sudocmd $CMD $pkg_filenames
140

141
}