#!/bin/sh

set -eu

if [ $# = 1 ]; then
	case "$1" in
		--output=*)
			exec 1>${1#*=}
			exec 2>&1
			;;
	esac
fi

export PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
export HOME=/home/midipix

if [ -z "$SYSROOT" ]; then
	echo '$SYSROOT is not set!'
	exit 2
else
	mkdir -p "$SYSROOT"
fi

for tarball in /tarballs/*.tar.gz; do
	echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	echo extracting files from $tarball
	echo ..................................................
	tar -xpvf $tarball -C "$SYSROOT"
	echo ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	echo
done

/custom.sh

echo
echo
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo Congrats! All tarballs were successfully extracted.
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
