Introduction
Today you will be compiling open source software from the source
code.
FreeBSD makes this easier with a system it calls 'Ports', a collection
of specially crafted 'Makefile's, that automate the process of
downloading, untaring, patching, configuring, building, installing and
tracking applications. FreeBSD has another system for installing
software, called 'Packages'. Packages are faster to install, because
they have already been compiled ahead of time, by either yourself, or
someone at the FreeBSD Project. However, they lack the ability to
change their major compile-time options. This is where the 'Ports'
system comes in, when you compile the software your self, you get to
choose the compile-time options. You can then roll these compiled files
into your own package, for distribution to multiple machines
Warnings and Notes for this Lab:
See
the FreeBSD Handbook Section on Ports
You will work in groups of three, one person will be the server, and
the other two will be the clients.
The server will require that the ports collection is installed. You can
do this through sysinstall, under 'configure' -> 'distributions'
If networking is not working, run: ifconfig lnc0 down; ifconfig lnc0
up; dhclient lnc0
The 'ports' collection automatically installs the man pages for the new
programs you install
remember you will have to run the 'rehash' command before newly
installed programs will work
Steps
- Enable NFSd on the server (see below)
- Enable NFS on the client (see below)
- Export /usr/ports on the server (edit /etc/exports,
see man exports)
- Restart Mountd (you must restart mountd after every change to /etc/exports)
- Verify that the /usr/ports directory is exported using
the showmount -e command
Setting up NFS Server:
You can use sysinstall to configure the nfs server.
Once you run sysinstall the daemons will be automatically started.
Sysinstall will also open the /etc/exports for editing.
Using sysinstall ensures that the deamons are started in the correct
order.
Setting up NFS Client: (in /etc/rc.conf)
nfs_client_enable="YES"
On The Client:
- Mount the /usr/ports that is exported on server, on the
client, as /usr/ports (See Below)
- Make the entry in /etc/fstab so you can easily mount
the exported directory in the future (hint: the 'fstype' will be nfs,
and you do not want it to automatically mount at boot)
- (Wait for the server to compile torsmo, since the NFS share
exported as read only)
- run: setenv WRKDIRPREFIX /usr/home/username (or use /usr/home/fbuser
if you did not create a user)
- change directory to /usr/ports/sysutils/torsmo
- run 'make' and then 'make install'
- (Wait for the server to build a package of emacs)
- run: cd /usr/ports/packages/editors
- run: pkg_add emacs-version#.tbz
- the Emacs package has now been installed on your client. notice
how much faster that was than compiling from the source
Mount an NFS Exported Directory
mount <host or ip of server>:<exported directory> <local mount point>
(examples)
mount 10.100.1.50:/usr/shared /media
mount freebie:/cdrom /cdrom
On The Server:
The ports collection is organized into categories, such as www,
ftp, net, editors, archivers, math, games, and sysutils.
inside each of these directories under the root of the ports tree, are
the directories for individual programs. Sometimes a program will
appear more than once, if there are multiple major versions of it.
Search the Ports Collection for a specific program:
cd /usr/ports
or in categories
cd /usr/ports/editors
- change directory to /usr/ports/sysutils/torsmo
- run the 'make' command (This will automatically download,
extract, patch, configure and build the source code)
- now run the 'make install' (This will automatically resolve any
dependancies, and install the program and its documentation)
- find and install some other port (zip, unzip, lynx)
- now, lets build a package, so you do not have to compile of each
client seperately
- run: mkdir /usr/ports/packages
- run: cd /usr/ports/editors/emacs20
- run: make
- run: make install
- run: make package
- now, the package will be created in /usr/ports/packages/editors
and will be named emacs-version#.tbz
- you can also use the ports system to uninstall a program. run:
make deinstall
- after you build something from source, alot of temporary files
are left over, run: make clean
On Both:
- run: pkg_info|less (this will show a list of every installed
program on your system)
- run: pkg_info -L torsmo\* (the escaped asterisk will
auto-complete the version number of the program for you) (the -L option
lists all files that were installed by the package)
- use pkg_delete to uninstall torsmo
- try to use pkg_delete to uninstall bash (why didn't this work)