Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2011-07-17 11:04:03 -0400
committerDan McGee <dan@archlinux.org>2011-07-18 10:34:56 -0500
commit3294039a00f3aa65181ed23518dc5c73e0201268 (patch)
treed85e6ac67f9db409204c2cb1f2b08f70b0f9a179 /contrib
parent0b92d9ed9c6bffcf4b47645a365ea6c3d162e89e (diff)
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>
Diffstat (limited to 'contrib')
-rw-r--r--contrib/Makefile.am4
-rwxr-xr-xcontrib/paclog-pkglist.in (renamed from contrib/paclog-pkglist)29
2 files changed, 23 insertions, 10 deletions
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 31238b8f..69304a44 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -2,6 +2,7 @@ OURSCRIPTS = \
bacman \
pacdiff \
paclist \
+ paclog-pkglist \
pacscripts \
pacsearch
@@ -13,7 +14,7 @@ EXTRA_DIST = \
PKGBUILD.vim \
bacman.in \
bash_completion.in \
- paclog-pkglist \
+ paclog-pkglist.in \
pacdiff.in \
paclist.in \
pacscripts.in \
@@ -51,6 +52,7 @@ bacman: $(srcdir)/bacman.in
bash_completion: $(srcdir)/bash_completion.in
pacdiff: $(srcdir)/pacdiff.in
paclist: $(srcdir)/paclist.in
+paclog-pkglist: $(srcdir)/paclog-pkglist.in
pacscripts: $(srcdir)/pacscripts.in
pacsearch: $(srcdir)/pacsearch.in
pactree: $(srcdir)/pactree.in
diff --git a/contrib/paclog-pkglist b/contrib/paclog-pkglist.in
index 2c66e634..4cf5e341 100755
--- a/contrib/paclog-pkglist
+++ b/contrib/paclog-pkglist.in
@@ -1,4 +1,4 @@
-#!/bin/awk -f
+#!/bin/bash
#
# 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
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-BEGIN {
- if (ARGC < 2) {
- printf "usage: log2pkglist <pacman log>\n"
- printf "example: log2pkglist /var/log/pacman.log\n"
- exit
- }
-}
+export TEXTDOMAIN='pacman'
+export TEXTDOMAINDIR='/usr/share/locale'
+declare logfile=${1:-@localstatedir@/log/pacman.log}
+
+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
pkgname = $4
@@ -54,4 +63,6 @@ END {
printf "%s %s\n",i,pkg[i]
}
}
-}
+}' | sort
+
+# vim: set ts=2 sw=2 noet: