#!/bin/bash
#
# Lists or extract files from .rpm archives
#
# Copyright (c) 1998, Massimo Dal Zotto <dz@cs.unitn.it>
#
# This file is distributed under the GNU General Public License
# either version 2, or (at your option) any later version.

if [ $# -lt 2 ]; then
    echo "Usage: $0 <-t|-x> <archive> [<files...>]" >&2
    exit 1
fi

cmd="$1"
archive="$2"
shift 2

case ${cmd#-} in
    t|v)
        rpm2cpio "$archive" | cpio --list --verbose "$@" 2>/dev/null
	;;
    x)
        rpm2cpio "$archive" | cpio --extract --preserve-modification-time \
                --verbose --make-directories "$@"
	;;
    *)
        echo "Unknown option: $cmd"
	;;
esac

# end of file
