fetch_libs.sh 1.11 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#!/bin/bash

DEST="$1"

rm -rf "$DEST"
mkdir -p "$DEST"
# Fetch Clean distribution
curl -sSL ftp://ftp.cs.ru.nl/pub/Clean/builds/linux-x64/clean-bundle-complete-linux-x64-latest.tgz |\
	tar -xz --exclude=exe -C "$DEST" --strip-components=2 clean-bundle-complete/lib

exec 5< <(jq '.[]' < libs.json | jq '.[]' | jq -cMr '.name,.fetch_url[0,1],.path')

while read lib <&5
do
	read fetch_method <&5
	read fetch_url <&5
	read path <&5

	case "$fetch_method" in
		"SVN")
			rm -rf "$DEST/$lib"
			if [[ "$path" == "null" ]]; then
				echo "Fetching $fetch_url..."
				svn checkout -q "$fetch_url" "$DEST/$lib"
			else
				echo "Fetching $fetch_url/$path..."
				svn checkout -q "$fetch_url/$path" "$DEST/$lib"
			fi
			;;
		"Git")
			rm -rf "$DEST/$lib"
			if [[ "$path" == "null" ]]; then
				echo "Fetching $fetch_url..."
				git clone -q "$fetch_url" "$DEST/$lib"
			else
				echo "Fetching $fetch_url/$path..."
				git clone -q "$fetch_url" "/tmp/$lib"
				mv "/tmp/$lib/$path" "$DEST/$lib"
				rm -rf "/tmp/$lib"
			fi
			;;
		"CleanDistribution")
			;;
		*)
			echo "Unknown fetch method '$fetch_method'"
			exit 1
			;;
	esac
done