#!/bin/sh

# Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

# Date: 2009-03-17 10:54:09-0400

# This script describes how i'm trying to build the xulrunner-ipc
# extension.

# each line should run without failure.
set -e

# we need at least these packages to be installed:

dpkg -l xulrunner-dev build-essential > /dev/null

# fetch files with known sha1sums if they are not already present:
get_and_check() {
    url="$1"
    sum="$2"
    file=$(basename "$url")
    
    if [ -e "$file" ] ; then
       if ! ( printf "%s  %s\n" "$sum" "$file" | sha1sum -c) ; then
	   rm -f "$file"
       fi
    fi
    if ! [ -e "$file" ] ; then
	wget "$url"
    fi
    printf "%s  %s\n" "$sum" "$file" | sha1sum -c
}

get_and_check 'http://mozilla-enigmail.org/ipc/ipc-source-1.2.0.tar.gz' \
 d43554c27e23999973701e032173dc665d9e3f21  
get_and_check 'http://lair.fifthhorseman.net/~dkg/src/xulrunner-ipc/debian-xulrunner-ipc-makefiles.tgz' \
 dc5d43fc63604c44ed44e82c6ad926644f742666

tar xzf ipc-source-1.2.0.tar.gz
tar xzf debian-xulrunner-ipc-makefiles.tgz

cd ipc
make
