blob: 9ab37be0ac92a10275c30f6722b6908a059a99be [file] [log] [blame]
Eric Andersen4bfb6b72000-11-29 21:39:02 +00001#!/bin/sh
2#
Eric Andersen5ec241d2000-12-12 16:49:12 +00003# This should work with the GNU version of cpio and gzip!
4# This should work with the bash or ash shell!
5# Requires the programs (cpio, gzip, and the pager more or less).
6#
Eric Andersen4bfb6b72000-11-29 21:39:02 +00007usage() {
8echo "Usage: unrpm -l package.rpm <List contents of rpm package>"
9echo " unrpm -x package.rpm /foo/boo <Extract rpm package to this directory,"
10echo " put . for current directory>"
11exit
12}
13
14rpm=$2
15
16exist() {
17if [ "$rpm" = "" ]; then
18usage
19elif [ ! -s "$rpm" ]; then
20echo "Can't find $rpm!"
21exit
22fi
23}
24
25if [ "$1" = "" ]; then
26usage
27elif [ "$1" = "-l" ]; then
28exist
29type more >/dev/null 2>&1 && pager=more
30type less >/dev/null 2>&1 && pager=less
Eric Andersen5ec241d2000-12-12 16:49:12 +000031[ "$pager" = "" ] && echo "No pager found!" && exit
32(echo -e "\nPress enter to scroll, q to Quit!\n" ; rpmunpack < $rpm | gzip -dc | cpio -tv --quiet) | $pager
Eric Andersen4bfb6b72000-11-29 21:39:02 +000033exit
34elif [ "$1" = "-x" ]; then
35exist
36if [ "$3" = "" ]; then
37usage
38elif [ ! -d "$3" ]; then
39echo "No such directory $3!"
40exit
41fi
Eric Andersen5ec241d2000-12-12 16:49:12 +000042rpmunpack < $rpm | gzip -d | (umask 0 ; cd $3 ; cpio -idmuv) || exit
Eric Andersen4bfb6b72000-11-29 21:39:02 +000043echo
44echo "Extracted $rpm to $3!"
45exit
46else
47usage
48fi