⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kernel.guess

📁 ocfs1.2.7 源码
💻 GUESS
字号:
#!/bin/shRHEL4_KERNEL_BASE="/usr/src/kernels"## This is a simple mapping of architectures to kernel flavors.  One# entry per architecture, <arch>:<flavor1>[,<flavor> ...]## This is used when detecting kernels to build packages for.  A kernel# is only built if build trees for all flavors are installed.## Unique to redhat, empty types (the 'default' kernel) are allowed.# Be careful parsing this!## Red Hat throws us another loop.  2.6.9-34.EL+ have a new "largesmp"# type.  So, we have TYPES and OLD TYPES.#RHEL4_KERNEL_TYPES="    i686:,smp,hugemem    x86_64:,smp,largesmp    ia64:,largesmp    ppc64:,largesmp    s390x:"guess_rhel4_arch(){    # This appears to DTRT (i686 on x86, ppc64 on pSeries).    uname -m}guess_rhel4_type(){    case "$1" in    *largesmp)        echo "largesmp"        ;;    *hugemem)        echo "hugemem"        ;;    *smp)        echo "smp"        ;;    *)        echo ""        ;;    esac}guess_rhel4_dir(){    KVER="$1"    DIRTYPE=$(guess_rhel4_type "$KVER")    ARCH=$(guess_rhel4_arch)    if [ -z "$DIRTYPE" ]    then        echo "${1%${DIRTYPE}}-${ARCH}"    else        echo "${1%${DIRTYPE}}-${DIRTYPE}-${ARCH}"    fi}## OCFS2 can only use RHEL4 U2 and newer#new_enough(){    KVER="$1"    #    # RHEL4 versions look like    #     2.6.9-<something>.EL<type>    # where <something> is a version string.  We really only care    # about the first number in it, which we'll call COUNTER.    #    EXTPART="${KVER#2.6.9-}"    EXTPART="${EXTPART%%.EL*}"    COUNTER="${EXTPART%%.*}"    # U2 is 22.EL    if [ -z "$COUNTER" -o "$COUNTER" -lt 22 ]    then        return 1    fi        return 0}verfromdir(){    TESTDIR="$1"    if [ -r "${TESTDIR}/include/linux/version.h" ]    then        awk '/UTS_RELEASE/{gsub(/"/,"",$3); print $3}' "${TESTDIR}/include/linux/version.h"    fi}validate_dir(){    KVER="$1"    DIR="$2"    if [ ! -d "${RHEL4_KERNEL_BASE}/${DIR}" ]    then        return 1    elif [ ! -f "${RHEL4_KERNEL_BASE}/${DIR}/include/linux/autoconf.h" ]    then        return 1    elif [ ! -f "${RHEL4_KERNEL_BASE}/${DIR}/include/linux/version.h" ]    then        return 1    fi    if [ "$KVER" != "$(verfromdir "${RHEL4_KERNEL_BASE}/${DIR}")" ]    then        return 1    fi    return 0}# Takes a `uname -r` and returns "ver type", where ver# is 2.6.9-NN.EL and type is "smp" or the like.validate_version(){    KVER="$1"    if ! new_enough "$KVER" 2>/dev/null    then        return    fi    dir=$(guess_rhel4_dir "$KVER")    if validate_dir "$KVER" "$dir"    then        echo "${RHEL4_KERNEL_BASE}/${dir}"    fi}find_version(){    # Find the most recent valid kernel    ls -1 -t "$RHEL4_KERNEL_BASE" | while read kdir    do        KVER="$(verfromdir "${RHEL4_KERNEL_BASE}/${kdir}")"        if validate_dir "$KVER" "$kdir"        then            echo "${RHEL4_KERNEL_BASE}/${kdir}"            break        fi    done}# For a given KVER, see if all the -devel packages existvalidate_target(){    KVER="$1"    ARCH="$2"    TYPELIST="$3"    # Red Hat introduced the "largesmp" type in 34.EL.  Anything older    # can ignore it.    LARGESMP="${KVER#2.6.9-}"    LARGESMP="${LARGESMP%%.*}"    if [ "$LARGESMP" -lt 34 ]    then        TYPELIST="${TYPELIST%,largesmp}"    fi    typelist="${TYPELIST#$ARCH:}"    while :    do        type="${typelist%%,*}"        VERDIR="$(validate_version ${KVER}${type})"        if [ -z "$VERDIR" ]        then            return 1        fi            # This loop walks the list of types being careful of the empty        # typename        tmp="${typelist#*,}"        if [ -z "$tmp" -o "$tmp" = "$typelist" ]        then            break        fi        typelist="$tmp"    done    return 0}find_targets(){    # Pre-calculate ARCH and TYPELIST, at least    ARCH="$(guess_rhel4_arch)"    if [ -z "$ARCH" ]    then        return    fi    TYPELIST=    for typelist in $RHEL4_KERNEL_TYPES    do        TARCH=$(echo "$typelist" | cut -f1 -d:)        if [ "$TARCH" = "$ARCH" ]        then            TYPELIST="$typelist"            break        fi    done    if [ -z "$TYPELIST" ]    then        return    fi        ls -1 -t "$RHEL4_KERNEL_BASE" | while read kdir    do        case "$kdir" in        2.6.9-5.EL*)            # Missing get_sb_pseudo()            continue            ;;        *)            ;;        esac        KVER="$(verfromdir "${RHEL4_KERNEL_BASE}/${kdir}")"        if ! new_enough "$KVER" 2>/dev/null        then            continue        fi        if ! validate_dir "$KVER" "$kdir"        then            continue        fi        if validate_target "$KVER" "$ARCH" "$TYPELIST"        then            echo "rhel4_${KVER}_rpm"        fi    done}case "$1" ininclude|build)    if [ -n "$2" ]    then        KPATH="$(validate_version "$2")"    else        KVER="$(uname -r)"        KPATH="$(validate_version "$KVER")"        if [ -z "$KPATH" ]        then            KPATH="$(find_version)"        fi    fi    if [ -n "$KPATH" ]    then        if [ "$1" = "include" ]        then            KPATH="${KPATH}/include"        fi        echo "${KPATH}"    fi    ;;targets)    find_targets    ;;"")    echo "Missing operation" >&2    ;;*)    echo "Invalid operation: $1" >&2    exit 1    ;;esac

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -