common.sh at [6305420046]

File server/buildpkgs/common.sh artifact 0a6dc891a3 part of check-in 6305420046


#! /bin/bash

function setup_tcl85 () {
	source "${PROJROOTDIR}/platform.magic.env-8.5" 2>/dev/null
}

function setup_tcl84 () {
	source "${PROJROOTDIR}/platform.magic.env-8.4" 2>/dev/null
}

function not_platforms () {
	local platform

	for platform in "$@"; do
		if [ "${PLATFORM}" = "${platform}" ]; then
			rm -rf out

			exit 0
		fi
	done
}

function only_platforms () {
	local platform

	for platform in "$@"; do
		if [ "${PLATFORM}" = "${platform}" ]; then
			return 0
		fi
	done

	rm -rf out

	exit 0
}

function download () {
	local url file

	file="$1"
	url="$2"

	if [ -s "${file}" ]; then
		return 0
	fi

	rm -f "${file}.tmp" "${file}"

	wget -O "${file}.tmp" "${url}" || return 1

	mv "${file}.tmp" "${file}"
}

function download_src () {
	if [ ! -f "${SRC}" -a -n "${SRC}" -a -n "${SRCURL}" ]; then
		mkdir -p "$(dirname "${SRC}")" >/dev/null 2>/dev/null

		download "${SRC}" "${SRCURL}" || exit 1
	fi
}

WORKDIR="${TMPDIR:-/tmp}/tcl-buildpkgs-$$${RANDOM}${RANDOM}${RANDOM}"
PLATDIR="$(pwd)/out/${PLATFORM}"
export WORKDIR PLATDIR

setup_tcl84