43 echo "${DEBUGCACHE}" >> ${DEBUGFILE}
46 # print_info(debuglevel, print [, newline [, prefixline [, forcefile ] ] ])
55 if [ "$#" -lt '2' ] ; then return 1; fi
57 # IF 3 OR MORE ARGS, CHECK IF WE WANT A NEWLINE AFTER PRINT
68 # IF 4 OR MORE ARGS, CHECK IF WE WANT TO PREFIX WITH A *
79 # IF 5 OR MORE ARGS, CHECK IF WE WANT TO FORCE OUTPUT TO DEBUG
80 # FILE EVEN IF IT DOESN'T MEET THE MINIMUM DEBUG REQS
91 # PRINT TO SCREEN ONLY IF PASSED DEBUGLEVEL IS HIGHER THAN
92 # OR EQUAL TO SET DEBUG LEVEL
93 if [ "$1" -lt "${DEBUGLEVEL}" -o "$1" -eq "${DEBUGLEVEL}" ]
98 # RETURN IF NOT OUTPUTTING ANYWHERE
99 if [ "${SCRPRINT}" != '1' -a "${FORCEFILE}" != '1' ]
104 # STRUCTURE DATA TO BE OUTPUT TO SCREEN, AND OUTPUT IT
105 if [ "${SCRPRINT}" -eq '1' ]
107 if [ "${PREFIXLINE}" = '1' ]
109 STR="${GOOD}*${NORMAL} ${2}"
114 if [ "${NEWLINE}" = '0' ]
122 # STRUCTURE DATA TO BE OUTPUT TO FILE, AND OUTPUT IT
123 if [ "${SCRPRINT}" -eq '1' -o "${FORCEFILE}" -eq '1' ]
126 STRR=${STRR//${BAD}/}
127 STRR=${STRR//${BOLD}/}
128 STRR=${STRR//${NORMAL}/}
130 if [ "${PREFIXLINE}" = '1' ]
137 if [ "${NEWLINE}" = '0' ]
139 if [ "${TODEBUGCACHE}" -eq 1 ]; then
140 DEBUGCACHE="${DEBUGCACHE}${STR}"
142 echo -ne "${STR}" >> ${DEBUGFILE}
145 if [ "${TODEBUGCACHE}" -eq 1 ]; then
146 DEBUGCACHE="${DEBUGCACHE}${STR}"$'\n'
148 echo "${STR}" >> ${DEBUGFILE}
158 GOOD=${BAD} print_info "$@"
163 GOOD=${WARN} print_info "$@"
166 # var_replace(var_name, var_value, string)
168 # $2 = variable value
173 # Escape '\' and '.' in $2 to make it safe to use
174 # in the later sed expression
176 SAFE_VAR=`echo "${2}" | sed -e 's/\([\/\.]\)/\\\\\\1/g'`
178 echo "${3}" | sed -e "s/%%${1}%%/${SAFE_VAR}/g" -
182 var_replace "ARCH" "${ARCH}" "${1}"
186 var_replace "KV" "${KV}" "${1}"
190 var_replace "CACHE" "${CACHE_DIR}" "${1}"
194 if [ -f "${DEBUGFILE}" ]
196 (echo > "${DEBUGFILE}") 2>/dev/null || small_die "Genkernel: Could not write to ${DEBUGFILE}."
205 print_error 1 "ERROR: ${1}"
208 print_info 1 "-- Grepping log... --"
211 if isTrue ${USECOLOR}
213 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}
215 grep -B5 -E "([Ww][Aa][Rr][Nn][Ii][Nn][Gg]|[Ee][Rr][Rr][Oo][Rr][ :,!]|[Ff][Aa][Ii][Ll][Ee]?[Dd]?)" ${DEBUGFILE}
218 print_info 1 "-- End log... --"
220 print_info 1 "Please consult ${DEBUGFILE} for more information and any"
221 print_info 1 "errors that were reported above."
223 print_info 1 "Report any genkernel bugs to bugs.gentoo.org and"
224 print_info 1 "assign your bug to genkernel@gentoo.org. Please include"
225 print_info 1 "as much information as you can in your bug report; attaching"
226 print_info 1 "${DEBUGFILE} so that your issue can be dealt with effectively."
228 print_info 1 'Please do *not* report compilation failures as genkernel bugs!'
231 # Cleanup temp dirs and caches if requested
237 if [ -e /var/log/dmesg ]
239 cat /var/log/dmesg | egrep -q '^loop:'
241 dmesg | egrep -q '^loop:'
243 if [ -e '/dev/loop0' -o -e '/dev/loop/0' -a ${PIPESTATUS[1]} ]
245 # We found devfs or standard dev loop device, assume
246 # loop is compiled into the kernel or the module is loaded
255 for mo in `grep ' ${BOOTDIR} ' /proc/mounts | cut -d ' ' -f 4 | sed -e 's/,/ /'`
257 if [ "x${mo}x" == "xrox" ]
268 [ ! -d "${CACHE_DIR}" ] && mkdir -p "${CACHE_DIR}"
270 if [ "${CLEAR_CACHE_DIR}" == 'yes' ]
272 print_info 1 "Clearing cache dir contents from ${CACHE_DIR}"
273 CACHE_DIR_CONTENTS=`ls ${CACHE_DIR}|grep -v CVS|grep -v cpio|grep -v README`
275 for i in ${CACHE_DIR_CONTENTS}
277 print_info 1 " >> removing ${i}"
286 if ! isTrue ${CMD_NOINSTALL}
288 TMPDIR_CONTENTS=`ls ${TMPDIR}`
289 print_info 1 "Removing tmp dir contents"
290 for i in ${TMPDIR_CONTENTS}
292 print_info 1 " >> removing ${i}"