home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / var / lib / dpkg / info / console-common.preinst < prev    next >
Encoding:
Text File  |  2006-07-06  |  5.3 KB  |  176 lines

  1. #! /bin/sh
  2.  
  3. set -e
  4.  
  5. # Rename old local keymaps dir if any
  6. if [ -d /usr/local/share/keytables ]
  7. then
  8.     if [ -d "`readlink -f /usr/local/share/keymaps`" ]
  9.     then
  10.     files=`find /usr/local/share/keytables -mindepth 1 -maxdepth 1`
  11.         [ "$files" ] && mv $files /usr/local/share/keymaps/
  12.         rmdir /usr/local/share/keytables
  13.     elif [ -e /usr/local/share/keymaps ]
  14.     then
  15.         echo >&2 "/usr/local/share/keymaps is buggy - please check it"
  16.         ls -ld /usr/local/share/keymaps >&2
  17.         echo >&2 "Press RETURN to continue"
  18.         read foo
  19.     else
  20.         mv /usr/local/share/keytables /usr/local/share/keymaps
  21.     fi
  22. elif [ -e /usr/local/share/keytables ]
  23. then
  24.     echo >&2 <<EOF
  25. /usr/local/share/keytables is not a dir.  I won\'t try to mess
  26. with it and you will surely want to do something with it, as the
  27. new location for local keymaps is now /usr/local/share/keymaps/.
  28.  
  29. Press RETURN to continue
  30. EOF
  31.     read foo
  32. fi
  33.  
  34.  
  35. # Import local files from obsolete /usr/lib/kbd directory
  36. if [ -d /usr/lib/kbd ]
  37. then
  38.     echo >&2 Importing local files from obsolete /usr/lib/kbd directory into /usr/local/:
  39.     set +e    # there may be no files in those directories !
  40.     for d in keytables consolefonts consoletrans videomodes; do
  41.     # if the dir exists and is not a link (into /usr/share)
  42.     if [ -d /usr/lib/kbd/${d} ] && [ ! -L /usr/lib/kbd/${d} ]
  43.     then
  44.         # maybe create local dir
  45.         test -d /usr/local/share/${d} || mkdir -p /usr/local/share/${d}
  46.         files=`find /usr/lib/kbd/${d} -mindepth 1 -maxdepth 1`
  47.         [ "$files" ] && mv $files /usr/local/share/${d}/
  48.         rmdir /usr/lib/kbd/${d}
  49.     fi
  50.     # remove an eventual symlink
  51.     rm -f /usr/lib/kbd/${d}
  52.     done
  53.     set -e
  54.     echo >&2 " done importing."
  55.     # try to remove the old dir, but be nice when not empty
  56.     rmdir /usr/lib/kbd 2>/dev/null || echo >&2 <<EOF 
  57. WARNING: /usr/lib/kbd/ not removed - other files there ?
  58. Check this and remove it by hand.
  59. EOF
  60. fi
  61.  
  62. . /usr/share/debconf/confmodule
  63.  
  64. if db_get console-data/keymap/qwertz/german/standard/keymap && [ "$RET" = "Standard" ];
  65. then
  66.     db_set console-data/keymap/qwertz/german/standard/keymap Programmer
  67. fi
  68.  
  69. # Remove some old, dodgy entries from the database
  70. if [ "$1" = configure ] && dpkg --compare-versions "$2" lt 0.7.24  ; then
  71.     db_unregister console-data/keymap/full || true
  72.     db_unregister console-data/keymap/azerty/french/variant || true
  73.     db_unregister console-data/keymap/qwertz || true
  74. fi
  75.  
  76. # Wipe old dodgy escaped values from db too. Closes: #254324.
  77. if db_get console-data/keymap/policy && [ "$RET" = "Don\'t touch keymap" ];
  78. then
  79.   db_set console-data/keymap/policy "Don't touch keymap"
  80. fi
  81.  
  82. # If the entry contains a / it's broken so overwrite it with a default
  83. # value.  See see #110873
  84. if db_get console-data/keymap/full && echo "$RET" | grep -q "/";
  85. then
  86.     db_set console-data/keymap/full us
  87. fi
  88.  
  89.  
  90. # Ensure we don't step on a hand-edited /etc/console/boottime.kmap.gz
  91. BOOT_MAP=/etc/console/boottime.kmap.gz
  92. MD="none"
  93. [ -r $BOOT_MAP ] && MD=`md5sum $BOOT_MAP |  cut -d' ' -f1 `
  94. if  db_get console-data/bootmap-md5sum && [ "$RET" != "$MD" ] ; then
  95.    db_set console-data/keymap/policy "Don't touch keymap"
  96. fi
  97.  
  98. db_get console-data/keymap/family
  99. CFAMILY=`echo $RET | perl -pe '$_ = lc; s/[^a-z0-9+\-\.\/\n]/_/g';`
  100. LAYOUT=console-data/keymap/$CFAMILY/layout
  101.  
  102. # Is there a chance that a user-provided keymap has to imported ?
  103. # Let's cross our fingers... it should never break, but...
  104. if db_get $LAYOUT && [ -x /usr/share/console/getkmapchoice.pl ];
  105. then
  106.    # Protect against failure of getkmapchoice.pl by locally turning
  107.    # off set -e.
  108.    set +e
  109.    choice="$(PERL_BADLANG=0 /usr/share/console/getkmapchoice.pl 2>&1)"
  110.    if [ $? != 0 ]; then
  111.       # See comment below
  112.       choice="useless"
  113.    fi
  114.    set -e
  115. else
  116.     # if getkmapchoice is not there, assume the user never had the
  117.     # oportunity to select no keymap to be installed using the
  118.     # console-common framework
  119.     choice="useless"
  120. fi
  121.  
  122.  
  123. # Maybe import boottime keymap
  124.  
  125. if [ "$choice" != KERNEL -a "$choice" != NONE -a ! -r /etc/console/boottime.kmap.gz ]
  126. then
  127.     # if we have to move a file, we need this dir
  128.     mkdir -p /etc/console
  129.  
  130.     if dpkg --status console-tools 2>/dev/null | grep -q '^Status: .* installed$'; then
  131.     # take it from console-tools
  132.  
  133.     if [ -r /etc/console-tools/default.kmap.gz ]
  134.     then
  135.         mv /etc/console-tools/default.kmap.gz /etc/console/boottime.kmap.gz
  136.     elif [ -r /etc/console-tools/default.kmap ]
  137.     then
  138.         gzip -9f /etc/console-tools/default.kmap
  139.         mv /etc/console-tools/default.kmap.gz /etc/console/boottime.kmap.gz
  140.     fi
  141.  
  142.     if [ -r /etc/console/boottime.kmap.gz ]
  143.     then
  144.         echo >&2 "Imported boot-time keymap from old console-tools settings"
  145.     fi
  146.  
  147.     elif dpkg --status kbd 2>/dev/null | grep -q '^Status: .* installed$'; then
  148.     # take it from kbd
  149.  
  150.     if [ -r /etc/kbd/default.kmap.gz ]
  151.     then
  152.         mv /etc/kbd/default.kmap.gz /etc/console/boottime.kmap.gz
  153.     elif [ -r /etc/kbd/default.kmap ]
  154.     then
  155.         gzip -9f /etc/kbd/default.kmap
  156.         mv /etc/kbd/default.kmap.gz /etc/console/boottime.kmap.gz
  157.     elif [ -r /etc/kbd/default.map.gz ]
  158.     then
  159.         mv /etc/kbd/default.map.gz /etc/console/boottime.kmap.gz
  160.     elif [ -r /etc/kbd/default.map ]
  161.     then
  162.         gzip -9f /etc/kbd/default.map
  163.         mv /etc/kbd/default.map.gz /etc/console/boottime.kmap.gz
  164.     fi
  165.  
  166.     if [ -r /etc/console/boottime.kmap.gz ]
  167.     then
  168.         echo >&2 "Imported boot-time keymap from old kbd settings"
  169.     fi
  170.  
  171.     fi
  172. fi
  173.  
  174.  
  175.  
  176.