C++ Library containing a lot of needful things: Stack Trace, Command Line Parser, Resource Handling, Configuration Files, Unix Command Execution, Directories, Regular Expressions, Tokenizer, Function Trace, Standard Extensions.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

resolve-debbuilddeps.sh 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #! /bin/bash -ex
  2. ## @id $Id$
  3. ## Resolve Debian Build Dependencies
  4. ## Installs all the required packages
  5. ## Call: ./resolve-debbuilddeps 'name of build schroot'
  6. ## e.g. call: ./resolve-debbuilddeps trusty_amd64
  7. ## 1 2 3 4 5 6 7 8
  8. ## 45678901234567890123456789012345678901234567890123456789012345678901234567890
  9. SCHROOTNAME="$1"
  10. if test -n "${SCHROOTNAME}"; then
  11. DO="schroot -c "${SCHROOTNAME}" --"
  12. SUDO="schroot -c "${SCHROOTNAME}" -u root -d / --"
  13. else
  14. DO=""
  15. if grep -q '/docker' /proc/1/cgroup; then
  16. SUDO=""
  17. else
  18. SUDO="sudo"
  19. fi
  20. fi
  21. function install() {
  22. if ${SUDO} apt-get install -y --force-yes --no-install-suggests --no-install-recommends $*; then
  23. return 0
  24. else
  25. return 1
  26. fi
  27. }
  28. TO_INSTALL=
  29. DEPS=
  30. if test -e debian/control.in -a ! -e debian/control; then
  31. function pkg_exists() {
  32. test -n "$(${DO} apt-cache policy -q ${1})"
  33. }
  34. function AX_PKG_CHECK() {
  35. local DEV_DEB_DIST_PKG=
  36. local DEV_DIST_PKG=
  37. local pkg=
  38. eval $4
  39. if test -z "$2"; then
  40. pkg=$1
  41. else
  42. pkg=$2
  43. fi
  44. pkg=${DEV_DEB_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-dev}
  45. if pkg_exists "${pkg}"; then
  46. echo $pkg
  47. fi
  48. }
  49. function AX_PKG_REQUIRE() {
  50. local DEV_DEB_DIST_PKG=
  51. local DEV_DIST_PKG=
  52. local pkg=
  53. eval $6
  54. if test -z "$2"; then
  55. pkg=$1
  56. else
  57. pkg=$2
  58. fi
  59. if test -n "$4"; then
  60. for f in $pkg $4; do
  61. if pkg_exists "${f}-dev"; then
  62. pkg=$f
  63. break
  64. fi
  65. done
  66. fi
  67. echo ${DEV_DEB_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-dev}
  68. }
  69. DEPS+=" $(eval $(sed -n '/^ *AX_PKG_REQUIRE/{s,^ *\(AX_PKG_REQUIRE\) *(\(.*\)).*,\1 \2,;s.\[\([^]]*\)\],\?."\1".g;s,$,;,g;p}' configure.ac))"
  70. DEPS+=" $(eval $(sed -n '/^ *AX_PKG_CHECK/{s,^ *\(AX_PKG_CHECK\) *(\(.*\)).*,\1 \2,;s.\[\([^]]*\)\],\?."\1".g;s,$,;,g;p}' configure.ac))"
  71. for f in $(sed -n 's, *AX_\(DEB\|ALL\)_DEPEND_IFEXISTS(\([^)]*\)).*,\2,p' configure.ac); do
  72. if pkg_exists "${f}"; then
  73. DEPS+=" ${f}"
  74. fi
  75. done
  76. for f in $(sed -n 's, *AX_\(DEB\|ALL\)_DEPEND_IFEXISTS_DEV(\([^)]*\)).*,\2,p' configure.ac); do
  77. if pkg_exists "${f}-dev"; then
  78. DEPS+=" ${f}-dev"
  79. fi
  80. done
  81. for f in $(sed -n 's, *AX_\(DEB\|ALL\)\(_BUILD\)\?_DEPEND(\([^)]*\)).*,\3,p' configure.ac); do
  82. DEPS+=" ${f}"
  83. done
  84. for f in $(sed -n 's, *AX_\(DEB\|ALL\)\(_BUILD\)\?_DEPEND_DEV(\([^)]*\)).*,\3,p' configure.ac); do
  85. DEPS+=" ${f}-dev"
  86. done
  87. trap "rm debian/control" INT TERM EXIT
  88. sed 's,@\(\(ALL\|DEB\)_DEPEND_IFEXISTS\|\(ALL\|DEB\)_BUILD_DEPEND\|\(ALL\|DEB\)_DEPEND\)@,,g' debian/control.in | \
  89. sed 's,@[^@]*@, dummytext,g' > debian/control
  90. fi
  91. install dpkg-dev
  92. DEPS+=" $(LANG= ${DO} dpkg-checkbuilddeps 2>&1 | sed -n '/Unmet build dependencies/ { s,.*Unmet build dependencies: ,,g; s, ([^)]*),,g; s, *| *,|,g; p}')"
  93. for pa in ${DEPS}; do
  94. if test "${pa//|/}" = "${pa}"; then
  95. TO_INSTALL+=" ${pa}"
  96. continue;
  97. fi
  98. success=0
  99. for p in ${pa//|/ }; do
  100. if install ${TO_INSTALL} ${p}; then
  101. TO_INSTALL+=" ${p}"
  102. success=1
  103. break
  104. fi
  105. done
  106. if test ${success} -eq 0; then
  107. echo "**** Error: Installation Failed: ${pa}"
  108. exit 1
  109. fi
  110. done
  111. if test -n "${TO_INSTALL}" && ! install ${TO_INSTALL}; then
  112. echo "**** Error: Installation Failed: ${TO_INSTALL}"
  113. exit 1
  114. fi
  115. FILES="$(LANG= ${DO} dpkg-checkbuilddeps 2>&1 | sed -n '/Unmet build dependencies/ { s,.*Unmet build dependencies: ,,g; s, ([^)]*),,g; s, *| *,|,g; p}')"
  116. if test -n "${FILES}"; then
  117. echo "**** ERROR: Cannot install: " $FILES
  118. exit 1
  119. fi
  120. echo "**** Success: All Dependencies Resolved"