epm-changelog 2.2 KB
Newer Older
1 2 3 4 5
#!/bin/sh
#
# Copyright (C) 2012  Etersoft
# Copyright (C) 2012  Vitaly Lipatov <lav@etersoft.ru>
#
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 22 23
#

load_helper epm-query

__epm_changelog_files()
{
24
	[ -z "$*" ] && return
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

	case $PMTYPE in
		apt-rpm|yum-rpm|zypper-rpm|urpm-rpm)
			docmd_foreach "rpm -p --changelog" $@ | less
			;;
#		apt-dpkg)
#			
#			;;
		*)
			fatal "Do not known command for $PMTYPE"
			;;
	esac

}

__epm_changelog_local_names()
{
42
	[ -z "$*" ] && return
43 44 45 46 47 48 49 50 51 52 53

	case $PMTYPE in
		apt-rpm|yum-rpm|urpm-rpm|zypper-rpm)
			docmd_foreach "rpm --changelog" $@ | less
			;;
		apt-dpkg)
			# FIXME: only first pkg
			docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less
			;;
		emerge)
			docmd view /usr/portage/category/$1/ChangeLog | less
54
			# docmd equery changes -f $1 | less
55 56
			;;
		pacman)
57
			docmd pacman -Qc $1 | less
58 59 60 61 62 63 64 65 66
			;;
		*)
			fatal "Do not known command for $PMTYPE"
			;;
	esac
}

__epm_changelog_unlocal_names()
{
67
	[ -z "$*" ] && return
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101

	case $PMTYPE in
		#apt-rpm)
		#	docmd_foreach "rpm --changelog" $@ | less
		#	;;
		#apt-dpkg)
		#	# FIXME: only first pkg
		#	docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less
		#	;;
		#yum-rpm)
		#	sudocmd yum clean all
		#	;;
		#urpm-rpm)
		#	sudocmd urpmi --clean
		#	;;
		#zypper-rpm)
		#	sudocmd zypper clean
		#	;;
		*)
			fatal "Do not known command for $PMTYPE"
			;;
	esac

}


epm_changelog()
{
	[ -n "$pkg_filenames" ] || fatal "Run changelog without params"

	__epm_changelog_files $pkg_files

	local pkg
	for pkg in $pkg_names ; do
102
		if is_installed $pkg ; then
103 104 105 106 107 108
			__epm_changelog_local_names $pkg
		else
			__epm_changelog_unlocal_names $pkg
		fi
	done
}