dump_debugcache() {
TODEBUGCACHE=0
- echo "${DEBUGCACHE}" >> ${DEBUGFILE}
+ echo "${DEBUGCACHE}" >> ${LOGFILE}
}
-# print_info(debuglevel, print [, newline [, prefixline [, forcefile ] ] ])
+# print_info(loglevel, print [, newline [, prefixline [, forcefile ] ] ])
print_info() {
local NEWLINE=1
local FORCEFILE=0
fi
fi
- # PRINT TO SCREEN ONLY IF PASSED DEBUGLEVEL IS HIGHER THAN
+ # PRINT TO SCREEN ONLY IF PASSED LOGLEVEL IS HIGHER THAN
# OR EQUAL TO SET DEBUG LEVEL
- if [ "$1" -lt "${DEBUGLEVEL}" -o "$1" -eq "${DEBUGLEVEL}" ]
+ if [ "$1" -lt "${LOGLEVEL}" -o "$1" -eq "${LOGLEVEL}" ]
then
SCRPRINT='1'
fi
if [ "${NEWLINE}" = '0' ]
then
- if [ "${TODEBUGCACHE}" -eq 1 ]; then
+ if [ "${TODEBUGCACHE}" -eq '1' ]; then
DEBUGCACHE="${DEBUGCACHE}${STR}"
else
- echo -ne "${STR}" >> ${DEBUGFILE}
+ echo -ne "${STR}" >> ${LOGFILE}
fi
else
- if [ "${TODEBUGCACHE}" -eq 1 ]; then
+ if [ "${TODEBUGCACHE}" -eq '1' ]; then
DEBUGCACHE="${DEBUGCACHE}${STR}"$'\n'
else
- echo "${STR}" >> ${DEBUGFILE}
+ echo "${STR}" >> ${LOGFILE}
fi
fi
fi
}
clear_log() {
- if [ -f "${DEBUGFILE}" ]
+ if [ -f "${LOGFILE}" ]
then
- (echo > "${DEBUGFILE}") 2>/dev/null || small_die "Genkernel: Could not write to ${DEBUGFILE}."
+ (echo > "${LOGFILE}") 2>/dev/null || small_die "Genkernel: Could not write to ${LOGFILE}."
fi
}
if isTrue ${USECOLOR}
then
- GREP_COLOR='1' grep -B5 -E --colour=always "([Ww][Aa][Rr][Nn][Ii][Nn][Gg]|[Ee][Rr][Rr][Oo][Rr][ :,!]|[Ff][Aa][Ii][Ll][Ee]?[Dd]?)" ${DEBUGFILE}
+ GREP_COLOR='1' grep -B5 -E --colour=always "([Ww][Aa][Rr][Nn][Ii][Nn][Gg]|[Ee][Rr][Rr][Oo][Rr][ :,!]|[Ff][Aa][Ii][Ll][Ee]?[Dd]?)" ${LOGFILE}
else
- grep -B5 -E "([Ww][Aa][Rr][Nn][Ii][Nn][Gg]|[Ee][Rr][Rr][Oo][Rr][ :,!]|[Ff][Aa][Ii][Ll][Ee]?[Dd]?)" ${DEBUGFILE}
+ grep -B5 -E "([Ww][Aa][Rr][Nn][Ii][Nn][Gg]|[Ee][Rr][Rr][Oo][Rr][ :,!]|[Ff][Aa][Ii][Ll][Ee]?[Dd]?)" ${LOGFILE}
fi
echo
print_info 1 "-- End log... --"
echo
- print_info 1 "Please consult ${DEBUGFILE} for more information and any"
+ print_info 1 "Please consult ${LOGFILE} for more information and any"
print_info 1 "errors that were reported above."
echo
print_info 1 "Report any genkernel bugs to bugs.gentoo.org and"
print_info 1 "assign your bug to genkernel@gentoo.org. Please include"
print_info 1 "as much information as you can in your bug report; attaching"
- print_info 1 "${DEBUGFILE} so that your issue can be dealt with effectively."
+ print_info 1 "${LOGFILE} so that your issue can be dealt with effectively."
print_info 1 ''
print_info 1 'Please do *not* report compilation failures as genkernel bugs!'
print_info 1 ''
fi
if [ -e '/dev/loop0' -o -e '/dev/loop/0' -a ${PIPESTATUS[1]} ]
then
- # We found devfs or standard dev loop device, assume
- # loop is compiled into the kernel or the module is loaded
+ # We found a standard dev loop device, assume loop is compiled into the
+ # kernel or the module is loaded
return 0
else
return 1
fi
}
+#
+# Helper function to allow command line arguments to override configuration
+# file specified values and to apply defaults.
+#
+# Arguments:
+# $1 Argument type:
+# 1 Switch type arguments (e.g., --color / --no-color).
+# 2 Value type arguments (e.g., --debuglevel=5).
+# $2 Config file variable name.
+# $3 Command line variable name.
+# $4 Default. If both the config file variable and the command line
+# option are not present, then the config file variable is set to
+# this default value. Optional.
+#
+# The order of priority of these three sources (highest first) is:
+# Command line, which overrides
+# Config file (/etc/genkernel.conf), which overrides
+# Default.
+#
+# Arguments $2 and $3 are variable *names*, not *values*. This function uses
+# various forms of indirection to access the values.
+#
+# For switch type arguments, all forms of "True" are converted to a numeric 1
+# and all forms of "False" (everything else, really) to a numeric 0.
+#
+# - JRG
+#
+set_config_with_override() {
+ local VarType=$1
+ local CfgVar=$2
+ local OverrideVar=$3
+ local Default=$4
+ local Result
+
+ #
+ # Syntax check the function arguments.
+ #
+ case "$VarType" in
+ 1|2)
+ ;;
+ *)
+ gen_die "Illegal variable type \"$VarType\" passed to set_config_with_override()."
+ ;;
+ esac
+
+ if [ -n "${!OverrideVar}" ]
+ then
+ Result=${!OverrideVar}
+ if [ -n "${!CfgVar}" ]
+ then
+ print_info 5 " $CfgVar overridden on command line to \"$Result\"."
+ else
+ print_info 5 " $CfgVar set on command line to \"$Result\"."
+ fi
+ else
+ if [ -n "${!CfgVar}" ]
+ then
+ Result=${!CfgVar}
+ print_info 5 " $CfgVar set in config file to \"${Result}\"."
+ else
+ if [ -n "$Default" ]
+ then
+ Result=${Default}
+ print_info 5 " $CfgVar defaulted to \"${Result}\"."
+ else
+ print_info 5 " $CfgVar not set."
+ fi
+ fi
+ fi
+
+ if [ "$VarType" -eq "1" ]
+ then
+ if isTrue "${Result}"
+ then
+ Result=1
+ else
+ Result=0
+ fi
+ fi
+
+ eval ${CfgVar}=\"${Result}\"
+}
+