On Fri, Apr 25, 2008 at 10:50:29AM +0200, Michael Schutte wrote:
> 
> Uh, that's bad.  I'll do the obvious thing and create an appropriate
> symlink.

Hardcoding paths of executables is almost always evil.  Please take a 
look at the attached patch (I haven't tested it).

Anton Zinoviev

--- install-keymap	2008-04-25 22:00:50.000000000 +0300
+++ install-keymap.new	2008-04-25 22:08:57.000000000 +0300
@@ -11,9 +11,23 @@
 TEXTDOMAIN=install-keymap
 export TEXTDOMAIN
 
-if [ -x /usr/bin/gettext ]
+# The same as /usr/bin/which - in order to make "which" available before
+# /usr is mounted
+which () {
+    local IFS
+    IFS=:
+    for i in $PATH; do
+        if [ -x "$i/$1" ]; then
+            echo "$i/$1"
+            return 0
+        fi
+    done
+    return 1
+}
+
+if which gettext >/dev/null
 then
-   GETTEXT="/usr/bin/gettext -e -s"
+   GETTEXT="gettext -e -s"
 else
    GETTEXT="echo -e"
 fi
@@ -59,7 +73,7 @@
 	fi
 }
 
-if [ ! -x /bin/loadkeys ]
+if ! which loadkeys >/dev/null
 then
   $GETTEXT >&2 "Warning: no console utilities installed yet.\n deferring keymap setting until either console-tools or kbd is installed."
   exit 0
@@ -70,7 +84,7 @@
 {
     # save keymap
     TMP=`tempfile`
-    if ! /usr/bin/dumpkeys >${TMP}; then
+    if ! dumpkeys >${TMP}; then
     	check_if_serial_console
 	$GETTEXT >&2 "Failed to dump keymap!"
 	$GETTEXT >&2 "This might be because your console cannot be opened.  Perhaps you don't have\na video card, are connected via the serial console or ssh.\nNot loading keymap!"
@@ -79,7 +93,7 @@
          exit 0
     fi
 
-    if ! (eval "$*" && /bin/loadkeys -q ${TMP}); then
+    if ! (eval "$*" && loadkeys -q ${TMP}); then
     	 check_if_serial_console
          $GETTEXT >&2 "Failed to preserve keymap!"
          rm -f ${TMP}
@@ -149,7 +163,7 @@
     do_preserving_keymap "loadkeys -q $keymap ; dumpkeys | $TRANSLATOR | gzip -9n > $NEW"
 
     # if diff is available, use it to install only if needed
-    if [ -r $CONFFILE -a -x /usr/bin/diff ]
+    if [ -r $CONFFILE ] && which diff >/dev/null
     then
 	if diff -q $CONFFILE $NEW >/dev/null
 	then
@@ -161,7 +175,7 @@
 	backup
     fi
 
-    if ! /bin/loadkeys -q $CONFFILE; then
+    if ! loadkeys -q $CONFFILE; then
         $GETTEXT >&2 "Failed to load keymap!"
     fi
     # Store md5sum. debconf code uses this to track keymaps it has installed,

Reply via email to