17.4. Flere programmer - ports systemet

Ports er en anden måde at installere programmer på. Fremfor at hente færdigkompilerede binære pakker, henter man kildekode med tilhørende lapper der som regel får en give pakke til kompilere smertefrit på OpenBSD.

For at dette kan lade sig gøre skal man have det jeg vil betegne som ports-definitioner liggende på sin egen maskine. Det er ganske enkelt en beskrivelse for hver enkelt program i ports, om hvor kildekoden kan findes, hvilke lapper der skal til, hvordan programmet skal kompileres og lignende. Yderlige er der indbyggede afhængigheder, således at ports-systemet selv sørger for at hente og kompilere eventuelle pakker der kræves for at kompilere et givet program.

For at kunne bruge ports skal man havedefinitionerne på plads først. Jeg synes det er nemmet at bruge CVSup til dette formål. Fra ftp://ftp.openbsd.org/pub/OpenBSD/3.4/packages/i386 hentede jeg cvsup-16.1g-no_x11.tgz og installerede. Ved samme lejlighed konstaterede jeg lige at der rent faktisk findes en oversætter på maskinen:

# pkg_add cvsup-16.1g-no_x11.tgz
# gcc -v
Reading specs from /usr/lib/gcc-lib/i386-unknown-openbsd3.4/2.95.3/specs
gcc version 2.95.3 20010125 (prerelease, propolice)
Jeg lavede en fil med definitioner til hvor CVSup skal hente sine oplysninger:
# Defaults that apply to all the collections
*default release=cvs
*default delete use-rel-suffix
*default umask=002
*default host=cvsup.uk.openbsd.org
*default base=/usr/cvs
*default prefix=/usr/cvs

# If your network link is a T1 or faster, comment out the following line.
*default compress

OpenBSD-ports tag=OPENBSD_3_4
og lod så root hente ports-definitionerne:
Parsing supfile "CVSup/CVSup.ports"
Connecting to cvsup.uk.openbsd.org
Connected to cvsup.uk.openbsd.org
Server software version: SNAP_16_1h
Negotiating file attribute support
Exchanging collection information
Establishing multiplexed-mode data connection
Running
Updating collection OpenBSD-ports/cvs
 Checkout ports/INDEX
 Checkout ports/Makefile
 Checkout ports/README
 Checkout ports/archivers/Makefile
 Checkout ports/archivers/arc/Makefile
 Checkout ports/archivers/arc/distinfo
 Checkout ports/archivers/arc/patches/patch-Makefile
 Checkout ports/archivers/arc/patches/patch-arc_c
 Checkout ports/archivers/arc/patches/patch-arc_h
 Checkout ports/archivers/arc/patches/patch-arcadd_c
 Checkout ports/archivers/arc/patches/patch-arccvt_c
 Checkout ports/archivers/arc/patches/patch-arcdata_c
 Checkout ports/archivers/arc/patches/patch-arcdos_c
 Checkout ports/archivers/arc/patches/patch-arcext_c
 Checkout ports/archivers/arc/patches/patch-arcio_c
 Checkout ports/archivers/arc/patches/patch-arclzw_c
 Checkout ports/archivers/arc/patches/patch-arcrun_c
 Checkout ports/archivers/arc/patches/patch-arcunp_c
 Checkout ports/archivers/arc/patches/patch-marc_c
 Checkout ports/archivers/arc/pkg/DESCR
 Checkout ports/archivers/arc/pkg/PLIST
 ...... 
 ......
 ...... 
 ......
 Checkout ports/x11/xwrits/pkg/PLIST
 Checkout ports/x11/xzoom/Makefile
 Checkout ports/x11/xzoom/distinfo
 Checkout ports/x11/xzoom/patches/patch-aa
 Checkout ports/x11/xzoom/pkg/DESCR
 Checkout ports/x11/xzoom/pkg/PLIST
Det tog lidt over en time.

For bare at afprøve ports installerede jeg bzip2. Jeg fandt den i /usr/cvs/ports/archivers/bzip2 ud fra en betragtning om at jeg nok skulle få brug for den senere. Jeg vil gerne installere bzip2 og fjerne kildekoden igen:

