View Single Post
Old 06-03-2009, 03:28 AM
graedus graedus is offline
Senior Member
Join Date: Jul 2006
Location: .mx
Posts: 605
Thanks: 0
Thanked 0 Times in 0 Posts
Default Installing apps from ports using PCBSD 7.1 / Vanilla FreeBSD
This procedure works for PCBSD 7.1 "Galileo".
If you wish to use this procedure in FreeBSD or a previous version of PCBSD, ignore all instances of "runports".

First of all, understand how ports and packages work by first reading the FreeBSD handbook's Chapter 4 on Ports

*** ATTENTION: Vanilla FreeBSD users skip this section until further notice! ***

Second, understand that PCBSD is tweaked and hacked to the bone, and, even though you might be savvy and seasoned enough with FreeBSD, you might break it if you mess with the base system. In the same line, understand that KDE is an essential part of PCBSD and PBI's and that you can't strip it away without breaking all PCBSD functionality (you can install other desktop environments alongside and still get less than full functionality). I totally ignore and doubt if there is any kind of documentation or even if it is possible to convert a vanilla FreeBSD installation into PCBSD. And one last thing on this respect, I'm completely certain that you can't upgrade any FreeBSD-6-based PCBSD system (such as 1.4 or 1.5) into PCBSD 7 by upgrading the underlying FreeBSD system using by making buildworld from cvsup'd source or freebsd-update.

Third, read (the still a bit lacking) PCBSD's User Handbook section on Changing the LOCALBASE to understand how PCBSD treats ports.

*** ATTENTION: Vanilla FreeBSD users RESUME reading from this point forward ***

Now, onto business:

- I highly recommend you install the ports-mgmt/portupgrade suit of tools. The procedures I explain mostly deal with it. I also, prefer packages over ports whenever necessary, to avoid compile time. Most of the computers I deal with don't have enough muscle to compile very large ports in a short time.

- There is no reliable ports-gui available. Even the BPM frontend is lacking in information as a reference source. For reference purposes, consult the Freshports Database

0. Open Konsole or other terminal emulator, get root credentials and switch LOCALBASE. You do this the quick way by:

Alt+F2, type "Konsole" press enter.
In Konsole run the following commands
Make sure you do this procedure before managing ports!
The command prompt will be a # if root. If it's > , then you invoked it as a normal user. Exit, su, and runports once again.

1/A. If you didn't add the ports tree at the installation time, run the following command:
portsnap fetch extract
You can do this too with csup, but IMHO portsnap is easier to use.

1/B. If you already have the ports tree in place, update it before installing new ports:
portsnap fetch update
2. In order to install a port from scratch, change directory to that port's sourcedir. The location is /usr/ports/{ports-category}/{port-name}. You can obtain this information from freshports. You can find other ways to search for ports using the command line at this link in the FreeBSD Handbook. I find useful having /usr/ports/ as a working directory, you can pretty much complete the names of the ports with the directory hierarchy or ls * with the help of the tab button.

I'll use as an example for this ports-mgmt/portupgrade, which by the way is a tool that I'll keep making reference, so it's a good idea to install it right away.

cd /usr/ports/ports-mgmt/portupgrade && make install clean
At this time, the system will download all files necessary and install all dependencies for this application before adding the application itself.

This will take a few minutes, and some compiling will be done. Be patient. It is important to at least have this application installed from source using the latest ports.

3. Once you have portupgrade installed, you can proceed and easily install any other application in ports.

In a nutshell, what I suggest to do is the following:

- First, attempt to fetch the latest binary packages.

- If some dependency fails to be fetched, then force to fetch the available binary packages in the whole dependency chain (even if not the latest).

- If still some dependencies couldn't be fetched as binary packages, compile just those needed.

- This procedure tries to avoid adding "building" dependencies (those required to compile the port), since portinstall -F will fetch those anyway.

3/A. To fetch the latest binary packages, run:
pkg_fetch -R port-category/port-name
If you receive no failed packages list, you're good to install straight away to 3/C with no issues, if not, check 3/B

3/B If you do receive a list of failed packages it means the latest version is not available as a package. Force fetch a not so new version of those dependencies:

portinstall -fFPPk port-category/port-name
Using the -PP will force to download packages only, -k will skip those failed dependencies, and -f will force the download of a previous version as necessary.

3/C. After fetching all binary packages from the internet, go ahead and install the application (You can do this offline). The name of the tarball appears on the output of either pkg_fetch or portinstall.
pkg_add /usr/ports/packages/All/portname-version.tbz
pkgdb -u
For your convenience, if using csh or similar shell, you can type part of the package name and complete it using the tab button.

If still some fetching failed, execute portinstall. It will compile just the missing ports.
portinstall -P port-category/port-name
I wish pkg_fetch, portinstall and portupgrade behaved this way automatically.

Some final notes:

0. This procedure works, and will be foolproof most of the time. I've lost a lot of time in the past installing and updating ports so I know pretty much what I'm doing. If this procedure looks long or tedious to you, you're free to do otherwise and learn the hard way of your mistakes. My advice is to follow these suggestions, this is the shortest path I've found to get ports going. If you have any ideas on how make this procedure easier, shorter, and foolproof, please don't hesitate and let me know.

*** ATTENTION: Vanilla FreeBSD users, the guide ends here, PCBSD specifics follow ***

1. Don't try to install desktop environments such as gnome or windowmaker using runports. Those won't work (at least not with full pcbsd functionality and without further tweaking things). Stick with the PBI's, or try to modify the PCBSD base at your own risk of breaking it up.

2. I wished there would be a special instance of the run window (alt+f2, perhaps meta+alt+f2, which would allow to run commands with a switched LOCALBASE (equivalent of executing runports and the application name).

3. In order to run an application (either command line based or with graphical user interface), you must do it from the command line. If it has a graphical user interface, you must do it from a terminal emulator (such as Konsole) within a graphical desktop environment (such as KDE, the default DE that appears when you login to PCBSD normally).

So, open up Konsole, and type the following command
the following message will appear:
Running as user "user". You may now run programs in the FreeBSD Ports tree
The prompt will change to a ">"

Once this is achieved, type the name of the port you wish to run. For example, portinstall is an application installed from ports, and was executed using this premise. If editors/emacs or sysutils/rename was installed, then by typing "emacs" or "rename", the respective application will be executed.

Note: Do not try and execute a graphical application as root using this procedure, since it will fail to run.

Here's why: Since you logged in as a user using a graphical desktop environment, a graphic server was already started, in this case it's called If you try to execute a graphical application as root, root will try to start by its own, but since FreeBSD can only have one instance of running, it will fail to start the graphical server, ergo the application won't start. No, you can't initially login as root, this is disabled by default, and I suggest you not to tweak the system to be able to do that.

Instead, to run a graphical application as root, press alt+f2 and type:
kdesu application-name
Common application names you might wish to run are the editor "kwrite" and the file manager "konqueror".

- EDIT: I updated this procedure.
Reply With Quote