#!/bin/sh
#
# Unpack the file(s) for the build architecture into tmp directory.
# Once this script is complete, files/ will hold the personal proxy, changelog,
# and may contain other doc files in doc/*.

mkdir tmp
mkdir files
mkdir files/docs
cd tmp

if [ ! "$1" ]; then
	arch=`dpkg --print-architecture`
else
	arch=$1
fi

case "$arch" in
  i386)
	file=rc5desproxyper-*-linux-x86.tar.gz
	binary=rc5desproxyper
	conffile=rc5desproxyper.ini
	otherdoc=readme.txt
  ;;
  alpha)
	file=rc5desproxyper-*-linux-alpha.tar.gz
	binary=rc5desproxyper
	conffile=rc5desproxyper.ini
	otherdoc=readme.txt
  ;;
esac

if [ "$file" ]; then
	tar zxvf ../$file
else
	echo $arch architecture not supported >&2
	exit 1
fi

#mv $changelog ../files/changelog
mv $binary ../files/distributed-net-pproxy
mv $conffile ../files/docs/distributed-net-pproxy.ini-sample
if [ ! -z "$otherdoc" ]; then
	mv $otherdoc ../files/docs/
fi
