5. Uncompressing / unpacking of source

In almost all cases, source consists of several / many files that are packed and compressed into a single archive file. Thus the first step is to uncompress / unpack the source.

Tarballs (.tgz / .tar.gz / .tar.Z)

These are tar archives that are compressed with gzip (.tgz / .tar.gz) or compress (.tar.Z). To unpack a tarball, use the following command that works regardless whether the archive was compressed with gzip or compress

          bash$ gunzip -c foo.tar.gz | tar -xvf -
	  foo/
	  foo/README
	  foo/Makefile.in
	  

TipTIP
 

Not all tarballs unpack into a subdirectory. To make sure your current directory will not get littered, you can get a listing without actually unpacking the tarball with the command

gunzip -c foo.tar.gz | tar -tf -

Source RPM archives (.src.rpm)

SRPM archives usually don't need to be unpacked before using them (see >). In the rare case that you really want to unpack an RPM (regardless whether it is a source or binary RPM), you could do it as follows (note that you need the utilities rpm2cpio and cpio):

rpm2cpio foo.rpm | cpio -idmv --no-absolute-filenames

In the case of a source RPM, the content will likely turn out to be two files a .spec file and a tarball (see above).

TipTIP
 

If you simply want to list the contents of an RPM package file, you can do that with

rpm --query --list -p foo.rpm

Zip archives (.zip)

Zip archives are used mostly on Windows. On Linux/Unix, you can use the unzip utility to unpack them:

unzip foo.zip

Tip