#!/bin/bash
# lhcs regression test installer
P=lhcs-install
DEFAULT_VERSION=1.6
. $SHELLPACK_INCLUDE/common.sh
WEB_LOCATION=https://raw.githubusercontent.com/autotest/autotest-client-tests/master/cpu_hotplug
MIRROR_LOCATION="$WEBROOT/lhcs/"

# Basic argument parser
TASKSET_SERVER=
TASKSET_CLIENT=

while [ "$1" != "" ]; do
	case "$1" in
	-v)
		VERSION=$2
		shift 2
		;;
	*)
		echo Unrecognised option: $1
		shift
	esac
done
if [ "$TASKSET_SERVER" != "" ]; then
	echo TASKSET_SERVER: $TASKSET_SERVER
	echo TASKSET_CLIENT: $TASKSET_CLIENT
fi
if [ -z "$VERSION" ]; then
	VERSION=$DEFAULT_VERSION
fi

# Unconditionally fetch the tar to find out the real version number
TARFILE=lhcs_regression-${VERSION}.tgz
sources_fetch $WEB_LOCATION/$TARFILE $MIRROR_LOCATION/$TARFILE $SHELLPACK_SOURCES/$TARFILE
cd $SHELLPACK_SOURCES
tar -xf $TARFILE
if [ $? -ne 0 ]; then
        error "$P: tar xf lhcs_regression-${VERSION}.tgz failed"
        popd > /dev/null
        exit $SHELLPACK_ERROR
fi

# Rename directory to something we expect.
DST_DIR=`tar tf $TARFILE | head -n 1 | awk -F / '{print $1}'`
mv $DST_DIR lhcs-${VERSION}-installed
pushd lhcs-${VERSION}-installed > /dev/null || die Failed to rename tar

echo lhcs installed successfully
#### Description Linux Hotplug CPU Support
#### Details lhcs 12
