#43 Add rpm -a support to rpmls
Merged 5 years ago by ngompa. Opened 5 years ago by dridi.
dridi/rpmdevtools rpmls-a  into  master

file modified
+41 -7
@@ -16,15 +16,49 @@ 

  # along with this program; if not, write to the Free Software

  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

  

+ set -u

+ 

+ all=

  owner=

- if [ "$1" = "-l" ] ; then

-     owner='%-8{fileusername} %-8{filegroupname} '

-     shift

- fi

+ 

+ usage() {

+ 	cat <<-EOF

+ 	rpmls -- List contents of rpm packages

+ 

+ 	Usage: rpmls [-a] [-l] PKG...

+ 	       rpmls -?

+ 

+ 	Options:

+ 	   -a  list all packages matching a PKG

+ 	   -l  use a long listing format

+ 	   -?  print this help and exit

+ 

+ 	The PKG arguments may either be package

+ 	name expressions or file names.

+ 	EOF

+ 	exit

+ }

+ 

+ while getopts 'al?' opt

+ do

+ 	case $opt in

+ 	a) all=a ;;

+ 	l) owner='%-8{fileusername} %-8{filegroupname} ' ;;

+ 	?) usage ;;

+ 	esac

+ done

+ 

+ shift $((OPTIND - 1))

+ 

  qf="[%-11{filemodes:perms} $owner%{filenames}\\n]"

  

  for arg in "$@" ; do

-     p=

-     case "$arg" in *.[rs]pm) p=p ;; esac

-     rpm -q$p --qf="$qf" --nodigest --nosignature "$arg"

+ 	a=$all

+ 	p=

+ 	if [ -f "$arg" ]

+ 	then

+ 		a=

+ 		p=p

+ 	fi

+ 	rpm -q$a$p --qf="$qf" --nodigest --nosignature "$arg"

  done

And grow a more robust handling of options and arguments. Using the -p
option should be based on whether the argument refers to a file instead
of a heuristic based on a glob expression *.[sr]pm that somehow will
accept .spm as a valid RPM extension.

It becomes possible to compose commands like this:

rpmls -la varnish\* |
awk '/^d/ {print $NF}' |
sort

Pull-Request has been merged by ngompa

5 years ago

Thanks, that was quick! Looking forward to the next release.

Metadata
Changes Summary 1