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.
 
 
 
 
 
 

95 lines
3.9 KiB

  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'amd64'
  7. cat rootdir/etc/apt/apt.conf.d/01multiarch.conf >> $(getaptconfig)
  8. if [ "$(id -u)" = '0' ]; then
  9. msgskip 'Tests for unreadable files do not work as root'
  10. exit 0
  11. fi
  12. insertinstalledpackage 'foo' 'amd64' '1'
  13. insertpackage 'unstable' 'foo' 'amd64' '2'
  14. setupaptarchive --no-update
  15. touch rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list
  16. touch rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.sources
  17. touch rootdir/etc/apt/apt.conf.d/unreadable.conf
  18. touch rootdir/etc/apt/preferences.d/unreadable.pref
  19. addtrap 'prefix' "chmod -R +r '$(escape_shell "$TMPWORKINGDIRECTORY")/rootdir/etc/apt';"
  20. chmod -r rootdir/etc/apt/trusted.gpg.d
  21. testfailure apt update
  22. chmod +r rootdir/etc/apt/trusted.gpg.d
  23. testsuccess apt update
  24. testsuccess apt policy foo
  25. testsuccess apt search foo
  26. testsuccessequal "Listing...
  27. foo/unstable 2 amd64 [upgradable from: 1]
  28. N: There is 1 additional version. Please use the '-a' switch to see it" apt list --upgradable
  29. runthemall() {
  30. local ERR="$1"
  31. local ERRNOTICEVER="$1${2-
  32. N: There is 1 additional version. Please use the '-a' switch to see it}"
  33. local ERRNOTICEREC="$1${2-
  34. N: There is 1 additional record. Please use the '-a' switch to see it}"
  35. testwarningmsg "$ERR" aptcache policy
  36. testwarningmsg "$ERR" aptcache policy foo
  37. testwarningmsg "$ERR" aptcache depends foo
  38. testwarningmsg "$ERR" aptcache rdepends foo
  39. testwarningmsg "$ERR" aptcache search foo
  40. testwarningmsg "$ERR" apt policy
  41. testwarningmsg "$ERR" apt policy foo
  42. testwarningmsg "$ERR" apt depends foo
  43. testwarningmsg "$ERR" apt rdepends foo
  44. testwarningmsg "$ERR" apt search foo
  45. testwarningmsg "$ERRNOTICEVER" apt list --upgradable
  46. testwarningmsg "$ERRNOTICEREC" apt show foo
  47. testwarningmsg "$ERRNOTICEREC" aptcache show foo --no-all-versions
  48. testwarningmsg "$ERR" aptmark auto foo
  49. testwarningmsg "$ERR" aptmark manual foo
  50. testwarningmsg "$ERR" aptmark auto foo
  51. }
  52. echo 'Apt::Cmd::Disable-Script-Warning "true";' >> aptconfig.conf
  53. msgmsg 'Unreadable one-line-style sources file'
  54. chmod -r rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list
  55. runthemall "W: Unable to read $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list - open (13: Permission denied)"
  56. chmod +r rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list
  57. msgmsg 'Unreadable deb822-style sources file'
  58. chmod -r rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.sources
  59. runthemall "W: Unable to read $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.sources - open (13: Permission denied)"
  60. chmod +r rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.sources
  61. msgmsg 'Unreadable config file'
  62. chmod -r rootdir/etc/apt/apt.conf.d/unreadable.conf
  63. runthemall "W: Unable to read ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/unreadable.conf - open (13: Permission denied)"
  64. chmod +r rootdir/etc/apt/apt.conf.d/unreadable.conf
  65. msgmsg 'Unreadable preferences file'
  66. chmod -r rootdir/etc/apt/preferences.d/unreadable.pref
  67. runthemall "W: Unable to read ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/preferences.d/unreadable.pref - open (13: Permission denied)"
  68. chmod +r rootdir/etc/apt/preferences.d/unreadable.pref
  69. msgmsg 'Unreadable sources directory'
  70. chmod -r rootdir/etc/apt/sources.list.d
  71. runthemall "W: Unable to read $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list.d/ - opendir (13: Permission denied)" ""
  72. chmod +r rootdir/etc/apt/sources.list.d
  73. msgmsg 'Unreadable config directory'
  74. chmod -r rootdir/etc/apt/apt.conf.d
  75. runthemall "W: Unable to read ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/ - opendir (13: Permission denied)"
  76. chmod +r rootdir/etc/apt/apt.conf.d
  77. msgmsg 'Unreadable preferences directory'
  78. chmod -r rootdir/etc/apt/preferences.d
  79. runthemall "W: Unable to read ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/preferences.d/ - opendir (13: Permission denied)"
  80. chmod +r rootdir/etc/apt/preferences.d