Debian Codegraph @

src/usr/lib/debian-installer.d/S60frontend

raw
1 get_mem () {
2 local ram=$(grep ^MemTotal: /proc/meminfo | { read x y z; echo $y; }) || true # in kilobytes
3 if [ -z "$ram" ]; then
4 echo "Cannot determine system memory" >&2
5 ram=0
6 else
7 ram=$(expr "$ram" / 1024) # convert to megabytes
8 fi
9 echo $ram
10 }
11
12 check_gtk () {
13 if [ -n "$LIVE_INSTALLER_MODE" ]; then
14 return 0
15 fi
16
17 OS="$(udpkg --print-os)"
18 if [ "$OS" = linux -a -z "$TERM_FRAMEBUFFER" ] ; then
19 echo "Framebuffer not available; disabling graphical frontend" >&2
20 return 1
21 fi
22 if [ "$OS" = hurd -a "$TERM" != hurd ] ; then
23 echo "Hurd console not started; disabling graphical frontend" >&2
24 return 1
25 fi
26 if [ "$GTK_NOVESA" ]; then
27 echo "No VESA framebuffer available; disabling graphical frontend" >&2
28 return 1
29 fi
30
31 case "$(archdetect)" in
32 # Tested with Uyghur
33 powerpc/*|amd64/*)
34 local MEMLIMIT=766 ;; # is 783460kB, qemu -m 810
35 hurd-i386/*)
36 local MEMLIMIT=750 ;; # qemu -m 750
37 hurd-amd64/*)
38 # TODO
39 local MEMLIMIT=750 ;; # qemu -m 750
40 *)
41 local MEMLIMIT=534 ;; # is 546188kB, qemu -m 550
42 esac
43
44 if [ $(get_mem) -lt $MEMLIMIT ] ; then
45 echo "Insufficient memory for graphical frontend; disabling" >&2
46 return 1
47 fi
48 return 0
49 }
50
51 if [ -z "$DEBIAN_FRONTEND" ] ; then
52 for frontend in gtk newt slang text ; do
53 if [ -e "/usr/lib/cdebconf/frontend/$frontend.so" ]; then
54 if [ "$frontend" = gtk ] ; then
55 check_gtk || continue
56 fi
57 DEBIAN_FRONTEND=$frontend
58 break
59 fi
60 done
61 fi
62 export DEBIAN_FRONTEND