Package Management in FreeBSD

When Bankei was preaching at Ryumon temple, a Shinshu priest, who believed in salvation through the repitition of the name of the Buddha of Love, was jealous of his large audience and wanted to debate with him.
Bankei was in the midst of a talk when the priest appeared, but the fellow made such a disturbance that bankei stopped his discourse and asked about the noise.

“The founder of our sect,” boasted the priest, “had such miraculous powers that he held a brush in his hand on one bank of the river, his attendant held up a paper on the other bank, and the teacher wrote the holy name of Amida through the air. Can you do such a wonderful thing?”

Bankei replied lightly: “Perhaps your fox can perform that trick, but that is not the manner of Zen. My miracle is that when I feel hungry I eat, and when I feel thirsty I drink.”

 

 

FreeBSD is one of those few operating systems which are truly miracules. And the best thing about FreeBSD is that the basics work very well and they always work the way they are supposed to work. Ofcourse FreeBSD has a host of advanced features which one can read about on their website.

In this article I would talk about the small things I liked in FreeBSD and its wonderful package management system.
The first thing that one notices about FreeBSD is the bootloader. The good feature about this loader is it’s ability to find and display all the available drives automatically. The FreeBSD time to boot and shutdown is also considerably lesser than most modern operating systems including Linux as well as M$ Windoze.

Once we login there are certain things which make FreeBSD look a bit older and boring. Right after login the contents of the file /etc/motd is displayed. By default it is a long boring text file. I have removed all lines from it and just written my computer name.

The default shell in FreeBSD is sh which is not the kind of shell one would drool over after hearing its features. It’s just an ordinary shell which works. Having used Linux for years, I have gotten used to bash and bash is what I want which leads me to a crucial question – How does one install packages in FreeBSD ?

Package Management in FreeBSD –
FreeBSD provides two technologies – ports and packages. There are over 13,000 applications available via ports or package. A port is collection of files designed to automate the process of compiling an application from source code. A package is a precompiled copies of all the commands for the application, as well as any configuration files or documentation.

From the FreeBSD Handbook –

Package Benefits

  • A compressed package tarball is typically smaller than the compressed tarball containing the source code for the application.

  • Packages do not require any additional compilation. For large applications, such as Mozilla, KDE, or GNOME this can be important, particularly if you are on a slow system.

  • Packages do not require any understanding of the process involved in compiling software on FreeBSD.

Ports Benefits

  • Packages are normally compiled with conservative options, because they have to run on the maximum number of systems. By installing from the port, you can tweak the compilation options to (for example) generate code that is specific to a Pentium IV or Athlon processor.

  • Some applications have compile time options relating to what they can and cannot do. For example, Apache can be configured with a wide variety of different built-in options. By building from the port you do not have to accept the default options, and can set them yourself.

    In some cases, multiple packages will exist for the same application to specify certain settings. For example, Ghostscript is available as a ghostscript package and a ghostscript-nox11 package, depending on whether or not you have installed an X11 server. This sort of rough tweaking is possible with packages, but rapidly becomes impossible if an application has more than one or two different compile time options.

  • The licensing conditions of some software distributions forbid binary distribution. They must be distributed as source code.

  • Some people do not trust binary distributions. At least with source code, you can (in theory) read through it and look for potential problems yourself.

  • If you have local patches, you will need the source in order to apply them.

  • Some people like having code around, so they can read it if they get bored, hack it, borrow from it (license permitting, of course), and so on.

So here’s how we can install bash.

Package method –
$ pkg_add -r bash

Note the -r option here. This would download the package from the internet (remotely). Else we must have a downloaded copy of the package.
Some of the commands of the pkg_tool are pkg_add , pkg_delete, pkg_info.

Ports method –
$ cd /usr/ports/shells/bash
$ make install clean

One good feature about ports and packages is that both take care of all the dependencies.

Once bash is installed make it the default shell by editing the /etc/password file. The last part of the user entry is the default shell. e.g. if root is to have a default shell as bash then the vipw should look like this –

$ vipw
root:$1$.r9nwhwd$Lq6FA/mYO2OIQ4DPRMQMm0:0:0::0:0:Amarjyoti Krishnan:/root:/usr/local/bin/bash

It is a nice idea to add bash to the /etc/shells file.
Another thing that all Linux users like is the directory listing withthe color option. Unfortunately the ls that comes with FreeBSD does not have the color option. But the gnuls is available both as a port and and package.

$ pkg_add – r gnuls

After the gnuls is installed. Make this the default ls.

$ mv /bin/ls /bin/ls.orig
$ ln -s /usr/local/bin/gnuls /bin/ls

Add the following in the .bashrc or .bash_profile file

alias ls=’ls –color=auto’

 
Now whenever the ls command is typed it would display the output in color.

Some of my other favourates shell based programs are lsof , mc, vi . All of these are available in FreeBSD.

We now go back to some configuration.

$ /stand/sysinstall  (in older FreeBSD versions) or
$ sysinstall

Take the Configure option and configure the mouse. Generally the default options work so the first thing that one must do is to enable the mouse. If the cursor does not move then try changing the Type and Port of the mouse.

With time we all need to upgrade the software and this is where ports shows its true class. By updating the ports tree we can easily get the latest ports on our system. All one needs to do after that is to goto the /usr/ports directory and make world. The entire system is updated.

We first need to install CVSup

# pkg_add -r cvsup

Then run the program

# cvsup -L 2 -h cvsup.FreeBSD.org /usr/share/examples/cvsup/ports-supfile 

Click on the button with the green arrow and the ports tree is updated.

 

I guess this is one of the reasons for me to say that FreeBSD is a miraculous Operating System. It’s concepts are so simple and powerful that all other Operating systems are trying to emulate it. There is a flavour of Linux called Getoo Linux which has the ports system for Linux. Other Linux distros are trying apt as a solution. The M$ World is working hard on Smart Update and the list just goes on.

One often wonders why FreeBSD is not as popular as Linux or M$ Windoze. Well the only explaination I could get was that the FreeBSD developers do not actually benefit from the OS in terms of money. This leaves them time to develop a lot of software on passion alone. And naturally, they are left with no time to market the product. This is one place where our friends at Microsoft and Linux win over FreeBSD.

 

Leave a Reply