Shell script extract rpm package _linux shell

Source: Internet
Author: User

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 >

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.