mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:32:45 +01:00
pkg/libfixmath: Protect svn checkout with a lock
This commit is contained in:
parent
51b7227c9f
commit
ecf3069e94
@ -1,9 +1,10 @@
|
||||
PKG_NAME := libfixmath
|
||||
PKG_VERSION := 91
|
||||
PKG_BRANCH := trunk
|
||||
PKG_URL := http://libfixmath.googlecode.com/svn/$(PKG_BRANCH)/
|
||||
export PKG_NAME := libfixmath
|
||||
export PKG_VERSION := 91
|
||||
export PKG_BRANCH := trunk
|
||||
export PKG_URL := http://libfixmath.googlecode.com/svn/$(PKG_BRANCH)/
|
||||
|
||||
CHECKOUT_FOLDER := $(CURDIR)/checkout/$(PKG_BRANCH)-r$(PKG_VERSION)
|
||||
export CHECKOUT_FOLDER := $(CURDIR)/checkout/$(PKG_BRANCH)-r$(PKG_VERSION)
|
||||
export SVN_INFO_FILE := $(CHECKOUT_FOLDER)/svn_info.xml
|
||||
|
||||
.PHONY: all clean distclean
|
||||
|
||||
@ -52,10 +53,9 @@ $(BINDIR)$(PKG_NAME)-headers/fix16.h: $(CHECKOUT_FOLDER)/svn_info.xml
|
||||
$(AD)echo $(patsubst %,'extern int %(void);',$(shell for f in $(CHECKOUT_FOLDER)/unittests/*.c; do basename $${f} .c; done )) \
|
||||
$(patsubst %,'%();',$(shell for f in $(CHECKOUT_FOLDER)/unittests/*.c; do basename $${f} .c; done)) | sed -e 's/;\s*/;\n/g' > $(@D)/fix16_unittests.inc
|
||||
|
||||
$(CHECKOUT_FOLDER)/svn_info.xml:
|
||||
$(SVN_INFO_FILE):
|
||||
$(AD)mkdir -p $(@D)
|
||||
$(AD)svn checkout -q -r $(PKG_VERSION) $(PKG_URL) $(@D)
|
||||
$(AD)svn info --xml $(@D) > $@
|
||||
$(AD)$(CURDIR)/checkout.sh
|
||||
|
||||
clean::
|
||||
$(AD)rm -rf $(BINDIR)$(PKG_NAME)-src/ $(BINDIR)$(PKG_NAME)-headers/
|
||||
|
36
pkg/libfixmath/checkout.sh
Executable file
36
pkg/libfixmath/checkout.sh
Executable file
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z "${CHECKOUT_FOLDER}" ]; then
|
||||
echo 'export CHECKOUT_FOLDER before running this script' >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
: ${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")/perform-svn-checkout.sh
|
||||
exit $?
|
||||
) 200>"${CHECKOUT_LOCKFILE}"
|
||||
elif type lockf >/dev/null 2>&1; then
|
||||
# lockf is usually installed on FreeBSD and OSX
|
||||
lockf -t ${LOCK_TIMEOUT} ${CHECKOUT_LOCKFILE} $(dirname "$0")/perform-svn-checkout.sh
|
||||
exit $?
|
||||
else
|
||||
# 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 https://github.com/discoteq/flock for a portable alternative.'
|
||||
echo 'Proceeding with svn checkout without locking...'
|
||||
$(dirname "$0")/perform-svn-checkout.sh
|
||||
exit $?
|
||||
fi
|
25
pkg/libfixmath/perform-svn-checkout.sh
Executable file
25
pkg/libfixmath/perform-svn-checkout.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
if [ -z "${PKG_URL}" ]; then
|
||||
echo 'export PKG_URL before running this script' >&2
|
||||
exit 2
|
||||
fi
|
||||
if [ -z "${CHECKOUT_FOLDER}" ]; then
|
||||
echo 'export CHECKOUT_FOLDER before running this script' >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
: ${SVN_INFO_FILE:=${CHECKOUT_FOLDER}/svn_info.xml}
|
||||
|
||||
if [ -s "${SVN_INFO_FILE}" ]; then
|
||||
# svn checkout was completed by another thread while we waited for the lock
|
||||
if [ "${QUIET}" -ne 1 ]; then
|
||||
echo "File already exists: ${SVN_INFO_FILE}, skipping svn checkout"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
if [ -n "${PKG_VERSION}" ]; then
|
||||
svn checkout -q -r ${PKG_VERSION} ${PKG_URL} ${CHECKOUT_FOLDER}
|
||||
else
|
||||
svn checkout -q ${PKG_URL} ${CHECKOUT_FOLDER}
|
||||
fi
|
||||
svn info --xml ${CHECKOUT_FOLDER} > ${SVN_INFO_FILE}
|
Loading…
Reference in New Issue
Block a user