#!/bin/sh
#
# Unpack the file(s) for the build architecture into tmp directory.
# Once this script is complete, files/ will hold distributed-net, 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=rc5des-linux-x86-mt-static.tar.gz
	changelog=ChangeLog.txt
	binary=rc5des
	otherdoc="readme.txt rc5des.txt"
  ;;
  powerpc)
	file=rc5des-linux-ppc.tar.gz
	changelog=changeLog.txt
	binary=rc5des
	otherdoc=rc5des.txt
  ;;
  alpha)
	file=rc5des*-linux-alpha*.tar.gz
	changelog=rc5des414/changeLog.txt
	binary=rc5des414/rc5des
	otherdoc="rc5des414/rc5des.txt rc5des414/readme.txt"
  ;;
  sparc)
	file=rc5des-linux-sparc.tar.gz
	binary=rc5des
	changelog=rc5des.txt
	otherdoc=
  ;;
#  m68k)
#	file=rc5des-linux-m68k-nomt.tar.gz
#	binary=rc5des
#	changelog=Readme.txt
#	otherdoc=
#  ;;
   arm)
   	file=rc5des-linux-arm-cli.tar.gz
	binary=rc5des
	changelog=changeLog.txt
	otherdoc="rc5des.txt 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
if [ ! -z "$otherdoc" ]; then
	mv $otherdoc ../files/docs/
fi
