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

Bug#130191: xserver-xfree86: debconf BusID question could have better default and explanation



tag 130191 + moreinfo
thanks

This debconf question has come a ways since I first created it.

Is the current template description and logic satisfactory?:

Template: xserver-xfree86/config/device/bus_id
Type: string
_Description: Please enter the video card's bus identifier.
 Users of PowerPC machines, and users of any computer with multiple video
 devices, should specify the BusID of the video card in the format:
 .
 PCI:nn:nn:nn
 .
 (where each nn is a decimal number referring to the card's bus, device, and
 function number, respectively).
 .
 For users of multi-head setups, this option will configure only one of the
 heads.  Further configuration will have to be done manually in the X server
 configuration file, /etc/X11/XF86Config-4.
 .
 You may wish to use the "lspci" command to determine the bus location of your
 PCI or AGP video card.  Keep in mind that lspci reports the bus, device, and
 function numbers in hexadecimal, not decimal.
 .
 When possible, this question has been pre-answered for you and you should
 accept the default unless you know it doesn't work.
 .
 Users of non-PowerPC machines with only one video card should leave this
 entry blank.

# BusID
PRIORITY=low
DEFAULT=
if [ "$ARCH" = "powerpc" -o "$MULTIHEAD" = "yes" ]; then
  if [ "$ARCH" = "powerpc" ]; then
    PRIORITY=medium
  fi
  if [ "$MULTIHEAD" = "yes" ]; then
    PRIORITY=high
  fi
  if which lspci > /dev/null 2>&1; then
    # try to guess the correct BusID
    VIDEO_CARD=$(LC_ALL=C lspci -n | grep "Class 0300:" | head -n 1 | cut -d\  -f1)
    if [ -n "$VIDEO_CARD" ]; then
      # we now have an entry in "hex:hex.hex" format, need "PCI:decimal:decimal:decimal"
      BUS=$(printf "%d" 0x$(echo $VIDEO_CARD | cut -d: -f1) )
      DEVICE=$(printf "%d" 0x$(echo $VIDEO_CARD | cut -d: -f2 | cut -d. -f1) )
      FUNCTION=$(printf "%d" 0x$(echo $VIDEO_CARD | cut -d. -f2) )
      DEFAULT=PCI:$BUS:$DEVICE:$FUNCTION
    fi
  fi
fi
# this question requires input validation
if [ -n "$DEFAULT" ]; then
  auto_answer validate_bus_id_db_input "$(priority_ceil $PRIORITY)" xserver-xfree86/config/device/bus_id "$DEFAULT"
else
  validate_bus_id_db_input "$(priority_ceil $PRIORITY)" xserver-xfree86/config/device/bus_id || debug_report_status "validate_bus_id_db_input $(priority_ceil $PRIORITY) xserver-xfree86/config/device/bus_id" "$?"
fi

validate_bus_id_db_input () {
  # Syntax: validate_bus_id_db_input priority template
  #
  # validate BusID input
  if [ $# -ne 2 ]; then
    echo "internal error: validate_bus_id_db_input() called with wrong number of arguments: $*" >&2
    exit 1
  fi
  PRIORITY=$1
  TEMPLATE=$2
  db_get "$TEMPLATE"
  SAFE="$RET"
  set +e
  while :; do
    db_input "$PRIORITY" "$TEMPLATE"
    # is the question going to be asked?
    if [ $? -eq 30 ]; then
      break # no; bail out of validation loop
    fi
    db_go
    db_get "$TEMPLATE"
    if [ -z "$RET" ] || expr "$RET" : "[A-Z]\+:[0-9]\{1,3\}:[0-9]\{1,3\}:[0-9]\{1,3\}$" > /dev/null 2>&1; then
      break # valid input
    fi
    # we only get to this point if the input was invalid; restore the known good
    # value in case we are interrupted before the user provides a valid one
    db_set "$TEMPLATE" "$SAFE"
    db_fset "$TEMPLATE" seen false
    # now show the user the error message
    db_fset xserver-xfree86/config/device/bus_id_error seen false
    db_input critical xserver-xfree86/config/device/bus_id_error
    db_go
  done
  set -e
}

-- 
G. Branden Robinson                |    Humor is a rubber sword - it allows
Debian GNU/Linux                   |    you to make a point without drawing
branden@debian.org                 |    blood.
http://people.debian.org/~branden/ |    -- Mary Hirsch

Attachment: signature.asc
Description: Digital signature


Reply to: