scripts/get: general cleanup

Signed-off-by: Ian Leonard <antonlacon@gmail.com>
This commit is contained in:
Ian Leonard 2018-11-08 09:40:43 +00:00
parent 0b524bc1a0
commit b216c8d545

View File

@ -3,32 +3,35 @@
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv) # Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv)
. config/options $1 . config/options "${1}"
if [ -z "$1" ]; then if [ -z "${1}" ]; then
for i in `find packages/ -type f -name package.mk`; do for i in $(find "${PACKAGES}/" -type f -name "package.mk"); do
GET_PKG=`grep ^PKG_NAME= $i | sed -e "s,\",,g" -e "s,PKG_NAME=,,"` GET_PKG=$(grep "^PKG_NAME=" "${i}" | sed -e "s,\",,g" -e "s,PKG_NAME=,,")
$SCRIPTS/get $GET_PKG "${SCRIPTS}"/get "${GET_PKG}"
done done
fi fi
# Avoid concurrent processing of the same package # Avoid concurrent processing of the same package
function lock_source_dir() { lock_source_dir() {
local _isblocked=N local _isblocked=N
exec 99<$SOURCES/$1 exec 99<"${SOURCES}/${1}"
while ! flock --nonblock --exclusive 99; do while ! flock --nonblock --exclusive 99; do
[ ${_isblocked} = N ] && { echo "Project/Device ${DEVICE:-${PROJECT}} waiting, to avoid concurrent processing of ${1}..."; _isblocked=Y; } if [ ${_isblocked} = N ]; then
echo "Project/Device ${DEVICE:-${PROJECT}} waiting, to avoid concurrent processing of ${1}..."
_isblocked=Y
fi
sleep 1 sleep 1
done done
} }
if [ -n "$PKG_URL" -a -n "$PKG_SOURCE_NAME" ]; then if [ -n "${PKG_URL}" -a -n "${PKG_SOURCE_NAME}" ]; then
mkdir -p $SOURCES/$1 mkdir -p "${SOURCES}/${1}"
PACKAGE="$SOURCES/$1/$PKG_SOURCE_NAME" PACKAGE="${SOURCES}/${1}/${PKG_SOURCE_NAME}"
STAMP_URL="$PACKAGE.url" STAMP_URL="${PACKAGE}.url"
STAMP_SHA="$PACKAGE.sha256" STAMP_SHA="${PACKAGE}.sha256"
# determine get handler based on protocol and/or filename # determine get handler based on protocol and/or filename
case "${PKG_URL}" in case "${PKG_URL}" in
@ -41,16 +44,14 @@ if [ -n "$PKG_URL" -a -n "$PKG_SOURCE_NAME" ]; then
esac esac
if ! listcontains "${GET_HANDLER_SUPPORT}" "${get_handler}"; then if ! listcontains "${GET_HANDLER_SUPPORT}" "${get_handler}"; then
echo "ERROR: get handler \"${get_handler}\" is not supported, unable to get package $1 - aborting!" die "ERROR: get handler \"${get_handler}\" is not supported, unable to get package ${1} - aborting!"
exit 1
else else
get_handler="${SCRIPTS}/get_${get_handler}" get_handler="${SCRIPTS}/get_${get_handler}"
if [ ! -f ${get_handler} ]; then if [ ! -f "${get_handler}" ]; then
echo "ERROR: get handler \"${get_handler}\" does not exist, unable to get package $1 - aborting!" die "ERROR: get handler \"${get_handler}\" does not exist, unable to get package ${1} - aborting!"
exit 1
else
source ${get_handler}
fi fi
. "${get_handler}"
fi fi
fi fi