There are times when you need to extract files from the RPM package without installing and installing RPM-related libraries and programs, and this little green script can help you achieve your wish.
Note:
1. This script comes from the Internet, the exact location does not remember, makes a little change relative to the source script
2. The system needs to install the Cpio procedure (the general system all takes)
#!/bin/sh #************************************************************* # Author:unknown, Modified by Jb51.net # Filename:rpmextract.sh # Description:extrac RPM package without install # RPM related program #************* If [$#-lt 1]; Then Echo-e "Anusage: ' basename $ ' <rpm_pkg_file> n" Exit 1 fi pkg=$1 if [!-e "$pkg"]; Then Echo-e "Nerr:package $pkg does not exist! n "Exit 1 fi ### check if cpio exists cpio_ver= ' cpio--version ' if [-Z ' $CPIO 2>/dev/null ']; Then ECHO-E "Nerr:prerequisite program Cpio does not found!" n "Exit 1 fi leadsize=96 o= ' expr $leadsize + 8 ' set ' Od-j $o-n 8-t U1 $pkg ' il= ' expr 256 * (256 * (256 * $ + $) + $) + $ ' dl= ' expr 256 * (256 * (256 * $ + $) + $) + $ ' # echo "sig IL: $il dl: $dl" sigsize= ' expr 8 + * $i L + $dl ' o= ' expr $o + $sigsize + (8-($sigsize% 8))% 8 + 8 ' Set ' Od-j $o-n 8-t U1 $pkg ' il= ' expr 256 * (256 * (256 * $ + $) + $) + $ ' dl= ' expr 256 * (256 * (256 * $ + $) + $) + $ ' # echo "HDR il: $il dl: $dl" hdrsize= " Expr 8 + * $il + $dl ' o= ' expr $o + $hdrsize ' dd if= $pkg ibs= $o skip=1 2>/dev/null | Gunzip | Cpio-idmuv | | DD if= $pkg ibs= $o skip=1 2>/dev/null | bzip2-d |
Cpio-idmuv
How to use: rpmextract.sh <rpm file >