A Poor Man’s apt-get
I love package management systems. Taking the headache out of dependency management, version snarls, and platform — oh, wait. There is not (to my knowledge!) a simple cross-platform package manager that allows you to simultaneously manage software on multiple architectures at once.
What I Want
I want a simple package management system, whose commands I can run on any of my three major platforms, so that I can have identical versions of various tools (python, ruby, perl, mysql-lib, ocaml, etc. etc.) installed on all three platforms.
I want to be able to check in the commands to SVN, so that when I’m getting a project started on a new host, I just need to check out the latest version of the project, then run a few commands to download/compile/install the various tools.
I don’t want to use different systems on different platforms. I suppose one solution would be a front-end that translates commands into the appropriate ports/rpm/apt-get/whatever command, but that’s icky.
My hacked-together solution
Most of my tools install with a standard ./configure && make && make install or a variant thereof. So I simply wrote a set of bash functions that take care of these steps (along with the downloading, checksumming, etc.).
See _common.sh for my set of routines.
An example installer
Now, on any platform, I can just run the following shell script to install an up-to-date version of the MySQL libraries and binaries:
#!/bin/sh
. _common.sh
#
## Settings
name="mysql-5.0.33"
file_name="$name.tar.gz"
dir_name="$name"
install_path="$HOME/external-software/$PLATFORM/stow/$name"
url="http://mirror.services.wisc.edu/mysql/Downloads/MySQL-5.0/$file_name"
md5="10cb85276a1468c7906a4ff4dd565d61"
##
#
# Sanity checks
cd /tmp
download_url "$url"
verify_file_md5 "$file_name" "$md5"
expand_file "$file_name"
pushd "$dir_name"
compile_gnu "--prefix=$install_path"
install_gnu
stow_dir "$install_path"
popd
cleanup_file_and_dir "$file_name" "$dir_name"`
This is basically a poor man’s version of a Portfile.
Of $PLATFORM
My single favorite environment variable is $PLATFORM. This variable simply combines operating system and architecture information. Values I’ve worked with include:
Darwin-Power_Macintosh
Darwin-i386
Linux-i686
Linux-x86_64
SunOS-sun4u
I stash all of my binaries in subdirectories by $PLATFORM, which makes everything neat and tidy.



