#!/bin/sh
# Note that this script is only meant to be used to download the SourcePackageManager repository without installing fossil.
# Usage: Create a new directory. Copy this script into the directory. Run this script.
[[ "$1" == "" ]] && exit 1
tmpf=$2
[[ "$2" == "" ]] && tmpf=tmp-$(date +%s)
curl -L http://www.fossil-scm.org/download/fossil-linux-x86-20130216000435.zip > fossil.zip
unzip -o fossil.zip
[[ "$?" == "0" ]] && rm fossil.zip
export PATH=$(pwd -P):$PATH
fossil clone http://chiselapp.com/user/mastersrp/repository/SourcePackageManager .SPM.fossil
mkdir -p .SPM && cd .SPM
fossil open ../.SPM.fossil
fossil close ../.SPM.fossil
./configure
./spm.sh fetch configure build
[[ "$?" -ne "0" ]] && exit $?
export PATH=$(pwd -P)/build/bin:$PATH
cd ..
fossil clone $1 ${tmpf}.fossil
mkdir -p $tmpf
cd $tmpf
fossil open ../${tmpf}.fossil
spm fetch configure build