list_valid_installed_externals 1.6 KB

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