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.
 
 
 

106 lines
2.1 KiB

  1. #!/bin/sh
  2. # Try to guess at whether the user would like a desktop installed on their
  3. # system. Of course Debian has many users who use it on a wide array of
  4. # hardware, so this is tricky, but it's only a default.
  5. set -e
  6. if ! [ "$NEW_INSTALL" ]; then
  7. exit 3
  8. fi
  9. arch="$(dpkg --print-architecture)"
  10. unmark () {
  11. exit 3
  12. }
  13. mark () {
  14. exit 2
  15. }
  16. # A few arches have the lion's share of desktops.
  17. common_desktop_architecture () {
  18. case "$arch" in
  19. i386|amd64|powerpc*)
  20. return 0
  21. ;;
  22. *)
  23. return 1
  24. ;;
  25. esac
  26. }
  27. # On some arches it's almost unheard of to run a desktop, at least using
  28. # this task.
  29. unlikely_desktop_architecture () {
  30. case "$arch" in
  31. m68k|s390|hppa)
  32. return 0
  33. ;;
  34. *)
  35. return 1
  36. ;;
  37. esac
  38. }
  39. # Modern desktops take a lot of ram.
  40. enough_ram () {
  41. min_ram=64
  42. ram=$(grep ^MemTotal: /proc/meminfo | { read x y z; echo $y; }) || true # kb
  43. # The 4 is a fuzz factor to allow for kernel ram usage.
  44. if [ "$ram" ] && [ "$ram" -ge "$(expr $(expr $min_ram - 4) \* 1024)" ]; then
  45. return 0
  46. else
  47. return 1
  48. fi
  49. }
  50. # The desktop task requires 2 gb or so of disk in /usr.
  51. # FIXME: this should really be generalised and used for tasksel to not
  52. # suggest any task for which there is not enough disk.
  53. enough_disk () {
  54. min_disk=2
  55. disk=$(df /usr | tail -1 | awk '{print $4}')
  56. if [ "$disk" ] && [ "$disk" -ge "$(expr $min_disk \* 1024 \* 1024)" ]; then
  57. return 0
  58. else
  59. return 1
  60. fi
  61. }
  62. desktop_hardware () {
  63. if laptop-detect; then
  64. # Nearly always appropriate to include a desktop.
  65. return 0
  66. else
  67. # TODO: test for the existence of a framebuffer and a mouse.
  68. # A mouse, in particular, almost always indicates a
  69. # desktop.
  70. :
  71. fi
  72. return 1
  73. }
  74. if ! enough_ram || ! enough_disk; then
  75. unmark
  76. fi
  77. if desktop_hardware; then
  78. mark
  79. fi
  80. if unlikely_desktop_architecture; then
  81. unmark
  82. elif common_desktop_architecture; then
  83. # XXX further heuristics here to avoid selecting the task on
  84. # high-end hardware that's intended to be used as a server.
  85. # For example, if it has two NICs with link, it's probably a
  86. # server. If it's rackmountable, a server, etc.
  87. mark # probably a desktop ...
  88. else
  89. # XXX further heuristics here
  90. :
  91. fi
  92. unmark