9.1 Unpacking Source Packages

9.1 Unpacking Source Packages

A package's source code distribution usually comes as a .tar.gz or .tar.bz2 file, and you should unpack the file as described in Section 1.18.

Before you unpack, though, verify the contents of the archive with tar tvf , because some packages don't create their own subdirectories in the directory where you extract the archive. Output like the following means that the package is probably okay to unpack:

 package-1.23/Makefile.in package-1.23/README package-1.23/main.c package-1.23/bar.c ... 

However, you might see that not all of the files are in a common directory (like package-1.23 in the preceding example):

 Makefile README main.c ... 

Extracting an archive like this one can leave a big mess in your current directory. To avoid this, create a new directory and cd there before extracting the contents of the archive.

Watch out for a test listing with absolute pathnames like this:

 /etc/passwd /etc/inetd.conf 

You likely won't come across anything like this, but if you do, remove the archive from your system, because it probably contains a Trojan horse or some other malicious code.

9.1.1 Where to Start

After you extract the contents of a source archive and have a bunch of files in front of you, try to get a feel for the package. In particular, look for these files: README and INSTALL .

Always look at any README files first. They often contain a description of the package, a small manual, installation hints, and other useful information. Many packages also come with INSTALL files that contain instructions on how to compile and install the package. Check for special compiler options and definitions.

Apart from the README and INSTALL files, you will find other package files that fall into roughly three categories:

  • Files relating to the make system, such as Makefile , Makefile.in , and configure . Some packages come with a Makefile that you may need to modify. However, most modern packages use GNU autoconf and come with a configure script to generate a Makefile from Makefile.in based on your system settings and configuration options.

  • Source code files ending in .c , .h , or .cc . C source code files may appear just about anywhere in a package directory. C++ source code files usually have .cc , .C , or .cxx suffixes.

  • Object files ending in .o or binaries. Normally there aren't any object files in source code distributions. However, you may find object files in rare cases when the package maintainer is not allowed to release certain source code, and you may need to do something special to use the object files. In most cases, object (or binary executable) files in a source distribution mean that the package wasn't put together too well, and you should run make clean to make sure that you get a fresh compile.

How Linux Works
How Linux Works: What Every Superuser Should Know
ISBN: 1593270356
EAN: 2147483647
Year: 2004
Pages: 189
Authors: Brian Ward

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net