Author Topic: rpm2cpio and cpio for rpm file investigation  (Read 4465 times)

Offline wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2469
  • Any Bugs in site?
rpm2cpio and cpio for rpm file investigation
« on: July 24, 2010, 07:00:11 AM »
I am doing a crash course investigating rpm, what it is etc. 

Figured my best bet was to place the topic in this section.

Finally I found what I was looking for, a way to peak into an rpm file:  VariCAD_2010-en-2.08-1.i586.rpm in:

http://www.cyberciti.biz/tips/how-to-extract-an-rpm-package-without-installing-it.html

I have searched Synaptic and find cpio and there was a mention somewhere els that in rpm version 4.x and up rpm2cpio as I understood was part of it.

I have looked hard but did not find rpm2cpio as part of rpm neither in Synaptic, would love to give it a try.

1.. If not part of pclos what is the equivalent available.

2.. What else will 'open' op and rpm
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6849
  • MLU
Re: rpm2cpio and cpio for rpm file investigation
« Reply #1 on: July 24, 2010, 07:17:57 AM »
rpmxdgtool

Offline wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2469
  • Any Bugs in site?
Re: rpm2cpio and cpio for rpm file investigation
« Reply #2 on: July 24, 2010, 09:29:08 AM »
JohnBoy
thanks for the hint, but out for me, seems I need to be expert just in case it trips me up   ;D (not there yet)

I have installed the program and I some aspects attractive, like when used from Konq will show basic information, file-list content, but asking for the the files to be installed (approx 3000) seems to fail, all I get is a list of the files, result as attached. Result was obtained using Konqueror, right click target file.rpm and select etc


root konsole:

Used with no file then crashes and can not generate crash report
--help works and I notice options not selected by preceding -, would be a bit confusing being used to the preceding -

normal konsole
Used with no name, error message tells you about a missing file
I guess it is meant to be used in gui

Edit one day later: carried out some editing, as I was finding it a bit difficult to understand myself. What I am saying is: when I used it in GUI mode to extract a file it stuffed up grand style.  When used in command line I found it disconcerting the command with no file had poor error handling.  Interesting what does happen but I am running short on time to follow up.
« Last Edit: July 25, 2010, 09:34:48 AM by wedgeling »
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15829
  • LXDE! Coffee, Bacon and Cheesecake!
Re: rpm2cpio and cpio for rpm file investigation
« Reply #3 on: July 24, 2010, 10:12:07 AM »
wedgeling,
You can use file roller to extract an RPM.
To create a cpio file, with only the files/folders you want in the folder you are working from,
in a terminal (konsole) type
Code: [Select]
cd /home/<you>/folder-name
to change to the correct location. Then type
Code: [Select]
ls | cpio -ov > cpio-fileto create your cpio file. -- Note "cpiofile" should be the name of the file.

Offline wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2469
  • Any Bugs in site?
Re: rpm2cpio and cpio for rpm file investigation
« Reply #4 on: July 24, 2010, 10:19:07 AM »
Neal
Thank you this rings a bell.

In the mean time my neck hair stood up and I searched a bit harder on the rpm2cpio and I am up the wall a bit, I think it must be here somewhere

[gert@localhost ~]$ rp hit TAB key, not enter, see later
rpcbind          rpcinfo          rpl8             rpmi
rpcclient        rpcinfo-flushed  rpm              rpmquery
rpcdebug         rpc.mountd       rpm2cpio         rpmsign
rpcgen           rpc.nfsd         rpmbuild         rpmu
rpc.gssd         rpc.statd        rpmdb            rpmverify
rpc.idmapd       rpc.svcgssd      rpme             rpmxdgtool

[gert@localhost ~]$ rpm2cpio    <<----- ??
argument is not an RPM package
# this is true, return/enter is not an rpm   :-[

[gert@localhost ~]$ cat rpm2cpio        <<----- ??
cat: rpm2cpio: No such file or directory
# quite true, if I had done an ls I would have seen that, but then just below I locate rpm2cpio, did it click with me then, no of course not, 2.30AM perhaps a bit too late.
#cat /usr/bin/rpm2cpio this is what I should have used, and it does work, fills the konsole with 'junk'

[gert@localhost ~]$ locate rpm2cpio
/usr/bin/rpm2cpio
/usr/lib/rpm/rpm2cpio.sh
/usr/share/man/man8/rpm2cpio.8.bz2

[gert@localhost ~]$ man rpm2cpio   <<--- "normal response" does work

[gert@localhost ~]$ rpm2cpio --help    <<----- ??  hangs, ctl-c to the rescue
[gert@localhost ~]$
# I think what is happening here is the same as using no argument at all, ie rpm2cpio{ENTER} to force an error/message but all that happens is action is returned to standar input, and waiting for me to type something, ie it hangs because I just sit there and stare.   :-[

[gert@localhost ~]$ man rp      <<----- ??
No manual entry for rp
[gert@localhost ~]$ rp --help
Command not found. Similar command is: 'pr'
[gert@localhost ~]$

