X-Git-Url: http://git.tremily.us/?a=blobdiff_plain;f=gen_funcs.sh;h=4f0a0fc25f9cf44b83ae3bbc2e75562f84145c1a;hb=457cc95b07fc706f12bdd9adf6b862ce64361448;hp=07a7f5fe618b0526589570232d9a9cb6724ef90a;hpb=35258a703f6953dcbc31ba9c4059103fed0c8d1d;p=genkernel.git diff --git a/gen_funcs.sh b/gen_funcs.sh index 07a7f5f..4f0a0fc 100755 --- a/gen_funcs.sh +++ b/gen_funcs.sh @@ -22,7 +22,7 @@ isTrue() { return 1 } -setColorVars() { +setColorVars() { if isTrue ${USECOLOR} then GOOD=$'\e[32;01m' @@ -94,7 +94,7 @@ print_info() { # PRINT TO SCREEN ONLY IF PASSED LOGLEVEL IS HIGHER THAN # OR EQUAL TO SET DEBUG LEVEL - if [ "$1" -lt "${LOGLEVEL}" -o "$1" -eq "${LOGLEVEL}" ] + if [ "$1" -lt "${LOGLEVEL}" -o "$1" = "${LOGLEVEL}" ] then SCRPRINT='1' fi @@ -106,7 +106,7 @@ print_info() { fi # STRUCTURE DATA TO BE OUTPUT TO SCREEN, AND OUTPUT IT - if [ "${SCRPRINT}" -eq '1' ] + if [ "${SCRPRINT}" = '1' ] then if [ "${PREFIXLINE}" = '1' ] then @@ -124,7 +124,7 @@ print_info() { fi # STRUCTURE DATA TO BE OUTPUT TO FILE, AND OUTPUT IT - if [ "${SCRPRINT}" -eq '1' -o "${FORCEFILE}" -eq '1' ] + if [ "${SCRPRINT}" = '1' -o "${FORCEFILE}" = '1' ] then STRR=${2//${WARN}/} STRR=${STRR//${BAD}/} @@ -140,13 +140,13 @@ print_info() { if [ "${NEWLINE}" = '0' ] then - if [ "${TODEBUGCACHE}" -eq '1' ]; then + if [ "${TODEBUGCACHE}" = '1' ]; then DEBUGCACHE="${DEBUGCACHE}${STR}" else echo -ne "${STR}" >> ${LOGFILE} - fi + fi else - if [ "${TODEBUGCACHE}" -eq '1' ]; then + if [ "${TODEBUGCACHE}" = '1' ]; then DEBUGCACHE="${DEBUGCACHE}${STR}"$'\n' else echo "${STR}" >> ${LOGFILE} @@ -178,7 +178,7 @@ var_replace() # in the later sed expression local SAFE_VAR SAFE_VAR=`echo "${2}" | sed -e 's/\([\/\.]\)/\\\\\\1/g'` - + echo "${3}" | sed -e "s/%%${1}%%/${SAFE_VAR}/g" - } @@ -186,10 +186,6 @@ arch_replace() { var_replace "ARCH" "${ARCH}" "${1}" } -kv_replace() { - var_replace "KV" "${KV}" "${1}" -} - cache_replace() { var_replace "CACHE" "${CACHE_DIR}" "${1}" } @@ -198,7 +194,7 @@ clear_log() { if [ -f "${LOGFILE}" ] then (echo > "${LOGFILE}") 2>/dev/null || small_die "Genkernel: Could not write to ${LOGFILE}." - fi + fi } gen_die() { @@ -208,29 +204,30 @@ gen_die() { then print_error 1 "ERROR: ${1}" fi - echo - print_info 1 "-- Grepping log... --" - echo + print_error 1 '' + print_error 1 "-- Grepping log... --" + print_error 1 '' 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]?)" ${LOGFILE} + 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} \ + | sed -s "s|^\(*\)\?|${BAD}*${NORMAL}|" else 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 ${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 "${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 '' + print_error 1 '' + print_error 1 "-- End log... --" + print_error 1 '' + print_error 1 "Please consult ${LOGFILE} for more information and any" + print_error 1 "errors that were reported above." + print_error 1 '' + print_error 1 "Report any genkernel bugs to bugs.gentoo.org and" + print_error 1 "assign your bug to genkernel@gentoo.org. Please include" + print_error 1 "as much information as you can in your bug report; attaching" + print_error 1 "${LOGFILE} so that your issue can be dealt with effectively." + print_error 1 '' + print_error 1 'Please do *not* report compilation failures as genkernel bugs!' + print_error 1 '' # Cleanup temp dirs and caches if requested cleanup @@ -250,30 +247,28 @@ setup_cache_dir() if [ "${CLEAR_CACHE_DIR}" == 'yes' ] then print_info 1 "Clearing cache dir contents from ${CACHE_DIR}" - CACHE_DIR_CONTENTS=`ls ${CACHE_DIR}|grep -v CVS|grep -v cpio|grep -v README` - - for i in ${CACHE_DIR_CONTENTS} + while read i do print_info 1 " >> removing ${i}" - rm ${CACHE_DIR}/${i} - done + rm "${i}" + done < <(find "${CACHE_DIR}" -maxdepth 1 -type f -name '*.tar.*' -o -name '*.bz2') fi } clear_tmpdir() { -if ! isTrue ${CMD_NOINSTALL} +if isTrue ${CMD_INSTALL} then - TMPDIR_CONTENTS=`ls ${TMPDIR}` - print_info 1 "Removing tmp dir contents" - for i in ${TMPDIR_CONTENTS} - do - print_info 1 " >> removing ${i}" - rm ${TMPDIR}/${i} - done + TMPDIR_CONTENTS=`ls ${TMPDIR}` + print_info 1 "Removing tmp dir contents" + for i in ${TMPDIR_CONTENTS} + do + print_info 1 " >> removing ${i}" + rm ${TMPDIR}/${i} + done fi -} +} # # Function to copy various kernel boot image products to the boot directory, @@ -303,7 +298,8 @@ copy_image_with_preserve() { # Old product might be a different version. If so, we need to read # the symlink to see what it's name is, if there are symlinks. - if [ "${SYMLINK}" -eq '1' ] + cd ${KERNEL_OUTPUTDIR} + if [ "${SYMLINK}" = '1' ] then print_info 4 "automatically managing symlinks and old images." 1 0 if [ -e "${BOOTDIR}/${symlinkName}" ] @@ -349,7 +345,7 @@ copy_image_with_preserve() { # When symlinks are not being managed by genkernel, old symlinks might # still be useful. Leave 'em alone unless managed. - if [ "${SYMLINK}" -eq '1' ] + if [ "${SYMLINK}" = '1' ] then print_info 5 " Deleting old symlinks, if any." rm -f "${BOOTDIR}/${symlinkName}" @@ -367,7 +363,7 @@ copy_image_with_preserve() { # print_info 5 " Same base version. May have to delete old image to make room." - if [ "${currDestImageExists}" -eq '1' ] + if [ "${currDestImageExists}" = '1' ] then if [ -e "${BOOTDIR}/${currDestImage}.old" ] then @@ -395,14 +391,14 @@ copy_image_with_preserve() { cp "${newSrceImage}" "${BOOTDIR}/${currDestImage}" || gen_die "Could not copy the ${symlinkName} image to ${BOOTDIR}!" - if [ "${SYMLINK}" -eq '1' ] + if [ "${SYMLINK}" = '1' ] then print_info 5 " Make new symlink(s) (from ${BOOTDIR}):" print_info 5 " ${symlinkName} -> ${currDestImage}" pushd ${BOOTDIR} >/dev/null ln -s "${currDestImage}" "${symlinkName}" || gen_die "Could not create the ${symlinkName} symlink!" - if [ "${prevDestImageExists}" -eq '1' ] + if [ "${prevDestImageExists}" = '1' ] then print_info 5 " ${symlinkName}.old -> ${prevDestImage}" ln -s "${prevDestImage}" "${symlinkName}.old" || @@ -450,7 +446,7 @@ set_config_with_override() { # Syntax check the function arguments. # case "$VarType" in - 1|2) + BOOL|STRING) ;; *) gen_die "Illegal variable type \"$VarType\" passed to set_config_with_override()." @@ -486,7 +482,7 @@ set_config_with_override() { fi fi - if [ "$VarType" -eq "1" ] + if [ "${VarType}" = BOOL ] then if isTrue "${Result}" then @@ -500,7 +496,7 @@ set_config_with_override() { } check_distfiles() { - for i in $BUSYBOX_SRCTAR $DEVICE_MAPPER_SRCTAR $MULTIPATH_SRCTAR $LVM_SRCTAR $DMRAID_SRCTAR $E2FSPROGS_SRCTAR + for i in $BUSYBOX_SRCTAR $MULTIPATH_SRCTAR $LVM_SRCTAR $DMRAID_SRCTAR $ISCSI_SRCTAR $GPG_SRCTAR do if [ ! -f "${i}" ] then @@ -513,7 +509,7 @@ find_kernel_binary() { local kernel_binary=$* local curdir=$(pwd) - cd "${KERNEL_DIR}" + cd "${KERNEL_OUTPUTDIR}" for i in ${kernel_binary} do if [ -e "${i}" ]