X Strike Force XFree86 SVN commit: r1791 - branches/debconf-overhaul/debian
Author: branden
Date: 2004-09-01 14:04:51 -0500 (Wed, 01 Sep 2004)
New Revision: 1791
Modified:
branches/debconf-overhaul/debian/CHANGESETS
branches/debconf-overhaul/debian/TODO
branches/debconf-overhaul/debian/changelog
branches/debconf-overhaul/debian/xserver-xfree86.config.in
Log:
Make extensive stylistic cleanups to xserver-xfree86 config script.
- Identify more "global" variables at top of script.
- Add comment headers to every function (where not already present)
synopsizing its syntax and purpose, and discussing any caveats.
- Add argument validation to all functions; in any case where we are
called incorrectly, report the bad argument list. In functions that
take arguments, this is done with internal_error() (also mention how
many arguments were expected); in functions that don't, this is done
with warn().
- Update many variable names to be more descriptive.
- Locally scope variables not used outside their enclosing function.
- Have all functions report their names in any user-visible messages
they issue.
- Add documentation comments where they seemed warranted.
- Add some trace() calls where they seemed warranted.
- Replace some awkward shell constructions with better ones.
- Fix language in some trace() calls to be more clear.
Modified: branches/debconf-overhaul/debian/CHANGESETS
===================================================================
--- branches/debconf-overhaul/debian/CHANGESETS 2004-09-01 18:49:17 UTC (rev 1790)
+++ branches/debconf-overhaul/debian/CHANGESETS 2004-09-01 19:04:51 UTC (rev 1791)
@@ -593,6 +593,23 @@
"Class " when the -n option is used. Ah, the joys of using
human-readable standard output as an interface. Thanks to Bill
Allombert for pointing out the new -X option.
++ Make extensive stylistic cleanups:
+ - Identify more "global" variables at top of script.
+ - Add comment headers to every function (where not already present)
+ synopsizing its syntax and purpose, and discussing any caveats.
+ - Add argument validation to all functions; in any case where we are
+ called incorrectly, report the bad argument list. In functions that
+ take arguments, this is done with internal_error() (also mention how
+ many arguments were expected); in functions that don't, this is done
+ with warn().
+ - Update many variable names to be more descriptive.
+ - Locally scope variables not used outside their enclosing function.
+ - Have all functions report their names in any user-visible messages
+ they issue.
+ - Add documentation comments where they seemed warranted.
+ - Add some trace() calls where they seemed warranted.
+ - Replace some awkward shell constructions with better ones.
+ - Fix language in some trace() calls to be more clear.
[XXX: REPLACE WITH REVISION NUMBER WHEN MERGED TO TRUNK]
vim:set ai et sts=4 sw=4 tw=80:
Modified: branches/debconf-overhaul/debian/TODO
===================================================================
--- branches/debconf-overhaul/debian/TODO 2004-09-01 18:49:17 UTC (rev 1790)
+++ branches/debconf-overhaul/debian/TODO 2004-09-01 19:04:51 UTC (rev 1791)
@@ -33,8 +33,6 @@
done about this [BR]
+ Use /proc/hardware on m68k architecture to set a reasonable default mouse
port. See <URL: http://lists.debian.org/debian-68k/2004/08/msg00392.html>.
- + Where applicable, use present perfect tense in trace messages so they are
- not confused with being in the imperative voice.
* Add FAQ entry describing Debian's plans in the X department.
4.3.0.dfsg.1-8
Modified: branches/debconf-overhaul/debian/changelog
===================================================================
--- branches/debconf-overhaul/debian/changelog 2004-09-01 18:49:17 UTC (rev 1790)
+++ branches/debconf-overhaul/debian/changelog 2004-09-01 19:04:51 UTC (rev 1791)
@@ -429,6 +429,23 @@
"Class " when the -n option is used. Ah, the joys of using
human-readable standard output as an interface. Thanks to Bill
Allombert for pointing out the new -X option.
+ + Make extensive stylistic cleanups:
+ - Identify more "global" variables at top of script.
+ - Add comment headers to every function (where not already present)
+ synopsizing its syntax and purpose, and discussing any caveats.
+ - Add argument validation to all functions; in any case where we are
+ called incorrectly, report the bad argument list. In functions that
+ take arguments, this is done with internal_error() (also mention how
+ many arguments were expected); in functions that don't, this is done
+ with warn().
+ - Update many variable names to be more descriptive.
+ - Locally scope variables not used outside their enclosing function.
+ - Have all functions report their names in any user-visible messages
+ they issue.
+ - Add documentation comments where they seemed warranted.
+ - Add some trace() calls where they seemed warranted.
+ - Replace some awkward shell constructions with better ones.
+ - Fix language in some trace() calls to be more clear.
Changes by Fabio M. Di Nitto and Branden Robinson:
@@ -540,7 +557,7 @@
missing to enable this feature. No keymaps currently use this feature,
but users may find it useful with broken keymaps.
- -- Branden Robinson <branden@debian.org> Wed, 1 Sep 2004 13:24:18 -0500
+ -- Branden Robinson <branden@debian.org> Wed, 1 Sep 2004 14:02:39 -0500
xfree86 (4.3.0.dfsg.1-6) unstable; urgency=low
Modified: branches/debconf-overhaul/debian/xserver-xfree86.config.in
===================================================================
--- branches/debconf-overhaul/debian/xserver-xfree86.config.in 2004-09-01 18:49:17 UTC (rev 1790)
+++ branches/debconf-overhaul/debian/xserver-xfree86.config.in 2004-09-01 19:04:51 UTC (rev 1791)
@@ -26,6 +26,8 @@
CONFIG_LOG="/var/log/$THIS_PACKAGE.config.log"
+AUTODETECT_VIDEO_CARD=
+DEFAULT_MODES=
NCARDS=0
NSERVERS=0
NDRIVERS=0
@@ -35,130 +37,175 @@
ARCH=$(dpkg --print-installation-architecture)
trace () {
+ # syntax: trace "message ..."
+ #
# This function wraps shell-lib's observe() function so that we can log the
# configuration process.
+ #
+ # This function is often called from other functions like this:
+ # trace "$func(): message"
+ #
+ # Do not be tempted to pass around or globally scope the func variable. The
+ # former is error-prone since observe() and trace() would no longer have the
+ # same interface, and latter is bad because if func is global, the trace
+ # messages will be wrong in the main loop after any function call or in
+ # another function if someone forgets to set its value. Misleading debugging
+ # messages are very bad.
echo "$(date +%F %X%z) ${*:-(empty message)}" >>"$CONFIG_LOG"
observe "$*"
}
discover_video () {
- # wrapper for discover command that can distinguish Discover 1.x and 2.x
+ # syntax: discover_video
+ #
+ # This is a wrapper for the discover command that can distinguish Discover 1.x
+ # and 2.x. It returns output in the following format:
+ # vendor+model server driver
+ # For example:
+ # ATI Radeon 9000 XFree86 ati
+ # A tab character separates each field.
- # Ugh, Discover 1.x didn't exit with nonzero status if given an unrecongized option!
+ local cmd discovered_video discover_errorfile discover_test driver_file func \
+ server_file vendor_model_file
+
+ func="discover_video"
+
+ # Validate function arguments.
+ if [ -n "$*" ]; then
+ warn "$func(): called with bogus arguments $@"
+ fi
+
+ # Ugh, Discover 1.x didn't exit with nonzero status if given an unrecongized
+ # option!
+ #
# Double ugh! Discover is crashy. People blame X when it crashes (but then,
# people blame X when *anything* crashes).
- DISCOVER_ERRORFILE=$(tempfile)
- if DISCOVER_TEST=$(discover --version 2>>"$DISCOVER_ERRORFILE"); then
- if expr "$DISCOVER_TEST" : 'discover 2.*' > /dev/null 2>&1; then
+ discover_errorfile=$(tempfile)
+ if discover_test=$(discover --version 2>>"$discover_errorfile"); then
+ if expr "$discover_test" : 'discover 2.*' >/dev/null 2>&1; then
# Discover 2.x
# XXX: this is sort of nasty
- VENDOR_MODEL_FILE=$(tempfile)
- SERVER_FILE=$(tempfile)
- DRIVER_FILE=$(tempfile)
+ vendor_model_file=$(tempfile)
+ server_file=$(tempfile)
+ driver_file=$(tempfile)
- CMD="discover --type-summary display"
- eval $CMD >>$VENDOR_MODEL_FILE || debug_report_status "$CMD" "$?"
- CMD="discover --data-path=xfree86/server/name \
+ cmd="discover --type-summary display"
+ eval $cmd >>$vendor_model_file || debug_report_status "$CMD" "$?"
+ cmd="discover --data-path=xfree86/server/name \
--data-version=${SOURCE_VERSION%-*} display"
- eval $CMD >>$SERVER_FILE || debug_report_status "$CMD" "$?"
- CMD="discover --data-path=xfree86/server/device/driver \
+ eval $cmd >>$server_file || debug_report_status "$CMD" "$?"
+ cmd="discover --data-path=xfree86/server/device/driver \
--data-version=${SOURCE_VERSION%-*} display"
- eval $CMD >>$DRIVER_FILE || debug_report_status "$CMD" "$?"
+ eval $cmd >>$driver_file || debug_report_status "$CMD" "$?"
- DISCOVERED_VIDEO=$(paste $VENDOR_MODEL_FILE $SERVER_FILE $DRIVER_FILE)
- rm -f $VENDOR_MODEL_FILE $SERVER_FILE $DRIVER_FILE
+ discovered_video=$(paste $vendor_model_file $server_file $driver_file)
+ rm -f $vendor_model_file $server_file $driver_file
else
# must be Discover 1.x
- DISCOVERED_VIDEO=$(discover --disable=serial,parallel \
+ discovered_video=$(discover --disable=serial,parallel \
--format="%V %M\t%S\t%D\n" video 2>/dev/null)
fi
- echo "$DISCOVERED_VIDEO"
+ echo "$discovered_video"
else
- warn "cannot use discover; failed with error message:" \
- "$(cat "$DISCOVER_ERRORFILE")"
+ warn "$func(): cannot use discover; failed with error message:" \
+ "$(cat "$discover_errorfile")"
fi
- rm "$DISCOVER_ERRORFILE" || warn "discover error file never created, or" \
- "already removed"
+ rm "$discover_errorfile" || warn "$func(): discover error file never" \
+ "created, or already removed"
}
validate_string_db_input () {
- # Syntax: validate_string_db_input priority template
+ # syntax: validate_string_db_input priority template
#
- # validate string input; can't have doublequotes
- # If $MAY_BE_NULL is a non-null value (e.g., "yes"), the string may be null.
+ # Validate string input; do not permit doublequotes. If $MAY_BE_NULL is a
+ # non-null value (e.g., "yes"), the string may be null.
+
+ local error func priority safe template
+
+ func="validate_string_db_input"
+
+ # Validate function arguments.
if [ $# -ne 2 ]; then
- internal_error "validate_string_db_input() called with wrong number of" \
- "arguments: $*"
+ internal_error "$func(): called with wrong number of arguments; expected" \
+ "2, got $@"
fi
- PRIORITY=$1
- TEMPLATE=$2
- db_get "$TEMPLATE"
- SAFE="$RET"
+
+ priority=$1
+ template=$2
+ db_get "$template"
+ safe="$RET"
set +e
while :; do
- db_input "$PRIORITY" "$TEMPLATE"
+ 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"
+ db_get "$template"
if [ -n "$RET" ]; then
if ! expr "$RET" : '.*".*' >/dev/null 2>&1; then
break # valid input
else
- ERROR=xserver-xfree86/config/doublequote_in_string_error
+ error=xserver-xfree86/config/doublequote_in_string_error
fi
else
if [ -n "$MAY_BE_NULL" ]; then
break # valid (null) input
else
- ERROR=xserver-xfree86/config/null_string_error
+ error=xserver-xfree86/config/null_string_error
fi
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
+ db_set "$template" "$safe"
+ db_fset "$template" seen false
# now show the user the error message
- db_fset "$ERROR" seen false
- db_input critical "$ERROR"
+ db_fset "$error" seen false
+ db_input critical "$error"
db_go
done
set -e
}
validate_numeric_db_input () {
- # Syntax: validate_numeric_db_input priority template
+ # syntax: validate_numeric_db_input priority template
#
- # validate numeric input; must have only digits, can be null
+ # Validate numeric input; must have only digits, can be null.
+
+ local error func priority safe template
+
+ func="validate_numeric_db_input"
+
+ # Validate function arguments.
if [ $# -ne 2 ]; then
- internal_error "validate_numeric_db_input() called with wrong number of" \
- "arguments: $*"
+ internal_error "$func(): called with wrong number of arguments; expected" \
+ "2, got $@"
fi
- PRIORITY=$1
- TEMPLATE=$2
- db_get "$TEMPLATE"
- SAFE="$RET"
+
+ priority=$1
+ template=$2
+ db_get "$template"
+ safe="$RET"
set +e
while :; do
- db_input "$PRIORITY" "$TEMPLATE"
+ 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"
+ db_get "$template"
if [ -z "$RET" ] || expr "$RET" : "[0-9]\+$" >/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
+ db_set "$template" "$safe"
+ db_fset "$template" seen false
# now show the user the error message
db_fset xserver-xfree86/config/nonnumeric_string_error seen false
db_input critical xserver-xfree86/config/nonnumeric_string_error
@@ -168,26 +215,33 @@
}
validate_bus_id_db_input () {
- # Syntax: validate_bus_id_db_input priority template
+ # syntax: validate_bus_id_db_input priority template
#
- # validate BusID input
+ # Validate BusID input.
+
+ local error func priority safe template
+
+ func="validate_bus_id_db_input"
+
+ # Validate function arguments.
if [ $# -ne 2 ]; then
- internal_error "validate_bus_id_db_input() called with wrong number of" \
- "arguments: $*"
+ internal_error "$func(): called with wrong number of arguments; expected" \
+ "2, got $@"
fi
- PRIORITY=$1
- TEMPLATE=$2
- db_get "$TEMPLATE"
- SAFE="$RET"
+
+ priority=$1
+ template=$2
+ db_get "$template"
+ safe="$RET"
set +e
while :; do
- db_input "$PRIORITY" "$TEMPLATE"
+ 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"
+ db_get "$template"
case "$RET" in
"")
# An empty string is valid.
@@ -242,8 +296,8 @@
esac
# 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
+ 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
@@ -253,7 +307,7 @@
}
validate_monitor_frequency_expr () {
- # Syntax: validate_monitor_frequency_expr expression
+ # syntax: validate_monitor_frequency_expr expression
#
# Confirm that the given expression is a valid monitor frequency expression
# per XF86Config-4(5x). Note that this does *not* handle (comma-delimited)
@@ -268,14 +322,18 @@
#
# Return true (0) if the expression is valid, and false (1) if it is not.
- local regex
- regex='^[[:space:]]*0*[0-9]+(\.[0-9]+)?(-0*[0-9]+(\.[0-9]+)?)?([[:space:]]*[kM]?Hz)?$'
+ local func regex
+ func="validate_monitor_frequency_expr"
+
+ # Validate function arguments.
if [ $# -ne 1 ]; then
- internal_error "validate_monitor_frequency_expr() called with wrong" \
- "number of arguments: $*"
+ internal_error "$func(): called with wrong number of arguments; expected" \
+ "1, got $@"
fi
+ regex='^[[:space:]]*0*[0-9]+(\.[0-9]+)?(-0*[0-9]+(\.[0-9]+)?)?([[:space:]]*[kM]?Hz)?$'
+
if echo "$1" | grep -Eiq "$regex"; then
return 0
else
@@ -284,42 +342,46 @@
}
validate_monitor_frequency_db_input () {
- # Syntax: validate_monitor_frequency_db_input priority template
+ # syntax: validate_monitor_frequency_db_input priority template
#
# validate monitor frequency input
- local valid freq_expr
+ local expr_is_valid freq_expr func priority safe template
+ func="validate_monitor_frequency_db_input"
+
+ # Validate function arguments.
if [ $# -ne 2 ]; then
- internal_error "validate_monitor_frequency_db_input() called with wrong" \
- "number of arguments: $*"
+ internal_error "$func(): called with wrong number of arguments; expected" \
+ "2, got $@"
fi
- PRIORITY=$1
- TEMPLATE=$2
- db_get "$TEMPLATE"
- SAFE="$RET"
+
+ priority=$1
+ template=$2
+ db_get "$template"
+ safe="$RET"
set +e
while :; do
- db_input "$PRIORITY" "$TEMPLATE"
+ 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"
+ db_get "$template"
# This is a string, and needs input validation; a regex match will have to
# do. We force the first character to be a number to avoid hideous problems
# in the debconf dialog frontend in 0.3.83 (it needs to be one anyway). We
# need to handle multiple expressions, delimited by commas. See
# XF86Config-4(5x) for more information.
if expr "$RET" : ".*,.*" >/dev/null 2>&1; then
- valid=true
+ expr_is_valid=true
echo "$RET" | tr -s ',' '\n' | while read freq_expr; do
if ! validate_monitor_frequency_expr "$freq_expr"; then
- valid=
+ expr_is_valid=
fi
done
- if [ -n "$valid" ]; then
+ if [ -n "$expr_is_valid" ]; then
break
fi
else
@@ -331,8 +393,8 @@
# 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
+ db_set "$template" "$safe"
+ db_fset "$template" seen false
# now show the user the error message
db_fset xserver-xfree86/config/monitor/range_input_error seen false
db_input critical xserver-xfree86/config/monitor/range_input_error
@@ -342,115 +404,125 @@
}
auto_answer () {
- # Syntax: auto_answer input_command priority template default_answer
+ # syntax: auto_answer input_command priority template default_answer
#
# Used to auto-answer questions that don't have reasonable defaults. Some
# people insist on running the xserver-xfree86 config script with the
# non-interactive frontend. For this to work, the debconf database will need
# to be pre-loaded with answers to several questions. You have been
# warned...
+
+ local default_answer func input_command priority template
+
+ func="auto_answer"
+
+ # Validate function arguments.
if [ $# -ne 4 ]; then
- internal_error "auto_answer() called with wrong number of arguments: $*"
+ internal_error "$func(): called with wrong number of arguments; expected" \
+ "4, got $@"
fi
- INPUT_COMMAND=$1
- PRIORITY=$2
- TEMPLATE=$3
- DEFAULT_ANSWER=$4
+
+ input_command=$1
+ priority=$2
+ template=$3
+ default_answer=$4
set +e
- trace "auto_answer() \"$INPUT_COMMAND $PRIORITY $TEMPLATE\" with default" \
- "\"$DEFAULT_ANSWER\""
+ trace "$func(): running \"$input_command $priority $template\" with default" \
+ "\"$default_answer\""
# are we re-configuring?
if [ -n "$RECONFIGURE" ]; then
# yes, we are reconfiguring
- db_get "$TEMPLATE"
- trace "auto_answer: (reconfiguring) preserving existing answer \"$RET\""
+ db_get "$template"
+ trace "$func(): (reconfiguring) preserving existing answer \"$RET\""
else
# not reconfiguring; has the question been seen before?
- db_fget "$TEMPLATE" seen
+ db_fget "$template" seen
if [ "$RET" = "true" ]; then
- db_get "$TEMPLATE"
- trace "auto_answer: (not reconfiguring) preserving existing answer" \
- "\"$RET\""
+ db_get "$template"
+ trace "$func(): (not reconfiguring) preserving existing answer \"$RET\""
else
- trace "auto_answer: auto-answering with \"$DEFAULT_ANSWER\""
- db_set $TEMPLATE "$DEFAULT_ANSWER"
+ trace "$func(): auto-answering with \"$default_answer\""
+ db_set $template "$default_answer"
fi
fi
- "$INPUT_COMMAND" "$PRIORITY" "$TEMPLATE"
+ "$input_command" "$priority" "$template"
if [ $? -eq 30 ]; then
- trace "auto_answer: $TEMPLATE is not being asked"
+ trace "$func(): not asking $template per exit status of $input_command"
else
- trace "auto_answer: asking $TEMPLATE"
+ trace "$func(): asking $template"
fi
set -e
db_go
- db_get "$TEMPLATE"
- trace "auto_answer: $TEMPLATE is \"$RET\""
+ db_get "$template"
+ trace "$func(): value of $template is now \"$RET\""
}
set_db_priority () {
# syntax: set_db_priority requested_priority
#
- # Given a variable PRIORITY_CEILING and a "requested_priority" argument, set
- # the PRIORITY environment variable to the lesser of the two.
-
+ # Given a (global) variable PRIORITY_CEILING and a "requested_priority"
+ # argument, set the (global) PRIORITY environment variable to the lesser of
+ # the two.
+ #
# Implementation note: a clever version of this could be done using "eval", or
# embedding a Perl script, but those would be more difficult to maintain.
# Better just to go the simple and stupid route. Yes, I know this is not very
# efficient.
- local priority_ceiling requested_priority
+ local func my_priority_ceiling requested_priority
- # Validate arguments.
+ func="set_db_priority"
+
+ # Validate function arguments.
if [ $# -ne 1 ]; then
- warn "set_db_priority() called with empty or bogus arguments \"$*\";" \
- "assuming argument of \"low\""
+ warn "$func(): called with empty or bogus arguments $@; assuming"
+ "requested priority of \"low\""
requested_priority=low
else
requested_priority="$1"
fi
- # If PRIORITY_CEILING is null or unset, it's same as not having one at all;
- # the sky's the limit. We use a locally scoped priority_ceiling variable
- # because we don't want to affect the value of the global one.
+ # If PRIORITY_CEILING is null or unset, it's the same as not having one at
+ # all; the sky's the limit. We use a locally scoped my_priority_ceiling
+ # variable because we don't want to affect the value of the global one.
if [ -n "$PRIORITY_CEILING" ]; then
- priority_ceiling="$PRIORITY_CEILING"
+ my_priority_ceiling="$PRIORITY_CEILING"
else
- priority_ceiling=critical
+ my_priority_ceiling=critical
fi
# Ensure the value of PRIORITY_CEILING is reasonable.
- if [ "$priority_ceiling" != "critical" ] \
- && [ "$priority_ceiling" != "high" ] \
- && [ "$priority_ceiling" != "medium" ] \
- && [ "$priority_ceiling" != "low" ]; then
- warn "set_db_priority() called with bogus value of \$PRIORITY_CEILING" \
- "\"$PRIORITY_CEILING\"; treating as \"critical\""
- priority_ceiling=critical
+ if [ "$my_priority_ceiling" != "critical" ] \
+ && [ "$my_priority_ceiling" != "high" ] \
+ && [ "$my_priority_ceiling" != "medium" ] \
+ && [ "$my_priority_ceiling" != "low" ]; then
+ warn "$func(): \$PRIORITY_CEILING has bogus value \"$PRIORITY_CEILING\";" \
+ "treating as \"critical\""
+ my_priority_ceiling=critical
fi
case "$requested_priority" in
critical)
# This is the highest priority, so there is nowhere to go but down.
- PRIORITY="$priority_ceiling"
+ PRIORITY="$my_priority_ceiling"
;;
high)
- case "$priority_ceiling" in
+ case "$my_priority_ceiling" in
critical)
PRIORITY="$requested_priority"
;;
high|medium|low)
- PRIORITY="$priority_ceiling"
+ PRIORITY="$my_priority_ceiling"
;;
esac
;;
medium)
- case "$priority_ceiling" in
+ case "$my_priority_ceiling" in
critical|high)
PRIORITY="$requested_priority"
;;
medium|low)
- PRIORITY="$priority_ceiling"
+ PRIORITY="$my_priority_ceiling"
;;
esac
;;
@@ -459,19 +531,29 @@
PRIORITY="$requested_priority"
;;
*)
- warn "set_db_priority() called with bogus argument" \
- "\"$requested_priority\"; returning \"low\""
+ warn "$func(): called with bogus argument \"$requested_priority\";" \
+ "returning \"low\""
PRIORITY="low"
;;
esac
}
select_default_x_server () {
+ # syntax: select_default_x_server
+ #
# Ask debconf questions that determine the destination of the default X server
# symbolic link.
- local bailout
+ local bailout choices default_x_server_package func owners \
+ videocard_server_report
+ func="select_default_x_server"
+
+ # Validate function arguments.
+ if [ -n "$*" ]; then
+ warn "$func(): called with bogus arguments $@"
+ fi
+
# If the symbolic link to the default X server is under manual control, do
# nothing. Perform tests to determine if this is the case.
@@ -481,7 +563,7 @@
# Is the symbolic link really a symbolic link? If not, bail.
if [ -e "$SERVER_SYMLINK" ] && [ ! -L "$SERVER_SYMLINK" ]; then
# The symbolic link is not a symbolic link.
- trace "$SERVER_SYMLINK exists but is not a symbolic link"
+ trace "$func(): $SERVER_SYMLINK exists but is not a symbolic link"
bailout=yes
else
# Does the symbolic link's checksum exist but not match the actual
@@ -489,11 +571,12 @@
if [ -e "$SERVER_SYMLINK_CHECKSUM" ]; then
if [ "$(readlink "$SERVER_SYMLINK" | md5sum)" != \
"$(cat "$SERVER_SYMLINK_CHECKSUM")" ]; then
- trace "$SERVER_SYMLINK link destination has been manually modified"
+ trace "$func(): $SERVER_SYMLINK link destination has been manually" \
+ "modified"
bailout=yes
fi
else
- trace "no stored checksum available for $SERVER_SYMLINK"
+ trace "$func(): no stored checksum available for $SERVER_SYMLINK"
bailout=yes
fi
fi
@@ -509,8 +592,8 @@
PRIORITY_CEILING=
if [ -e "$SERVER_SYMLINK" ]; then
if [ -x "$(readlink "$SERVER_SYMLINK")" ]; then
- trace "X server symlink exists and points to executable X server;" \
- "capping X server question priority at medium"
+ trace "$func(): X server symlink exists and points to executable X" \
+ "server; capping X server question priority at medium"
PRIORITY_CEILING=medium
fi
fi
@@ -519,227 +602,247 @@
set_db_priority "high"
db_metaget shared/default-x-server owners
- OWNERS="$RET"
+ owners="$RET"
db_metaget shared/default-x-server choices
- CHOICES="$RET"
+ choices="$RET"
- if [ "$OWNERS" != "$CHOICES" ]; then
- trace "\$OWNERS does not equal \$CHOICES: \"$OWNERS\" != \"$CHOICES\""
- db_subst shared/default-x-server choices $OWNERS
+ if [ "$owners" != "$choices" ]; then
+ trace "$func(): \$owners does not equal \$choices: \"$owners\" != " \
+ "\"$choices\""
+ db_subst shared/default-x-server choices $owners
db_fset shared/default-x-server seen false
fi
- if ! expr "$OWNERS" : ".*,.*" >/dev/null 2>&1; then
- trace "\$OWNERS has only one value; shared/default-x-server will not be" \
- "asked"
+ if ! expr "$owners" : ".*,.*" >/dev/null 2>&1; then
+ trace "$func(): \$owners has only one value; shared/default-x-server" \
+ "will not be asked"
fi
# set a failsafe default answer for shared/default-x-server
- DEFAULT="$THIS_PACKAGE"
+ default_x_server_package="$THIS_PACKAGE"
# if configuring for the first time, ask if user wants to autodetect
if [ -z "$RECONFIGURE" ]; then
if which discover >/dev/null 2>&1; then
set_db_priority "medium"
auto_answer db_input "$PRIORITY" \
- xserver-xfree86/autodetect_video_card "false"
+ xserver-xfree86/autodetect_video_card "true"
db_get xserver-xfree86/autodetect_video_card
AUTODETECT_VIDEO_CARD="$RET"
if [ "$AUTODETECT_VIDEO_CARD" = "true" ]; then
if [ $NSERVERS -eq 0 ]; then
- trace "could not autodetect X server: no video card detected, or no" \
- "server known for it"
+ trace "$func(): could not autodetect X server: no video card" \
+ "detected, or no server known for it"
set_db_priority "high"
run db_input "$PRIORITY" shared/no_known_x-server
db_go
elif [ $NSERVERS -eq 1 ]; then
- trace "autodetected X server: $SERVERS"
+ trace "$func(): autodetected X server: $SERVERS"
if [ "$SERVERS" = "${THIS_SERVER##*/}" ]; then
# the autodetected X server is the only one on the system, and the
# one we're currently configuring; it's unlikely the user will want
# to use something else
set_db_priority "low"
else
- trace "X server autodetected, but does not correspond to this" \
- "package"
+ trace "$func(): X server autodetected, but does not correspond" \
+ "to this package"
# we do not set shared/default-x-server here, because the
# autodetected X server might not be getting installed
fi
elif [ $NSERVERS -gt 1 ]; then
- trace "could not autodetect X server: multiple servers for video" \
- "cards"
- VIDEOCARD_SERVER_REPORT=$(echo "$DISCOVERED_VIDEO" \
+ trace "$func(): could not autodetect X server: multiple servers for" \
+ "video cards"
+ videocard_server_report=$(echo "$DISCOVERED_VIDEO" \
| awk 'BEGIN { FS="\t"; printf " %-40s%20s\n .\n", "Detected Video Card", "Suggested X server" } { printf " %-50s%10s\n", $1, $2 } END { printf " .\n" }')
# can't do this until there is a way to embed newlines into debconf
# command streams :(
# db_subst shared/multiple_possible_x-servers detected_cards \
- # "$VIDEOCARD_SERVER_REPORT"
- trace "$VIDEOCARD_SERVER_REPORT"
+ # "$videocard_server_report"
+ trace "$videocard_server_report"
set_db_priority "high"
run db_input "$PRIORITY" shared/multiple_possible_x-servers
db_go
fi
else
- trace "user declined video card autodetection (server)"
+ trace "$func(): user declined video card autodetection"
fi
else
- trace "could not autodetect X server: discover not found"
+ trace "$func(): could not autodetect X server: discover not found"
fi
else
- trace "not prompting for video card autodetection; reconfiguring"
+ trace "$func(): not prompting for video card autodetection; reconfiguring"
fi
# now the default-x-server question may be asked
db_fget shared/default-x-server seen
- trace "seen flag of shared/default-x-server is $RET"
- trace "db_input $PRIORITY shared/default-x-server"
+ trace "$func(): seen flag of shared/default-x-server is $RET"
auto_answer db_input $PRIORITY shared/default-x-server \
- "$DEFAULT"
+ "$default_x_server_package"
}
configure_video_device () {
+ # syntax: configure_video_device
+ #
+ # Ask debconf questions that determine the contents of the "Device" section of
+ # the XF86Config-4 file.
+
+ local default_bus_id default_driver default_identifier default_use_fbdev \
+ driver_dir driver_list fb_type func lspci_id pci_bus pci_device pci_domain \
+ pci_function videocard_driver_report
+
+ func="configure_video_device"
+
+ # Validate function arguments.
+ if [ -n "$*" ]; then
+ warn "$func(): called with bogus arguments $@"
+ fi
+
# priority of xserver-xfree86/config/device/driver
set_db_priority "high"
- DRIVER_DIR=/usr/X11R6/lib/modules/drivers
+ driver_dir=/usr/X11R6/lib/modules/drivers
# Build list of available video drivers, omitting the atimisc, r128, and
# radeon sub-modules (the ati driver knows when and how to load these).
# v4l is not a display driver, and dummy is for advanced users.
- DRIVER_LIST="$(echo $(find "$DRIVER_DIR" -name '*_drv.o' 2>/dev/null \
+ #
+ # We won't find any drivers if we're being pre-configured and the package is
+ # not currently unpacked to the system (e.g., fresh install). In that event,
+ # we set up a hard-coded, architecture-specific list later.
+ driver_list="$(echo $(find "$driver_dir" -name '*_drv.o' 2>/dev/null \
| sed 's|^.*/\(.*\)_drv\.o|\1|' \
| egrep -v '(atimisc|dummy|r128|radeon|v4l)' | sort) \
| sed 's/ /, /g')"
- if [ -z "$DRIVER_LIST" ]; then
- trace "no video driver modules found in $DRIVER_DIR"
+ if [ -z "$driver_list" ]; then
+ trace "$func(): no video driver modules found in $driver_dir"
fi
# Set a hard-coded module list (if necessary) and default driver module on an
# architecture-specific basis.
case "$ARCH" in
alpha)
- DRIVER_LIST=${DRIVER_LIST:=ati, cirrus, glint, mga, nv, rendition, s3, s3virge, savage, siliconmotion, tdfx, tga, vga}
- DEFAULT_DRIVER=vga
+ : ${driver_list:=ati, cirrus, glint, mga, nv, rendition, s3, s3virge, savage, siliconmotion, tdfx, tga, vga}
+ default_driver=vga
;;
amd64)
- DRIVER_LIST=${DRIVER_LIST:=apm, ark, ati, chips, cirrus, cyrix, fbdev, glint, i128, i740, i810, imstt, mga, neomagic, newport, nsc, nv, rendition, s3, s3virge, savage, siliconmotion, sis, tdfx, tga, trident, tseng, vesa, vga, vmware}
- DEFAULT_DRIVER=vesa
+ : ${driver_list:=apm, ark, ati, chips, cirrus, cyrix, fbdev, glint, i128, i740, i810, imstt, mga, neomagic, newport, nsc, nv, rendition, s3, s3virge, savage, siliconmotion, sis, tdfx, tga, trident, tseng, vesa, vga, vmware}
+ default_driver=vesa
;;
arm|hppa)
- DRIVER_LIST=${DRIVER_LIST:=ati, chips, fbdev, glint, mga, nv, s3, s3virge, savage, sis, tdfx, trident, vga}
- DEFAULT_DRIVER=fbdev
+ : ${driver_list:=ati, chips, fbdev, glint, mga, nv, s3, s3virge, savage, sis, tdfx, trident, vga}
+ default_driver=fbdev
;;
hurd-i386)
- DRIVER_LIST=${DRIVER_LIST:=apm, ark, ati, chips, cirrus, cyrix, fbdev, glint, i128, i740, i810, imstt, mga, neomagic, newport, nsc, nv, rendition, s3, s3virge, savage, siliconmotion, sis, tdfx, tga, trident, tseng, vesa, vga, via, vmware}
- DEFAULT_DRIVER=vesa
+ : ${driver_list:=apm, ark, ati, chips, cirrus, cyrix, fbdev, glint, i128, i740, i810, imstt, mga, neomagic, newport, nsc, nv, rendition, s3, s3virge, savage, siliconmotion, sis, tdfx, tga, trident, tseng, vesa, vga, via, vmware}
+ default_driver=vesa
;;
i386)
- DRIVER_LIST=${DRIVER_LIST:=apm, ark, ati, chips, cirrus, cyrix, fbdev, glide, glint, i128, i740, i810, imstt, mga, neomagic, newport, nsc, nv, rendition, s3, s3virge, savage, siliconmotion, sis, tdfx, tga, trident, tseng, vesa, vga, via, vmware}
- DEFAULT_DRIVER=vesa
+ : ${driver_list:=apm, ark, ati, chips, cirrus, cyrix, fbdev, glide, glint, i128, i740, i810, imstt, mga, neomagic, newport, nsc, nv, rendition, s3, s3virge, savage, siliconmotion, sis, tdfx, tga, trident, tseng, vesa, vga, via, vmware}
+ default_driver=vesa
;;
ia64)
- DRIVER_LIST=${DRIVER_LIST:=apm, ark, ati, chips, cirrus, cyrix, fbdev, glint, i128, i740, i810, imstt, mga, neomagic, newport, nv, rendition, s3, s3virge, savage, siliconmotion, sis, tdfx, tga, trident, tseng, vesa, vga, vmware}
- DEFAULT_DRIVER=fbdev
+ : ${driver_list:=apm, ark, ati, chips, cirrus, cyrix, fbdev, glint, i128, i740, i810, imstt, mga, neomagic, newport, nv, rendition, s3, s3virge, savage, siliconmotion, sis, tdfx, tga, trident, tseng, vesa, vga, vmware}
+ default_driver=fbdev
;;
m68k|powerpc)
- DRIVER_LIST=${DRIVER_LIST:=ati, chips, fbdev, glint, imstt, mga, nv, s3, s3virge, savage, sis, tdfx, trident, vga}
- DEFAULT_DRIVER=fbdev
+ : ${driver_list:=ati, chips, fbdev, glint, imstt, mga, nv, s3, s3virge, savage, sis, tdfx, trident, vga}
+ default_driver=fbdev
;;
mips|mipsel)
- DRIVER_LIST=${DRIVER_LIST:=ati, chips, fbdev, glint, mga, newport, nv, s3, s3virge, savage, sis, tdfx, trident}
+ : ${driver_list:=ati, chips, fbdev, glint, mga, newport, nv, s3, s3virge, savage, sis, tdfx, trident}
# Are we dealing with an SGI Indy or Indigo2?
if [ -e /proc/cpuinfo ]; then
if grep -q "system type.*:.*SGI Ind" /proc/cpuinfo; then
set_db_priority "medium"
- DEFAULT_DRIVER=newport
+ default_driver=newport
fi
fi
- DEFAULT_DRIVER=${DEFAULT_DRIVER:=fbdev}
+ : ${default_driver:=fbdev}
;;
sparc)
- DRIVER_LIST=${DRIVER_LIST:=apm, ark, ati, chips, cirrus, fbdev, glint, i128, i740, imstt, mga, neomagic, nv, rendition, s3virge, savage, siliconmotion, sunbw2, suncg14, suncg3, suncg6, sunffb, sunleo, suntcx, tdfx, trident, vesa, vga}
- DEFAULT_DRIVER=fbdev
+ : ${driver_list:=apm, ark, ati, chips, cirrus, fbdev, glint, i128, i740, imstt, mga, neomagic, nv, rendition, s3virge, savage, siliconmotion, sunbw2, suncg14, suncg3, suncg6, sunffb, sunleo, suntcx, tdfx, trident, vesa, vga}
+ default_driver=fbdev
;;
*)
- internal_error "no driver list known for architecture $ARCH"
+ internal_error "$func(): no driver list known for architecture $ARCH"
;;
esac
- trace "available video driver list set to \"$DRIVER_LIST\""
+ trace "$func(): available video driver list set to \"$driver_list\""
# attempt to autodetect
if which discover >/dev/null 2>&1; then
if [ "$AUTODETECT_VIDEO_CARD" = "true" ]; then
if [ $NDRIVERS -eq 0 ]; then
- trace "could not autodetect X server driver: no video card detected," \
- "or no driver known for it"
+ trace "$func(): could not autodetect X server driver: no video card" \
+ "detected, or no driver known for it"
elif [ $NDRIVERS -eq 1 ]; then
- trace "autodetected X server driver: $DRIVERS"
+ trace "$func(): autodetected X server driver: $DRIVERS"
set_db_priority "low"
- DEFAULT_DRIVER="$DRIVERS"
+ default_driver="$DRIVERS"
elif [ $NDRIVERS -gt 1 ]; then
- trace "could not autodetect X server driver: multiple drivers for" \
- "video cards"
- VIDEOCARD_DRIVER_REPORT=$(echo "$DISCOVERED_VIDEO" \
+ trace "$func(): could not autodetect X server driver: multiple" \
+ "drivers for video cards"
+ videocard_driver_report=$(echo "$DISCOVERED_VIDEO" \
| awk 'BEGIN { FS="\t"; printf " %-30s%30s\n .\n", "Detected Video Card", "Suggested driver module" } { printf " %-50s%10s\n", $1, $3 } END { printf " .\n" }')
# can't do this until there is a way to embed newlines into debconf
# command streams :(
# db_subst shared/multiple_possible_x-drivers detected_cards \
- # "$VIDEOCARD_DRIVER_REPORT"
- trace "$VIDEOCARD_DRIVER_REPORT"
+ # "$videocard_driver_report"
+ trace "$videocard_driver_report"
set_db_priority "high"
run db_input "$PRIORITY" xserver-xfree86/multiple_possible_x-drivers
db_go
fi
else
- trace "user declined video card autodetection (driver)"
+ trace "$func(): user declined video card autodetection"
fi
else
- trace "could not autodetect X server driver: discover not found"
+ trace "$func(): could not autodetect X server driver: discover not found"
fi
- db_subst xserver-xfree86/config/device/driver choices "$DRIVER_LIST"
+ db_subst xserver-xfree86/config/device/driver choices "$driver_list"
auto_answer db_input "$PRIORITY" \
- xserver-xfree86/config/device/driver "$DEFAULT_DRIVER"
+ xserver-xfree86/config/device/driver "$default_driver"
# card identifier; try to set a sensible default
- DEFAULT=
+ default_identifier=
if [ -n "$NDRIVERS" ] && [ -n "$NCARDS" ] && [ $NDRIVERS -eq 1 ] \
&& [ $NCARDS -eq 1 ]; then
if which discover >/dev/null 2>&1; then
if [ "$AUTODETECT_VIDEO_CARD" = "true" ]; then
- DEFAULT=$(echo "$DISCOVERED_VIDEO" | cut -f1)
+ default_identifier=$(echo "$DISCOVERED_VIDEO" | cut -f1)
fi
fi
fi
- if [ -z "$DEFAULT" ]; then
+ if [ -z "$default_identifier" ]; then
# fall back to some language-specific generic text
# TODO: make this a read-only debconf template
case "${LC_ALL:-${LC_MESSAGES:-$LANG}}" in
- ca_*) DEFAULT="Targeta de v�o gen�ca" ;;
- da_*) DEFAULT="Standard Video Kort" ;;
- de_*) DEFAULT="Standardgrafikkarte" ;;
- es_*) DEFAULT="Tarjeta de v�o gen�ca" ;;
- fr_*) DEFAULT="Carte vid�g�rique" ;;
- gl_*) DEFAULT="Tarxeta de Video Xen�ca" ;;
- it_*) DEFAULT="Scheda video generica" ;;
+ ca_*) default_identifier="Targeta de v�o gen�ca" ;;
+ da_*) default_identifier="Standard Video Kort" ;;
+ de_*) default_identifier="Standardgrafikkarte" ;;
+ es_*) default_identifier="Tarjeta de v�o gen�ca" ;;
+ fr_*) default_identifier="Carte vid�g�rique" ;;
+ gl_*) default_identifier="Tarxeta de Video Xen�ca" ;;
+ it_*) default_identifier="Scheda video generica" ;;
# ja
# nl
- pt_BR) DEFAULT="Placa de V�o Gen�ca" ;;
+ pt_BR) default_identifier="Placa de V�o Gen�ca" ;;
# ru
# sv
- *) DEFAULT="Generic Video Card" ;;
+ *) default_identifier="Generic Video Card" ;;
esac
fi
set_db_priority "low"
# this question requires input validation
MAY_BE_NULL= auto_answer validate_string_db_input "$PRIORITY" \
- xserver-xfree86/config/device/identifier "$DEFAULT"
+ xserver-xfree86/config/device/identifier "$default_identifier"
# BusID
set_db_priority "low"
- DEFAULT=
+ default_bus_id=
# Some PowerPCs need to be told where to find the video card even if there is
# only one in the machine (broken PCI bus code in the XFree86 X server, most
@@ -747,11 +850,17 @@
# primary head.
if [ "$ARCH" = "powerpc" ] || [ "$MULTIHEAD" = "yes" ]; then
if [ "$ARCH" = "powerpc" ]; then
+ trace "$func(): PowerPC system detected; setting BusID question" \
+ "priority to medium"
set_db_priority "medium"
fi
+
if [ "$MULTIHEAD" = "yes" ]; then
+ trace "$func(): multihead system detected; setting BusID question" \
+ "priority to high"
set_db_priority "high"
fi
+
if which lspci >/dev/null 2>&1; then
# Use the output of lspci to try to guess the Bus ID of the primary head.
# Very recent versions of lspci support a -X option that feeds us exactly
@@ -760,44 +869,44 @@
# say "Class " before the PCI class identifier when the -n option is used.
if lspci -X >/dev/null 2>&1; then
trace "$(lspci -Xn | grep -E "(Class )?0300:")"
- DEFAULT=$(LC_ALL=C lspci -Xn | grep -E "(Class )?0300:" \
+ default_bus_id=$(LC_ALL=C lspci -Xn | grep -E "(Class )?0300:" \
| sort -n | head -n 1 | cut -d\ -f1)
- if [ -z "$DEFAULT" ]; then
- trace "lspci -Xn reported no video cards on system"
+ if [ -z "$default_bus_id" ]; then
+ trace "$func(): lspci -Xn reported no video cards on system"
fi
else
trace "$(lspci -n | grep -E "(Class )?0300:")"
- LSPCI_ID=$(LC_ALL=C lspci -n | grep -E "(Class )?0300:" | sort -n \
+ lspci_id=$(LC_ALL=C lspci -n | grep -E "(Class )?0300:" | sort -n \
| head -n 1 | cut -d\ -f1)
- if [ -n "$LSPCI_ID" ]; then
+ if [ -n "$lspci_id" ]; then
# Recent versions of lspci report a four-digit domain as the first
# field.
- if expr "$LSPCI_ID" : ".*:.*:.*\..*" >/dev/null 2>&1; then
+ if expr "$lspci_id" : ".*:.*:.*\..*" >/dev/null 2>&1; then
# We have an entry in "hex:hex:hex.hex" format; we need
# "PCI:decimal:decimal:decimal" (we don't use the domain).
- DOMAIN=$(printf "%d" 0x$(echo $LSPCI_ID | cut -d: -f1) )
- BUS=$(printf "%d" 0x$(echo $LSPCI_ID | cut -d: -f2) )
- DEVICE=$(printf "%d" 0x$(echo $LSPCI_ID | cut -d: -f3 \
+ pci_domain=$(printf "%d" 0x$(echo $lspci_id | cut -d: -f1) )
+ pci_bus=$(printf "%d" 0x$(echo $lspci_id | cut -d: -f2) )
+ pci_device=$(printf "%d" 0x$(echo $lspci_id | cut -d: -f3 \
| cut -d. -f1) )
- FUNCTION=$(printf "%d" 0x$(echo $LSPCI_ID | cut -d. -f2) )
- DEFAULT="PCI:$BUS:$DEVICE:$FUNCTION"
- elif expr "$LSPCI_ID" : ".*:.*\..*" >/dev/null 2>&1; then
+ pci_function=$(printf "%d" 0x$(echo $lspci_id | cut -d. -f2) )
+ default_bus_id="PCI:$pci_bus:$pci_device:$pci_function"
+ elif expr "$lspci_id" : ".*:.*\..*" >/dev/null 2>&1; then
# We have an entry in "hex:hex.hex" format; we need
# "PCI:decimal:decimal:decimal".
- BUS=$(printf "%d" 0x$(echo $LSPCI_ID | cut -d: -f1) )
- DEVICE=$(printf "%d" 0x$(echo $LSPCI_ID | cut -d: -f2 \
+ pci_bus=$(printf "%d" 0x$(echo $lspci_id | cut -d: -f1) )
+ pci_device=$(printf "%d" 0x$(echo $lspci_id | cut -d: -f2 \
| cut -d. -f1) )
- FUNCTION=$(printf "%d" 0x$(echo $LSPCI_ID | cut -d. -f2) )
- DEFAULT="PCI:$BUS:$DEVICE:$FUNCTION"
+ pci_function=$(printf "%d" 0x$(echo $lspci_id | cut -d. -f2) )
+ default_bus_id="PCI:$pci_bus:$pci_device:$pci_function"
else
- warn "unrecognized output from lspci: \"$LSPCI_ID\""
+ warn "$func(): unrecognized output from lspci: \"$lspci_id\""
fi
else
- trace "lspci -n reported no video cards on system"
+ trace "$func(): lspci -n reported no video cards on system"
fi
fi
else
- trace "cannot autodetect BusID; lspci command not available"
+ trace "$func(): cannot autodetect BusID; lspci command not available"
fi
fi
@@ -806,14 +915,14 @@
if [ -e /proc/cpuinfo ]; then
if grep -q "system type.*:.*SGI Indigo2" /proc/cpuinfo; then
set_db_priority "medium"
- DEFAULT=1
+ default_bus_id=1
fi
fi
# this question requires input validation
- if [ -n "$DEFAULT" ]; then
+ if [ -n "$default_bus_id" ]; then
auto_answer validate_bus_id_db_input "$PRIORITY" \
- xserver-xfree86/config/device/bus_id "$DEFAULT"
+ xserver-xfree86/config/device/bus_id "$default_bus_id"
else
run validate_bus_id_db_input "$PRIORITY" \
xserver-xfree86/config/device/bus_id
@@ -828,54 +937,69 @@
set_db_priority "high"
case "$ARCH" in
alpha|hurd-i386|i386)
- DEFAULT_USEFBDEV=false
+ default_use_fbdev=false
;;
*)
- DEFAULT_USEFBDEV=true
+ default_use_fbdev=true
;;
esac
- DEFAULT_USEFBDEV=
+ default_use_fbdev=
# XXX: is this a good test for /proc being mounted?
if [ -e /proc/self ]; then
if [ -e /proc/fb ]; then
- FB_TYPE="$(grep '^0 ' /proc/fb | sed 's/[^[:space:]] //')"
- trace "/proc/fb reports framebuffer type \"$FB_TYPE\""
+ fb_type="$(grep '^0 ' /proc/fb | sed 's/[^[:space:]] //')"
+ trace "$func(): /proc/fb reports framebuffer type \"$fb_type\""
# did we actually get back anything?
- if [ -n "$FB_TYPE" ]; then
+ if [ -n "$fb_type" ]; then
set_db_priority "medium"
- case "$FB_TYPE" in
+ case "$fb_type" in
OFfb|VESA)
- trace "this framebuffer type does not support UseFBDev"
- DEFAULT_USEFBDEV=false
+ trace "$func(): this framebuffer type does not support UseFBDev"
+ default_use_fbdev=false
;;
*)
# other framebuffers do support UseFBDev
- DEFAULT_USEFBDEV=true
+ default_use_fbdev=true
;;
esac
fi
else
- trace "/proc/fb does not exist; assuming fbcon not in use"
+ trace "$func(): /proc/fb does not exist; assuming fbcon not in use"
fi
else
- trace "/proc not mounted; cannot determine if fbcon in use"
+ trace "$func(): /proc not mounted; cannot determine if fbcon in use"
fi
# re-set the default answer to false if need be
run db_get xserver-xfree86/config/device/use_fbdev
- if [ "$RET" = "true" ] && [ "$DEFAULT_USEFBDEV" = "false" ]; then
- trace "xserver-xfree86/config/device/use_fbdev is \"true\" but /proc/fb" \
- "does not exist, is empty, or reports a framebuffer type with which" \
- "UseFBDev cannot be used; setting template to \"false\""
+ if [ "$RET" = "true" ] && [ "$default_use_fbdev" = "false" ]; then
+ trace "$func(): xserver-xfree86/config/device/use_fbdev is \"true\" but" \
+ "/proc/fb does not exist, is empty, or reports a framebuffer type" \
+ "with which UseFBDev cannot be used; setting template to \"false\""
db_set xserver-xfree86/config/device/use_fbdev false
fi
auto_answer db_input "$PRIORITY" xserver-xfree86/config/device/use_fbdev \
- "$DEFAULT_USEFBDEV"
+ "$default_use_fbdev"
}
configure_keyboard () {
+ # syntax: configure_keyboard
+ #
+ # Ask debconf questions that determine the contents of the "InputDevice"
+ # section (using the "keyboard" driver) of the XF86Config-4 file.
+
+ local default_model default_rules func
+ # TODO: default_layout default_options default_variant
+
+ func="configure_keyboard"
+
+ # Validate function arguments.
+ if [ -n "$*" ]; then
+ warn "$func(): called with bogus arguments $@"
+ fi
+
# TODO: query of debian-installer's keyboard configuration debconf template
# goes here
@@ -883,34 +1007,41 @@
set_db_priority "medium"
if [ "$ARCH" = "sparc" ]; then
- DEFAULT=sun
+ trace "$func(): SPARC architecture detected; using \"sun\" as default" \
+ "XkbRules"
+ default_rules=sun
else
- DEFAULT=xfree86
+ default_rules=xfree86
fi
- MAY_BE_NULL= auto_answer validate_string_db_input \
- "$PRIORITY" \
- xserver-xfree86/config/inputdevice/keyboard/rules "$DEFAULT"
+ MAY_BE_NULL= auto_answer validate_string_db_input "$PRIORITY" \
+ xserver-xfree86/config/inputdevice/keyboard/rules "$default_rules"
db_get xserver-xfree86/config/inputdevice/keyboard/rules
if [ "$RET" = "sun" ]; then
- DEFAULT=type5
+ trace "$func(): \"sun\" rules being used; using \"type5\" as default" \
+ "XkbModel"
+ default_model=type5
elif [ "$RET" = "xfree86" ]; then
if [ "$ARCH" = "powerpc" ]; then
- DEFAULT=macintosh
+ trace "$func(): PowerPC architecture detected and \"xfree86\" rules" \
+ "being used; using \"macintosh\" as default XkbModel"
+ default_model=macintosh
# good old-fashioned BRAIN DAMAGE
if [ -e /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes ]; then
if [ "$(cat /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes)" \
= "0" ]; then
- DEFAULT=macintosh_old
+ trace "$func(): Macintosh HID not sending Linux keycodes; using" \
+ "\"macintosh_old\" as default XkbModel"
+ default_model=macintosh_old
fi
fi
else
- DEFAULT=pc104
+ default_model=pc104
fi
fi
MAY_BE_NULL= auto_answer validate_string_db_input \
"$PRIORITY" \
- xserver-xfree86/config/inputdevice/keyboard/model "$DEFAULT"
+ xserver-xfree86/config/inputdevice/keyboard/model "$default_model"
MAY_BE_NULL= auto_answer validate_string_db_input \
"$PRIORITY" \
@@ -932,121 +1063,143 @@
}
configure_mouse () {
- # mouse device detection
+ # syntax: configure_mouse
+ #
+ # Ask debconf questions that determine the contents of the "InputDevice"
+ # section (using the "mouse" driver) of the XF86Config-4 file.
+ local autodetected_port autodetected_protocol default_port default_protocol \
+ func mdetect_output mouse_port_choices mouse_protocol_choices using_devfs
+
+ func="configure_mouse"
+
+ # Validate function arguments.
+ if [ -n "$*" ]; then
+ warn "$func(): called with bogus arguments $@"
+ fi
+
# priority of xserver-xfree86/config/inputdevice/mouse/{port,protocol}
set_db_priority "high"
- AUTODETECTED_PORT=
- AUTODETECTED_PROTOCOL=
+ autodetected_port=
+ autodetected_protocol=
# determine if we're using devfs
if [ -c /dev/.devfsd ]; then
- USING_DEVFS=true
+ using_devfs=true
else
- USING_DEVFS=
+ using_devfs=
fi
- if [ -n "$USING_DEVFS" ]; then
- MOUSE_PORT_CHOICES="/dev/misc/psaux, /dev/tts/0, /dev/tts/1, /dev/tts/2, /dev/tts/3, /dev/input/mice, /dev/misc/atixl, /dev/gpmdata"
- DEFAULT_PORT="/dev/misc/psaux"
+ if [ -n "$using_devfs" ]; then
+ trace "$func(): devfs appears to be in use; using devfs names for mouse" \
+ "port choices"
+ mouse_port_choices="/dev/misc/psaux, /dev/tts/0, /dev/tts/1, /dev/tts/2, /dev/tts/3, /dev/input/mice, /dev/misc/atixl, /dev/gpmdata"
+ default_port="/dev/misc/psaux"
else
- MOUSE_PORT_CHOICES="/dev/psaux, /dev/ttyS0, /dev/ttyS1, /dev/ttyS2, /dev/ttyS3, /dev/input/mice, /dev/atibm, /dev/sunmouse, /dev/gpmdata"
- DEFAULT_PORT="/dev/psaux"
+ trace "$func(): devfs does not appear to be in use"
+ mouse_port_choices="/dev/psaux, /dev/ttyS0, /dev/ttyS1, /dev/ttyS2, /dev/ttyS3, /dev/input/mice, /dev/atibm, /dev/sunmouse, /dev/gpmdata"
+ default_port="/dev/psaux"
fi
# if configuring for the first time, ask if user wants to autodetect
if [ -z "$RECONFIGURE" ]; then
while :; do
- # bail out if autodetection tool not available
- which mdetect >/dev/null 2>&1 || break
+ # Bail out if autodetection tool not available.
+ if ! which mdetect >/dev/null 2>&1; then
+ trace "$func(): not autodetecting mouse port and protocol; mdetect" \
+ "command not available"
+ break
+ fi
+
auto_answer db_input "$PRIORITY" \
xserver-xfree86/autodetect_mouse "false"
db_get xserver-xfree86/autodetect_mouse
if [ "$RET" = "true" ]; then
- MDETECT_OUTPUT=$(run mdetect -x)
- if [ -n "$MDETECT_OUTPUT" ]; then
- if [ $(echo "$MDETECT_OUTPUT" | wc -l) -ne 2 ]; then
- trace "bug in mdetect; did not return two lines of output"
+ mdetect_output=$(run mdetect -x)
+ if [ -n "$mdetect_output" ]; then
+ if [ $(echo "$mdetect_output" | wc -l) -ne 2 ]; then
+ trace "$func(): bug in mdetect; did not return two lines of output"
break
fi
- AUTODETECTED_PORT=$(echo "$MDETECT_OUTPUT" | head -n 1)
- AUTODETECTED_PROTOCOL=$(echo "$MDETECT_OUTPUT" | tail -n 1)
- trace "mdetect returned port \"$AUTODETECTED_PORT\"; protocol" \
- "\"$AUTODETECTED_PROTOCOL\""
- if [ -n "$AUTODETECTED_PORT" ]; then
+ autodetected_port=$(echo "$mdetect_output" | head -n 1)
+ autodetected_protocol=$(echo "$mdetect_output" | tail -n 1)
+ trace "$func(): mdetect returned port \"$autodetected_port\";" \
+ "protocol \"$autodetected_protocol\""
+ if [ -n "$autodetected_port" ]; then
# /dev/input/mouse* means we autodetected a USB pointer; we will
# store /dev/input/mice instead.
- if expr "$AUTODETECTED_PORT" : "/dev/input/mouse.*" >/dev/null \
+ if expr "$autodetected_port" : "/dev/input/mouse.*" >/dev/null \
2>&1; then
- AUTODETECTED_PORT="/dev/input/mice"
+ autodetected_port="/dev/input/mice"
fi
else
- trace "bug in mdetect: returned nothing for mouse port"
+ trace "$func(): bug in mdetect: returned nothing for mouse port"
break
fi
- if [ -z "$AUTODETECTED_PROTOCOL" ]; then
- trace "bug in mdetect: returned nothing for mouse protocol"
+ if [ -z "$autodetected_protocol" ]; then
+ trace "$func(): bug in mdetect: returned nothing for mouse protocol"
break
fi
else
- trace "mdetect returned no output; unable to autodetect mouse"
+ trace "$func(): mdetect returned no output; unable to autodetect" \
+ "mouse"
# permit user to retry, but set to false in the case question doesn't
# get asked (for noninteractive configuration)
db_set xserver-xfree86/autodetect_mouse "false"
fi
- if [ -n "$AUTODETECTED_PORT" ] && [ -n "$AUTODETECTED_PROTOCOL" ]; then
+ if [ -n "$autodetected_port" ] && [ -n "$autodetected_protocol" ]; then
set_db_priority "medium"
break # port and protocol determined
fi
else
- trace "user declined mouse autodetection"
+ trace "$func(): user declined mouse autodetection"
break # bail out; autodetection not desired
fi
done
else
- trace "not prompting for mouse autodetection; reconfiguring"
+ trace "$func(): not prompting for mouse autodetection; reconfiguring"
fi
db_subst xserver-xfree86/config/inputdevice/mouse/port choices \
- "$MOUSE_PORT_CHOICES"
+ "$mouse_port_choices"
auto_answer db_input "$PRIORITY" \
xserver-xfree86/config/inputdevice/mouse/port \
- "${AUTODETECTED_PORT:-$DEFAULT_PORT}"
+ "${autodetected_port:-$default_port}"
db_get xserver-xfree86/config/inputdevice/mouse/port
case "$RET" in
*psaux)
- MOUSE_PROTOCOL_CHOICES="PS/2, ImPS/2, GlidePointPS/2, NetMousePS/2, NetScrollPS/2, ThinkingMousePS/2, MouseManPlusPS/2, ExplorerPS/2"
- DEFAULT_PROTOCOL="PS/2"
+ mouse_protocol_choices="PS/2, ImPS/2, GlidePointPS/2, NetMousePS/2, NetScrollPS/2, ThinkingMousePS/2, MouseManPlusPS/2, ExplorerPS/2"
+ default_protocol="PS/2"
;;
*ttyS*|*tts/*)
- MOUSE_PROTOCOL_CHOICES="Auto, Microsoft, MouseSystems, GlidePoint, ThinkingMouse, ValuMouseScroll, MouseMan, Logitech, IntelliMouse, MMSeries, MMHitTab"
- DEFAULT_PROTOCOL="Auto"
+ mouse_protocol_choices="Auto, Microsoft, MouseSystems, GlidePoint, ThinkingMouse, ValuMouseScroll, MouseMan, Logitech, IntelliMouse, MMSeries, MMHitTab"
+ default_protocol="Auto"
;;
*input/mice)
- MOUSE_PROTOCOL_CHOICES="ImPS/2"
- DEFAULT_PROTOCOL="ImPS/2"
+ mouse_protocol_choices="ImPS/2"
+ default_protocol="ImPS/2"
;;
*atibm|*atixl|*sunmouse)
- MOUSE_PROTOCOL_CHOICES="BusMouse"
- DEFAULT_PROTOCOL="BusMouse"
+ mouse_protocol_choices="BusMouse"
+ default_protocol="BusMouse"
;;
*gpmdata)
- MOUSE_PROTOCOL_CHOICES="IntelliMouse"
- DEFAULT_PROTOCOL="IntelliMouse"
+ mouse_protocol_choices="IntelliMouse"
+ default_protocol="IntelliMouse"
;;
esac
db_subst xserver-xfree86/config/inputdevice/mouse/protocol choices \
- "$MOUSE_PROTOCOL_CHOICES"
- if ! expr "$MOUSE_PROTOCOL_CHOICES" : ".*,.*" >/dev/null 2>&1; then
- trace "\$MOUSE_PROTOCOL_CHOICES has only one value; setting" \
- "xserver-xfree86/config/inputdevice/mouse/protocol to" \
- "\"$DEFAULT_PROTOCOL\""
- db_set xserver-xfree86/config/inputdevice/mouse/protocol "$DEFAULT_PROTOCOL"
+ "$mouse_protocol_choices"
+ if ! expr "$mouse_protocol_choices" : ".*,.*" >/dev/null 2>&1; then
+ trace "$func(): \$mouse_protocol_choices has only one value; setting" \
+ "xserver-xfree86/config/inputdevice/mouse/protocol to" \
+ "\"$default_protocol\""
+ db_set xserver-xfree86/config/inputdevice/mouse/protocol "$default_protocol"
else
auto_answer db_input "$PRIORITY" \
xserver-xfree86/config/inputdevice/mouse/protocol \
- "${AUTODETECTED_PROTOCOL:-$DEFAULT_PROTOCOL}"
+ "${autodetected_protocol:-$default_protocol}"
fi
set_db_priority "low"
@@ -1058,17 +1211,35 @@
}
configure_monitor () {
+ # syntax: configure_monitor
+ #
+ # Ask debconf questions that determine the contents of the "Monitor" section
+ # of the XF86Config-4 file.
+
+ local default_horiz_sync default_identifier default_vert_refresh \
+ edid_dump edid_horiz_sync edid_id edid_vert_refresh func
+ # $DEFAULT_MODES is global; keep it that way, because we need its value in
+ # other functions, like configure_display_modes_and_depth().
+
+ func="configure_monitor"
+
+ # Validate function arguments.
+ if [ -n "$*" ]; then
+ warn "$func(): called with bogus arguments $@"
+ fi
+
set_db_priority "high"
- DEFAULT_HORIZ_SYNC="28-50"
- DEFAULT_VERT_REFRESH="43-75"
+ default_horiz_sync="28-50"
+ default_vert_refresh="43-75"
db_fget xserver-xfree86/config/monitor/identifier seen
if [ "$RET" = "false" ]; then
- trace "xserver-xfree86/config/monitor/identifier has not been seen"
+ trace "$func(): xserver-xfree86/config/monitor/identifier has not been seen"
fi
db_get xserver-xfree86/config/monitor/identifier
- trace "xserver-xfree86/config/monitor/identifier is already set to \"$RET\""
+ trace "$func(): xserver-xfree86/config/monitor/identifier is already set to" \
+ "\"$RET\""
# The horiz-sync and vert-refresh questions may have answers even though they
# haven't been seen; autodetection, pre-loading, and the simple and medium
@@ -1076,119 +1247,122 @@
db_fget xserver-xfree86/config/monitor/horiz-sync seen
if [ "$RET" = "false" ]; then
- trace "xserver-xfree86/config/monitor/horiz-sync has not been seen"
+ trace "$func(): xserver-xfree86/config/monitor/horiz-sync has not been seen"
fi
db_get xserver-xfree86/config/monitor/horiz-sync
- trace "xserver-xfree86/config/monitor/horiz-sync is already set to \"$RET\""
+ trace "$func(): xserver-xfree86/config/monitor/horiz-sync is already set to" \
+ "\"$RET\""
db_fget xserver-xfree86/config/monitor/vert-refresh seen
if [ "$RET" = "false" ]; then
- trace "xserver-xfree86/config/monitor/vert-refresh has not been seen"
+ trace "$func(): xserver-xfree86/config/monitor/vert-refresh has not been" \
+ "seen"
fi
db_get xserver-xfree86/config/monitor/vert-refresh
- trace "xserver-xfree86/config/monitor/vert-refresh is already set to \"$RET\""
+ trace "$func(): xserver-xfree86/config/monitor/vert-refresh is already set" \
+ "to \"$RET\""
# if configuring for the first time, ask if user wants to autodetect
if [ -z "$RECONFIGURE" ]; then
if which get-edid >/dev/null 2>&1; then
- auto_answer db_input "$PRIORITY" \
- xserver-xfree86/autodetect_monitor "false"
+ auto_answer db_input "$PRIORITY" xserver-xfree86/autodetect_monitor \
+ "false"
db_get xserver-xfree86/autodetect_monitor
if [ "$RET" = "true" ]; then
set +e
- EDID_DUMP=$( (get-edid | parse-edid) 2>/dev/null)
+ edid_dump=$( (get-edid | parse-edid) 2>/dev/null)
set -e
if [ $? -eq 0 ]; then
# quite crude
- MONITOR_IDENTIFIER=$(echo "$EDID_DUMP" | grep Identifier \
- | cut -f2 -d\")
- if [ -n "$MONITOR_IDENTIFIER" ]; then
- trace "get-edid reports monitor identifier of" \
- "\"$MONITOR_IDENTIFIER\""
- DEFAULT_MONITOR_IDENTIFIER="$MONITOR_IDENTIFIER"
+ edid_id=$(echo "$edid_dump" | grep Identifier | cut -f2 -d\")
+ if [ -n "$edid_id" ]; then
+ trace "$func(): get-edid reports monitor identifier of \"$edid_id\""
+ default_identifier="$edid_id"
else
- trace "got null monitor identifier from get-edid"
+ trace "$func(): got null monitor identifier from get-edid"
fi
# even cruder
- HORIZ_SYNC=$(echo "$EDID_DUMP" | grep HorizSync | awk '{print $2}')
- VERT_REFRESH=$(echo "$EDID_DUMP" | grep VertRefresh \
+ edid_horiz_sync=$(echo "$edid_dump" | grep HorizSync \
| awk '{print $2}')
+ edid_vert_refresh=$(echo "$edid_dump" | grep VertRefresh \
+ | awk '{print $2}')
# get-edid may succeed but be unable to return info anyway
- if [ -n "$HORIZ_SYNC" ]; then
- trace "get-edid reports horizonal sync of \"$HORIZ_SYNC\""
- DEFAULT_HORIZ_SYNC="$HORIZ_SYNC"
+ if [ -n "$edid_horiz_sync" ]; then
+ trace "$func(): get-edid reports horizonal sync of" \
+ "\"$edid_horiz_sync\""
+ default_horiz_sync="$edid_horiz_sync"
else
- trace "get-edid returned blank hsync"
+ trace "$func(): get-edid returned blank hsync"
fi
- if [ -n "$VERT_REFRESH" ]; then
- trace "get-edid reports vertical refresh of \"$VERT_REFRESH\""
- DEFAULT_VERT_REFRESH="$VERT_REFRESH"
+ if [ -n "$edid_vert_refresh" ]; then
+ trace "$func(): get-edid reports vertical refresh of" \
+ "\"$edid_vert_refresh\""
+ default_vert_refresh="$edid_vert_refresh"
else
- trace "get-edid returned blank vrefresh"
+ trace "$func(): get-edid returned blank vrefresh"
fi
else
- trace "get-edid returned an error"
+ trace "$func(): get-edid returned an error"
fi
else
- trace "user declined monitor autodetection"
+ trace "$func(): user declined monitor autodetection"
fi
else
- trace "could not autodetect monitor frequencies; get-edid not found"
+ trace "$func(): could not autodetect monitor frequencies; get-edid not" \
+ "found"
fi
else
- trace "not prompting for monitor autodetection; reconfiguring"
+ trace "$func(): not prompting for monitor autodetection; reconfiguring"
fi
# priority of xserver-xfree86/config/monitor/identifier
set_db_priority "low"
# monitor identifier; try to set a sensible default
- if [ -n "$DEFAULT_MONITOR_IDENTIFIER" ]; then
- DEFAULT="$DEFAULT_MONITOR_IDENTIFIER"
- else
+ if [ -z "$default_identifier" ]; then
# fall back to some language-specific generic text
# TODO: make this a read-only debconf template
case "${LC_ALL:-${LC_MESSAGES:-$LANG}}" in
- ca_*) DEFAULT="Monitor gen�c" ;;
- da_*) DEFAULT="Standard Sk�" ;;
- de_*) DEFAULT="Standardbildschirm" ;;
- es_*) DEFAULT="Monitor gen�co" ;;
- fr_*) DEFAULT="�ran g�rique" ;;
+ ca_*) default_identifier="Monitor gen�c" ;;
+ da_*) default_identifier="Standard Sk�" ;;
+ de_*) default_identifier="Standardbildschirm" ;;
+ es_*) default_identifier="Monitor gen�co" ;;
+ fr_*) default_identifier="�ran g�rique" ;;
# gl
- it_*) DEFAULT="Monitor Generico" ;;
+ it_*) default_identifier="Monitor Generico" ;;
# ja
# nl
- pt_BR) DEFAULT="Monitor Gen�co" ;;
+ pt_BR) default_identifier="Monitor Gen�co" ;;
# ru
# sv
- *) DEFAULT="Generic Monitor" ;;
+ *) default_identifier="Generic Monitor" ;;
esac
fi
# this question requires input validation
- MAY_BE_NULL= auto_answer validate_string_db_input \
- "$PRIORITY" xserver-xfree86/config/monitor/identifier \
- "$DEFAULT"
+ MAY_BE_NULL= auto_answer validate_string_db_input "$PRIORITY" \
+ xserver-xfree86/config/monitor/identifier "$default_identifier"
# priority of xserver-xfree86/config/monitor/selection-method
set_db_priority "medium"
- if [ -n "$HORIZ_SYNC" ] && [ -n "$VERT_REFRESH" ]; then
- trace "\$HORIZ_SYNC: \"$HORIZ_SYNC\" ; \$VERT_REFRESH: \"$VERT_REFRESH\";" \
- "setting question priority to low"
+ if [ -n "$edid_horiz_sync" ] && [ -n "$edid_vert_refresh" ]; then
+ trace "$func(): \$edid_horiz_sync: \"$edid_horiz_sync\";" \
+ "\$edid_vert_refresh: \"$edid_vert_refresh\"; setting question" \
+ "priority to low"
set_db_priority "low"
else
- trace "at least of one of hsync \"$HORIZ_SYNC\" or vrefresh" \
- "\"$VERT_REFRESH\" is null; not setting question priority to low"
+ trace "$func(): at least of one of hsync \"$edid_horiz_sync\" or vrefresh" \
+ "\"$edid_vert_refresh\" is null; not setting question priority to low"
fi
- trace "monitor hsync and vrefresh question priority is $PRIORITY"
+ trace "$func(): monitor hsync and vrefresh question priority is $PRIORITY"
auto_answer db_input "$PRIORITY" \
xserver-xfree86/config/monitor/lcd "false"
db_get xserver-xfree86/config/monitor/lcd
- trace "xserver-xfree86/config/monitor/lcd is $RET"
+ trace "$func(): xserver-xfree86/config/monitor/lcd is $RET"
if [ "$RET" = "true" ]; then
db_subst xserver-xfree86/config/monitor/selection-method choices \
"Medium, Advanced"
@@ -1208,8 +1382,7 @@
db_get xserver-xfree86/config/monitor/selection-method
case "$RET" in
Simple)
- run db_input "$PRIORITY" \
- xserver-xfree86/config/monitor/screen-size
+ run db_input "$PRIORITY" xserver-xfree86/config/monitor/screen-size
db_go
db_get xserver-xfree86/config/monitor/screen-size
case "$RET" in
@@ -1241,8 +1414,7 @@
esac
;;
Medium)
- run db_input "$PRIORITY" \
- xserver-xfree86/config/monitor/mode-list
+ run db_input "$PRIORITY" xserver-xfree86/config/monitor/mode-list
db_go
db_get xserver-xfree86/config/monitor/mode-list
# The mode and range information below is adapted from the built-in
@@ -1413,47 +1585,61 @@
DEFAULT_MODES="2048x1536"
;;
*)
- internal_error "configure_monitor(): no handler for" \
- "xserver-xfree86/config/monitor/mode-list value \"$RET\""
+ internal_error "$func(): no handler for" \
+ "xserver-xfree86/config/monitor/mode-list value" \
+ "\"$RET\""
;;
esac
;;
Advanced)
- auto_answer validate_monitor_frequency_db_input \
- "$PRIORITY" \
+ auto_answer validate_monitor_frequency_db_input "$PRIORITY" \
xserver-xfree86/config/monitor/horiz-sync "28-50"
- auto_answer validate_monitor_frequency_db_input \
- "$PRIORITY" \
+ auto_answer validate_monitor_frequency_db_input "$PRIORITY" \
xserver-xfree86/config/monitor/vert-refresh "43-75"
;;
esac
}
configure_display_modes_and_depth () {
+ # syntax: configure_display_modes_and_depth
+ #
+ # Ask debconf questions that determine some of the contents of the "Screen"
+ # section of the XF86Config-4 file.
+
+ local default_depth func
+ # $DEFAULT_MODES is global because it is also used by configure_monitor().
+
+ func="configure_display_modes_and_depth"
+
+ # Validate function arguments.
+ if [ -n "$*" ]; then
+ warn "$func(): called with bogus arguments $@"
+ fi
+
# Configure available video modes. For certain drivers we will override any
# existing value of $DEFAULT_MODES, because they only support certain modes.
# Otherwise, the existing value of $DEFAULT_MODES is preserved.
db_get xserver-xfree86/config/device/driver
+ trace "$func(): \"xserver-xfree86/config/device/driver\" is \"$RET\""
case "$RET" in
newport)
- DEFAULT_DEPTH=8
+ default_depth=8
DEFAULT_MODES="1280x1024"
;;
vga)
- DEFAULT_DEPTH=4
+ default_depth=4
DEFAULT_MODES="640x480"
;;
*)
- DEFAULT_DEPTH=24
+ default_depth=24
# If a default mode list is not already set, set one that should work
# across a broad range of hardware (as of August 2004).
: ${DEFAULT_MODES:="1152x864, 1024x768, 800x600, 640x480"}
;;
esac
- trace "\"xserver-xfree86/config/device/driver\" is \"$RET\"; set default" \
- "color depth to $DEFAULT_DEPTH and available video modes to" \
- "\"$DEFAULT_MODES\""
+ trace "$func(): default color depth is $default_depth and default video" \
+ "modes are \"$DEFAULT_MODES\""
set_db_priority "medium"
@@ -1463,10 +1649,24 @@
# default display depth
auto_answer db_input "$PRIORITY" \
- xserver-xfree86/config/display/default_depth "$DEFAULT_DEPTH"
+ xserver-xfree86/config/display/default_depth "$default_depth"
}
configure_server_modules () {
+ # syntax: configure_server_modules
+ #
+ # Ask debconf questions that determine the contents of the "Modules" section
+ # of the XF86Config-4 file.
+
+ local func
+
+ func="configure_server_modules"
+
+ # Validate function arguments.
+ if [ -n "$*" ]; then
+ warn "$func(): called with bogus arguments $@"
+ fi
+
# server modules to load
db_get xserver-xfree86/config/device/driver
set_db_priority "low"
@@ -1475,20 +1675,57 @@
}
configure_files () {
+ # syntax: configure_files
+ #
+ # Ask debconf questions that determine the contents of the "Files" section of
+ # the XF86Config-4 file.
+
+ local func
+
+ func="configure_files"
+
+ # Validate function arguments.
+ if [ -n "$*" ]; then
+ warn "$func(): called with bogus arguments $@"
+ fi
+
run db_input "$PRIORITY" xserver-xfree86/config/write_files_section
db_go
}
configure_dri () {
+ # syntax: configure_dri
+ #
+ # Ask debconf questions that determine the contents of the "DRI" section of
+ # the XF86Config-4 file.
+
+ local func
+
+ func="configure_dri"
+
+ # Validate function arguments.
+ if [ -n "$*" ]; then
+ warn "$func(): called with bogus arguments $@"
+ fi
+
run db_input "$PRIORITY" xserver-xfree86/config/write_dri_section
db_go
}
configure_xfree86_x_server () {
+ # syntax: configure_xfree86_x_server
+ #
# Ask debconf questions that determine what XF86Config-4 will look like.
- local bailout
+ local bailout func
+ func="configure_xfree86_x_server"
+
+ # Validate function arguments.
+ if [ -n "$*" ]; then
+ warn "$func(): called with bogus arguments $@"
+ fi
+
# If the XF86Config-4 configuration file is under manual control, do nothing.
# Perform tests to determine if this is the case.
@@ -1503,11 +1740,11 @@
# Compare the current and stored checksums; if they do not match, the
# file is under manual control.
if [ "$(md5sum "$XF86CONFIG")" != "$(cat "$XF86CONFIG_CHECKSUM")" ]; then
- trace "$XF86CONFIG file has been customized"
+ trace "$func(): $XF86CONFIG file has been customized"
bailout=yes
fi
else
- trace "no stored checksum available for $XF86CONFIG"
+ trace "$func(): no stored checksum available for $XF86CONFIG"
bailout=yes
fi
fi
@@ -1524,8 +1761,8 @@
# default").
PRIORITY_CEILING=
if [ -e "$XF86CONFIG" ]; then
- trace "$XF86CONFIG file exists; capping configuration question priority" \
- "at medium"
+ trace "$func(): $XF86CONFIG file exists; capping configuration question" \
+ "priority at medium"
PRIORITY_CEILING=medium
fi
@@ -1546,12 +1783,12 @@
# This is main().
-# analyze arguments; used by auto_answer()
+# Analyze script arguments.
if [ "$1" = "reconfigure" ] || [ -n "$2" ]; then
# if we are reconfiguring, or already have installed the package at least
# once before, we should not let auto_answer stomp on existing answers to
# debconf questions
- trace "package being reconfigured"
+ trace "$THIS_PACKAGE is being reconfigured"
RECONFIGURE=true
else
RECONFIGURE=
@@ -1601,7 +1838,7 @@
# Only add the module if it's not already there.
if ! expr "$RET" : ".*v4l.*" >/dev/null 2>&1; then
trace "upgrading from package version $2; adding v4l to list of selected" \
- "modules"
+ "modules"
trace "old value of template \"xserver-xfree86/config/modules\": \"$RET\""
# Add it to the end with a comma and space prepended if there are already
# some selected modules. Otherwise, make v4l the only selected module.
Reply to: