LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 03-21-2006, 04:29 AM   #1
nayankk
LQ Newbie
 
Registered: Mar 2005
Location: Mysore
Distribution: Madrake, PCQLinux
Posts: 10

Rep: Reputation: 0
How to extract spec file from rpm file


Hi all,

Is there any way to extract the spec file from rpm package(not *.src.rpm)?

Thanks
 
Old 03-21-2006, 04:55 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,688
Blog Entries: 54

Rep: Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955
A .spec is similar to a Makefile. When you install an application from tarball it (usually) doesnt automagically install the Makefile. When you make a rpm from spec it doesnt include the spec file. So, no there isnt any way. Any reason why you would need that?
 
Old 03-21-2006, 04:59 AM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
If the espec file is held within the compiled rpm, which, along with UnSpawn, i don't think it is, then you can enter an rpm archive using tools like mc, and copy out arbitrary files of interest.
 
Old 03-22-2006, 02:16 AM   #4
nayankk
LQ Newbie
 
Registered: Mar 2005
Location: Mysore
Distribution: Madrake, PCQLinux
Posts: 10

Original Poster
Rep: Reputation: 0
I want to extract the depends field of rpm package. When i give rpm -q --requires, it gives depends information in the form of capabilities.
For example,
Code:
#rpm -q --requires xmms

arts-devel >= 1.0.1
gtk+-devel  
esound-devel  
mikmod  
/usr/bin/automake-1.4  
/usr/bin/autoconf-2.13  
rpmlib(CompressedFileNames) <= 3.0.4-1
I want to get these information in terms of package names (as in debian) and not in terms of capabilities. Is there any way to do so?. I thought i could get these information from spec file.

Thanks.
 
Old 03-22-2006, 07:00 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,688
Blog Entries: 54

Rep: Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955
I want to get these information in terms of package names (as in debian) and not in terms of capabilities. Is there any way to do so?
What you could do after you -q --requires is resolve capabilities to filenames, then query the rpm db for the package the filenames are in (using queryformat tag for names). Since rpm doesn't need to resolve capabilities like you want to, depending on how you resolve capabilities it will either be rather CPU/IO intensive or less accurate.
 
Old 03-22-2006, 08:23 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
coulda sworn i hit reply when i typed a response earlier....

anyway... just use the -p option to show what the dependencies of an actual rpm file are, irrespective of the state of rpm database on your system
 
Old 03-22-2006, 08:55 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,688
Blog Entries: 54

Rep: Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955
just use the -p option to show what the dependencies of an actual rpm file are
You sure? On my boxen only thing "-p" does is select a rpm that wasn't installed.
 
Old 03-22-2006, 10:26 AM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
-p is package, so "rpm -qpl blah.rpm" shows the contents of the blah.rpm file, as opposed to the file list dug out of the rpm db in the case of a normal already installed package.
 
Old 03-22-2006, 06:24 PM   #9
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,688
Blog Entries: 54

Rep: Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955
-p is package, so "rpm -qpl blah.rpm" shows the contents of the blah.rpm file
But thats got no bearing on the whole finding dependencies thing, innit?
 
Old 03-23-2006, 02:11 AM   #10
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
Code:
[root@kermit ~]# rpm -qp --requires  rdesktop-1.4.1-0.2.el4.test.i386.rpm
libX11.so.6
libc.so.6
libc.so.6(GLIBC_2.0)
libc.so.6(GLIBC_2.1)
libc.so.6(GLIBC_2.2.3)
libc.so.6(GLIBC_2.3)
libcrypto.so.4
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
 
Old 03-23-2006, 09:34 AM   #11
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,688
Blog Entries: 54

Rep: Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955
Like I said. Only the ability to select not installed packages.
 
Old 10-12-2007, 08:24 PM   #12
kumkee
LQ Newbie
 
Registered: Sep 2007
Posts: 1

Rep: Reputation: 0
You can extract the spec file from a source rpm file (some times a binary rpm file), using command:

rpm2cpio {FullNameOfRPM} | cpio -iumd {NameOfRPM.spec}
 
Old 03-10-2009, 03:09 AM   #13
Ramanan
LQ Newbie
 
Registered: Jul 2005
Location: Australia
Posts: 2

Rep: Reputation: 0
Donsn't help

This doesn't help to find out the script that rpm run during and after copying files.
Is there any way to find that ?


Quote:
Originally Posted by kumkee View Post
You can extract the spec file from a source rpm file (some times a binary rpm file), using command:

rpm2cpio {FullNameOfRPM} | cpio -iumd {NameOfRPM.spec}
 
Old 11-11-2009, 10:30 AM   #14
PeterKittReilly
LQ Newbie
 
Registered: Nov 2009
Posts: 1

Rep: Reputation: 0
Probably too late, but the way to see a spec file in an rpm file is
rpm --scripts -qp my-great-app-1.1.2.rpm
 
Old 11-11-2009, 02:11 PM   #15
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,775

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
Binary rpm archives *do* contain the spec file -it's written into the header of the archive. rpm needs them so that it can extract any postinst scripts etc which are needed for the package. If you open an rpm in a hex editor you can see the text contents of the spec file close to the top.
 
  


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
questions on writing own rpm .spec file adrianmak Linux - Software 0 08-18-2005 07:03 AM
RPM spec file install rule how its evaluated? cranium2004 Programming 2 03-11-2005 03:03 AM
%file attribute for RPM SPEC files Brian of Gep Linux - Software 3 06-18-2004 05:51 AM
%file attribute for RPM SPEC files Brian of Gep Fedora 0 06-15-2004 08:12 PM
RPM Spec file creation: %file section question davidas Linux - Newbie 0 03-16-2004 11:36 PM


All times are GMT -5. The time now is 02:00 PM.

Main Menu
Advertisement
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