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