????
Current Path : /proc/324102/root/usr/bin/ |
Current File : //proc/324102/root/usr/bin/rpmargs |
#!/bin/sh -ef export LC_ALL=C rpmargs_cmd= rpmargs_pkg= while getopts c:ph rpmargs_opt; do case "$rpmargs_opt" in c) rpmargs_cmd="${OPTARG:?}" readonly rpmargs_cmd ;; p) rpmargs_pkg=1 ;; h) pod2usage --exit=0 "$0"; exit 0 ;; *) pod2usage --exit=2 "$0"; exit 2 ;; esac done shift "$((OPTIND-1))"; OPTIND=1 if [ -z "$rpmargs_cmd" ]; then echo "${0##*/}: command not specified" >&2 pod2usage --exit=2 "$0"; exit 2 fi if [ -z "$*" ]; then echo "${0##*/}: not enough arguments" >&2 pod2usage --exit=2 "$0"; exit 2 fi rpmargs_files() { ls -1 "$1" |grep -x '[^.].*[.]rpm' >rpmargs_files sort -o rpmargs_files -u rpmargs_files local f while read -r f; do $rpmargs_cmd "$1/$f" >rpmargs.out [ -s rpmargs.out ] || continue awk -v f="$f" '{print f"\t"$0}' rpmargs.out done <rpmargs_files } rpmargs_packages() { packages "$1" >rpmargs_packages sort -t$'\t' -o rpmargs_packages -u -k1,1 rpmargs_packages local p v f while IFS=$'\t' read -r p v f _; do $rpmargs_cmd "$1/$f" >rpmargs.out [ -s rpmargs.out ] || continue awk -v p="$p" '{print p"\t"$0}' rpmargs.out done <rpmargs_packages } . /usr/share/rpmdevtools/tmpdir.sh rpmargs_tmpdir=$TMPDIR for rpmarg; do rpmarg="$(readlink -ev "${rpmarg:?}")" cd "$rpmargs_tmpdir" if [ -d "$rpmarg" -a -n "$rpmargs_pkg" ]; then rpmargs_packages "$rpmarg" elif [ -d "$rpmarg" -a -z "$rpmargs_pkg" ]; then rpmargs_files "$rpmarg" else $rpmargs_cmd "$rpmarg" fi cd - >/dev/null done : <<'__EOF__' =head1 NAME rpmargs - process RPM packages =head1 SYNOPSIS B<rpmargs> [B<-h>] B<-c> I<command> [B<-p>] [I<FILE>...] [I<DIR>...] =head1 DESCRIPTION B<rpmargs> executes a I<command> against each RPM package given on the command line. Extra word splitting is performed on the I<command>. Each I<FILE> is treated as RPM package. Each I<DIR> is processed with C<*.rpm> pattern, and RPM file basename is prepended to the I<command> output. =head1 OPTIONS =over =item B<-p> When processing a directory, list package names, not file names; furthermore, enable special treatment of packages with the same name; that is, process only the one with the latest version. =item B<-h> Display this help and exit. =back =head1 AUTHOR Written by Alexey Tourbin <at@altlinux.org>. =head1 COPYING Copyright (c) 2005 Alexey Tourbin, ALT Linux Team. This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. =cut __EOF__