|
||||||||||||
|
|
4.5 Using the PortsCollectionThe following sections provide basic instructions on using the ports collection toinstall or remove programs from your system. 4.5.1 Obtaining the PortsCollectionBefore you can install ports, you must first obtain the ports collection--which isessentially a set of Makefiles, patches, and description filesplaced in /usr/ports. When installing your FreeBSD system, sysinstall asked ifyou would like to install the ports collection. If you chose no, you can follow theseinstructions to obtain the ports collection: Sysinstall Method This method involves using sysinstall again to manuallyinstall the ports collection.
The alternative method to obtain and keep your ports collection up to date is by usingCVSup. Look at the ports CVSupfile, /usr/share/examples/cvsup/ports-supfile. See CVSup Method This is a quick method for getting the ports collection using
4.5.2 InstallingPortsThe first thing that should be explained when it comes to the ports collection is whatis actually meant by a ``skeleton''. In a nutshell, a port skeleton is a minimal set offiles that tell your FreeBSD system how to cleanly compile and install a program. Eachport skeleton includes:
Some ports have other files, such as pkg-message. The portssystem uses these files to handle special situations. If you want more details on thesefiles, and on ports in general, check out the FreeBSD Porter's Handbook. Now that you have enough background information to know what the ports collection isused for, you are ready to install your first port. There are two ways this can be done,and each is explained below. Before we get into that, however, you will need to choose a port to install. There area few ways to do this, with the easiest method being the ports listing on the FreeBSD website. You can browse through the ports listed there or use the search function on thesite. Each port also includes a description so you can read a bit about each port beforedeciding to install it. Another method is to use the # whereis lsoflsof: /usr/ports/sysutils/lsof This tells us that lsof (a system utility) can be found inthe /usr/ports/sysutils/lsof directory. Yet another way to find a particular port is by using the ports collection's built-insearch mechanism. To use the search feature, you will need to be in the # cd /usr/ports# make search name=lsofPort: lsof-4.56.4Path: /usr/ports/sysutils/lsofInfo: Lists information about open files (similar to fstat(1))Maint: obrien@FreeBSD.orgIndex: sysutilsB-deps: R-deps: The part of the output you want to pay particular attention to is the ``Path:'' line,since that tells you where to find the port. The other information provided is not neededin order to install the port, so it will not be covered here. For more in-depth searching you can also use make search key= In both of these cases, the search string is case-insensitive. Searching for ``LSOF''will yield the same results as searching for ``lsof''.
Now that you have found a port you would like to install, you are ready to do theactual installation. The port includes instructions on how to build source code, but doesnot include the actual source code. You can get the source code from a CD-ROM or from theInternet. Source code is distributed in whatever manner the software author desires.Frequently this is a tarred and gzipped file, but it might be compressed with some othertool or even uncompressed. The program source code, whatever form it comes in, is calleda ``distfile''. You can get the distfile from a CD-ROM or from the Internet.
4.5.2.1 Installing Ports from aCD-ROMThe FreeBSD Project's official CD-ROM images no longer include distfiles. They take upa lot of room that is better used for precompiled packages. CD-ROM products such as theFreeBSD PowerPak do include distfiles, and you can order these sets from a vendor such asthe FreeBSD Mall. This sectionassumes you have such a FreeBSD CD-ROM set. Place your FreeBSD CD-ROM in the drive. Mount it on /cdrom.(If you use a different mount point, the install will not work.) To begin, change to thedirectory for the port you want to install: # cd /usr/ports/sysutils/lsof Once inside the lsof directory, you will see the portskeleton. The next step is to compile, or ``build'', the port. This is done by simplytyping make at the prompt. Once you have done so, you should seesomething like this: # make>> lsof_4.57D.freebsd.tar.gz doesn't seem to exist in /usr/ports/distfiles/.>> Attempting to fetch from file:/cdrom/ports/distfiles/.===> Extracting for lsof-4.57...[extraction output snipped]...>> Checksum OK for lsof_4.57D.freebsd.tar.gz.===> Patching for lsof-4.57===> Applying FreeBSD patches for lsof-4.57===> Configuring for lsof-4.57...[configure output snipped]...===> Building for lsof-4.57...[compilation output snipped]...# Notice that once the compile is complete you are returned to your prompt. The nextstep is to install the port. In order to install it, you simply need to tack one wordonto the make command, and that word is # make install===> Installing for lsof-4.57...[installation output snipped]...===> Generating temporary packing list===> Compressing manual pages for lsof-4.57===> Registering installation for lsof-4.57===> SECURITY NOTE: This port has installed the following binaries which execute with increased privileges.# Once you are returned to your prompt, you should be able to run the application youjust installed. Since lsof is a program that runs with increasedprivileges, a security warning is shown. During the building and installation of ports,you should take heed of any other warnings that may appear.
4.5.2.2 Installing Ports from theInternetAs with the last section, this section makes an assumption that you have a workingInternet connection. If you do not, you will need to perform the Installing a port from the Internet is done exactly the same way as it would be if youwere installing from a CD-ROM. The only difference between the two is that the distfileis downloaded from the Internet instead of read from the CD-ROM. The steps involved are identical: # make install>> lsof_4.57D.freebsd.tar.gz doesn't seem to exist in /usr/ports/distfiles/.>> Attempting to fetch from ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/.Receiving lsof_4.57D.freebsd.tar.gz (439860 bytes): 100%439860 bytes transferred in 18.0 seconds (23.90 kBps)===> Extracting for lsof-4.57...[extraction output snipped]...>> Checksum OK for lsof_4.57D.freebsd.tar.gz.===> Patching for lsof-4.57===> Applying FreeBSD patches for lsof-4.57===> Configuring for lsof-4.57...[configure output snipped]...===> Building for lsof-4.57...[compilation output snipped]...===> Installing for lsof-4.57...[installation output snipped]...===> Generating temporary packing list===> Compressing manual pages for lsof-4.57===> Registering installation for lsof-4.57===> SECURITY NOTE: This port has installed the following binaries which execute with increased privileges.# As you can see, the only difference is the line that tells you where the system isfetching the port distfile from. The ports system uses For users which cannot be connected all the time, the make
In some rare cases, users may need to acquire the tarballs from a site other than theMASTER_SITES (the location where files are downloaded from). Youcan override the MASTER_SITES option with the followingcommand: # cd /usr/ports/ In this example we change the MASTER_SITES option to
4.5.2.3 Overriding the Default PortsDirectoriesSometimes it is useful (or mandatory) to use a different distfiles and portsdirectory. The PORTSDIR and PREFIXvariables can override the default directories. For example: # will compile the port in /usr/home/example/ports and installeverything under /usr/local. # will compile it in /usr/ports and install it in And of course, # will combine the two (it is too long to completely write on this page, but it shouldgive you the general idea). Alternatively, these variables can also be set as part of your environment. Read themanual page for your shell for instructions on doing so. 4.5.2.4 Dealing with |
|
||||||||||
|
||||||||||||