# make install clean
"/usr/share/mk/bsd.port.mk", line 3: Could not find /usr/ports/infrastructure/mk/bsd.port.mk
Fatal errors encountered -- cannot continue
BANG! Så let skulle det ikke være. Men egentlig er det jo nok min egen skyld. FreeBSD's ports-træ ligger under /usr/ports og jeg har lagt mit under /usr/cvs/ports. Efter 10 sekunders Googling fik jeg lavet en fil der kan definere hvor ports-træet ligger:
# cat /etc/mk.conf
PORTSDIR=/usr/cvs/ports
og så gik det bedre:
# make install clean
===>  Checking files for bzip2-1.0.2
>> bzip2-1.0.2.tar.gz doesn't seem to exist on this system.
>> Attempting to fetch /usr/cvs/ports/distfiles/bzip2-1.0.2.tar.gz from ftp://mirrors.rcn.net/mirrors/sources.redhat.com/bzip2/v102/.

100% |**************************************************|   649 KB    00:16    
>> Checksum OK for bzip2-1.0.2.tar.gz. (sha1)
===>  Extracting for bzip2-1.0.2
===>  Patching for bzip2-1.0.2
===>  Configuring for bzip2-1.0.2
===>  Building for bzip2-1.0.2

If compilation produces errors, or a large number of warnings, 
please read README.COMPILATION.PROBLEMS -- you might be able to
adjust the flags in this Makefile to improve matters.

cc -O2   -Wall -Winline -fomit-frame-pointer -fno-strength-reduce -c blocksort.c
cc -O2   -Wall -Winline -fomit-frame-pointer -fno-strength-reduce -c huffman.c
cc -O2   -Wall -Winline -fomit-frame-pointer -fno-strength-reduce -c crctable.c
cc -O2   -Wall -Winline -fomit-frame-pointer -fno-strength-reduce -c randtable.c......
......
......
......
......
......
===>  Building package for bzip2-1.0.2
Creating package /usr/cvs/ports/packages/i386/all/bzip2-1.0.2.tgz
Creating gzip'd tar ball in '/usr/cvs/ports/packages/i386/all/bzip2-1.0.2.tgz'
Running "tar -c -f /usr/cvs/ports/packages/i386/all/bzip2-1.0.2.tgz -z +CONTENTS +COMMENT +DESC -C /usr/cvs/ports/archivers/bzip2/w-bzip2-1.0.2/fake-i386//usr/local -I /tmp/tpkg.AEKWD17865 "
Link to /usr/cvs/ports/packages/i386/ftp/bzip2-1.0.2.tgz
Link to /usr/cvs/ports/packages/i386/cdrom/bzip2-1.0.2.tgz
===>  Installing bzip2-1.0.2 from /usr/cvs/ports/packages/i386/all/bzip2-1.0.2.tgz
===>  Cleaning for bzip2-1.0.2
Det gik jo egentlig meget nemt.
# which bzip2
/usr/local/bin/bzip2
Fint. Det virker! Vi prøver lige Emacs også:
# pwd
/usr/cvs/ports/editors/emacs
# make install clean
===>  Checking files for emacs-20.7
>> emacs-20.7.tar.gz doesn't seem to exist on this system.
>> Attempting to fetch /usr/cvs/ports/distfiles/emacs-20.7.tar.gz from ftp://ftp.gnu.org/gnu/emacs/.
 79% |***************************************           | 11698 KB    00:31 ETA
[snip en times tid]
===>  Building package for emacs-leim-20.7
Creating package /usr/cvs/ports/packages/i386/all/emacs-leim-20.7.tgz
Creating gzip'd tar ball in '/usr/cvs/ports/packages/i386/all/emacs-leim-20.7.tgz'
Running "tar -c -f /usr/cvs/ports/packages/i386/all/emacs-leim-20.7.tgz -z +CONTENTS +COMMENT +DESC -C /usr/cvs/ports/editors/emacs/w-emacs-20.7/fake-i386//usr/local -I /tmp/tpkg.HrdZid6926 "
Link to /usr/cvs/ports/packages/i386/ftp/emacs-leim-20.7.tgz
Link to /usr/cvs/ports/packages/i386/cdrom/emacs-leim-20.7.tgz
===>  Installing emacs-20.7 from /usr/cvs/ports/packages/i386/all/emacs-20.7.tgz
===>  Cleaning for emacs-20.7