It is 2.30AM and I am landed with this, anyone have pity on me   :'( :'( :'(

Edit: the # marked lines inserted after I had done battle with cpio and realised something about standard input and standard output, reading the man then gave me the clues.

The rp I have found nothing about yet.


« Last Edit: July 24, 2010, 08:53:14 PM by wedgeling »
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15829
  • LXDE! Coffee, Bacon and Cheesecake!
Re: rpm2cpio and cpio for rpm file investigation
« Reply #5 on: July 24, 2010, 10:40:04 AM »
Instead of
Quote
[gert@localhost ~]$ rpm2cpio    <<----- ??
argument is not an RPM package

try
Quote
[gert@localhost ~]$ rpm2cpio name-version-etc.rpm

The full name of the RPM should be used. There should be only a single space between the command (rpm2cpio) and its target (the RPM). In the above example from your post, you used 4. Always keep it to one.

Offline wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2469
  • Any Bugs in site?
Re: rpm2cpio and cpio for rpm file investigation
« Reply #6 on: July 24, 2010, 07:34:42 PM »
Neal
Thanx, figured that something like what you are saying (not had time to try it out just yet, spent so much time straying away from logical thinking or something, there are so many fascinating  and often unrelated leads sometimes.)

In general if I don't know if xxx exsists I will go to konsole and just type xxx ENTER and in many cases I will get a friendly reminder about how to use it or other message.  Using the rp command, thanx to tip I read from Leiche, I believe I know the rpm2cpio existed and my logic said, now I have got you, despite having searched Synaptic and not found any hint it was installed.

Quote
[root@localhost ~]# rpm2cpio {ENTER}
^C                         <--------------------------- hanging just waiting, until I terminate with ^C
[root@localhost ~]#

Quote
[root@localhost ~]# rpm2cpio --help
^C                          <--------------------------- hanging just waiting, until I terminate with ^C
[root@localhost ~]#

At this stage I was tempted to think I was wrong it is just not there, only because I had recently had some fun with locate did it occur to me to try  and the result of course got me back on track, actually very surprised I got a result.

Not much success trying to do the same to rp still no idea what this is googling gave me no hint at all about this being something Linux using Forum search on rp, hmmm 114 pages.

Anyway must be a blind alley I am going back to play with cpio and rpm2cpio.   :D

rpm2cpio

Code: [Select]
[root@localhost 1-Linux_Varicad202]# rpm2cpio VariCAD_2010-en-2.08-1.i586.rpm
---------------------------
^C
[root@localhost 1-Linux_Varicad202]#  #now 2nd Option

[root@localhost 1-Linux_Varicad202]# rpm2cpio VariCAD_2010-en-2.08-1.i586.rpm >/home/gert/y-cpio_scrap
[root@localhost 1-Linux_Varicad202]#

The first line shows my interpretation of how to use rpm2cpio from using the manual, I was expecting a file with package_name.cpio written to current directory?  What I got was a character string to terminal window, I intterrupted as I know the file will be over 100MB

Trying the second option using re-direction to a file, seems to work ( I don't know yet what is in the file) but I did not get .cpio added to my filename (probably not important, only visual indiction of file format??)

« Last Edit: July 24, 2010, 08:12:03 PM by wedgeling »
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15829
  • LXDE! Coffee, Bacon and Cheesecake!
Re: rpm2cpio and cpio for rpm file investigation
« Reply #7 on: July 24, 2010, 07:52:33 PM »
Another tip: Use the Provided Packages option in Synaptic's search to find something that may be part of another package.

Offline wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2469
  • Any Bugs in site?
Re: rpm2cpio and cpio for rpm file investigation
« Reply #8 on: July 24, 2010, 08:08:35 PM »
Ooops, thanx for tip, perhaps one day I need to take a course in Synaptic as I keep forgetting the roll down window.

I guess your mean the following attachment? I ran the search and just popped up the search window again and took snap. Did not get anything.
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen

Offline muungwana

  • Hero Member
  • *****
  • Posts: 6269
Re: rpm2cpio and cpio for rpm file investigation
« Reply #9 on: July 24, 2010, 08:52:20 PM »

This is how i "open" rpm packages.

rpm2cpio package_name.rpm  | cpio -idmv

in your case wedgeling, the command for this package will is:

rpm2cpio VariCAD_2010-en-2.08-1.i586.rpm  | cpio -idmv

copy and paste the command on the terminal while the terminal's working directory contains the above mentioned rpm package and see if it will extract it
.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Offline wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2469
  • Any Bugs in site?
Re: rpm2cpio and cpio for rpm file investigation
« Reply #10 on: July 24, 2010, 09:11:33 PM »
muungwana
Thank you, in the "VariCAD" topic or one of them I credit you with my success of getting my VariCAD program running, it was where you suggested opening the *.deb version, which is avaialble as well as the *rpm.  The concept was fine I just made some really silly mistakes on the way before I got it sorted out, but I am very happy with the result.

I am now trying to dissect the *rpm version for fun and practice and thought it would be a piece of cake, tough piece of cake it turns out to be   ;D ;D, As synaptic is rpm based I thought this ought to be the target solution.

Your suggestion I agree with, and coming from you I was very confident the result would be success, but  :'(


Code: [Select]
[root@localhost 1-Linux_Varicad202]# rpm2cpio VariCAD_2010-en-2.08-1.i586.rpm  | cpio -idmv

cpio: warning: skipped 43778 bytes of junk
cpio: R&
        
cpio: warning: skipped 16349 bytes of junk
cpio: warning: archive header has reverse byte-order
cpio: �L
��WjA(ua��ǥ�: unknown file type
cpio: warning: skipped 2008 bytes of junk
cpio: k�o�I�wa��
�ؗ���U�f�+�� �ߋhzj�I�.�"�ltC2��o�#��R&���_���$'Y�l�s���%g��r��?��▒����L� �k@��� 5����W�
 �S���o9���KیM�0��w�D����sF���l����'P��!: unknown file type
cpio: warning: skipped 51245 bytes of junk
cpio: warning: skipped 80879 bytes of junk
cpio: ����~��K�!\�$�|/�B;80��*�� IX׃~<)���V"�"��ÿdw�6yO����'��{�X1��▒�#�j�P����
                                                                            
cpio: premature end of file
[root@localhost 1-Linux_Varicad202]#


I have trimmed out lots of code, just leaving samples and what I could read.

I was expecting something like this too (from experimenting with cpio) and tried first to redirect  to a file (..>file-x) but that failed to with an empty file, then I tried your suggetion (pure copy and paste)

In my opinion it should work  ;D
« Last Edit: July 24, 2010, 09:24:09 PM by wedgeling »
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen

Offline muungwana

  • Hero Member
  • *****
  • Posts: 6269
Re: rpm2cpio and cpio for rpm file investigation
« Reply #11 on: July 24, 2010, 09:24:34 PM »
that command works most of the time but it doesnt in certain occasions and I havent investigate when it doesnt works since it rarely doesnt. I should have mentioned this in my earlier post

i will investigate further to see if there is any predictable pattern. It works in all packages from the repository i have used it with.
.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Offline wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2469
  • Any Bugs in site?
Re: rpm2cpio and cpio for rpm file investigation
« Reply #12 on: July 24, 2010, 09:40:20 PM »
Ahh, that is good to hear that is fails sometimes.
Could you suggest a small trial package that I can test on, one you know works? I am on a crash course learning a little bit of rpm, no expert, only rather inquisitve  ;D

In answer to you suggestion below I have picked the first one,
http://distro.ibiblio.org/pub/linux/distributions/texstar/pclinuxos/apt/pclinuxos/2010/RPMS.kde4/DoAsRoot-2.1.1-4pclos2010.i586.rpm

cpioEdit: for my record before I forget, below
Using this site
http://www.cyberciti.biz/faq/how-do-i-use-cpio-command-under-linux/

I have tried

Quote
[root@localhost 1-Linux_Varicad202]# cpio -it -F VariCAD_2010-en-2.08-1.i586.rpm >/home/gert/y-cpio_list_scrap
cpio: warning: skipped 217914 bytes of junk
cpio: premature end of file
# the file was empty

[root@localhost 1-Linux_Varicad202]# cpio -it -F VariCAD_2010-en-2.08-1.i586.rpm
cpio: warning: skipped 217914 bytes of junk

cpio: premature end of file
[root@localhost 1-Linux_Varicad202]# cpio -it VariCAD_2010-en-2.08-1.i586.rpm
^C

# above the first one I don't really know if there was an output
# above two tries the last seem to be waiting, I exited with ^C
# below I changed immediately to test your suggestion, here my first attempt modified by redirection as I expected something big, using your suggestion
# no capture, file made but no content

[root@localhost 1-Linux_Varicad202]# rpm2cpio VariCAD_2010-en-2.08-1.i586.rpm  | cpio -idmv >/home/gert/y-cpio_list_scrap



I have just dicovered a "funny file" no content see attached picture, I am not sure but I think it may be the result of one of the cpio tests where I work in the current directory, have not given filename.

What concerns me I seem to get same result from both commands. I will just leave this so I don't loose the record of having tried.
« Last Edit: July 24, 2010, 10:21:24 PM by wedgeling »
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen

Offline muungwana

  • Hero Member
  • *****
  • Posts: 6269
.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Offline Texstar

  • Administrator
  • Super Villain
  • *****
  • Posts: 12662
Re: rpm2cpio and cpio for rpm file investigation
« Reply #14 on: July 24, 2010, 09:54:29 PM »
It only works with binary packages created with rpm 4.4.6 or SRPMS of any rpm version. It will not work on binary packages created with rpm 4.6.x.

Thanks to everyone who donates. You keep the servers running.
Follow me on Twitter for the latest development info.