source: drbl_ui/backup/test_busybox/busybox-1.7.2/examples/unrpm @ 27

Last change on this file since 27 was 20, checked in by chris, 17 years ago
File size: 1.1 KB
RevLine 
[20]1#!/bin/sh
2#
3# 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#
7usage() {
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
31[ "$pager" = "" ] && echo "No pager found!" && exit
32(echo -e "\nPress enter to scroll, q to Quit!\n" ; rpm2cpio $rpm | cpio -tv --quiet) | $pager
33exit
34elif [ "$1" = "-x" ]; then
35exist
36if [ "$3" = "" ]; then
37usage
38elif [ ! -d "$3" ]; then
39echo "No such directory $3!"
40exit
41fi
42rpm2cpio $rpm | (umask 0 ; cd $3 ; cpio -idmuv) || exit
43echo
44echo "Extracted $rpm to $3!"
45exit
46else
47usage
48fi
Note: See TracBrowser for help on using the repository browser.