Hi my name is Don Bishop and this is my “Deal” Today... Basically, anything that interest me. Music, Computers, Software, Apps, Linux OS's - Distros, Space, Science, Auto's, Trucks, 4x4's, Motorcycles and other slightly interesting info that I find on the Web. There may, or may not be, any correlation between my Posts. Just whatever interests me at the time. I hope someone out there finds some of this interesting too!:)
Search My Blog
Friday, November 19, 2010
Maximum RPM: Taking the Red Hat Package Manager to the Limit
As the name implies,rpm2cpiotakes an RPM package file and converts it to acpioarchive. Because it's written to be used primarily as a filter, there's not much to be specified.rpm2cpiotakes only only one argument, and eventhat'soptional!
The optional argument is the name of the package file to be converted. If there is no filename specified on the command line,rpm2cpiowill simply read from standard input and convertthatto acpioarchive. Let's give it a try:
# rpm2cpio logrotate-1.0-1.i386.rpm0707020001a86a000081a4000000000000000000000001313118bb000002c200000008000 000030000000000000000000000190000e73eusr/man/man8/logrotate.8." logrotate - log fi le rotator .TH rpm 8 "28 November 1995" "Red Hat Software" "Red Hat Linux" .SH NAME
(We've just shown the first few lines of output.)
What on earth is all that stuff? Remember,rpm2cpiois written as a filter. It writes thecpioarchive contained in the package file to standard output, which, if you've not redirected it somehow, is your screen. Here's a more reasonable example:
Here we've directedrpm2cpioto convert thelogrotatepackage file. We've also redirectedrpm2cpio's output to a file calledblah.cpio. Next, using thefilecommand, we find that the resulting file is indeed a true-bluecpioarchive file. The following command is entirely equivalent to the one above and showsrpm2cpio's ability to read the package file from its standard input:
While there's nothing wrong with usingrpm2cpioto actually create acpioarchive file, it's takes a few more steps and uses a bit more disk space than is strictly necessary. A somewhat cleaner approach would be to piperpm2cpio's output directly intocpio:
In this example, we used the-toption to directcpioto produce a "table of contents" of the archive created byrpm2cpio. This can make it much easier to get the right filename and path when you want to extract a file.
Continuing the example above, let's extract the man page from thelogrotatepackage. In the table of contents, we see that the full path isusr/man/man8/logrotate.8. All we need to do is to use the filename and path as shown below:
In this case, thecpiooptions-i,-v, and-ddirectcpioto:
Extract one or more files from an archive.
Display the names of any files processed, along with the size of the archive file, in 512-byte blocks.
Create any directories that precede the filename specified in thecpiocommand.
So where did the file end up? The last option (-d) tocpioprovides a hint. Let's take a look:
# ls -altotal 5 -rw-rw-r-- 1 root root 3918 May 30 11:02 logrotate-1.0-1.i386.rpm drwx------ 3 root root 1024 Jul 14 12:42 usr# cd usr# ls -altotal 1 drwx------ 3 root root 1024 Jul 14 12:42 man# cd man# ls -altotal 1 drwx------ 2 root root 1024 Jul 14 12:42 man8# cd man8# ls -altotal 1 -rw-r--r-- 1 root root 706 Jul 14 12:42 logrotate.8# cat logrotate.8.\" logrotate - log file rotator .TH rpm 8 "28 November 1995" "Red Hat Software" "Red Hat Linux" .SH NAME logrotate \- log file rotator .SH SYNOPSIS \fBlogrotate\fP [configfiles] .SH DESCRIPTION \fBlogrotate\fP is a tool to prevent log files from growing without …#
Since the current directory didn't have ausr/man/man8/path in it, the-doption causedcpioto create all the directories leading up to thelogrotate.8file in the current directory. Based on this, it's probably safest to usecpiooutsidethe normal system directories unless you're comfortable withcpio, and you know what you're doing!