# ITMS Transporter installation

# From: https://help.apple.com/itc/transporteruserguide/en.lproj/static.html
ITMS_URL=https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/resources/download/public/Transporter__Linux/bin

install_if_downloaded:
	test -f transporter_installer.sh && exec make install \
		|| echo "transporter_installer.sh not found. Skipping installation."

download_from_bucket:
	aws s3 cp s3://prod-orcdbucket/bin/iTMSTransporter_installer_linux_x64_4.2.0.16.sh transporter_installer.sh

download_from_apple:
	curl --progress-bar -f -o transporter_installer.sh $(ITMS_URL)

download: download_from_apple

install:
	echo "Installing iTMSTransporter..."
	test -e transporter_installer.sh || exit 1

	rm -rf venv
	python -m venv venv
	venv/bin/pip install pexpect

	venv/bin/python run_transporter_installer.py transporter_installer.sh

	# validate installation
	/usr/local/itms/bin/iTMSTransporter -help > /dev/null
	rm -rf venv

clean:
	rm -f transporter_installer.sh
	rm -rf venv
