Merge "sched: Don't allow ast_sched_del to deadlock ast_sched_runq from same thread"
[asterisk/asterisk.git] / build_tools / list_valid_installed_externals
1 #!/usr/bin/env bash
2
3 if [[ ( ${BASH_VERSINFO[0]} == 4 && ${BASH_VERSINFO[1]} > 1 ) || ${BASH_VERSINFO[0]} > 4 ]] ; then
4         shopt -s compat41
5 fi
6 set -e
7
8 ASTTOPDIR=${ASTTOPDIR:-.}
9 export make=`sed -n -e "s/^MAKE\s*=\s*//gp" ${ASTTOPDIR}/makeopts`
10
11 getvar() {
12         $make --quiet --no-print-directory -f- <<EOF
13 include ${ASTTOPDIR}/makeopts
14 all:
15         @echo "\$($1)"
16 EOF
17 }
18
19
20 XMLSTARLET=`getvar XMLSTARLET`
21 ASTMODDIR=`getvar ASTMODDIR`
22 HOST_CPU=`getvar HOST_CPU`
23
24 tmpdir=$(mktemp -d)
25 if [[ -z "${tmpdir}" ]] ; then
26         echo "${module_name}: Unable to create temporary directory."
27         exit 1
28 fi
29 trap "rm -rf ${tmpdir}" EXIT
30
31 if [[ -z "${ASTMODDIR}" ]] ; then
32         echo "${module_name}: Unable to parse ${ASTTOPDIR}/makeopts."
33         exit 1
34 fi
35
36 if [[ "${XMLSTARLET}" = ":" ]] ; then
37         echo "${module_name}: The externals downloader requires xmlstarlet to be installed."
38         exit 1
39 fi
40
41 version=$(${ASTTOPDIR}/build_tools/make_version ${ASTTOPDIR})
42 if [[ ! ${version} =~ ^(GIT-)?([^.-]+)[.-].* ]] ; then
43         echo "${module_name}: Couldn't parse version ${version}"
44         exit 1
45 fi
46 major_version=${BASH_REMATCH[2]}.0
47
48 if [[ "${HOST_CPU}" = "x86_64" ]] ; then
49         host_bits=64
50 else
51         host_bits=32
52 fi
53
54 names=""
55 for manifest in ${DESTDIR}${ASTMODDIR}/*.manifest.xml ; do
56         if [ ! -f "$manifest" ] ; then
57                 break
58         fi
59         package_version=$(${XMLSTARLET} sel -t -v "/package/@version" ${manifest})
60         package_major_version=${package_version%_*}
61         package_arch=$(${XMLSTARLET} sel -t -v "/package/@arch" ${manifest})
62         if [[ "$package_major_version" = "$major_version" && "${package_arch}" = "x86_${host_bits}" ]] ; then
63                 names+=$(${XMLSTARLET} sel -t -m "//file[@executable = 'yes']" -v "concat(@name, ' ')" ${manifest})
64         fi
65 done
66 echo $names