[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Writing udebs



Hello again gurus,

I'm attempting to update a couple of small udebs to work under etch and I've run into a snag. For some reason I seem to be killing /sbin/debian-installer with my udebs and I don't know what's causing it.

As an example, here's one of the udebs in question: multi-netcfg. It's run after the ethernet hardware has been discovered, but before netcfg. It's sole purpose is to try to find a preseed file who's filename matches the hardware ethernet address of (any of) the newly-discovered ethernet cards found on the system. The postinst script is as follows:

------------------------------------------------------------
#!/bin/sh

set -e

. /usr/share/debconf/confmodule

##############################################################################
#
# The following from sarge/packages/preseed/file-preseed.postinst
#
. /lib/preseed/preseed.sh
##############################################################################

___my_name=$(basename $0 ".postinst")

log () {
   while [ $# -gt 0 ]; do
       logger -t "${___my_name}" -- "$@"
       shift
   done
}

log_output () {
   while read line; do
       log "| ${line}"
   done
}

wait4it () {
   log "Waiting for /tmp/go to appear..."
   while [ ! -f /tmp/go ]; do sleep 1 ; done
   log "Found /tmp/go, continuing"
   rm -f /tmp/go
}

##############################################################################
#
# The following from sarge/packages/preseed/file-preseed.postinst
#

usedfloppy=

# Used by preseed function.
preseed_fetch () {
   if [ "${1%/*}" = "/floppy" ]; then
       mountfloppy || true
       usedfloppy=1
   fi
if [ ! -e "$1" ] || ! cp "$1" $2; then
       return 1
   else
       return 0
   fi
}

preseed_relative () {
   if [ -z "${1##/*}" ]; then
       return 1
else return 0
   fi
}

##############################################################################

read_preseed_file () {
       db_set multi-netcfg/this-file "${1}"
       preseed multi-netcfg/this-file
       db_set multi-netcfg/this-file ""
}

set_netcfg_interface () {
   #echo "d-i netcfg/choose_interface select $1" > /tmp/eraseme.now
   #debconf-set-selections /tmp/eraseme.now
   #rm -f /tmp/eraseme.now

   #if ! db_set netcfg/choose_interface "${1}" ; then
       db_register debian-installer/dummy netcfg/choose_interface
       db_set netcfg/choose_interface "${1}"
       db_subst netcfg/choose_interface ID netcfg/choose_interface
       db_fset netcfg/choose_interface seen true
   #fi
}

log "Searching for network card(s)..."
dev_list=$( \
   ifconfig -a 2>&1 \
   | grep '^[^ ]' \
   | cut -d' ' -f1 \
   | grep -v '^lo$' \
   )

db_version 2.0
db_settitle debian-installer/multi-netcfg/title
db_get multi-netcfg/preseed-dir
dir="${RET}"

log "Auto-NetCfg Dir: ${dir}"
for dev in ${dev_list}; do
   hwaddr=$( \
       ifconfig -a \
       | grep ${dev} \
       | grep HWaddr \
       | cut -b39- \
       | sed 's, ,,g' \
       )
   log "Found device: ${dev} (HWaddr: ${hwaddr})"
   file=$(echo "${hwaddr}" | sed 's,:,-,g')
   log "Searching for File or Dir: ${dir}/${file}"
   if [ -f "${dir}/${file}" ]; then
       log "Found file"
       set_netcfg_interface ${dev}
       read_preseed_file "${dir}/${file}"
   elif [ -d "${dir}/${file}" ]; then
       log "Found directory"
       set_netcfg_interface ${dev}
       ls -1 "${dir}/${file}/" \
       | while read line; do
           if [ -f "${line}" ]; then
               log "Reading file: ${line}"
               read_preseed_file "${line}"
           else
               log "Skipping subdirectory: ${line}"
           fi
       done
   else
       log "No such file or directory found"
   fi
done

db_stop

# wait4it

# vim:ts=2:shiftwidth=2:filetype=sh:syntax=sh:
------------------------------------------------------------

The script itself does it's job -- it's able to find and load the correct preseed file for me:

Sep 28 13:35:42 multi-netcfg: Searching for network card(s)...
Sep 28 13:35:42 multi-netcfg: Auto-NetCfg Dir: /cdrom/preseed/netcfg
Sep 28 13:35:42 multi-netcfg: Found device: eth0 (HWaddr: 00:30:48:77:D8:A2)
Sep 28 13:35:42 multi-netcfg: Searching for File or Dir: /cdrom/preseed/netcfg/00-30-48-77-D8-A2
Sep 28 13:35:42 multi-netcfg: Found file
Sep 28 13:35:42 multi-netcfg: successfully loaded preseed file from /cdrom/preseed/netcfg/00-30-48-77-D8-A2
Sep 28 13:35:42 multi-netcfg: Found device: eth1 (HWaddr: 00:30:48:77:D8:A3)
Sep 28 13:35:42 multi-netcfg: Searching for File or Dir: /cdrom/preseed/netcfg/00-30-48-77-D8-A3
Sep 28 13:35:42 multi-netcfg: No such file or directory found

The problem comes immediately after:

Sep 28 13:35:42 main-menu[2429]: INFO: Priority changed externally, setting main-menu default to 'medium' () Sep 28 13:35:43 main-menu[2429]: INFO: Falling back to the package description for kbd-chooser Sep 28 13:35:43 main-menu[2429]: WARNING **: Internal error! Cannot find "ok" in menu. Sep 28 13:35:44 init: Process '/sbin/debian-installer' (pid 2382) exited. Scheduling it for restart. Sep 28 13:35:44 init: Starting pid 12449, console /dev/vc/1: '/sbin/debian-installer'

During this time, the screen shows the following:

Trying to enable the frame buffer...
(process:2410): INFO: kbd-mode: setting console mode to Unicode (UTF-8)

(process:12468): INFO: kbd-mode: setting console mode to Unicode (UTF-8)

(process:15449): INFO: kbd-mode: setting console mode to Unicode (UTF-8)

I assume that this output is from the debian-installer restarting.

I'm assuming that it's my own inexperience with Debian udebs that's causing the problem, and I'm hoping that someone out there will be able to spot my mistake straight away.

Hopefully?

Thanks for any help you can give,

Michael Peek



Reply to: