source: MondoRescue/branches/stable/mindi-busybox/examples/unrpm @ 821

Last change on this file since 821 was 821, checked in by Bruno Cornec, 14 years ago

Addition of busybox 1.2.1 as a mindi-busybox new package
This should avoid delivering binary files in mindi not built there (Fedora and Debian are quite serious about that)

File size: 1.1 KB
Line 
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.