Friday, May 29, 2009

Fixing pkg_add -r on FreeBSD (things no one tells you)

On FreeBSD when you want to install a program you have to make a choice. Your two choices are to install a package or compile from ports.

Installing a package means you download a binary package and copy all the files to the right places. Everything is already compiled. This is how Windows works. When you install a piece of software it has already been compiled.

Your second option is to compile from ports. What this means is that the source files are downloaded and then compiled on your system. You need to have all the prerequisites for the compile to be successful.

Why choose one over the other? Well with packages sometimes the binary doesn't work. Either you happen to have a newer or older file than what the creator compiled it with or you changed something with your system and it doesn't match anymore with the author's compiled environment. However packages are fast to install. No need to break out gcc and compile source code.

Ports on the other hand will almost always work. They are targetted for your system because you are compiling them. It takes a bit longer but you also get to customize any of the build options.


To install a program from package you use this command:

pkg_add -r

Examples:

pkg_add -r xorg
pkg_add -r nano
pkg_add -r curl

I like pkg_add -r because it fetches the package for me and installs it. It does that by looking at your system's uname (I think) and forms a URL to FreeBSD's software repository. The problem is that after a while repositories are taken offline. So if you are using some older version of FreeBSD and trying to do a pkg_add -r it will return that it can't find the package.

The thing is, the package is probably still around but in a newer form. The newer package is compatible with your version if you can find it. FreeBSD makes a statement that says packages in the same stable branch will always be compatible.

To force pkg_add -r to bend to your will you edit the PACKAGESITE environment variable. If you want to force pkg_add -to download FreeBSD 7-STABLE packages, set PACKAGESITE to ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-7-stable/Latest/.

Be very careful though that you point to the right URL. I actually pointed to the wrong URL and downloaded 32-bit packages instead of the amd64 packages which I needed:

http://ftp2.at.freebsd.org/pub/FreeBSD/ports/amd64/packages-7-stable/Latest/

Tuesday, May 12, 2009

Ubuntu: Getting files off your phone using bluetooth

Sometimes you just want to get a file off your phone. One of the easiest ways to do this is bluetooth. The problem is that some carriers (such as Verizon) lock their phones down so you can't transfer files from your phone to your PC over bluetooth.

The real technicality is that while the phone can't initiate the sending of the file, you can still browse the phone for files and pull them.

So far the most useful tool I found to get files off my phone (which is an LG Chocolate) is obexftp.

To get started install the package using Synaptic then open up a console and type:

$ obexftp -b

When you find a device you want you connect to it like so:

$ obexftp -b 00:1E:75:ED:62:2C -l
Browsing 00:1E:75:ED:62:2C ...
Channel: 7
Connecting...done
Receiving "(null)"...
done
Disconnecting...done

The way obexftp works is that you basically have to run the command over and over with different options to get what you want. So after running it with this "list" option I say I want to browse the folder "MyPictures".

$ obexftp -b 00:1E:75:ED:62:2C -c MyPictures -l
Browsing 00:1E:75:ED:62:2C ...
Channel: 7
Connecting...done
Sending "MyPictures"... done
Receiving "(null)"...
done
Disconnecting...done

Now that I know the location of the file I can procede to actually get the file.

$ obexftp -b 00:1E:75:ED:62:2C -c MyPictures -g 0512091207.jpg
Browsing 00:1E:75:ED:62:2C ...
Channel: 7
Connecting...done
Sending "MyPictures"... done
Receiving "0512091207.jpg"...|done
Disconnecting...done

Easy enough. Probably not the most intuitive way to do things but it gets the job done.