Twitter Updates

Sunday, 19 July 2009

OSX eat my GNU

Trying to setup snapback2 bbackup software but started running into issues because the os x commands are based on the BSD variants not the more standard GNU versions used on most Unix's and Linux's.

Tried some manual installs but eventually after hitting a few dead ends found the package in port (mac ports formerly darwin ports).

1) Assuming Mac Ports is already installed (if not do that first, to tired to give instructions for that)
2) $ sudo port install coreutils
NB: since os x 10.5 sudo only works if you have a password set.
3) Get that pesky BSD cp out the way
$ sudo mv /bin/cp /bin/cp-osx
4) link to the new shiny GNU
$ ln -s /opt/local/bin/gcp /bin/cp

5) test old version
$ cp-osx --version
>/bin/cp-osx: illegal option -- -
>usage: cp [-R [-H | -L | -P]] [-fi | -n] [-pvX] source_file target_file
>cp [-R [-H | -L | -P]] [-fi | -n] [-pvX] source_file ... target_directory

Note The excellent handling when requesting the version!

6) Now the new version:
$cp --version
>cp (GNU coreutils) 7.4
>Copyright (C) 2009 Free Software Foundation, Inc.
>License GPLv3+: GNU GPL version 3 or later .
>This is free software: you are free to change and redistribute it.
>There is NO WARRANTY, to the extent permitted by law.
>Written by Torbjörn Granlund, David MacKenzie, and Jim Meyering.

This can be repeated for any other GNU commands you would like to map from /opt/local/bin/ to /bin. Most are prepend with g but if it is a 3rd party script that you are trying to get working it is often easier to make the default the gnu version.

No comments: