blob: 2cd1aa9c9d9b806f5ab4e693eb8596eb425457f7 [file] [log] [blame]
Eric Andersen4bfb6b72000-11-29 21:39:02 +00001#!/bin/sh
2#
3usage() {
4echo "Usage: unrpm -l package.rpm <List contents of rpm package>"
5echo " unrpm -x package.rpm /foo/boo <Extract rpm package to this directory,"
6echo " put . for current directory>"
7exit
8}
9
10rpm=$2
11
12exist() {
13if [ "$rpm" = "" ]; then
14usage
15elif [ ! -s "$rpm" ]; then
16echo "Can't find $rpm!"
17exit
18fi
19}
20
21if [ "$1" = "" ]; then
22usage
23elif [ "$1" = "-l" ]; then
24exist
25type more >/dev/null 2>&1 && pager=more
26type less >/dev/null 2>&1 && pager=less
27(echo -e "\nPress enter to scroll, q to Quit!\n" ; rpmunpack < $rpm | gunzip -c | cpio -tvf --quiet) | $pager
28exit
29elif [ "$1" = "-x" ]; then
30exist
31if [ "$3" = "" ]; then
32usage
33elif [ ! -d "$3" ]; then
34echo "No such directory $3!"
35exit
36fi
37rpmunpack < $rpm | gunzip | (cd $3 ; cpio -idmuv) || exit
38echo
39echo "Extracted $rpm to $3!"
40exit
41else
42usage
43fi