[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

rpm2cpio.sh (was: Re: Obtaining source code w/out recent rpm version)



In regard to: Obtaining source code w/out recent rpm version, Mr E_T said...:

>I have been trying to get the source code for rpm-4.2 but have found it
>to be in rpm version only in the dist/4.2 and all the test*/ directories.

I've also thought it was a pain to have to use the 4.x tools to extract
the 4.N.x tarball from the src RPM.  Not a problem for most RH customers,
but a chicken-or-the-egg problem for those that don't have any (or any
recent) RPM available.  I do have access to RH 7.3/8.0/9 systems, so I
can extract there and then move the source to a platform where I don't
have RPM 4.x, but that's kind of a pain.

The good news is that Jeff Johnson has several times posted (to this list)
a very short shell script that works like a stripped down rpm2cpio.  No
recent copy of RPM needed, you just need the shell script and a version of
cpio that can read the stream (you may also encounter problems there,
depending on platform -- the cpio implementation that's part of RPM
generates archives that can't be read on some platforms with the vendor
cpio).

Here's the shell script, courtesy of Jeff Johnson:


#!/bin/sh

pkg=$1
if [ "$pkg" = "" -o ! -e "$pkg" ]; then
    echo "no package supplied" 1>&2
   exit 1
fi

leadsize=96
o=`expr $leadsize + 8`
set `od -j $o -N 8 -t u1 $pkg`
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`

sigsize=`expr 8 + 16 \* $il + $dl`
o=`expr $o + $sigsize + \( 8 - \( $sigsize \% 8 \) \) \% 8 + 8`
set `od -j $o -N 8 -t u1 $pkg`
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`

hdrsize=`expr 8 + 16 \* $il + $dl`
o=`expr $o + $hdrsize`

dd if=$pkg ibs=$o skip=1 2>/dev/null | gunzip





You just need to save that to rpm2cpio.sh, make it executable, and then
run

	rpm2cpio rpm-4.1.1-1.7x.src.rpm | cpio -idv

and you should end up with the source code in the current directory (if
your cpio can read the archive).

Tim
-- 
Tim Mooney                              mooney@dogbert.cc.ndsu.NoDak.edu
Information Technology Services         (701) 231-1076 (Voice)
Room 242-J6, IACC Building              (701) 231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []