# vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:

# increment this if you have made a change that should force a new kernel
# to be built for this release of this distribution (only -- if you want to
# force a kernel build on all releases of this distribution, update the BUILD_GEN
# variable in build/lbuild-rhel and if you want to force kernel bulid for all
# distributions, update the BUILD_GEN variable in build/lbuild)
#BUILD_GEN+=".0"
#BUILD_GEN+=".1"		# added --with firmware to rpmbuild for rhel6
#BUILD_GEN+=".0"	# TT-107: don't cache the BUILD dir (reset major to 5)
BUILD_GEN+=".1"	# LU-1361: enable kernel ABI

source ${LBUILD_DIR}/lbuild-rhel

SPEC_NAME="kernel.spec"
DEVEL_PATH_ARCH_DELIMETER="."
USE_KABI=true

patch_spec() {
    local buildid="$1"

    # edit the SPEC with our changes
    patch_spec_common "$buildid"
    sed -i -e '/^# empty final patch file to facilitate testing of kernel patches/i\
# adds Lustre patches\
Patch99995: linux-%{version}-lustre.patch' \
           -e '/^ApplyOptionalPatch linux-kernel-test.patch/i\
\
# lustre patch\
ApplyOptionalPatch linux-%{version}-lustre.patch\
' \
           -e '/rm -f include\/generated\/kernel.cross/i\
  # lustre kernel config.\
  if [ -f %{_topdir}/lustre/lustre/kernel_patches/kernel_configs/kernel-%{version}-2.6-rhel6-%{_target_cpu}.config ]; then\
    echo "# $Arch" > configs/kernel-%{version}-%{_target_cpu}.config\
    cat %{_topdir}/lustre/lustre/kernel_patches/kernel_configs/kernel-%{version}-2.6-rhel6-%{_target_cpu}.config >> configs/kernel-%{version}-%{_target_cpu}.config\
  fi'\
           -e '/^# Dynamically generate kernel/a echo "CONFIG_BH_LRU_SIZE=16" >> config-generic'\
          SPECS/$SPEC_NAME 2>&1 || \
        fatal 1 "Error while editing SPECS/$SPEC_NAME"


    return 0

}

unpack_linux_devel_rpm-rhel6() {
    local callers_rpm="$1"

    unpack_linux_devel_rpm-rhel "$callers_rpm"


    return 0

}

get_rpmbuildopts() {

    if $KERNEL_LUSTRE_NAMING; then
        echo -e "--define \"variant -lustre\" \c"
    fi
    echo "--with firmware"

    return 0

}

find_linux_rpm-rhel6() {
    local prefix="$1"
    local wanted_kernel="$2"
    local pathtorpms=${3:-"${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}/${TARGET_ARCH}"}

    find_linux_rpm-rhel "$prefix" "$wanted_kernel" "$pathtorpms"

}

kernel_srpm_location() {

    echo "http://ftp.redhat.com/pub/redhat/linux/enterprise/6Server/en/os/SRPMS/"

}
