You are here: DesktopBSD Wiki Portal » doc » The Ports System
Ports are the crown jewels of FreeBSD. If you are looking at the ports you will see many makefiles. Those makefiles are the construction manuals for many applications and other addons, like fonts etc. Those makefiles make things easy because they do all the work that you need to do to install an application and they'll rarely give you trouble. In fact they can even resolve dependencies, fetch the current sourcecode, patch applications, etc. Many beginners will hesitate because of the saying “You have to compile the application on FreeBSD in order to get the latest version”, but it's not hard as it seems. Of course errors may happen because of faulty operation or a system misbehavior. However, this can also happen on some Linux distros too. It sometimes even happens when using their binary package systems. Nothing is perfect, so relax.
In practice it's rather easy, but to some extent it is a pain to gather the needed information. Yes, there is a nice handbook and so on, but it's difficult for a beginner to distinguish between many of the possible ways of doing it that the system offers.
At first, this is very important, you have to refresh the ports-tree. This you can do with cvsup or portsnap. The latter is easier to use and accelerates the update-process. So let's begin with the easier one, portsnap.
# su
-makes you into root
# portsnap fetch extract
-fetches the portstree from FreeBSD portsnap servers and then extracts it into your /usr/ports directory
That's it, you're all done. Now you're ready to use your ports tree. For future updates of the portstree portsnap fetch update is sufficient.
# su
-makes you into root
# cd /usr/share/examples/cvsup
-change the directory to the example configuration of cvsup
# cp ports-supfile /etc/ports-supfile
-copy it to /etc
After this, you have to edit the configuration in /etc
# ee /etc/ports-supfile
Scroll down to this line,
and change it to this,
cvsup4 is one of many cvsup mirrors, you can choose between different country-codes too (e.g. de and so on).
Press “escape” while in the editor, select the “leave editor” option and don't forget to save your changes.
Now you can update the ports-tree via,
# cvsup -g -L 2 /etc/ports-supfile
This will take a while. Make sure you do a,
# cd /usr/ports
# make fetchindex
This is very important. If you forget it, something will break.
edit or create:
# ee /etc/make.conf
add this lines:
SUP_UPDATE= YES SUP= /usr/local/bin/cvsup SUPFLAGS= -g -L 2 SUPHOST= cvsup4.FreeBSD.org SUPFILE= /usr/share/examples/cvsup/standard-supfile PORTSSUPFILE= /usr/share/examples/cvsup/ports-supfile DOCSUPFILE= /usr/share/examples/cvsup/doc-supfile DOC_LANG= fr_FR.ISO8859-1 en_US.ISO8859-1
update ports:
# cd /usr/ports/ # make update
update distribution (all):
# cd /usr/src/ # make update
you need a /usr/src/Makefile before
Portupgrade is a requirement for certain commands used in this howto. So you have to install it first. But make sure you have refreshed your ports-tree!
# cd /usr/ports/sysutils/portupgrade # make install clean
Now it is ready and you have some powerful tools at hand.
I am using VLC (the universal mediaplayer) as an example. To find what your are looking for,
# su
# whereis vlc
This will print,
# /usr/ports/multimedia/vlc
So we know the path now and can proceed with installing the application. And again, you have two possibilities to do so.
# su
# cd /usr/ports/multimedia/vlc
# make install clean
Advantage to using this: you can use some special switches to configure the application.
For example,
# make WITH_X264=yes && make install clean
WITH_X264 will compile the x264 videocodec in VLC.
Too see all of the dependencies of a certain application, you can do a
# make readmes
This will compile a file named README.html, which can be read with Firefox for example or any other browser.
/usr/ports/multimedia/vlc/README.html
Enter this in the browser an you will see the dependencies and so on.
# portinstall vlc
This command will install vlc, it's pretty much the same as make install clean.
If the command can't find the application, you have to add the directory of the file.
# portinstall multimedia/vlc
Portinstall is a part of Portupgrade.
# portupgrade -N vlc
and
# portinstall vlc
are the same thing
With pkg_deinstall you can deinstall a certain application. Again there are many possiblities.
To make sure you do not break some dependencies while removing an application, you can gather the info about it.
# pkg_info | grep vlc
This will print,
vlc-0.8.5_2
# pkg_info -R vlc-0.8.5.2
This commands lists the dependencies. But vlc does not have any of it in this case, so you can safely remove it.
# pkg_deinstall -d vlc-0.8.5_2
The option -d will clean up all directories of the deinstalled port. If vlc did have any dependencies you can remove them and the application itself with
# pkg_deinstall -R vlc-0.8.5_2
Beware that this will not remove the dependencies that other programs are using.
Of course you can force remove an application - but beware, you should know what you are doing!
# pkg_deinstall -f vlc-0.8.5_2
If you want to force the deletion of the program and it's dependencies, you can use
# pkg_deinstall -Rf vlc-0.8.5_2
You can also type just vlc instead of vlc-0.8.5_2, as long as a pkg_info | grep vlc shows the package vlc-0.8.5_2, which in this case it has. So you could use
# pkg_deinstall vlc
The other method to deinstall an application is to use make in the directory of the choosen port.
# cd /usr/ports/multimedia/vlc
# make deinstall && make clean
You can easily upgrade ports via portupgrade.
# portupgrade -a
this would update all of it. This is not a good idea, because something can and will break. So do it port to port. And remember to look into /usr/ports/UPDATING to gather the needed information of important changes in ports! And don't forget do an update only if you're really in need of it, don't do it because it's new ;)
# portupgrade vlc
This command line will update vlc. If there is something new found, then it will go through the process of updating it.
Maybe certain applications are in need of fresh dependencies (some new library etc.), so you have to compile those dependencies too.
# portupgrade -r vlc
This can take some time, so take a look at the dependencies first! Important, use the man pages - for example man portupgrade, so you can fine-tune certain things.
Most of time a simple portupgrade vlc is enough.
And of course, you can do it the manual way in the application directory.
# make deinstall && make reinstall clean
This will deinstall the application and reinstall it.
If the application will not register, you can force it
# make reinstall FORCE_PKG_REGISTER=yes
In FreeBSD there is the possibility to use binary packages too.
# pkg_add -r vlc
This will remotely fetch the universal mediaplayer vlc and install it.
The advantage: you don't need to compile it, saving hours or even days.
The disadvantages: the software may be a few versions behind and the program will not be optimized for your system thereby making it a little slower.
Think of optimizing things for your system as getting something customized just for you.
There are some other uses for binary packages. One of these other uses is that if you have more than one computer in your home (all with DesktopBSD for example), it's not necessary to compile vlc on every machine. Save time and create some binary packages of your own.
# pkg_info | grep vlc
# pkg_create -b vlc-0.8.5_2
This creates a binary package, vlc-0.8.5_2.tgz
You can install it on the other machines with
# cd <directory of the application> (ex. cd /home/<username>/Desktop/>
# pkg_add vlc-0.8.5_2.tgz
Most of the time all of your machines will have the same configuration, so this is sufficient. But it may occur that some machine lacks a certain library, application etc. which is a dependency.
# pkg_create -Rb vlc-0.8.5_2
With the switch -R you will also create the programs dependencies as packages. To install it on the other machine, you have to make sure that the application and all of its dependencies are in the same directory.
# cd <directory of the application and it's dependencies> (e.g. cd /home/<username>/Desktop/>
# pkg_add vlc-0.8.5_2.tgz
This will add the application and the dependencies needed to the computer.
This howto was in a hierarchical order.
-refresh the portstree, if you are using cvsup, do not forget a make fetchindex afterwards!
-you can fix possible errors in the database with
# pkgdb -uF
This command will do some things automatically, in fact it will show you certain possibilities. Most of the time it chooses the right ones. But sometimes you have to manually choose the right one, especially if you have done some changes, like removed applications with dependencies etc.
I hope this is somewhat useful for a beginner. If you see some possible errors, change it or tell me in the forum.