mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-04 16:45:07 -05:00
contrib/paclog-pkglist: rework as bash wrapping awk
Avoid some pain in awk's limited handling of command line arguments by wrapping this in a Bash script. We also default to @localstatedir@/log/pacman.log when no args are specified, meaning that -h or --help is required to get the help message. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
0b92d9ed9c
commit
3294039a00
@ -2,6 +2,7 @@ OURSCRIPTS = \
|
|||||||
bacman \
|
bacman \
|
||||||
pacdiff \
|
pacdiff \
|
||||||
paclist \
|
paclist \
|
||||||
|
paclog-pkglist \
|
||||||
pacscripts \
|
pacscripts \
|
||||||
pacsearch
|
pacsearch
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ EXTRA_DIST = \
|
|||||||
PKGBUILD.vim \
|
PKGBUILD.vim \
|
||||||
bacman.in \
|
bacman.in \
|
||||||
bash_completion.in \
|
bash_completion.in \
|
||||||
paclog-pkglist \
|
paclog-pkglist.in \
|
||||||
pacdiff.in \
|
pacdiff.in \
|
||||||
paclist.in \
|
paclist.in \
|
||||||
pacscripts.in \
|
pacscripts.in \
|
||||||
@ -51,6 +52,7 @@ bacman: $(srcdir)/bacman.in
|
|||||||
bash_completion: $(srcdir)/bash_completion.in
|
bash_completion: $(srcdir)/bash_completion.in
|
||||||
pacdiff: $(srcdir)/pacdiff.in
|
pacdiff: $(srcdir)/pacdiff.in
|
||||||
paclist: $(srcdir)/paclist.in
|
paclist: $(srcdir)/paclist.in
|
||||||
|
paclog-pkglist: $(srcdir)/paclog-pkglist.in
|
||||||
pacscripts: $(srcdir)/pacscripts.in
|
pacscripts: $(srcdir)/pacscripts.in
|
||||||
pacsearch: $(srcdir)/pacsearch.in
|
pacsearch: $(srcdir)/pacsearch.in
|
||||||
pactree: $(srcdir)/pactree.in
|
pactree: $(srcdir)/pactree.in
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/awk -f
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# paclog-pkglist - Parse a log file into a list of currently installed packages
|
# paclog-pkglist - Parse a log file into a list of currently installed packages
|
||||||
#
|
#
|
||||||
@ -17,14 +17,23 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
BEGIN {
|
export TEXTDOMAIN='pacman'
|
||||||
if (ARGC < 2) {
|
export TEXTDOMAINDIR='/usr/share/locale'
|
||||||
printf "usage: log2pkglist <pacman log>\n"
|
declare logfile=${1:-@localstatedir@/log/pacman.log}
|
||||||
printf "example: log2pkglist /var/log/pacman.log\n"
|
|
||||||
exit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if [[ $1 ]]; then
|
||||||
|
if [[ $1 = -@(h|-help) ]]; then
|
||||||
|
printf 'usage: %s [pacman log]\n' "${0##*/}"
|
||||||
|
printf 'example: %s @localstatedir@/log/pacman.log\n' "${0##*/}"
|
||||||
|
printf '\ndefaults to: @localstatedir@/log/pacman.log\n'
|
||||||
|
exit 0
|
||||||
|
elif [[ ! -e $logfile ]]; then
|
||||||
|
printf $"target not found: %s\n" "$1"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
<"$logfile" awk '
|
||||||
{
|
{
|
||||||
action = $3
|
action = $3
|
||||||
pkgname = $4
|
pkgname = $4
|
||||||
@ -54,4 +63,6 @@ END {
|
|||||||
printf "%s %s\n",i,pkg[i]
|
printf "%s %s\n",i,pkg[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}' | sort
|
||||||
|
|
||||||
|
# vim: set ts=2 sw=2 noet:
|
Loading…
Reference in New Issue
Block a user