#!/bin/sh 

#This is to change a rpm file to a tar.gz file
#Created by James Stevenson
#mistral@zetnet.co.uk
#Bug: it will extract the tar into the current directory not
#into a sub dir!

if [ $# != 1 ] ; then
    echo 
    echo "Usage: $0 <file.rpm>"
    echo
    exit 1
fi
if [ ! -e $1 ] ; then
    echo "$0: Cannot open $1: file does not exist"
    exit 1
fi
out=`echo $1|tr "/" "_"`
pd=`pwd`
mkdir /tmp/$$
rpm2cpio $1 | (cd /tmp/$$ ; cpio -i --make-directories)
cd /tmp/$$
tar -cf /tmp/$out.tar *
cd $pd
mv /tmp/$out.tar .
rm -rf /tmp/$$
