NBash

Форк
0
121 строка · 2.9 Кб
1
#!/bin/sh
2
#
3
# Copyright (C) 2012, 2016  Etersoft
4
# Copyright (C) 2012, 2016  Vitaly Lipatov <lav@etersoft.ru>
5
#
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU Affero General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU Affero General Public License for more details.
15
#
16
# You should have received a copy of the GNU Affero General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
#
19

20
load_helper epm-query
21

22
__epm_changelog_apt()
23
{
24
    local i
25
    for i in $@ ; do
26
        docmd apt-cache show $i | grep -A 1000 "^Changelog:"
27
    done
28
}
29

30
__epm_changelog_files()
31
{
32
    [ -z "$*" ] && return
33

34
    # TODO: detect every file
35
    case $(get_package_type $1) in
36
        rpm)
37
            assure_exists rpm
38
            docmd_foreach "rpm -q -p --changelog" $@
39
            ;;
40
#        deb)
41
#            
42
#            ;;
43
        *)
44
            fatal "Have no suitable command for $1"
45
            ;;
46
    esac
47
}
48

49
__epm_changelog_local_names()
50
{
51
    [ -z "$*" ] && return
52

53
    case $PMTYPE in
54
        apt-rpm|yum-rpm|dnf-rpm|urpm-rpm|zypper-rpm)
55
            docmd_foreach "rpm -q --changelog" $@
56
            ;;
57
        apt-dpkg|aptitude-dpkg)
58
            docmd zcat /usr/share/doc/$1/changelog.Debian.gz
59
            ;;
60
        emerge)
61
            assure_exists equery
62
            docmd equery changes -f $1
63
            ;;
64
        pacman)
65
            docmd pacman -Qc $1
66
            ;;
67
        *)
68
            fatal "Have no suitable command for $PMTYPE"
69
            ;;
70
    esac
71
}
72

73
__epm_changelog_unlocal_names()
74
{
75
    [ -z "$*" ] && return
76

77
    case $PMTYPE in
78
        apt-rpm)
79
            __epm_changelog_apt "$1"
80
            ;;
81
        #apt-dpkg)
82
        #    # FIXME: only first pkg
83
        #    docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less
84
        #    ;;
85
        #yum-rpm)
86
        #    sudocmd yum clean all
87
        #    ;;
88
        urpm-rpm)
89
            docmd urpmq --changelog "$1"
90
            ;;
91
        #zypper-rpm)
92
        #    sudocmd zypper clean
93
        #    ;;
94
        emerge)
95
            assure_exists equery
96
            docmd equery changes -f "$1"
97
            ;;
98
        *)
99
            fatal "Have no suitable command for $PMTYPE. Try install the package firstly."
100
            ;;
101
    esac
102

103
}
104

105

106
epm_changelog()
107
{
108
    [ -n "$pkg_filenames" ] || fatal "Changelog: Missing package(s) name"
109

110
    __epm_changelog_files $pkg_files
111

112
    # TODO: add less or bat
113
    local pkg
114
    for pkg in $pkg_names ; do
115
        if is_installed $pkg ; then
116
            __epm_changelog_local_names $pkg
117
        else
118
            __epm_changelog_unlocal_names $pkg
119
        fi
120
    done
121
}
122

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.