test-bug-661537-build-profiles-support 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'amd64' 'i386' 'armel'
  7. insertinstalledpackage 'build-essential' 'all' '0' 'Multi-Arch: foreign'
  8. insertpackage 'unstable' 'foo' 'all' '1.0'
  9. insertpackage 'unstable' 'bar' 'all' '1.0'
  10. insertsource 'unstable' 'buildprofiles' 'any' '1' 'Build-Depends: foo (>= 1.0) [i386 arm] <!stage1 !cross>, bar'
  11. # table from https://wiki.debian.org/BuildProfileSpec
  12. insertsource 'unstable' 'spec-1' 'any' '1' 'Build-Depends: foo <!stage1>'
  13. insertsource 'unstable' 'spec-2' 'any' '1' 'Build-Depends: foo <stage1>'
  14. insertsource 'unstable' 'spec-3' 'any' '1' 'Build-Depends: foo <!stage1 !notest>'
  15. insertsource 'unstable' 'spec-4' 'any' '1' 'Build-Depends: foo <stage1 notest>'
  16. insertsource 'unstable' 'spec-5' 'any' '1' 'Build-Depends: foo <!stage1 notest>'
  17. insertsource 'unstable' 'spec-6' 'any' '1' 'Build-Depends: foo <stage1 !notest>'
  18. insertsource 'unstable' 'spec-7' 'any' '1' 'Build-Depends: foo <stage1> <!notest>'
  19. setupaptarchive
  20. testsuccessequal 'Reading package lists...
  21. Building dependency tree...
  22. The following NEW packages will be installed:
  23. bar
  24. 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
  25. Inst bar (1.0 unstable [all])
  26. Conf bar (1.0 unstable [all])' aptget build-dep buildprofiles -s
  27. testsuccessequal 'Reading package lists...
  28. Building dependency tree...
  29. The following NEW packages will be installed:
  30. bar foo
  31. 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
  32. Inst bar (1.0 unstable [all])
  33. Inst foo (1.0 unstable [all])
  34. Conf bar (1.0 unstable [all])
  35. Conf foo (1.0 unstable [all])' aptget build-dep buildprofiles -s -o APT::Architecture=i386
  36. testsuccessequal 'Reading package lists...
  37. Building dependency tree...
  38. The following NEW packages will be installed:
  39. bar
  40. 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
  41. Inst bar (1.0 unstable [all])
  42. Conf bar (1.0 unstable [all])' aptget build-dep buildprofiles -s -o APT::Architecture=armel
  43. testsuccessequal 'Reading package lists...
  44. Building dependency tree...
  45. The following NEW packages will be installed:
  46. bar
  47. 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
  48. Inst bar (1.0 unstable [all])
  49. Conf bar (1.0 unstable [all])' aptget build-dep buildprofiles -s -o APT::Architecture=i386 -P stage1
  50. KEEP='Reading package lists...
  51. Building dependency tree...
  52. The following NEW packages will be installed:
  53. foo
  54. 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
  55. Inst foo (1.0 unstable [all])
  56. Conf foo (1.0 unstable [all])'
  57. setdrop() {
  58. DROP="Reading package lists...
  59. Building dependency tree...
  60. $1 has no build depends.
  61. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded."
  62. }
  63. msgtest 'Check if version of installed dpkg is high enough for' 'build profiles support'
  64. if dpkg --compare-versions "$(command dpkg-query --showformat='${Version}' --show dpkg)" 'ge' '1.17.14'; then
  65. msgpass
  66. testwithdpkg() {
  67. msgtest "Test with" "dpkg-checkbuilddeps -d '$1' -P '$2'"
  68. local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testwithdpkg.output"
  69. if dpkgcheckbuilddeps -d "$1" -P "$2" /dev/null >$OUTPUT 2>&1; then
  70. if [ "$3" = "$DROP" ]; then
  71. msgpass
  72. else
  73. cat $OUTPUT
  74. msgfail
  75. fi
  76. else
  77. if [ "$3" = "$KEEP" ]; then
  78. msgpass
  79. else
  80. cat $OUTPUT
  81. msgfail
  82. fi
  83. fi
  84. }
  85. else
  86. msgskip
  87. testwithdpkg() {
  88. msgtest "Test with" "dpkg-checkbuilddeps -d '$1' -P '$2'"
  89. msgskip
  90. }
  91. fi
  92. testprofile() {
  93. if [ -n "$3" ]; then
  94. testequal "$4" aptget build-dep "$1" -s -P "$3"
  95. export DEB_BUILD_PROFILES="$(echo "$3" | tr ',' ' ')"
  96. testequal "$4" aptget build-dep "$1" -s -o with::environment=1
  97. unset DEB_BUILD_PROFILES
  98. else
  99. testequal "$4" aptget build-dep "$1" -s
  100. fi
  101. testwithdpkg "$2" "$3" "$4"
  102. }
  103. setdrop 'spec-1'
  104. testprofile 'spec-1' 'foo <!stage1>' '' "$KEEP"
  105. testprofile 'spec-1' 'foo <!stage1>' 'stage1' "$DROP"
  106. testprofile 'spec-1' 'foo <!stage1>' 'notest' "$KEEP"
  107. testprofile 'spec-1' 'foo <!stage1>' 'stage1,notest' "$DROP"
  108. setdrop 'spec-2'
  109. testprofile 'spec-2' 'foo <stage1>' '' "$DROP"
  110. testprofile 'spec-2' 'foo <stage1>' 'stage1' "$KEEP"
  111. testprofile 'spec-2' 'foo <stage1>' 'notest' "$DROP"
  112. testprofile 'spec-2' 'foo <stage1>' 'stage1,notest' "$KEEP"
  113. setdrop 'spec-3'
  114. testprofile 'spec-3' 'foo <!stage1 !notest>' '' "$KEEP"
  115. testprofile 'spec-3' 'foo <!stage1 !notest>' 'stage1' "$DROP"
  116. testprofile 'spec-3' 'foo <!stage1 !notest>' 'notest' "$DROP"
  117. testprofile 'spec-3' 'foo <!stage1 !notest>' 'stage1,notest' "$DROP"
  118. setdrop 'spec-4'
  119. testprofile 'spec-4' 'foo <stage1 notest>' '' "$DROP"
  120. testprofile 'spec-4' 'foo <stage1 notest>' 'stage1' "$DROP"
  121. testprofile 'spec-4' 'foo <stage1 notest>' 'notest' "$DROP"
  122. testprofile 'spec-4' 'foo <stage1 notest>' 'stage1,notest' "$KEEP"
  123. setdrop 'spec-5'
  124. testprofile 'spec-5' 'foo <!stage1 notest>' '' "$DROP"
  125. testprofile 'spec-5' 'foo <!stage1 notest>' 'stage1' "$DROP"
  126. testprofile 'spec-5' 'foo <!stage1 notest>' 'notest' "$KEEP"
  127. testprofile 'spec-5' 'foo <!stage1 notest>' 'stage1,notest' "$DROP"
  128. setdrop 'spec-6'
  129. testprofile 'spec-6' 'foo <stage1 !notest>' '' "$DROP"
  130. testprofile 'spec-6' 'foo <stage1 !notest>' 'stage1' "$KEEP"
  131. testprofile 'spec-6' 'foo <stage1 !notest>' 'notest' "$DROP"
  132. testprofile 'spec-6' 'foo <stage1 !notest>' 'stage1,notest' "$DROP"
  133. setdrop 'spec-7'
  134. testprofile 'spec-7' 'foo <stage1> <!notest>' '' "$KEEP"
  135. testprofile 'spec-7' 'foo <stage1> <!notest>' 'stage1' "$KEEP"
  136. testprofile 'spec-7' 'foo <stage1> <!notest>' 'notest' "$DROP"
  137. testprofile 'spec-7' 'foo <stage1> <!notest>' 'stage1,notest' "$KEEP"