test-apt-get-autoremove 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'i386'
  7. buildsimplenativepackage 'unrelated' 'all' '1' 'unstable'
  8. buildsimplenativepackage 'po-debconf' 'all' '1.0.16' 'unstable'
  9. buildsimplenativepackage 'debhelper' 'all' '8.0.0' 'unstable' 'Depends: po-debconf'
  10. setupaptarchive
  11. testsuccess aptget install unrelated debhelper -y
  12. testdpkginstalled 'unrelated' 'debhelper' 'po-debconf'
  13. testmarkedauto 'po-debconf'
  14. testsuccess aptget remove debhelper -y
  15. testdpkgnotinstalled 'debhelper'
  16. testdpkginstalled 'po-debconf' 'unrelated'
  17. echo 'unrelated purge' | dpkg --set-selections
  18. testdpkgstatus 'pi' '1' 'unrelated'
  19. AUTOREMOVE='apt autoremove'
  20. if [ -n "$SUDO_USER" ]; then
  21. AUTOREMOVE="sudo $AUTOREMOVE"
  22. fi
  23. echo 'APT::NeverAutoRemove { "^debc.*nf$"; };' > rootdir/etc/apt/apt.conf.d/00autoremove
  24. testsuccessequal 'Reading package lists...
  25. Building dependency tree...
  26. Reading state information...
  27. The following packages will be REMOVED:
  28. po-debconf
  29. 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
  30. Remv po-debconf [1.0.16]' aptget autoremove -s
  31. testequal "Reading package lists...
  32. Building dependency tree...
  33. Reading state information...
  34. The following package was automatically installed and is no longer required:
  35. po-debconf
  36. Use '$AUTOREMOVE' to remove it.
  37. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s
  38. testequal "Reading package lists...
  39. Building dependency tree...
  40. Reading state information...
  41. 1 package was automatically installed and is no longer required.
  42. Use '$AUTOREMOVE' to remove it.
  43. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -o APT::Get::HideAutoRemove=small
  44. testdpkginstalled 'po-debconf'
  45. echo 'APT::NeverAutoRemove { "^po-debconf$"; };' > rootdir/etc/apt/apt.conf.d/00autoremove
  46. testsuccess aptget autoremove -y
  47. testdpkginstalled 'po-debconf'
  48. testdpkgstatus 'pi' '1' 'unrelated'
  49. echo 'APT::NeverAutoRemove { "^po-.*$"; };' > rootdir/etc/apt/apt.conf.d/00autoremove
  50. testsuccess aptget autoremove -y
  51. testdpkginstalled "po-debconf"
  52. testdpkgstatus 'pi' '1' 'unrelated'
  53. rm rootdir/etc/apt/apt.conf.d/00autoremove
  54. testsuccess aptget autoremove -y
  55. testdpkgnotinstalled 'po-debconf'
  56. testdpkgstatus 'pi' '1' 'unrelated'
  57. testmarkedauto
  58. sed rootdir/var/log/apt/history.log -e '/^Commandline: / d' \
  59. -e '/^Start-Date: / d' -e '/^End-Date: / d' \
  60. -e '/^Requested-By: / d' \
  61. -e 's#), #)\nInstall: #g' | sort -u > apt-history.log
  62. testfileequal 'apt-history.log' '
  63. Install: debhelper:i386 (8.0.0)
  64. Install: po-debconf:i386 (1.0.16, automatic)
  65. Install: unrelated:i386 (1)
  66. Remove: debhelper:i386 (8.0.0)
  67. Remove: po-debconf:i386 (1.0.16)'
  68. testsuccess aptget install debhelper -y
  69. testdpkgstatus 'pi' '1' 'unrelated'
  70. testdpkginstalled 'debhelper' 'po-debconf'
  71. testsuccess aptmark auto debhelper
  72. testmarkedauto 'debhelper' 'po-debconf'
  73. testsuccessequal 'Reading package lists...
  74. Building dependency tree...
  75. Reading state information...
  76. The following packages will be REMOVED:
  77. debhelper po-debconf
  78. 0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
  79. Remv debhelper [8.0.0]
  80. Remv po-debconf [1.0.16]' aptget autoremove -s
  81. testequal "Reading package lists...
  82. Building dependency tree...
  83. Reading state information...
  84. The following packages were automatically installed and are no longer required:
  85. debhelper po-debconf
  86. Use '$AUTOREMOVE' to remove them.
  87. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s
  88. testequal "Reading package lists...
  89. Building dependency tree...
  90. Reading state information...
  91. 2 packages were automatically installed and are no longer required.
  92. Use '$AUTOREMOVE' to remove them.
  93. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -o APT::Get::HideAutoRemove=small
  94. testsuccess aptmark hold debhelper
  95. testsuccessequal 'Reading package lists...
  96. Building dependency tree...
  97. Reading state information...
  98. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.' aptget autoremove -s
  99. testsuccess aptget autoremove debhelper -y --allow-change-held-packages
  100. testdpkgnotinstalled 'po-debconf' 'debhelper'
  101. testdpkgstatus 'pi' '1' 'unrelated'
  102. testmarkedauto
  103. testsuccess aptget install debhelper --solver apt -y -o Debug::pkgDepCache::Marker=1
  104. testmarkedauto 'po-debconf'
  105. testdpkgstatus 'pi' '1' 'unrelated'
  106. insertinstalledpackage 'bar' 'all' '1' 'Depends: foo-provider'
  107. insertinstalledpackage 'foo-multi1-1' 'all' '1' 'Provides: foo-provider
  108. Source: foo-multi (1)'
  109. insertinstalledpackage 'foo-multi1-2' 'all' '1' 'Provides: foo-provider
  110. Source: foo-multi (2)'
  111. insertinstalledpackage 'foo-multi1-3' 'all' '1' 'Provides: foo-provider
  112. Source: foo-multi (3)'
  113. insertinstalledpackage 'foo-multi2-1' 'all' '1' 'Provides: foo-provider
  114. Source: foo-multi (1)'
  115. insertinstalledpackage 'foo-multi2-2' 'all' '1' 'Provides: foo-provider
  116. Source: foo-multi (2)'
  117. insertinstalledpackage 'foo-multi2-3' 'all' '1' 'Provides: foo-provider
  118. Source: foo-multi (3)'
  119. insertinstalledpackage 'foo-plus-1' 'all' '1' 'Provides: foo-provider
  120. Source: foo-plus (1)'
  121. insertinstalledpackage 'foo-plus-2' 'all' '1' 'Provides: foo-provider
  122. Source: foo-plus (2)'
  123. insertinstalledpackage 'foo-plus-3' 'all' '1' 'Provides: foo-provider
  124. Source: foo-plus (3)'
  125. insertinstalledpackage 'foo-single-1' 'all' '1' 'Provides: foo-provider'
  126. insertinstalledpackage 'foo-single-2' 'all' '1' 'Provides: foo-provider'
  127. testsuccess aptmark auto 'foo-*'
  128. testsuccessequal 'Reading package lists...
  129. Building dependency tree...
  130. Reading state information...
  131. The following packages will be REMOVED:
  132. foo-multi1-1 foo-multi1-2 foo-multi2-1 foo-multi2-2 foo-plus-1 foo-plus-2
  133. 0 upgraded, 0 newly installed, 6 to remove and 0 not upgraded.
  134. Remv foo-multi1-1 [1]
  135. Remv foo-multi1-2 [1]
  136. Remv foo-multi2-1 [1]
  137. Remv foo-multi2-2 [1]
  138. Remv foo-plus-1 [1]
  139. Remv foo-plus-2 [1]' apt autoremove -s
  140. testdpkgstatus 'pi' '1' 'unrelated'
  141. testsuccess apt purge unrelated -y