epm-changelog 2.24 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
#

load_helper epm-query

22
# TODO: use 
23 24
__epm_changelog_files()
{
25
	[ -z "$*" ] && return
26

27 28 29
	# TODO: detect every file
	case $(get_package_type $1) in
		rpm)
30 31 32 33 34 35
			docmd_foreach "rpm -p --changelog" $@ | less
			;;
#		apt-dpkg)
#			
#			;;
		*)
36
			fatal "Have no suitable command for $1"
37 38 39 40 41 42 43
			;;
	esac

}

__epm_changelog_local_names()
{
44
	[ -z "$*" ] && return
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)
			docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less
			;;
		emerge)
54 55
			assure_exists equery
			docmd equery changes -f $1 | less
56 57
			;;
		pacman)
58
			docmd pacman -Qc $1 | less
59 60
			;;
		*)
61
			fatal "Have no suitable command for $PMTYPE"
62 63 64 65 66 67
			;;
	esac
}

__epm_changelog_unlocal_names()
{
68
	[ -z "$*" ] && return
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

	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
		#	;;
87 88 89 90
		emerge)
			assure_exists equery
			docmd equery changes -f $1 | less
			;;
91
		*)
92
			fatal "Have no suitable command for $PMTYPE"
93 94 95 96 97 98 99 100 101 102 103 104 105 106
			;;
	esac

}


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

	__epm_changelog_files $pkg_files

	local pkg
	for pkg in $pkg_names ; do
107
		if is_installed $pkg ; then
108 109 110 111 112 113
			__epm_changelog_local_names $pkg
		else
			__epm_changelog_unlocal_names $pkg
		fi
	done
}