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

20 21
load_helper epm-query

22 23 24 25 26 27 28 29 30 31 32 33 34 35
__replace_alt_version_in_repo()
{
	local i
	assure_exists apt-repo
	echo "Upgrading $DISTRNAME from $1 to $2 ..."
	docmd apt-repo list | sed -e "s|\($1/branch\)|{\1}->$2/branch<|g" | egrep --color -- "$1/branch"
	confirm "Are these correct changes?" || fatal "Exiting"
	for i in /etc/apt/sources.list /etc/apt/sources.list.d/*.list ; do
		[ -s "$i" ] || continue
		# TODO: only for uncommended strings
		#sed -i -r -e "s!$1/branch!$2/branch!g" $i
		regexp_subst "/^ *#/! s!$1/branch!$2/branch!g" $i
		
		# TODO: start with improve to [p8] - install some package firstly?
36
		regexp_subst "/^ *#/! s!\[$1\]![alt]!g" $i
37 38 39 40
	done
	docmd apt-repo list
}

41 42 43
__update_alt_repo_to_next_distro()
{
	case "$DISTRVERSION" in
44 45
		p6)
			__replace_alt_version_in_repo p6 p7
46 47 48 49
			docmd epm update
			docmd epm install apt rpm || fatal
			docmd epm upgrade
			docmd epm update-kernel
50 51 52 53
			info "Run epm release-upgrade again for update to p8"
			;;
		p7)
			__replace_alt_version_in_repo p7 p8
54 55 56 57 58 59 60 61
			docmd epm update
			docmd epm install apt rpm || fatal
			if is_installed systemd ; then
				docmd epm install systemd || fatal
			fi
			docmd epm upgrade || fatal
			#info " # epmi branding-simply-linux-release branding-simply-linux-graphics"
			docmd epm update-kernel
62
			;;
63
		*)
64
			info "Have no idea how to update from $DISTRNAME $DISTRVERSION"
65 66 67 68
			return 1
	esac
}

69 70
epm_release_upgrade()
{
71
	assure_root
Vitaly Lipatov's avatar
Vitaly Lipatov committed
72
	info "Starting upgrade whole system to the next release"
73
	info "Check also http://wiki.etersoft.ru/Admin/UpdateLinux"
74

75 76
	case $DISTRNAME in
	ALTLinux)
77 78
		docmd epm update
		docmd epm install apt rpm
Vitaly Lipatov's avatar
Vitaly Lipatov committed
79
		load_helper epm-repofix
80
		pkg_filenames= epm_repofix
81
		__update_alt_repo_to_next_distro
82 83 84 85 86 87 88 89 90 91
		return
		;;
	*)
		;;
	esac

	case $PMTYPE in
	apt-rpm)
		docmd epm update
		info "Have no idea how to upgrade $DISTRNAME"
92
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
93
	*-dpkg)
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
		sudocmd do-release-upgrade -d
		;;
	yum-rpm)
		docmd epm install rpm yum
		sudocmd yum clean all
		# TODO
		showcmd rpm -Uvh http://mirror.yandex.ru/fedora/linux/releases/16/Fedora/x86_64/os/Packages/fedora-release-16-1.noarch.rpm
		docmd epm Upgrade
		;;
	urpm-rpm)
		sudocmd urpmi.removemedia -av
		# TODO
		showcmd urpmi.addmedia --distrib http://mirror.yandex.ru/mandriva/devel/2010.2/i586/
		sudocmd urpmi --auto-update --replacefiles
		;;
	zypper-rpm)
		docmd epm repolist
		# TODO
		# sudocmd zypper rr <номер_репозитория>
		showcmd rr N
		showcmd epm ar http://mirror.yandex.ru/opensuse/distribution/11.1/repo/oss 11.1oss
		showcmd zypper ref
		docmd epm update
		docmd epm install rpm zypper
		docmd epm upgrade
		;;
	pacman)
121
		epm Upgrade
122
		;;
123 124 125
	conary)
		epm Upgrade
		;;
126 127 128 129 130 131
	emerge)
		epm Upgrade
		;;
	guix)
		sudocmd guix pull --verbose
		;;
132
	*)
133
		fatal "Have no suitable command for $PMTYPE"
134 135 136 137
		;;
	esac

}