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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. DROP='Reading package lists...
  58. Building dependency tree...
  59. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.'
  60. msgtest 'Check if version of installed dpkg is high enough for' 'build profiles support'
  61. if dpkg --compare-versions "$(command dpkg-query --showformat='${Version}' --show dpkg)" 'ge' '1.17.14'; then
  62. msgpass
  63. testwithdpkg() {
  64. msgtest "Test with" "dpkg-checkbuilddeps -d '$1' -P '$2'"
  65. local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testwithdpkg.output"
  66. if dpkgcheckbuilddeps -d "$1" -P "$2" /dev/null >$OUTPUT 2>&1; then
  67. if [ "$3" = "$DROP" ]; then
  68. msgpass
  69. else
  70. cat $OUTPUT
  71. msgfail
  72. fi
  73. else
  74. if [ "$3" = "$KEEP" ]; then
  75. msgpass
  76. else
  77. cat $OUTPUT
  78. msgfail
  79. fi
  80. fi
  81. }
  82. else
  83. msgskip
  84. testwithdpkg() {
  85. msgtest "Test with" "dpkg-checkbuilddeps -d '$1' -P '$2'"
  86. msgskip
  87. }
  88. fi
  89. testprofile() {
  90. if [ -n "$3" ]; then
  91. testequal "$4" aptget build-dep "$1" -s -P "$3"
  92. export DEB_BUILD_PROFILES="$(echo "$3" | tr ',' ' ')"
  93. testequal "$4" aptget build-dep "$1" -s -o with::environment=1
  94. unset DEB_BUILD_PROFILES
  95. else
  96. testequal "$4" aptget build-dep "$1" -s
  97. fi
  98. testwithdpkg "$2" "$3" "$4"
  99. }
  100. testprofile 'spec-1' 'foo <!stage1>' '' "$KEEP"
  101. testprofile 'spec-1' 'foo <!stage1>' 'stage1' "$DROP"
  102. testprofile 'spec-1' 'foo <!stage1>' 'notest' "$KEEP"
  103. testprofile 'spec-1' 'foo <!stage1>' 'stage1,notest' "$DROP"
  104. testprofile 'spec-2' 'foo <stage1>' '' "$DROP"
  105. testprofile 'spec-2' 'foo <stage1>' 'stage1' "$KEEP"
  106. testprofile 'spec-2' 'foo <stage1>' 'notest' "$DROP"
  107. testprofile 'spec-2' 'foo <stage1>' 'stage1,notest' "$KEEP"
  108. testprofile 'spec-3' 'foo <!stage1 !notest>' '' "$KEEP"
  109. testprofile 'spec-3' 'foo <!stage1 !notest>' 'stage1' "$DROP"
  110. testprofile 'spec-3' 'foo <!stage1 !notest>' 'notest' "$DROP"
  111. testprofile 'spec-3' 'foo <!stage1 !notest>' 'stage1,notest' "$DROP"
  112. testprofile 'spec-4' 'foo <stage1 notest>' '' "$DROP"
  113. testprofile 'spec-4' 'foo <stage1 notest>' 'stage1' "$DROP"
  114. testprofile 'spec-4' 'foo <stage1 notest>' 'notest' "$DROP"
  115. testprofile 'spec-4' 'foo <stage1 notest>' 'stage1,notest' "$KEEP"
  116. testprofile 'spec-5' 'foo <!stage1 notest>' '' "$DROP"
  117. testprofile 'spec-5' 'foo <!stage1 notest>' 'stage1' "$DROP"
  118. testprofile 'spec-5' 'foo <!stage1 notest>' 'notest' "$KEEP"
  119. testprofile 'spec-5' 'foo <!stage1 notest>' 'stage1,notest' "$DROP"
  120. testprofile 'spec-6' 'foo <stage1 !notest>' '' "$DROP"
  121. testprofile 'spec-6' 'foo <stage1 !notest>' 'stage1' "$KEEP"
  122. testprofile 'spec-6' 'foo <stage1 !notest>' 'notest' "$DROP"
  123. testprofile 'spec-6' 'foo <stage1 !notest>' 'stage1,notest' "$DROP"
  124. testprofile 'spec-7' 'foo <stage1> <!notest>' '' "$KEEP"
  125. testprofile 'spec-7' 'foo <stage1> <!notest>' 'stage1' "$KEEP"
  126. testprofile 'spec-7' 'foo <stage1> <!notest>' 'notest' "$DROP"
  127. testprofile 'spec-7' 'foo <stage1> <!notest>' 'stage1,notest' "$KEEP"