#!/bin/bash

CWD=$(pwd)

for i in libideviceactivation ideviceinstaller usbmuxd libusbmuxd libimobiledevice libirecovery libplist ifuse idevicerestore sbmanager
	do 
		if [ ! -d "$i" ]; then
			git clone https://github.com/libimobiledevice/$i
		else
			# update
			echo "Updating $i"
			cd $i
			git fetch origin
			cd ..
		fi
		echo "Tarbal of $i"
		# SlackBuild expects version in folder
		if [ ! -d "${i}-git" ]; then
			cp -pR ${i} ${i}-git
		fi
		# create configure 
		cd ${CWD}/${i}-git
		sh ./autogen.sh
		cd ${CWD}
		tar cJf ${i}-git.tar.xz ${i}-git
	done

for i in libideviceactivation ideviceinstaller libimobiledevice libirecovery ifuse idevicerestore sbmanager
	do	
		echo "cp $i.SlackBuild"
		cp /usr/doc/$i*/*.SlackBuild ./
	done

echo "Start the Slackbuilds with \$VERSION=iOS11."
export VERSION=git
echo export VERSION=git
