blob: 7fd3676f6496e2e4444fcd48eb93c3f77b5b4b0c [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,"
Eric Andersenc7bda1c2004-03-15 08:29:22 +000010echo " put . for current directory>"
Eric Andersen4bfb6b72000-11-29 21:39:02 +000011exit
12}
13
14rpm=$2
Eric Andersenc7bda1c2004-03-15 08:29:22 +000015
Eric Andersen4bfb6b72000-11-29 21:39:02 +000016exist() {
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
Glenn L McGrathf8736d22001-06-26 01:19:34 +000032(echo -e "\nPress enter to scroll, q to Quit!\n" ; rpm2cpio $rpm | 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
Glenn L McGrathf8736d22001-06-26 01:19:34 +000042rpm2cpio $rpm | (umask 0 ; cd $3 ; cpio -idmuv) || exit
Eric Andersen4bfb6b72000-11-29 21:39:02 +000043echo
44echo "Extracted $rpm to $3!"
45exit
46else
47usage
48fi