Friday, June 19, 2009

MacPorts registry error on upgrading gettext

MacPorts 1.7.0. I just ran:

sudo port upgrade outdated

and ran into the following problem:

---> Deactivating gettext @0.17_3
>> Error: Deactivating gettext 0.17_3 failed:
>> Error: Unable to upgrade port: dyld: Library not loaded:
>> /opt/local/lib/libintl.8.dylib
>> Referenced from: /opt/local/bin/ln
>> Reason: image not found

The same error occurs when I run ln, which is the GNU version /opt/local/bin/ln in my case. Native BSD versions like /bin/ln are unaffected.

The problem appears to be a port error caused by the port implementation shelling out to utilities like rm and ln without full paths, and getting GNU versions, since I have installed coreutils +with_default_names. Here's the fix. Edit the file /opt/local/etc/macports/macports.conf and set the MacPorts registry path to have BSD utils ahead of GNU utils:

binpath /bin:/sbin:/usr/bin:/usr/sbin:/opt/local/bin:/opt/local/sbin:/usr/X11R6/bin


Now you should be able to deactivate the old gettext, activate the new one, fix your coreutils, and complete the update:

sudo port deactivate gettext
sudo port activate gettext
sudo vi /opt/local/etc/macports/macports.conf ## return binpath to previous value
sudo port uninstall coreutils +with_default_names
sudo port install coreutils


Of course, now your coreutils are installed in /opt/local/bin with names like gls, grm, etc. On the whole, this appears to be the safer option. In cases where you really want to use the GNU version, something like this in your shell init file should do the trick:

case $(uname) in
Darwin)
if [ -x "$(which gdircolors)" ] ; then
eval `gdircolors ~/.dir_colors`
fi
if [ -x "$(which gls)" ] ; then
alias ls='gls --color=tty'
else
alias ls='ls -G'
fi
;;
Linux)
if [ -x "$(which dircolors)" ] ; then
eval `dircolors ~/.dir_colors`
fi
alias ls='ls --color=tty'
;;
esac

Thursday, June 18, 2009

Installing flash plugin on 64-bit Arch Linux

This post on the Arch Linux wiki is now out of date. There is a 64-bit flash plugin, and it is trivial to install:

# pacman -S flashplugin
# file /usr/lib/mozilla/plugins/libflashplayer.so
/usr/lib/mozilla/plugins/libflashplayer.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, stripped


Beautiful.

Wednesday, June 17, 2009

Posting to blogger from emacs using e-blog

g-client is a bit of a nightmare to get working. I plan to go back and play with it, since it sets up a lot of useful plumbing for google services. But for now, no go on the blog.

weblogger looks like it may work for other blogging services, but appears to have been broken by blogger API changes.

However, e-blog works great with a minimum of fuss. Simply install in a lisp directory, and add this to ~/.emacs:


(load-file '~/path/to/e-blog/e-blog.el')


Invoke with:

M-x e-blog-new-post


Here's a shortcut function:

(defun blog ()
(interactive)
(e-blog-new-post))

Tuesday, June 16, 2009

Juniper Network Connect VPN on 64-bit Arch Linux

There are several guides out there that describe running Juniper Network Connect VPN client on linux (see particularly MadScientist's guide for Ubuntu). These are just some notes on running the client from the command-line on a 64-bit Arch Linux system.

Since the netsvc client is 32-bit, we need to install some 32-bit support software. The method I use is to install 32-bit compatibility libs (effectively making my system multilib). Another solution would be to install and run netsvc from a 32-bit chroot environment.

To download Network Connect, connect to your VPN server with a browser and click the Network Connect Start button. This will download the software to ~/.juniper_networks.

Install 32-bit libs:

pacman -S lib32-glibc lib32-gcc-libs lib32-zlib


Extract your certificate:

cd ~/.juniper_networks
jar -xf ncLinuxApp.jar getx509certificate.sh
sh getx509certificate.sh your.vpn.server.com certfile


You can now run netsvc as follows:

netsvc -h your.vpn.server.com -u username -f certfile -r realm -p passwd


Your realm can be found from the HTML code of the server page. Look for something like:

<input name="realm" value="Your Realm" type="hidden">


The following simple script takes care of the whole thing:

#!/bin/bash
## Install as vpn.sh.
## Run as 'vpn.sh start' and input your password.
## It should be as simple as that.

## settings
HOST="your.vpn.server.com"
USER="YourUsername"
REALM="Your Realm"
JAR="/opt/java/bin/jar"
JUNIPER="${HOME}/.juniper_networks"
CERT="${JUNIPER}/network_connect/${HOST}.cert"
NCSVC="${JUNIPER}/network_connect/ncsvc"

start () {
## get passwd
read -s -p "Password: " passwd
echo ""

## get server certificate
pushd ${JUNIPER}
if [ ! -x "getx509certificate.sh" ]; then
${JAR} -xf ncLinuxApp.jar getx509certificate.sh
fi
sh getx509certificate.sh "${HOST}" "${CERT}" || die "failed get cert from $HOST"
popd

## run the network connect program
"${NCSVC}" -h "$HOST" -u "$USER" -f "$CERT" -r "$REALM" -p $passwd &
}

stop () {
## kill Network Connect
${NCSVC} -K
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
;;
esac