3
# Copyright (C) 2023 Etersoft
4
# Copyright (C) 2023 Vitaly Lipatov <lav@etersoft.ru>
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.
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.
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/>.
20
EHOG='\(apt-get\|rpm\)'
21
JCHAN='-t apt-get -t rpm'
23
__alt_epm_history_journal()
28
__alt_epm_history_uniq()
30
__alt_epm_history_journal | grep "$EHOG\[[0-9][0-9]*\]:" | sed -e "s@.*$EHOG\[\([0-9][0-9]*\)\]: .*@\2@" | uniq | tac
33
# args: pid, removed|installed
34
__alt_epm_history_select()
38
__alt_epm_history_journal | grep "$EHOG\[$pid\]: .*$verb" | sed -e "s@.*$EHOG\[[0-9][0-9]*\]: @@" | cut -d" " -f 1
41
_alt_epm_history_date()
44
__alt_epm_history_journal | grep "$EHOG\[$pid\]: " | head -n1 | cut -d" " -f 1-3,5 | sed -e 's|:$||'
47
_alt_epm_history_print_group()
65
__alt_epm_history_removed()
67
echo "Removed packages history:"
68
__alt_epm_history_uniq | while read pid ; do
69
date="$(_alt_epm_history_date $pid)"
70
removed="$(epm print shortname for $(__alt_epm_history_select $pid "removed") )"
71
installed="$(epm print shortname for $(__alt_epm_history_select $pid "installed") )"
72
_alt_epm_history_print_group "$date" $(estrlist exclude "$installed" "$removed")
76
__alt_epm_history_installed()
78
echo "Installed packages history:"
79
__alt_epm_history_uniq | while read pid ; do
80
date="$(_alt_epm_history_date $pid)"
81
#epm print shortname for $(__alt_epm_history_select $pid "installed") | sed -e "s|^| |"
82
removed="$(epm print shortname for $(__alt_epm_history_select $pid "removed") )"
83
installed="$(epm print shortname for $(__alt_epm_history_select $pid "installed") )"
84
_alt_epm_history_print_group "$date" $(estrlist exclude "$removed" "$installed")
88
__alt_epm_history_updated()
90
echo "Updated packages history:"
91
__alt_epm_history_uniq | while read pid ; do
92
date="$(_alt_epm_history_date $pid)"
93
#epm print shortname for $(__alt_epm_history_select $pid "installed") | sed -e "s|^| |"
94
removed="$(epm print shortname for $(__alt_epm_history_select $pid "removed") )"
95
installed="$(epm print shortname for $(__alt_epm_history_select $pid "installed") )"
96
_alt_epm_history_print_group "$date" $(estrlist intersection "$removed" "$installed")
102
echo "package management history"
103
get_help HELPCMD $SHAREDIR/epm-history
107
epm history --removed
115
if [ $PMTYPE = "apt-rpm" ] ; then
117
"-h"|"--help"|"help") # HELPCMD: help
121
--installed) # HELPCMD: print only new installed packages
122
__alt_epm_history_installed
125
--removed) # HELPCMD: print only removed packages
126
__alt_epm_history_removed
129
--updated) # HELPCMD: print only updated packages
130
__alt_epm_history_updated
133
--list) # HELPCMD: (or empty) print all history entries
134
docmd journalctl $JCHAN
140
fatal "Unknown option $1. Use epm history --help to get help."
144
[ -z "$*" ] || fatal "No arguments are allowed here"
148
docmd journalctl $JCHAN -r
151
docmd cat /var/log/dpkg.log
157
sudocmd eopkg history
160
docmd cat /var/log/zypp/history
163
docmd cat /var/log/pacman.log
166
docmd cat /var/log/portage
169
fatal "Have no suitable command for $PMTYPE"