Опубликован: 06.08.2012 | Доступ: свободный | Студентов: 1189 / 25 | Оценка: 5.00 / 5.00 | Длительность: 53:41:00
Лекция 9:

The Ports Collection

< Лекция 8 || Лекция 9: 123 || Лекция 10 >

What's in that port?

One problem with the Ports Collection is the sheer number. It can be difficult just to find out what they're supposed to do. If you build all the ports, you'll be busy for weeks, and there's no way you could read all the documentation in one lifetime. Where can you get an overview? Here are some suggestions. In each case, you should have the directory /usr/ports, as your current working directory.

  • There's an index in /usr/ports/INDEX. If you have updated the ports tree, you can make the index with the following commands:
    #  cd /usr/ports
    #  make index
    

    index, is the name of a target, the part of a rule that identifies it. It's usually either a file name or an abbreviation for an operation to perform. We'll see a number of make, targets in the course of the book.

    The index is intended for use by other programs, so it's written as a single long line per package, with fields delimited by the vertical bar character (|). Here are two lines as an example, wrapped over three lines to fit on the page:

    mp3asm-0.1.3|/usr/ports/audio/mp3asm|/usr/local|MP3 frame level editor|/usr/port
    s/audio/mp3asm/pkg-descr|ports@FreeBSD.org|audio| autoconf213-2.13.000227_1||
    htt p://mp3asm.sourceforge.net/
    mp3blaster-3.0p8|/usr/ports/audio/mp3blaster|/usr/local|MP3 console ncurses-base
    dplayer|/usr/ports/audio/mp3blaster/pkg-descr|greid@FreeBSD.org|audio|||
    http:// www.stack.nl/~brama/mp3blaster.html
    

    You'll probably want to process it with other tools.

  • You can print the index with the following commands:
    #  cd /usr/ports
    #  make print-index | lpr
    

    Note that there are about 1,000 pages of output, which look like this:

    Port:    zip-2.3_1
    Path:    /usr/ports/archivers/zip
    Info:    Create/update ZIP files compatible with pkzip
    Maint:   ache@FreeBSD.org
    Index:   archivers
    B-deps:  unzip-5.50
    R-deps:
    
  • You can search for a specific keyword with the search target. For example, to find ports related to Emacs, you might enter:
    #  cd /usr/ports
    #  make search key=Emacs | less
    

    Pipe the output through less, it can be quite a lot.

  • You can build a series of nearly 10,000 html, pages like this:
    #  cd /usr/ports
    #  make readmes
    

    You can then browse them at the URL file:///usr/ports/README.html.

Getting the source archive

You'll see from the above example that there are not many files in the port. Most of the files required to build the software are in the original source code archive (the "tar ball"), but that's not part of the port.

There are a number of places from which you can get the sources. If you have a CD-ROM set, many of them are scattered over the CD-ROMs, in the directory /cdrom/ports/distfiles, on each CD-ROM. The Ports Collection Make files look for them in this directory (another good reason to mount your CD-ROM on /cdrom), and also in /usr/ports/distfiles.

If you don't have the source tar ball, that's not a problem. Part of the function of the Ports Collection is to go out on the Net and get them for you. This is completely automatic: you just type make, and the build process gets the source archive for you and builds it. Of course, you must be connected to the Internet for this to work.

If you mount your CD-ROM elsewhere (maybe because you have more than one CD-ROM drive, and so you have to mount the CD-ROM on, say, /cd4), the Make files will not find the distribution files and will try to load the files from the Internet. One way to solve this problem is to create a symbolic link from /cd4/ports/distfiles, to /usr/ports/distfiles. The trouble with this approach is that you will then no longer be able to load new distribution files into /usr/ports/distfiles, because it will be on CD-ROM. Instead, do:

#  cd /cd4/ports/distfiles
#  mkdir -p /usr/ports/distfiles       make sure you have a distfiles directory
#  for i in *; do
>  ln -s /cd4/ports/distfiles/$i /usr/ports/distfiles/$i
>  done

If you're using csh, or tcsh, enter:

# cd /cd4/ports/distfiles
# mkdir -p /usr/ports/distfiles       make sure you have a distfiles directory
# foreach i (*)
?  ln -s /cd4/ports/distfiles/$i /usr/ports/distfiles/$i
? end

This creates a symbolic link to each distribution file, but if the file for a specific port isn't there, the Ports Collection can fetch it and store it in the directory.

Building the port

Once you have the skeleton files for the port, the rest is simple. Just enter:

#  cd /usr/ports/editors/emacs21
#  make
#  make install
====> To enable menubar fontset support, define WITH_MENUBAR_FONTSET
>> emacs-21.2.tar.gz doesn't seem to exist in /usr/ports/distfiles/.
>> Attempting to fetch from ftp://ftp.gnu.org/gnu/emacs/.
===>   Extracting for emacs-21.2_1
>> Checksum OK for emacs-21.2.tar.gz.
===>     emacs-21.2_1 depends on executable: gmake - found
===>     emacs-21.2_1 depends on executable: autoconf213 - not found
===>      Verifying install for autoconf213 in /usr/ports/devel/autoconf213
===>   Extracting for autoconf213-2.13.000227_2
>> Checksum OK for autoconf-000227.tar.bz2.
===>     autoconf213-2.13.000227_2 depends on executable: gm4 - not found
===>      Verifying install for gm4 in /usr/ports/devel/m4
===>   Extracting for m4-1.4_1
>> Checksum OK for m4-1.4.tar.gz.
===>   Patching for m4-1.4_1
===>   Applying FreeBSD patches for m4-1.4_1
===>   Configuring for m4-1.4_1
creating cache ./config.cache
checking for mawk... no
(etc)

It's a good idea to perform the make, step first: make install, does not always build the package.

Port dependencies

Sometimes, it's not enough to build a single port. Many ports depend on other ports. If you have the complete, up-to-date ports tree installed on your systcode, the Ports Collection will take care of this for you: it will check if the other port is installed, and if it isn't, it will install it for you. For example, tkdesk, depends on tk, tk depends on tcl. If you don't have any of them installed, and you try to build tkdesk, it will recursively install tk and tcl for you.

< Лекция 8 || Лекция 9: 123 || Лекция 10 >
Владимир Шишкин
Владимир Шишкин
Россия, Киров
Олег Страхов
Олег Страхов
Россия