FreeBSD Challenge: Day 04 of 30
I had a ton of fun today getting acquainted with FreeBSD. While I am still installing my common set of software I use daily, I learned many valuable lessons, and why FreeBSD has to be so stable. Hint: its not just because compiling ports sometimes takes eons. All Joking aside, it was a great day, and very profitable. Read on for more!
Adventures in Package Management
Gather round you people. It’s time for a story of BSD, of might and magic, and frustration. Today, I pretty much got the common tasks of installation, updating, and upgrading down, albeit with a few hiccups along the way. If there is one piece of advice I must give a new user of FreeBSD it is this question:
“Would you like a side of Ports or Binaries with your BSD salad sir?”
Allow me to elaborate. Sure, veterans of BSD can argue technical reasons on how they can coexist, and I’m sure I will learn along the way some methods that do work in that respect, but as a new user, try your hardest to make this decision early. Not only will this result in less frustration and headache early on, but make you much more in tune with your system going forward. Mixing and matching management types is never a fun thing anyway. In summary, I personally found this:
Using the Ports system:
- Works as advertised when you get the hang of it
- Updated and fresh software
- Full control of the software installation process
- Can be quite slow to compile programs on lower end CPU types (as I found out in VirtualBox testing)
- You must maintain your packages in a structured manor. This is further helped by utilities such as portmaster and portsnap
- When you encounter errors, you must do some digging to get down to the root cause
- Easy, plain English searching, installing, and maintenance of binary packages
- Many tools available for the job
- Confidence that package will install needed dependencies without too much of a fuss
- I’ve found binary packages to be a little old in comparison to things in the Ports tree
- When things do not install correctly, output on the issue is not always transparent (due to lack of verbose output vs. compiling)
- Availability of binaries over the same set of applications available in Ports.
I found very early on, when I attempted to install VLC through ports, that my local perl installation installed by pkg_add (could also be through pkgng as well), was on conflict with the version VLC wanted through ports. I took a step back and tried to think of what I did way in the beginning. I had first added packages with ‘pkg_add -r’ and tried a port or two, then converted over to pkgng with ‘pkg2ng’. In hindsight, that may have been the wrong thing to do. This most certainly contributed to my package conflicts, now that I landed on using the Ports system exclusively.
So what do you do?
I visited many web pages, seeked IRC help on the #freebsd channel on irc.freenode.net, among other things. Here are some helpful troubleshooting tips I did come across that worked for me:
- Did the package fail with a stop message?
- Did you try removing configuration options with ‘make rmconfig-recursive’ and installing again?
- Have you cleaned the build directory you are in?
- Did you try removing the directory you are in and fetching the list of ports?
These of course, are just some of the things you can do to elevate your problem. Two such tools that made this headache a bit easier for me was portsnap and portmaster. Portsnap will fetch the latest ports tree from the available FTP mirror, and make life grand. It will also make upgrading your system relatively painless. You can then use portmaster to do all your dirty work.
Wrangling portsnap and portmaster
On first run, I had to fetch, extract, and update. This three staged “super attack” will pull the ports tree from the internet, extract all the contents, and update your local ports tree on your system. If you were a new user like me and inadvertently deleted a ports folder (in my case ‘multimedia/vlc’), this process can remedy such a thing. Once you have extracted and updated your ports tree on the first run, you only need to run the “fetch” and “update” commands from now on to keep things fresh.
mkdir /usr/ports portsnap fetch portsnap extract portsnap update
You can also combine portsnap commands for a one-two punch:
portsnap fetch update
Once I had the VLC directory back and intact, I was able to install to a certain point. Ports complained that I needed some newer packages as well as dependencies. So in this case, what do you do? I found the simplest way was to run the following:
portsnap fetch portsnap update portmaster -b -d -y -a --no-confirm
I am sure there are some better ways to do this, and will be told as such, but for now that is what worked fine for me. The exciting part about Unix and Linux is always finding great ways to do amazing things. Also word to the wise, plan according on disk space if you are going to use the Ports system. Yes you can do clean up regularly (using ‘make install clean’ is a good habit), but you will be expanding some decent space if you are compiling the programs yourself. Generally, the process of maintaining comes down to 4 things:
- Fetch the latest ports tree
- Update the locate ports tree on your system
- Update your installed ports using portmaster or your preferred tool
- When possible, upgrade your system with freebsd-update
There are a few other things I wanted to mention. When you experience issues compiling a package, using a debugger/analyser such as gnomelogalyzer from “www.freebsd.org/gnome/gnomelogalyzer.sh”, will definitely help you pin down trouble areas when you hit a snag. If you do get a package conflict and need to update the existing package, running ‘make deinstall && make install clean’ will reinstall that package and get it up to date. There may have been a few other things, but it was quite a busy day for me.
That’s all for today. Until tomorrow…
Huge thank you to TJ of @bsdnow for additional help! You can reach him on twitter using the handle