LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-01-2008, 06:13 AM   #1
amit_pansuria
Member
 
Registered: Sep 2006
Posts: 73

Rep: Reputation: 15
how to extract binary or what ever files from rpm package


Helo,

I have already rpm package.
how I exctract and keep that extracted binary files ,configurations from
rpm package


Regards,
Amit
 
Old 08-01-2008, 06:22 AM   #2
jcookeman
Member
 
Registered: Jul 2003
Location: London, UK
Distribution: FreeBSD, OpenSuse, Ubuntu, RHEL
Posts: 417

Rep: Reputation: 33
Oops...meant to post rpm2cpio.

Last edited by jcookeman; 08-01-2008 at 06:25 AM.
 
Old 08-01-2008, 06:32 AM   #3
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
You can try rpm2cpio in conjunction to cpio. The command rpm2cpio extract the rpm to a cpio archive and write it to the standard output. You can pipe the output of rpm2cpio to the cpio command to actually write/save the files. For example:
Code:
rpm2cpio package-x.x-x.noarch.rpm | cpio -dimv
this will preserve the structure inside the rpm package, that is it will create all the directories specified in the paths, but relative to the current directory. For example if a file is meant to be installed in /usr/share, you will find it under $PWD/usr/share. See man cpio for future reference.
 
Old 08-01-2008, 07:07 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,984
Blog Entries: 54

Rep: Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742
Quote:
Originally Posted by colucix View Post
it will create all the directories specified in the paths, but relative to the current directory.
I use a simple script which dumps contents in ~/tmp/packagename/ instead. It prints info like changelog and such as well:
Code:
#!/bin/bash
# Purpose: Unpack RPM archives
# Args: /path/to/archive
# Deps: Bash, GNU utils, RPM
rpmDetails() { for Q in changelog provides requires scripts triggers triggerscripts; do 
 rpm -q -p --${Q} "${f}" 2>&1 | grep -v NOKEY > "${Q}.log"; done; }
rpmUnpack() { f=$(readlink -f "${f}"); file "${f}"|grep -q "RPM.v" && \
 { d=$(basename "${f}" .rpm); d="${HOME}/tmp/${d:=ERROR_$$}"; mkdir -p "${d}" && \
 { cd "${d}" && rpm2cpio "${f}" | cpio -idmv && rpmDetails "${f}"; }; }; }
for f in $@; do rpmUnpack "${f}"; done
exit 0
HTH
 
Old 08-01-2008, 07:35 AM   #5
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
Awesome!
 
Old 08-01-2008, 06:26 PM   #6
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,094
Blog Entries: 2

Rep: Reputation: 111Reputation: 111
alien

alien --to-tgz file.rpm
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
package executable files in rpm uxan Linux - Software 2 05-15-2008 07:49 AM
Why is rpm skipping some package files? khym_chanur Mandriva 3 06-29-2007 08:45 PM
RPM: How do you extract just one file from the package? Thetargos Fedora 4 07-17-2004 03:03 AM
how to find all files and programs in a package (RPM) 1kyle Linux - Software 1 07-13-2004 04:16 AM
How to extract files from an rpm package mayankjohri Linux - Networking 3 06-12-2002 12:33 AM


All times are GMT -5. The time now is 11:07 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration