summaryrefslogtreecommitdiff
path: root/build_tools/list_valid_installed_externals
blob: 862447a645c0da2e96642b91dd5710c9109292bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash

if [[ ( ${BASH_VERSINFO[0]} == 4 && ${BASH_VERSINFO[1]} > 1 ) || ${BASH_VERSINFO[0]} > 4 ]] ; then
	shopt -s compat41
fi
set -e

ASTTOPDIR=${ASTTOPDIR:-.}
export make=`sed -n -e "s/^MAKE\s*=\s*//gp" ${ASTTOPDIR}/makeopts`

getvar() {
	$make --quiet --no-print-directory -f- <<EOF
include ${ASTTOPDIR}/makeopts
all:
	@echo "\$($1)"
EOF
}


XMLSTARLET=`getvar XMLSTARLET`
ASTMODDIR=`getvar ASTMODDIR`
HOST_CPU=`getvar HOST_CPU`

tmpdir=$(mktemp -d)
if [[ -z "${tmpdir}" ]] ; then
	echo "${module_name}: Unable to create temporary directory."
	exit 1
fi
trap "rm -rf ${tmpdir}" EXIT

if [[ -z "${ASTMODDIR}" ]] ; then
	echo "${module_name}: Unable to parse ${ASTTOPDIR}/makeopts."
	exit 1
fi

if [[ "${XMLSTARLET}" = ":" ]] ; then
	echo "${module_name}: The externals downloader requires xmlstarlet to be installed."
	exit 1
fi

version=$(${ASTTOPDIR}/build_tools/make_version ${ASTTOPDIR})
if [[ ! ${version} =~ ^(GIT-)?([^.-]+)[.-].* ]] ; then
	echo "${module_name}: Couldn't parse version ${version}"
	exit 1
fi
major_version=${BASH_REMATCH[2]}.0

if [[ "${HOST_CPU}" = "x86_64" ]] ; then
	host_bits=64
else
	host_bits=32
fi

names=""
for manifest in ${DESTDIR}${ASTMODDIR}/*.manifest.xml ; do
	if [ ! -f "$manifest" ] ; then
		break
	fi
	package_version=$(${XMLSTARLET} sel -t -v "/package/@version" ${manifest})
	package_major_version=${package_version%_*}
	package_arch=$(${XMLSTARLET} sel -t -v "/package/@arch" ${manifest})
	if [[ "$package_major_version" = "$major_version" && "${package_arch}" = "x86_${host_bits}" ]] ; then
		names+=$(${XMLSTARLET} sel -t -m "//file[@executable = 'yes']" -v "concat(@name, ' ')" ${manifest})
	fi
done
echo $names