test-apt-cdrom 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #!/bin/sh
  2. set -e
  3. TESTDIR=$(readlink -f $(dirname $0))
  4. . $TESTDIR/framework
  5. setupenvironment
  6. configarchitecture 'amd64' 'i386'
  7. buildsimplenativepackage 'testing' 'amd64,i386' '0.8.15' 'stable'
  8. setupaptarchive --no-update
  9. changetocdrom 'Debian APT Testdisk 0.8.15'
  10. # -de is not in the Release file, but picked up anyway for compatibility
  11. cd rootdir/media/cdrom-unmounted/dists/stable/main/i18n
  12. chmod +w .
  13. sed -e '/^Description-en:/ d' -e '/^ / d' -e '/^$/ d' Translation-en > Translation-de
  14. echo 'Description-de: automatisch generiertes Testpaket testing=0.8.15/stable
  15. Diese Pakete sind nur für das testen von APT gedacht,
  16. sie erfüllen keinen Zweck auf einem normalen System…
  17. ' >> Translation-de
  18. compressfile Translation-de
  19. rm -f Translation-en Translation-de
  20. chmod -R 555 .
  21. cd - > /dev/null
  22. aptcdromlog() {
  23. rm -f rootdir/tmp/apt-cdrom.log
  24. test ! -e rootdir/media/cdrom || echo "CD-ROM is mounted, but shouldn't be!"
  25. test -e rootdir/media/cdrom-unmounted || echo "Unmounted CD-ROM doesn't exist, but it should!"
  26. aptcdrom "$@" -o quiet=1 >rootdir/tmp/apt-cdrom.log 2>&1 </dev/null
  27. sed -e '/gpgv\?: Signature made/ d' -e '/gpgv\?: Good signature/ d' -e '/^Identifying/ d' -e '/Reading / d' rootdir/tmp/apt-cdrom.log
  28. test ! -e rootdir/media/cdrom || echo "CD-ROM is mounted, but shouldn't be!"
  29. test -e rootdir/media/cdrom-unmounted || echo "Unmounted CD-ROM doesn't exist, but it should!"
  30. }
  31. CDROM_PRE="Using CD-ROM mount point $(readlink -f ./rootdir/media)/cdrom/
  32. Unmounting CD-ROM...
  33. Waiting for disc...
  34. Please insert a Disc in the drive and press enter
  35. Mounting CD-ROM...
  36. Scanning disc for index files..."
  37. CDROM_POST="This disc is called:
  38. 'Debian APT Testdisk 0.8.15'
  39. Writing new source list
  40. Source list entries for this disc are:
  41. deb cdrom:[Debian APT Testdisk 0.8.15]/ stable main
  42. deb-src cdrom:[Debian APT Testdisk 0.8.15]/ stable main
  43. Unmounting CD-ROM...
  44. Repeat this process for the rest of the CDs in your set."
  45. testequal "$CDROM_PRE
  46. Found 2 package indexes, 1 source indexes, 1 translation indexes and 1 signatures
  47. Found label 'Debian APT Testdisk 0.8.15'
  48. $CDROM_POST" aptcdromlog add
  49. testequal "Using CD-ROM mount point $(readlink -f ./rootdir/media)/cdrom/
  50. Mounting CD-ROM...
  51. Stored label: Debian APT Testdisk 0.8.15
  52. Unmounting CD-ROM..." aptcdromlog ident
  53. # apt-setup uses these commands (expect the tr in the id) to find id and label
  54. ident="$(LC_ALL=C aptcdrom ident 2>&1 )"
  55. CD_ID="$(echo "$ident" | grep "^Identifying" | head -n1 | cut -d" " -f2 | tr --delete '[]')"
  56. CD_LABEL="$(echo "$ident" | grep "^Stored label:" | head -n1 | sed "s/^[^:]*: //")"
  57. testequal "CD::${CD_ID} \"${CD_LABEL}\";
  58. CD::${CD_ID}::Label \"${CD_LABEL}\";" cat rootdir/var/lib/apt/cdroms.list
  59. testcdromusage() {
  60. touch rootdir/var/lib/apt/extended_states
  61. testequal 'Reading package lists...
  62. Building dependency tree...
  63. Reading state information...
  64. The following NEW packages will be installed:
  65. testing
  66. 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
  67. Inst testing (0.8.15 stable [amd64])
  68. Conf testing (0.8.15 stable [amd64])' aptget install testing -s
  69. testdpkgnotinstalled testing
  70. testsuccess aptget install testing -y
  71. testdpkginstalled testing
  72. testsuccess aptget purge testing -y
  73. testdpkgnotinstalled testing
  74. testequal 'Reading package lists...
  75. Building dependency tree...
  76. Reading state information...
  77. The following NEW packages will be installed:
  78. testing:i386
  79. 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
  80. Inst testing:i386 (0.8.15 stable [i386])
  81. Conf testing:i386 (0.8.15 stable [i386])' aptget install testing:i386 -s
  82. testdpkgnotinstalled testing:i386
  83. testsuccess aptget install testing:i386 -y
  84. testdpkginstalled testing:i386
  85. testsuccess aptget purge testing:i386 -y
  86. testdpkgnotinstalled testing:i386
  87. cd downloaded
  88. rm -f testing_0.8.15_amd64.deb
  89. testsuccess aptget download testing
  90. testsuccess test -s testing_0.8.15_amd64.deb
  91. rm -f testing_0.8.15_amd64.deb
  92. rm -f testing_0.8.15.dsc
  93. testsuccess aptget source testing --dsc-only -d
  94. testsuccess test -s testing_0.8.15.dsc
  95. rm -f testing_0.8.15.dsc
  96. cd - >/dev/null
  97. }
  98. testcdromusage
  99. # check Idempotence of apt-cdrom (and disabling of Translation dropping)
  100. testequal "$CDROM_PRE
  101. Found 2 package indexes, 1 source indexes, 2 translation indexes and 1 signatures
  102. $CDROM_POST" aptcdromlog add -o APT::CDROM::DropTranslation=0
  103. # take Translations from previous runs as needed
  104. testequal "$CDROM_PRE
  105. Found 2 package indexes, 1 source indexes, 2 translation indexes and 1 signatures
  106. $CDROM_POST" aptcdromlog add
  107. msgtest 'Test for the german description translation of' 'testing'
  108. aptcache show testing -o Acquire::Languages=de | grep -q '^Description-de: ' && msgpass || msgfail
  109. rm -rf rootdir/var/lib/apt/lists
  110. mkdir -p rootdir/var/lib/apt/lists/partial
  111. testequal "$CDROM_PRE
  112. Found 2 package indexes, 1 source indexes, 1 translation indexes and 1 signatures
  113. $CDROM_POST" aptcdromlog add
  114. msgtest 'Test for the english description translation of' 'testing'
  115. aptcache show testing -o Acquire::Languages=en | grep -q '^Description-en: ' && msgpass || msgfail
  116. # ensure cdrom method isn't trying to mount the cdrom
  117. mv rootdir/media/cdrom-unmounted rootdir/media/cdrom-ejected
  118. # ensure an update doesn't mess with cdrom sources
  119. testsuccess aptget update
  120. testfileequal rootdir/tmp/testsuccess.output 'Reading package lists...'
  121. mv rootdir/media/cdrom-ejected rootdir/media/cdrom-unmounted
  122. testcdromusage
  123. # and again to check that it withstands the temptation even if it could mount
  124. testsuccess aptget update
  125. testfileequal rootdir/tmp/testsuccess.output 'Reading package lists...'
  126. testcdromusage
  127. msgmsg 'Check that nothing touched our' 'CD-ROM'
  128. for file in $(find rootdir/media/cdrom-unmounted/dists); do
  129. testfilestats "$file" '%U:%G:%a' '=' "${USER}:${USER}:555"
  130. done