Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Absolute BSD - The Ultimate Guide To FreeBSD (2002).pdf
Скачиваний:
25
Добавлен:
17.08.2013
Размер:
8.15 Mб
Скачать

variable! Setting variables on the command line is much simpler than figuring out how to add these commands to the build process on your own.

If you use several make commands to build the port (for example, make patch and then make install clean), you must include any options you want with every make command. Otherwise, the port might not build correctly. For example, if you wanted to use the flexresp option in Snort, but had your own custom patch to apply, you would need to run the following:

...............................................................................................

# make patch WITH_FLEXRESP=YES

...............................................................................................

Then you would apply your patch and run this:

...............................................................................................

# make install WITH_FLEXRESP=YES

...............................................................................................

Otherwise, you would patch your system with the customization option WITH_FLEXRESP, but you wouldn't give it the correct instructions when compiling the software. Your program would be internally inconsistent, and quite possibly would fail.

The hardest part of customizing the way your software builds is deciding which options you'd like. Unfortunately, there is no easy answer to this question, so it's best to check the software manual or Web site to help you decide. More than once I've installed a piece of software, read the documentation, and turned right around to uninstall and reinstall with the options I needed.

Uninstalling and Reinstalling

One nice thing about installing ports is that, once installed, the port is treated just like a package. You can uninstall a port with pkg_delete, and learn about it with pkg_info. Since the port's installation is recorded under /var/db/pkg, you can also go through the contents file and investigate every file the port includes.

You also can uninstall a port from the port directory. For example, suppose FreeBSD includes several different versions of one port, like the Apache Web server. You might want to build several different versions of the port, evaluate each, and pick one to install for long−term use. Then, once you've evaluated one version of the program, and want to uninstall it, you can run make deinstall in the port directory to erase the program from the main system.

Note Once you've run make install, the compiled program and source files still live under the work subdirectory in the port. You can run make reinstall to reinstall an uninstalled program. You can uninstall and reinstall a program as many times as you like.

At some point, you may find that you want to reinstall a port you've removed with pkg_delete and that when you run make reinstall it fails, complaining that the port is already installed. Why? Well, do a "long list" of the problem port's work directory:

...............................................................................................

# cd /usr/ports/www/apache13/work

243

# ls −a

 

 

 

 

 

 

total 21

 

 

 

 

 

969094

drwxr−xr−x 3 root

wheel

512

Jul 22 21:24 .

778196

drwxr−xr−x 4 root

wheel

512

Jul 27 20:42 ..

969343

−rw−r−−r−− 1 root

wheel 17163 Jul 22 21:24 .PLIST.mktmp

969344

−rw−r−−r−− 1 root

wheel

0

Jul 22 21:24 .PLIST.setuid

969345

−rw−r−−r−− 1 root

wheel

19

Jul 22 21:24 .PLIST.startup

969341

−rw−r−−r−− 1 root

wheel

0

Jul 22 21:23 .build_done

969115

−rw−r−−r−− 1 root

wheel

0

Jul 22 21:22 .configure_done

969112

−rw−r−−r−− 1 root

wheel

0

Jul 22

21:21 .extract_done

969342

−rw−r−−r−− 1

root

wheel

0

Jul 22

21:24 .install_done

969113

−rw−r−−r−− 1

root

wheel

0

Jul 22

21:21 .patch_done

318289

drwxr−xr−x 8

root

wheel

512

Jul 22

21:23 apache_1.3.20

#

 

 

 

 

 

 

...............................................................................................

So what does this tell us? Well, all files whose names begin with a period (which is most of the files listed here, except for apache_1.3.20) are "hidden" files that don't show up on a normal directory listing. The ports system and the make process uses these files to keep track of what stage the build process is in. Every port uses these files. See the hidden file .install_done? If that file exists, the port believes that it's already installed, and it refuses to overwrite itself. So there's our problem.

Remove that file, and the make reinstall will succeed.

Cleaning Up with Make Clean

Ports can take up a lot of room. Some, such as XFree86, can soak up a couple hundred megs of disk once they're extracted and built. Most of this disk usage is from the original source code, which you will no longer need. The ports system includes a method to remove excess source code.

Once you have your program installed and configured the way you like it, you don't really need the copy of the source code in the ports directory any more. You can remove it with make clean. (This blows away the work directory, so be sure that you're happy with your program before you do it!) You can also clean a new port immediately on install by running make install clean when you install it.

You might also clean the port's original distfiles, which are stored in /usr/ports/distfiles. (Check this directory now and then, because it can fill up quickly if you build a lot of ports.) Removing unneeded distfiles frees considerable disk space.

To clean the entire ports tree, run make clean directly under /usr/ports. This takes some time, though, and, while there are faster and more efficient ways to remove every work directory in the ports tree, this one is directly supported by the FreeBSD Project.

Building Packages

If you're using ports, you can build your own packages to install on other FreeBSD machines, which can save you a lot of time and ensure that you have identical software on every machine. If you have several machines running Snort, for example, and you want them all to have the same features, you can build Snort once and then make a package out of it to install on all the other machines.

244