Skip to content
Snippets Groups Projects
Commit 341151f0 authored by Andre Moreira Magalhaes's avatar Andre Moreira Magalhaes
Browse files

Fix arch parsing on external-binaries.cfg


This fixes an issue prefix= and filename= were provided
but no architecture specified.

Signed-off-by: default avatarAndre Moreira Magalhaes (andrunko) <andre.magalhaes@collabora.co.uk>
parent 7c4d8a70
No related branches found
No related tags found
No related merge requests found
......@@ -57,6 +57,18 @@ ARCHS="amd64 armhf arm64"
PACKAGES=""
BINARIES=""
trim()
{
local trimmed="$1"
# Strip leading space.
trimmed="${trimmed## }"
# Strip trailing space.
trimmed="${trimmed%% }"
echo "$trimmed"
}
download_packages_description() {
for SOURCE in ${SOURCES} ; do
[ -f Packages.${ARCH}.${SOURCE} ] && continue
......@@ -84,15 +96,20 @@ download_extract_packages () {
[[ "$line" =~ ^#.*$ ]] && continue
IFS=" " read -r PACKAGE GLOB AVAILABLE_OPTIONS <<< $line
IFS="," read -r -a AVAILABLE_OPTIONS <<< $AVAILABLE_OPTIONS
#Leave only the list of arches if any
AVAILABLE_OPTIONS="${AVAILABLE_OPTIONS//prefix=.*(|,)/}"
AVAILABLE_OPTIONS="${AVAILABLE_OPTIONS//filename=.*(|,)/}"
# If package is listed for all architectures implicitly
[ -z "$AVAILABLE_OPTIONS" ] && AVAILABLE_OPTIONS="${ARCH}"
local REQUESTED_ARCHS=
for i in ${!AVAILABLE_OPTIONS[@]}; do
# If not a key=value pair, lets consider it a requested arch
if ! [[ ${AVAILABLE_OPTIONS[i]} =~ ^.*=.* ]]; then
REQUESTED_ARCHS="$REQUESTED_ARCHS ${AVAILABLE_OPTIONS[i]}"
continue
fi
done
[ -z "$REQUESTED_ARCHS" ] && REQUESTED_ARCHS="${ARCH}"
# If target arch is listed in arches list
if [[ "$AVAILABLE_OPTIONS" =~ (^|[[:space:]]|,)$ARCH($|[[:space:]]|,) ]]; then
if [[ "$REQUESTED_ARCHS" =~ (^|[[:space:]])$ARCH($|[[:space:]]) ]]; then
get_package ${PACKAGE}
dpkg --extract ${PACKAGE}_*_${ARCH}.deb ${EXTRACT}
fi
......@@ -111,26 +128,42 @@ test_repository_requires_binaries () {
update_test_repository () {
# Parse available options
# Format is <package> <file> <arch1>,<arch2>,prefix=<relative path>
# Format is <package> <file> <arch1>,<arch2>,prefix=<relative path>,filename=<filename>
# If an arch is specified, all non specified archs will be skipped
# If a prefix is added, the file will copied to target project under
# If prefix is specified, the file will copied to target project under
# <arch>/<relative path>. It is copied below "<arch>/bin" if no prefix
# is specified
# If filename is specified, use it as the file name
while read -r line ; do
# skip lines starting with "#"
[[ "$line" =~ ^#.*$ ]] && continue
IFS=" " read -r PACKAGE GLOB AVAILABLE_OPTIONS <<< $line
IFS="," read -r -a AVAILABLE_OPTIONS <<< $AVAILABLE_OPTIONS
local PREFIX=
local FILENAME=
local REQUESTED_ARCHS=
for i in ${!AVAILABLE_OPTIONS[@]}; do
# If not a key=value pair, lets consider it a requested arch
if ! [[ ${AVAILABLE_OPTIONS[i]} =~ ^.*=.* ]]; then
REQUESTED_ARCHS="$REQUESTED_ARCHS ${AVAILABLE_OPTIONS[i]}"
continue
fi
local PREFIX=$(echo "$AVAILABLE_OPTIONS" | sed -n 's/.*prefix=\([^,]*\).*/\1/p')
AVAILABLE_OPTIONS=${AVAILABLE_OPTIONS/prefix=$PREFIX/}
local FILENAME=$(echo "$AVAILABLE_OPTIONS" | sed -n 's/.*filename=\([^,]*\).*/\1/p')
AVAILABLE_OPTIONS=${AVAILABLE_OPTIONS/filename=$FILENAME/}
IFS="=" read -r -a REQUESTED_OPTIONS <<< ${AVAILABLE_OPTIONS[i]}
local OPTION_KEY=$(trim "${REQUESTED_OPTIONS[0]}")
local OPTION_VALUE=$(trim "${REQUESTED_OPTIONS[1]}")
case $OPTION_KEY in
prefix) PREFIX="$OPTION_VALUE" ;;
filename) FILENAME="$OPTION_VALUE" ;;
*) ;;
esac
done
# skip binaries not available for this arch
if [ ! -z "$AVAILABLE_OPTIONS" ]; then
AVAILABLE_OPTIONS=${AVAILABLE_OPTIONS//,/ } # {var//x/y} replaces all occurences of x in var
if ! [[ $AVAILABLE_OPTIONS =~ (^|[[:space:]])$ARCH($|[[:space:]]) ]]; then
if [ ! -z "$REQUESTED_ARCHS" ]; then
if ! [[ "$REQUESTED_ARCHS" =~ (^|[[:space:]])$ARCH($|[[:space:]]) ]]; then
echo "skipping ${GLOB} for ${ARCH}"
continue
fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment