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.
 
 
 
 
 
 

229 lines
9.4 KiB

  1. #!/bin/sh
  2. set -e
  3. local TESTDIR=$(readlink -f $(dirname $0))
  4. . $TESTDIR/framework
  5. setupenvironment
  6. configarchitecture "i386"
  7. buildaptarchive
  8. setupflataptarchive
  9. STATUS=$(readlink -f rootdir/var/lib/dpkg/status)
  10. APTARCHIVE=$(readlink -f aptarchive)
  11. testequalpolicy() {
  12. local SP="$1"
  13. local AP="$2"
  14. shift 2
  15. testequal "Package files:
  16. $(echo "$SP" | awk '{ printf("%3s\n",$0) }') ${STATUS}
  17. release a=now
  18. $(echo "$AP" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/ Packages
  19. release c=
  20. Pinned packages:" aptcache policy $*
  21. }
  22. aptget update -qq
  23. testequalpolicy 100 500
  24. testequalpolicy 990 500 -t now
  25. sed -i aptarchive/Release -e 1i"NotAutomatic: yes"
  26. rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
  27. aptget update -qq
  28. testequalpolicy 100 1 -o Test=NotAutomatic
  29. testequalpolicy 990 1 -o Test=NotAutomatic -t now
  30. sed -i aptarchive/Release -e 1i"ButAutomaticUpgrades: yes"
  31. rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
  32. aptget update -qq
  33. testequalpolicy 100 100 -o Test=ButAutomaticUpgrades
  34. testequalpolicy 990 100 -o Test=ButAutomaticUpgrades -t now
  35. sed -i aptarchive/Release -e 's#NotAutomatic: yes#NotAutomatic: no#' -e '/ButAutomaticUpgrades: / d'
  36. rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
  37. aptget update -qq
  38. testequalpolicy 100 500 -o Test=Automatic
  39. testequalpolicy 990 500 -o Test=Automatic -t now
  40. buildsimplenativepackage "coolstuff" "all" "1.0" "stable"
  41. buildsimplenativepackage "coolstuff" "all" "2.0~bpo1" "backports"
  42. setupaptarchive
  43. testequalpolicycoolstuff() {
  44. local INSTALLED="${1:-(none)}"
  45. local CANDIDATE="${2:-(none)}"
  46. local AB="$3"
  47. local AS="$4"
  48. local PB="$5"
  49. local PINVERSION="$6"
  50. if [ -n "$PINVERSION" ]; then
  51. PINVERSION="Package pin: $PINVERSION
  52. "
  53. fi
  54. local IS=""
  55. local IB=""
  56. local SB=""
  57. local SS=""
  58. [ "$1" = "2.0~bpo1" ] && IB="***" && SB="
  59. 100 $STATUS" || IB=" "
  60. [ "$1" = "1.0" ] && IS="***" && SS="
  61. 100 $STATUS" || IS=" "
  62. local BPO1ARCHIVE=""
  63. local BPO2ARCHIVE=""
  64. if [ ! "$7" = "2.0~bpo2" ]; then
  65. BPO1ARCHIVE=" $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/ backports/main i386 Packages"
  66. else
  67. BPO2ARCHIVE="
  68. 2.0~bpo2 $PB
  69. $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/ backports/main i386 Packages"
  70. SB="$(echo "$SB" | tail -n 1)"
  71. shift
  72. fi
  73. shift 6
  74. testequal "coolstuff:
  75. Installed: $INSTALLED
  76. Candidate: $CANDIDATE
  77. ${PINVERSION}Version table:${BPO2ARCHIVE}
  78. $IB 2.0~bpo1 $PB
  79. ${BPO1ARCHIVE}$SB
  80. $IS 1.0 $PB
  81. $(echo "$AS" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/ stable/main i386 Packages$SS" \
  82. aptcache policy coolstuff -o Policy=${INSTALLED}-${CANDIDATE}-${AB}-${AS}-${PB} $*
  83. }
  84. testequalpolicycoolstuff "" "2.0~bpo1" 500 500 0 ""
  85. testequalpolicycoolstuff "" "1.0" 500 990 0 "" -t stable
  86. testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -t backports
  87. echo "Package: *
  88. Pin: release n=backports
  89. Pin-Priority: 200" > rootdir/etc/apt/preferences
  90. testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=GlobalPin
  91. testequalpolicycoolstuff "" "1.0" 200 990 0 "" -o Test=GlobalPin -t stable
  92. testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=GlobalPin -t backports
  93. echo "Package: *
  94. Pin: release n=backports
  95. Pin-Priority: 600" > rootdir/etc/apt/preferences
  96. testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=GlobalPin
  97. testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=GlobalPin -t stable
  98. echo "Package: coolstuff
  99. Pin: release n=backports
  100. Pin-Priority: 200" > rootdir/etc/apt/preferences
  101. #FIXME: policy can't differentiate between two sources where one has a package specific pin in place
  102. # testequalpolicycoolstuff "" "1.0" 500 500 200 "2.0~bpo1" -o Test=PackagePin
  103. # testequalpolicycoolstuff "" "1.0" 990 500 200 "2.0~bpo1" -o Test=PackagePin -t backports
  104. testequalpolicycoolstuff "" "1.0" 500 990 200 "2.0~bpo1" -o Test=PackagePin -t stable
  105. echo "Package: coolstuff
  106. Pin: release n=backports
  107. Pin-Priority: 600" > rootdir/etc/apt/preferences
  108. testequalpolicycoolstuff "" "2.0~bpo1" 500 500 600 "2.0~bpo1" -o Test=PackagePin
  109. testequalpolicycoolstuff "" "1.0" 500 990 600 "2.0~bpo1" -o Test=PackagePin -t stable
  110. testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=PackagePin -t backports
  111. echo "Package: coolstuff
  112. Pin: release n=backports
  113. Pin-Priority: -1" > rootdir/etc/apt/preferences
  114. # testequalpolicycoolstuff "" "1.0" 500 500 -1 "2.0~bpo1" -o Test=PackagePin
  115. # testequalpolicycoolstuff "" "1.0" 990 500 -1 "2.0~bpo1" -o Test=PackagePin -t backports
  116. # testequalpolicycoolstuff "" "1.0" 500 990 -1 "2.0~bpo1" -o Test=PackagePin -t stable
  117. rm rootdir/etc/apt/preferences
  118. sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
  119. signreleasefiles
  120. rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
  121. aptget update -qq
  122. testequalpolicycoolstuff "" "1.0" 1 500 0 "" -o Test=NotAutomatic
  123. testequalpolicycoolstuff "" "1.0" 1 990 0 "" -o Test=NotAutomatic -t stable
  124. testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=NotAutomatic -t backports
  125. echo "Package: *
  126. Pin: release n=backports
  127. Pin-Priority: 200" > rootdir/etc/apt/preferences
  128. testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=NotAutomatic
  129. echo "Package: *
  130. Pin: release n=backports
  131. Pin-Priority: 600" > rootdir/etc/apt/preferences
  132. testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=NotAutomatic
  133. testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=NotAutomatic -t stable
  134. echo "Package: coolstuff
  135. Pin: release n=backports
  136. Pin-Priority: 200" > rootdir/etc/apt/preferences
  137. testequalpolicycoolstuff "" "1.0" 1 500 200 "2.0~bpo1" -o Test=NotAutomatic
  138. echo "Package: coolstuff
  139. Pin: release n=backports
  140. Pin-Priority: 600" > rootdir/etc/apt/preferences
  141. testequalpolicycoolstuff "" "2.0~bpo1" 1 500 600 "2.0~bpo1" -o Test=NotAutomatic
  142. testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=NotAutomatic -t backports
  143. testequalpolicycoolstuff "" "1.0" 1 990 600 "2.0~bpo1" -o Test=NotAutomatic -t stable
  144. rm rootdir/etc/apt/preferences
  145. sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
  146. signreleasefiles
  147. rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
  148. aptget update -qq
  149. testequalpolicycoolstuff "" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
  150. testequalpolicycoolstuff "" "1.0" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
  151. testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
  152. echo "Package: *
  153. Pin: release n=backports
  154. Pin-Priority: 200" > rootdir/etc/apt/preferences
  155. testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=ButAutomaticUpgrades
  156. echo "Package: *
  157. Pin: release n=backports
  158. Pin-Priority: 600" > rootdir/etc/apt/preferences
  159. testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=ButAutomaticUpgrades
  160. testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=ButAutomaticUpgrades -t stable
  161. echo "Package: coolstuff
  162. Pin: release n=backports
  163. Pin-Priority: 200" > rootdir/etc/apt/preferences
  164. testequalpolicycoolstuff "" "1.0" 100 500 200 "2.0~bpo1" -o Test=ButAutomaticUpgrades
  165. echo "Package: coolstuff
  166. Pin: release n=backports
  167. Pin-Priority: 600" > rootdir/etc/apt/preferences
  168. testequalpolicycoolstuff "" "2.0~bpo1" 100 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades
  169. testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t backports
  170. testequalpolicycoolstuff "" "1.0" 100 990 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t stable
  171. rm rootdir/etc/apt/preferences
  172. aptget install coolstuff -qq > /dev/null 2> /dev/null
  173. testequalpolicycoolstuff "1.0" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
  174. aptget dist-upgrade -qq > /dev/null 2> /dev/null
  175. testequalpolicycoolstuff "1.0" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
  176. testequalpolicycoolstuff "1.0" "1.0" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
  177. testequalpolicycoolstuff "1.0" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
  178. aptget install coolstuff -t backports -qq > /dev/null 2> /dev/null
  179. testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 0 "" -o Test=ButAutomaticUpgrades
  180. aptget dist-upgrade -qq > /dev/null 2> /dev/null
  181. testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 0 "" -o Test=ButAutomaticUpgrades
  182. testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
  183. testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
  184. rm incoming/backports.main.pkglist incoming/backports.main.srclist
  185. buildsimplenativepackage "coolstuff" "all" "2.0~bpo2" "backports"
  186. setupaptarchive
  187. sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
  188. signreleasefiles
  189. rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
  190. aptget update -qq
  191. testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 500 0 "" "2.0~bpo2" -o Test=NotAutomatic
  192. testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 990 0 "" "2.0~bpo2" -o Test=NotAutomatic -t stable
  193. testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 0 "" "2.0~bpo2" -o Test=NotAutomatic -t backports
  194. sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
  195. signreleasefiles
  196. rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
  197. aptget update -qq
  198. testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades
  199. testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 990 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t stable
  200. testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t backports