Monthly Archives: November 2013

Launch Aquamacs from within a shell

Problem

  • Opening Aquamacs from the shell (/Applications/Aquamacs.app/Contents/MacOS/Aquamacs) throws many deprecation warnings.
  • Multiple instances of Aquamacs are appended to the dock when launched, and it is annoying.

Solution

  1. Open Aquamacs.app
  2. Click “Tools
  3. Click “Install Command Line Tools

Resolution

The path to Aquamacs after installing the command line tool package is /usr/bin/aquamacs

Building CATAPACK on OS X

What?

CATAPACK is a package for management and manipulation of photometric catalogues of stellar fields, particularly suitable for the determination of accurate astrometric solutions […] (ref)

Download

I could not find a copy of CATAPACK on the internet, however the source code is GPLv2, so I have decided to provide the software on this site.

Link: CataPack-2.1.19.tar.gz

Update (06/19/2014)

CataPack found itself a maintainer and a minor revision bump as well…

Main site: CataPack
Link: CataPack-2.2.4.tar.gz

Building

Prerequisites

Dependencies

Compiling

Install dependencies

sudo port install gsl gtk-engines wcslib wcstools

Unpack the source

tar xf CataPack-2.1.19.tar.gz
cd CataPack-2.1.19

Remove the usage of ancient RSML entries

gsed -i -e 's|.so|#.so|'  
src/CataCal.in  
src/gsc2.in

Build the source

./configure --prefix=/usr/local
make

Install CATAPACK

sudo make install

 

Remote filesystems and mlocate

Have you ever worked in a clustered environment that provided remote home directories?  Furthermore, have you ever been annoyed by the fact mlocate does not descend into these remote file systems by default?  Me too.  I’ve written two small BASH scripts to address this problem.

updatedb_extern

#!/bin/bash

# Edit DEST to point to a local directory you have write access to
DEST=/path/to/local/database/directory

#Don't edit below this line (no point)
EXTERN=( "$@" )
DATABASES=()

#Did we receive any paths to process?
if [ -z "$EXTERN" ] ; then
	echo "No path(s) specified."
	exit 1
fi

#Simple adapation logic to ensure we will have a writable data area
if [ ! -d "$DEST" ] ; then
	mkdir -p $DEST 2>/dev/null
	if [ $? != 0 ] ; then
		DEST=/var/tmp/mlocate
		mkdir -p $DEST 2>/dev/null
		if [ $? != 0 ] ; then
			echo "No suitable path to store locate database."
			exit $?
		fi
	fi
fi

#Generate database names based on external path
#Example: /home/myuser becomes _home_myuser.db
for path in "${EXTERN[@]}"
do
	database=$(echo $path | sed -e "s|/|_|g")
	DATABASES[${#DATABASES[*]}]="$DEST/${database}.db"
done

#For each external path generate an mlocate database
MAX=${#EXTERN[@]}
for (( i=0; i<$MAX; i++))
do
	i_fake=$(( i + 1 ))
	path=${EXTERN[$i]}
	dbpath=${DATABASES[$i]}
	echo "[$(echo $(( $i_fake * 100 / $MAX )))%] $path -> $dbpath"
	updatedb -l 0 -o $dbpath -U $path
done
echo

The developers of mlocate were nice enough to implement the environment variable, LOCATE_PATH, to extend the database search path.  We’re going to use it to our advantage with the following script.

updatedb_extern_setup

#!/bin/bash

DEST=$1
if [ -z "$DEST" ] ; then
	echo "No database path specified."
	exit 1
fi

for db in $DEST/*.db
do
	DELIM=":"
	if [ -z "$LOCATE_PATH" ] ; then
		DELIM=
	fi

	LOCATE_PATH=${LOCATE_PATH}${DELIM}${db}
done
echo "$LOCATE_PATH"

 

Example Usage

In your ~/.bashrc or ~/.bash_profile (or ~/.profile):

export LOCATE_PATH=`update_extern_setup /path/to/local/database/directory`

In your crontab (e.g. crontab -e):

* 2 * * * updatedb_extern /home/username /some/remote/path

Manually:
updatedb_extern /home/username /some/remote/path