You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.3 KiB

#!/usr/bin/env bash
if [ -z "${CHECKOUT_FOLDER}" ]; then
echo 'export CHECKOUT_FOLDER before running this script' >&2
exit 2
: ${CHECKOUT_LOCKFILE:=${CHECKOUT_FOLDER}/.riot-svn-checkout-lockfile}
# Default timeout, in seconds
: ${LOCK_TIMEOUT:=120}
# We need to protect SVN checkout with a lock to avoid parallel make runs from
# disrupting each other
if type flock >/dev/null 2>&1; then
# Try flock(1) command first, usually found on Linux
flock -w "${LOCK_TIMEOUT}" 200 || (
echo "Timed out waiting to acquire lock ${CHECKOUT_LOCKFILE}" >&2
exit 1
$(dirname "$0")/
exit $?
elif type lockf >/dev/null 2>&1; then
# lockf is usually installed on FreeBSD and OSX
lockf -t ${LOCK_TIMEOUT} ${CHECKOUT_LOCKFILE} $(dirname "$0")/
exit $?
# flock(1) and lockf(1) shell commands are missing from the system
echo 'Missing both flock(1) and lockf(1),'
echo 'flock is part of util-linux on most Linux systems, lockf is usually installed on FreeBSD.'
echo 'see for a portable alternative.'
echo 'Proceeding with svn checkout without locking...'
$(dirname "$0")/
exit $?