+++ /dev/null
-#!/bin/sh
-
-# option variables
-DESTDIR=
-KERNELDIR=
-TARGET=
-# Not sure what to put here
-# TARGET_ARCH=$(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
-TARGET_ARCH=
-TARGET_CONFIG=
-JOBS=1
-CONFIGURE_FLAGS=
-TMPDIR=${TMPDIR:-"/var/tmp"}
-
-# commands to run
-BUILD_LUSTRE=0
-BUILD_KERNEL=0
-DEPEND_KERNEL=0
-INSTALL_LUSTRE=0
-INSTALL_KERNEL=0
-SAVE_HEADERS=0
-UNPACK_KERNEL=0
-
-# provided by target file
-KERNEL=
-SERIES=
-CONFIG=
-VERSION=
-EXTRA_VERSION=
-
-BASE_ARCHS=
-BIGMEM_ARCHS=
-BOOT_ARCHS=
-JENSEN_ARCHS=
-SMP_ARCHS=
-BIGSMP_ARCHS=
-PSERIES64_ARCHS=
-UP_ARCHS=
-
-RHBUILD=0
-SUSEBUILD=0
-
-# flat-out globals
-TOPDIR=
-TARGET_FILE=
-KERNEL_FILE=
-SERIES_FILE=
-CONFIG_FILE=
-RPMBUILD=
-XEN=false
-
-# build the lustre-tests rpm?
-LUSTRE_TESTS=true
-
-canon()
-{
- pushd $1 >/dev/null
- echo $PWD
- popd >/dev/null
-}
-TOPDIR="${0%%${0##*/}}"
-if [ "${TOPDIR}" ] ; then
- TOPDIR=$(canon "${TOPDIR}/..")
-else
- TOPDIR=$(canon "..")
-fi
-
-lbuild_topdir()
-{
- retdir=$TOPDIR
- while [ ! -d $retdir/BUILD ] ; do
- retdir=$(canon "$retdir/..")
- if [ "$retdir" = "/" ] ; then
- break;
- fi
- done
- echo "$retdir"
-}
-
-cleanup()
-{
- true
-}
-
-fatal()
-{
- cleanup
- [ "$2" ] && echo
- [ "$2" ] && echo "${0##*/}: $2"
- exit $1
-}
-
-list_targets()
-{
- echo -n "Available targets:"
- for target in $TOPDIR/lustre/kernel_patches/targets/*.target ; do
- target_file=${target##*/}
- echo -n " ${target_file%%.target}"
- done
- echo
-}
-
-
-usage()
-{
- cat <<EOF
-Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
-
-Options:
-
- --build
- same as --build-kernel --build-lustre --unpack-kernel
-
- --build-lustre
- configure and compile lustre. Requires that --build-kernel was
- already run.
-
- --build-kernel
- configure and compile a kernel. Implies --depend-kernel.
- Requires that --unpack-kernel was already run.
-
- --depend-kernel)
- Prepares a kernel tree for building (similar to make mrproper
- oldconfig dep). Requires that --unpack-kernel was already run.
-
- --destdir=DESTDIR
- Root directory to install into (like DESTDIR with auto*).
-
- --extraversion=EXTRAVERSION
- Overrides the target kernel\'s EXTRAVERSION text.
-
- -h, --help
- Display this message.
-
- --install
- same as --install-kernel --install-lustre
-
- --install-lustre
- run make install in the Lustre tree.
-
- --install-kernel
- install the kernel image and modules.
-
- -j jobs
- This works just like the -j option to make, and is passed to make
- when building.
-
- --kerneldir=KERNELDIR
- Directory containing linux source tarballs.
-
- --target=TARGET
- Name of the configuration to use. The available targets are
- listed below.
-
- --target-arch=ARCH
- Specifies an architecture to use when choosing a kernel config
- file. Default is i386.
-
- --target-config=CONFIG
- Specifies a special option (such as smp, bigsmp, bigmem, or BOOT)
- to use when choosing a kernel config file. This also modifies the
- kernel version and modules directory.
-
- --unpack-kernel
- Untars and patches the kernel source.
-
- --xen
- Builds a Xen domX kernel.
-
- The order that commands (--build-lustre, --unpack-kernel) are
- specified on the command line is ignored; ${0##*/} will always
- execute them in the correct order (unpack, then build, then install
- etc.).
-
-EOF
- list_targets
-
- fatal "$1" "$2"
-}
-
-check_options()
-{
- (( $BUILD_LUSTRE || $BUILD_KERNEL || $DEPEND_KERNEL || \
- $INSTALL_LUSTRE || $INSTALL_KERNEL || $SAVE_HEADERS || \
- $UNPACK_KERNEL )) || \
- fatal 1 "No commands specified."
-
- if (( $UNPACK_KERNEL )) ; then
- [ "$KERNELDIR" ] || \
- fatal 1 "A kernel directory must be specified with --kerneldir."
- [ -d "$KERNELDIR" ] || \
- fatal 1 "$KERNELDIR is not a directory."
- fi
-
- if (( $INSTALL_LUSTRE || $INSTALL_KERNEL || $SAVE_HEADERS )) ; then
- [ -z "$DESTDIR" -o -d "$DESTDIR" ] || \
- fatal 1 "$DESTDIR is not a directory."
- fi
-
- [ "$TARGET" ] || usage 1 "A target must be specified with --target."
- TARGET_FILE="$TOPDIR/lustre/kernel_patches/targets/$TARGET.target"
- [ -r "$TARGET_FILE" ] || \
- fatal 1 "Target '$TARGET' was not found. Try --list-targets."
-
- if [ -z "$JOBS" -o "$JOBS" -lt "1" ] ; then
- JOBS=1
- fi
-
- RPMBUILD=$(which rpmbuild 2>/dev/null | head -1)
- if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
- RPMBUILD=$(which rpm 2>/dev/null | head -1)
- if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
- usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)."
- fi
- fi
-}
-
-get_lustre_version()
-{
- for series in $SERIES ; do
- SERIES_FILE="$TOPDIR/lustre/kernel_patches/series/$series"
- lustre_patch=$(grep lustre_version "$SERIES_FILE" 2>/dev/null)
- [ "$lustre_patch" ] && break
- done
- [ "$lustre_patch" ] || \
- fatal 1 "Could not determine Lustre version from $SERIES series."
-
- awk '/^\+#define LUSTRE_KERNEL_VERSION /{ print $3 }' \
- "$TOPDIR/lustre/kernel_patches/patches/$lustre_patch" 2>/dev/null
-}
-
-load_target()
-{
- EXTRA_VERSION_save="$EXTRA_VERSION"
-
- . "$TARGET_FILE"
-
- # doesn't make any sense to build OFED for xen domX's
- if $XEN; then
- OFED_VERSION=""
- fi
-
- [ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel."
-# Suse 2.6 has our patches in already
-# [ "$SERIES" ] || fatal 1 "Target $TARGET did not specify a patch series."
-# [ "$CONFIG" ] || fatal 1 "Target $TARGET did not specify a kernel config."
- [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify the kernel version."
-
- if [ "$KERNELDIR" ] ; then
- KERNEL_FILE="$KERNELDIR/$KERNEL"
- [ -r "$KERNELDIR/$KERNEL" ] || \
- fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR."
- fi
-
- if [ "$SERIES" ] ; then
- for series in $SERIES ; do
- SERIES_FILE="$TOPDIR/lustre/kernel_patches/series/$series"
- [ -r "$SERIES_FILE" ] || \
- fatal 1 "Target $TARGET's series $SERIES missing from $TOPDIR/lustre/kernel_patches/series."
- done
- fi
-
- local XENPOSTFIX=""
- if $XEN; then
- XENPOSTFIX="-xen"
- fi
-
- TARGET_ARCH=${TARGET_ARCH:-$BASE_ARCHS}
- CONFIG_TARGET="${TARGET}${XENPOSTFIX}-${TARGET_ARCH}${TARGET_CONFIG:+-$TARGET_CONFIG}"
- CONFIG_FILE="$TOPDIR/lustre/kernel_patches/kernel_configs/kernel-$VERSION-$CONFIG_TARGET.config"
- [ -r "$CONFIG_FILE" ] ||
- fatal 1 "Target $TARGET's config file $CONFIG_FILE missing from $TOPDIR/lustre/kernel_patches/configs."
-
- if [ "$EXTRA_VERSION_save" ] ; then
- EXTRA_VERSION="$EXTRA_VERSION_save"
- else
- EXTRA_VERSION="${EXTRA_VERSION}_lustre.$(get_lustre_version)"
- fi
-}
-
-# do these after load_target(), which maybe export CC
-setup_ccache_distcc()
-{
- # distcc can't handle ".incbin"
- if [ "$TARGET" == "2.6-suse" -o "$TARGET" == "2.6-rhel4" ]; then
- if [ "$TARGET_ARCH" == "x86_64" ]; then
- unset DISTCC
- fi
- fi
-
- CC=${CC:-gcc}
- if [ "$CCACHE" ]; then
- [[ $CC != ccache\ * ]] && CC="$CCACHE $CC"
- [ "$DISTCC" ] && export CCACHE_PREFIX="$DISTCC"
- else
- [ "$DISTCC" ] && CC="$DISTCC $CC"
- fi
-}
-
-tarflags()
-{
- case "$1" in
- '')
- fatal 1 "tarflags(): File name argument missing."
- ;;
- *.tar.gz | *.tgz)
- echo 'zxf'
- ;;
- *.tar.bz2)
- echo 'jxf'
- ;;
- *.tar)
- echo 'xf'
- ;;
- *)
- fatal 1 "tarflags(): Unrecognized tar extension in file: $1"
- ;;
- esac
-}
-
-untar()
-{
- echo "Untarring ${1##*/}..."
- tar $(tarflags $1) $1
-}
-
-
-extract_kernel()
-{
- (( $UNPACK_KERNEL )) || return 0
- pushd "$TOPDIR" >/dev/null
- if [ -d linux ] ; then
- [ -L linux ] && rm -rf $(readlink linux)
- rm -rf linux
- fi
- untar "$KERNEL_FILE" || fatal 1 "Error unpacking Linux tarball"
- [ -d linux ] || ln -sf linux* linux
- popd >/dev/null
-}
-
-patch_kernel()
-{
- (( $UNPACK_KERNEL )) || return 0
- [ "$SERIES" ] || return 0
- pushd "$TOPDIR/linux" >/dev/null
- for series in $SERIES ; do
- echo -n "Applying series $series:"
- SERIES_FILE="$TOPDIR/lustre/kernel_patches/series/$series"
- for patch in $(<"$SERIES_FILE") ; do
- PATCH_FILE="$TOPDIR/lustre/kernel_patches/patches/$patch"
- [ -r "$PATCH_FILE" ] || \
- fatal 1 "Patch file not found: $patch"
- echo -n " $patch"
- patch -s -p1 < "$PATCH_FILE" || fatal 1 "Error applying patch $patch."
- done
- echo
- done
- popd >/dev/null
-}
-
-set_make()
-{
- MAKE="make -s"
- [ "$CC" ] && {
- if [ "$TARGET_ARCH" == "ppc64" ] ; then
- MAKE_CC="CC=$CC -m64"
- else
- MAKE_CC="CC=$CC"
- fi
- }
- if [ "$ARCH" ] ; then
- MAKE_ARCH="$MAKE ARCH=$ARCH"
- else
- case $TARGET_ARCH in
- i?86)
- ;;
- *)
- MAKE_ARCH="$MAKE ARCH=$TARGET_ARCH"
- ;;
- esac
- fi
- MAKE_J="$MAKE -j $JOBS"
-}
-
-timed_run() {
- SLEEP_TIME=$1
- shift
-
- set -o monitor
-
- #bash -c "$@" &
- ("$@") &
- child_pid=$!
-
- (sleep $SLEEP_TIME
- kill -TERM -$child_pid 2>/dev/null
- sleep 5
- kill -KILL -$child_pid 2>/dev/null
- echo "$1 was killed due to timeout") &
- dog_pid=$!
-
- wait $child_pid
- # status will be set to 143 if the process had to be killed due to timeout
- status=${PIPESTATUS[0]}
- kill -KILL -$dog_pid
- return $status
-}
-
-depend_kernel()
-{
- (( $DEPEND_KERNEL )) || return 0
- # we need to override $CC at make time, since there is no
- # configure
- set_make
- pushd "$TOPDIR/linux" >/dev/null
- echo "Overriding EXTRAVERSION in kernel..."
- local extra_version="${EXTRA_VERSION_DELIMITER}${EXTRA_VERSION}"
- if [ -n "${TARGET_CONFIG}" ]; then
- extra_version="${extra_version}${TARGET_DELIMITER}${TARGET_CONFIG}"
- fi
- sed -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = ${extra_version}/" Makefile
- echo "Making depend in $PWD..."
- $MAKE "$MAKE_CC" mrproper || fatal 1 "Error running make mrproper"
- rm -f rpm-release
- # remove localversion-* files to avoid kernel release string
- # srewing up by the top-level Makefile
- rm -f localversion-*
- cp "$CONFIG_FILE" .config
- local UPDATE_OLDCONFIG=
- for oc in oldconfig_nonint silentoldconfig oldconfig ; do
- if grep -q "$oc" Makefile ; then
- timed_run 300 $MAKE "$MAKE_CC" $oc || UPDATE_OLDCONFIG=1
- break
- fi
- done
-
- if [ "$UPDATE_OLDCONFIG" ] ; then
- # use the expect script to "make oldconfig" and answer the questions for
- # new items conservatively. QA will get notified on anything newly added
- # for them to review and adjust accordingly.
- local logfile=$(mktemp /tmp/XXXXXX)
- #timed_run 300 $TOPDIR/build/update_oldconfig $logfile
- #local RC=${PIPESTATUS[0]}
- #local RC=$(strace -f -o update_oldconfig.strace bash -c "$TOPDIR/build/update_oldconfig $logfile; echo \$?")
- $TOPDIR/build/update_oldconfig $logfile
- local RC=${PIPESTATUS[0]}
- #$TOPDIR/build/update_oldconfig $logfile
- #local RC=${PIPESTATUS[0]}
- if [ $RC -eq 143 ]; then
- fatal 1 "update_oldconfig timed out"
- elif [ $RC -ne 0 ]; then
- # dump the log
- cat $logfile
- rm -f $logfile
- if [ -f update_oldconfig.strace ]; then
- cat update_oldconfig.strace
- rm -f update_oldconfig.strace
- fi
- fatal 1 "update_oldconfig failed: $RC. See log above."
- fi
- fi
- rm -f $logfile
- # now notify if resulting .config is different than $CONFIG_FILE
- local tmpfile=$(mktemp /tmp/XXXXXX)
- diff -I '^#.*' -u "$CONFIG_FILE" .config >$tmpfile
- if [ -s $tmpfile ]; then
- { cat <<EOF
-To: lustre-qa-team@sun.com
-Subject: kernel_config change
-
-The result of a make oldconfig on file $CONFIG_FILE resulted in a
-difference when compared to .config in the following way:
-
-EOF
- cat $tmpfile
- echo -e "\n\nPlease consider updating $CONFIG_FILE for version: $extra_version."
- # not sure these are entirely useful. the above and "patch" are good
- #echo -e "\nThe entire new .config file:\n"
- #cat .config
- # sadly, the build roots can't e-mail out, so we can only display this
- # to stderr for an interested party to inspect
- #} | sendmail -flustre-qa-team@sun.com -t
- } >&2
- fi
- rm -f $tmpfile
-
- case "$VERSION" in
- 2.6*)
- $MAKE "$MAKE_CC" include/asm
- ;;
- 2.4*)
- $MAKE "$MAKE_CC" symlinks
- $MAKE "$MAKE_CC" dep || fatal 1 "Error running make dep"
- ;;
- esac
- $MAKE "$MAKE_CC" include/linux/version.h || fatal 1 "Error making include/linux/version.h"
-}
-
-build_kernel()
-{
- (( $BUILD_KERNEL )) || return 0
- set_make
- echo "Building kernel in $PWD..."
- if $XEN; then
- $MAKE_J "$MAKE_CC" vmlinuz || fatal 1 "Error making vmlinux."
- else
- case "$TARGET_ARCH" in
- i386 | i586 | i686 | athlon | x86_64)
- $MAKE_J "$MAKE_CC" bzImage || fatal 1 "Error making bzImage."
- ;;
- ia64 | ppc | ppc64)
- $MAKE_J "$MAKE_CC" vmlinux || fatal 1 "Error making vmlinux."
- ;;
- *)
- $MAKE_J "$MAKE_CC" boot || fatal 1 "Error making boot."
- ;;
- esac
- fi
- $MAKE_J "$MAKE_CC" modules || fatal 1 "Error building modules."
-
- popd >/dev/null
-}
-
-build_kernel_ib()
-{
- (( $BUILD_KERNEL )) || return 0
- # build kernel-ib{,-devel}
- # some I/B drivers are architecture dependent and kernel-ib's configure
- # does not figure it out for us ~sigh~
- local configure_options=""
- case "$TARGET_ARCH" in
- x86_64 | ia64)
- configure_options="--with-ipath_inf-mod"
- ;;
- ppc64)
- configure_options="--with-ipath_inf-mod --with-ehca-mod"
- ;;
- esac
- local K_SRC="K_SRC"
- # ofed 1.3 had a bug in the rpm spec
- if [ "$OFED_VERSION" = "1.3" ]; then
- K_SRC="KSRC"
- fi
- if ! $RPMBUILD --rebuild --define 'build_kernel_ib 1' --define 'build_kernel_ib_devel 1' \
- --define "_topdir $(lbuild_topdir)" --target ${TARGET_ARCH} \
- --define "KVERSION ${FULL_VERSION}" \
- --define "$K_SRC ${PWD}/linux" \
- --define "LIB_MOD_DIR /lib/modules/${FULL_VERSION}" \
- --define "configure_options --without-quilt --with-core-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod --with-srp-target-mod --with-core-mod --with-mthca-mod --with-mlx4-mod --with-cxgb3-mod --with-nes-mod --with-ipoib-mod --with-sdp-mod --with-srp-mod --with-rds-mod --with-iser-mod --with-qlgc_vnic-mod --with-madeye-mod $configure_options" $(lbuild_topdir)/OFED/SRPMS/ofa_kernel-*.src.rpm 2>&1; then
- fatal 1 "Error building kernel-ib"
- fi
-
- pushd "$TOPDIR" >/dev/null
- rm -rf kernel-ib-devel
- mkdir kernel-ib-devel
- cd kernel-ib-devel
- local rpm=$(ls $(lbuild_topdir)/RPMS/*/kernel-ib-devel-*-${FULL_VERSION//-/_}.*.rpm)
- rpm2cpio -itv < $rpm | cpio -id
- CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/ofa_kernel ${CONFIGURE_FLAGS}"
- popd >/dev/null
-}
-
-
-configure_lustre()
-{
- return 0
- (( $BUILD_LUSTRE )) || return 0
- pushd "$TOPDIR" >/dev/null
- [ -f Makefile ] && make -s clean
- [ -f configure ] || sh ./autogen.sh
- ./configure --with-linux=$PWD/linux $CONFIGURE_FLAGS || \
- fatal 1 "Error configuring Lustre."
- popd >/dev/null
-}
-
-build_lustre()
-{
- (( $BUILD_LUSTRE )) || return 0
- set_make
- pushd "$TOPDIR" >/dev/null
- sed \
- -e s^@VERSION@^${LUSTRE_VERSION}^g \
- -e s^@LINUXRELEASE@^${FULL_VERSION}^g \
- -e s^@RELEASE@^${FULL_VERSION//-/_}^g \
- < lustre.spec.in \
- > lustre.spec
- # convert the $LUSTRE_TESTS boolean to an empty/not-empty boolean
- # as silly as this seems, it makes the syntax of the rpmbuild command
- # simpler and not need an eval to deal with the quotes in the quotes
- # ditto for the lustre-tests boolean
- local lustre_tests=""
- if ! $LUSTRE_TESTS; then
- lustre_tests="no"
- fi
-
- $RPMBUILD --target ${TARGET_ARCH} -bb lustre.spec \
- --define "configure_args --with-linux=${PWD}/linux ${CONFIGURE_FLAGS}" \
- ${lustre_tests:+--define "build_lustre_tests 0"} \
- --define "_tmppath $TMPDIR" \
- --define "_topdir $(lbuild_topdir)" 2>&1 || \
- fatal 1 "Error building Lustre rpms."
- # $MAKE_J "$MAKE_CC" || fatal 1 "Error building Lustre."
- popd >/dev/null
-}
-
-install_kernel()
-{
- (( $INSTALL_KERNEL )) || return 0
- set_make
- pushd "$TOPDIR/linux" >/dev/null
- mkdir -p "$DESTDIR/boot"
-
- install -m 644 System.map "$DESTDIR/boot/System.map-${FULL_VERSION}"
- # install -m 644 module-info ...
- install -m 644 "$CONFIG_FILE" "$DESTDIR/boot/config-${FULL_VERSION}"
-
- mkdir -p "$DESTDIR/dev/shm"
- mkdir -p "$DESTDIR/lib/modules/${FULL_VERSION}"
-
- $MAKE "$MAKE_CC" INSTALL_MOD_PATH="$DESTDIR" KERNELRELEASE="$FULL_VERSION" \
- -s modules_install || \
- fatal 1 "Error installing modules."
-
- if $XEN; then
- cp vmlinuz "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
- cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}"
- ln -sf "../lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
- else
- case "$TARGET_ARCH" in
- i386 | i586 | i686 | athlon)
- cp arch/i386/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
- cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
- ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
- ;;
- x86_64)
- cp arch/x86_64/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
- cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
- ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
- ;;
- ppc | ppc64)
- cp vmlinux "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
- ln -sf "$DESTDIR/boot/vmlinux-${FULL_VERSION}" "../lib/modules/${FULL_VERSION}/vmlinux"
- ;;
- ia64)
- gzip -cfv vmlinux > vmlinuz
- mkdir -p "$DESTDIR/boot/efi/redhat"
- install -m 755 vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
- install -m 755 vmlinuz "$DESTDIR/boot/efi/redhat/vmlinuz-${FULL_VERSION}"
- ln -sf "../../../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/efi/redhat/vmlinux-${FULL_VERSION}"
- ln -sf "efi/redhat/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
- ln -sf "efi/redhat/vmlinuz-${FULL_VERSION}" "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
- ;;
- *)
- cp vmlinuz "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
- cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}"
- ln -sf "../lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
- ;;
- esac
- fi
- if [ -e init/kerntypes.o ] ; then
- cp init/kerntypes.o "$DESTDIR/boot/Kerntypes-${FULL_VERSION}"
- fi
-
- popd >/dev/null
-}
-
-cleanup_libmodules()
-{
- (( $INSTALL_LUSTRE )) || return 0
-
- KVERREL="${VERSION}${EXTRA_VERSION_DELIMITER}${EXTRA_VERSION}"
- i="$DESTDIR/lib/modules/${FULL_VERSION}"
-
- rm -f $i/build
- rm -f $i/source
-
- if (( $LINUX26 )) ; then
- ln -sf ../../../usr/src/linux-${KVERREL}-obj/${TARGET_ARCH}/${TARGET_CONFIG} $i/build
- ln -sf ../../../usr/src/linux-${KVERREL} $i/source
- else
- ln -sf ../../../usr/src/linux-${KVERREL} $i/build
- fi
-}
-
-install_lustre()
-{
- (( $INSTALL_LUSTRE )) || return 0
- return 0
- set_make
- pushd "$TOPDIR" >/dev/null
- $MAKE "$MAKE_CC" -s install "DESTDIR=$DESTDIR" KERNELRELEASE="$FULL_VERSION" || fatal 1 "Error installing Lustre."
- popd >/dev/null
-}
-
-build_kms()
-{
- (( $BUILD_KERNEL )) || return 0
- (( $SUSEBUILD )) || return 0
- set_make
- mkdir -p "${TOPDIR}/modules-${FULL_VERSION}"
- for dir in /usr/src/kernel-modules/* ; do
- # we are replacing lustre-lite, so don't include it
- if [ "${dir##*/}" != "lustre-lite" -a -e $dir/Makefile ]; then
- build_dir="${TOPDIR}/modules-${FULL_VERSION}/${dir##*/}"
- cp -a $dir $build_dir
- # these modules are terrible, and don't all build
- $MAKE_J "$MAKE_CC" -C $build_dir modules KERNEL_SOURCE="${TOPDIR}/linux"
- fi
- done
-}
-
-symver()
-{
- local file=$1 name=${1%.ko}
- nm $file \
- | sed -ne 's,^0*\([0-9a-f]\{8\}\) A __crc_\(.*\),0x\1\t\2\t'"$name"',p'
-}
-
-install_kms()
-{
- (( $INSTALL_KERNEL )) || return 0
- (( $LINUX26 )) || return 0
- set_make
- for build_dir in "${TOPDIR}/modules-${FULL_VERSION}/*" ; do
- [ -d $build_dir ] || continue
- # these modules are terrible, and don't all build
- $MAKE "$MAKE_CC" -C $build_dir KERNEL_SOURCE="${TOPDIR}/linux" INSTALL_MOD_PATH="$DESTDIR"
- done
- local symvers_file="${DESTDIR}/boot/symvers-${VERSION}${EXTRA_VERSION_DELIMITER}${EXTRA_VERSION}-${TARGET_ARCH}"
- if [ -n "$TARGET_CONFIG" ]; then
- symvers_file="${symvers_file}${TARGET_DELIMITER}${TARGET_CONFIG}"
- fi
- symvers_file="$symvers_file.gz"
- ( symver vmlinux
- moddir="${DESTDIR}/lib/modules/${FULL_VERSION}"
- cd $moddir/kernel
- for module in $(find * -name '*.ko'); do
- symver $module
- done
- cd $moddir
- for module in $(find * -path 'kernel/*' -prune -o \
- -name '*.ko' -print); do
- symver $module
- done
- ) | sort -u -k2 | gzip -c9 > $symvers_file
-}
-
-save_headers()
-{
- (( $SAVE_HEADERS )) || return 0
-
- echo "Saving headers for ${TARGET_CONFIG:-up} ${TARGET_ARCH}..."
- pushd linux >/dev/null
-
- KVERREL="${VERSION}${EXTRA_VERSION_DELIMITER}${EXTRA_VERSION}"
- # deal with the kernel headers that are version specific
-
- saveddir="$RPM_BUILD_ROOT/usr/src/linux-${KVERREL}/savedheaders/${TARGET_ARCH}/${TARGET_CONFIG:-up}"
- mkdir -p "$saveddir"
- install -m 644 include/linux/autoconf.h "$saveddir/autoconf.h"
- install -m 644 include/linux/version.h "$saveddir/version.h"
- mv include/linux/modules "$saveddir/"
- echo ${TARGET_ARCH} ${TARGET_CONFIG} ../../savedheaders/${TARGET_ARCH}/${TARGET_CONFIG:-up}/ \
- >> "$RPM_BUILD_ROOT/usr/src/linux-${KVERREL}/savedheaders/list"
- popd >/dev/null
-}
-
-save_all_headers()
-{
- (( $SAVE_HEADERS )) || return 0
-
- for arch in $BIGMEM_ARCHS ; do
- save_headers bigmem $arch
- done
-
- for arch in $BOOT_ARCHS ; do
- save_headers BOOT $arch
- done
-
- for arch in $JENSEN_ARCHS ; do
- save_headers jensen $arch
- done
-
- for arch in $SMP_ARCHS ; do
- save_headers smp $arch
- done
-
- for arch in $BIGSMP_ARCHS ; do
- save_headers bigsmp $arch
- done
- for arch in $PSERIES64_ARCHS ; do
- save_headers pseries64 $arch
- done
- for arch in $UP_ARCHS ; do
- save_headers up $arch
- done
-}
-
-longopts="build,build-lustre,build-kernel,depend-kernel,destdir:,extraversion:"
-longopts="$longopts,help,install,install-lustre,install-kernel,kerneldir:"
-longopts="$longopts,save-headers,target:,target-arch:,target-config:,unpack-kernel,xen"
-
-options=$(getopt -o hj: -l "$longopts" -- "$@")
-
-eval set -- "$options"
-
-while [ "$1" ] ; do
- case "$1" in
- '')
- usage 1
- ;;
- --build)
- BUILD_LUSTRE=1
- BUILD_KERNEL=1
- DEPEND_KERNEL=1
- UNPACK_KERNEL=1
- shift
- ;;
- --build-lustre)
- BUILD_LUSTRE=1
- shift
- ;;
- --build-kernel)
- BUILD_KERNEL=1
- DEPEND_KERNEL=1
- shift
- ;;
- --depend-kernel)
- DEPEND_KERNEL=1
- shift
- ;;
- --destdir)
- DESTDIR=$2
- shift 2
- ;;
- --extraversion)
- EXTRA_VERSION=$2
- shift 2
- ;;
- --help | -h)
- usage 0
- ;;
- --install)
- INSTALL_LUSTRE=1
- INSTALL_KERNEL=1
- shift
- ;;
- --install-lustre)
- INSTALL_LUSTRE=1
- shift
- ;;
- --install-kernel)
- INSTALL_KERNEL=1
- shift
- ;;
- -j)
- JOBS=$2
- shift 2
- ;;
- --kerneldir)
- KERNELDIR=$2
- shift 2
- ;;
- --save-headers)
- SAVE_HEADERS=1
- shift
- ;;
- --target)
- TARGET=$2
- shift 2
- ;;
- --target-arch)
- TARGET_ARCH=$2
- shift 2
- ;;
- --target-config)
- TARGET_CONFIG=$2
- shift 2
- ;;
- --unpack-kernel)
- UNPACK_KERNEL=1
- shift
- ;;
- --xen)
- XEN=true
- shift
- ;;
- --)
- shift
- # there are actually some lustre configure flags that we need to
- # handle ourselves (but we still give them to configure)
- if [[ \ $@\ == *\ --disable-tests\ * ]]; then
- LUSTRE_TESTS=false
- fi
- CONFIGURE_FLAGS=$@
- break
- ;;
- *)
- usage 1 "Unrecognized option: $1"
- ;;
- esac
-done
-
-check_options
-load_target
-EXTRA_VERSION_DELIMITER=${EXTRA_VERSION_DELIMITER:-"-"}
-FULL_VERSION="${VERSION}${EXTRA_VERSION_DELIMITER}${EXTRA_VERSION}"
-if [ -n "$TARGET_CONFIG" ]; then
- FULL_VERSION="${FULL_VERSION}${TARGET_DELIMITER}${TARGET_CONFIG}"
-fi
-setup_ccache_distcc
-
-extract_kernel
-patch_kernel
-
-depend_kernel
-build_kernel
-
-if [ -n "$OFED_VERSION" ]; then
- if [ "$OFED_VERSION" = "inkernel" ]; then
- CONFIGURE_FLAGS="--with-o2ib=yes ${CONFIGURE_FLAGS}"
- else
- build_kernel_ib
- fi
-fi
-
-configure_lustre
-build_lustre
-
-build_kms
-
-install_kernel
-install_lustre
-
-install_kms
-
-cleanup_libmodules
-
-save_headers
-
-exit 0
+++ /dev/null
-Summary: The Linux kernel (the core of the Linux operating system)
-
-# Versions of various parts
-
-#
-# Polite request for people who spin their own kernel rpms:
-# please modify the "release" field in a way that identifies
-# that the kernel isn't the stock RHL kernel, for example by
-# adding some text to the end of the version number.
-#
-%define kversion @KERNEL_VERSION@
-%define kextraver @KERNEL_EXTRA_VERSION@
-%define kextraverdelim @KERNEL_EXTRA_VERSION_DELIMITER@
-%define flavordelim "@KERNEL_TARGET_DELIMITER@"
-%define release @KERNEL_RELEASE@
-# /usr/src/%{kslnk} -> /usr/src/linux-%{KVERREL}
-%define kslnk linux-2.4
-%define kprovides %(bash -c "echo %{kversion}%{kextraverdelim}%{kextraver} | sed -e 's/-[^0-9]*smp$//'")
-
-# groups of related archs
-%define all_x86 i386 i686 i586 athlon
-#define all_x86 i686 i386 i586 athlon
-
-%define nptlarchs %{all_x86}
-#define nptlarchs noarch
-%define rhbuild @RHBUILD@
-%define susebuild @SUSEBUILD@
-%define linux26 @LINUX26@
-%define lmakeopts @LMAKEOPTS@
-
-# disable build root strip policy
-%define __spec_install_post /usr/lib/rpm/brp-compress || :
-#
-# RPM foo magic
-%define _missing_doc_files_terminate_build 0
-%define _unpackaged_files_terminate_build 0
-%define debug_package %{nil}
-
-# Enable this to build a board-specific kernel configuration
-# some architectures have LOTS of different setups and this
-# is a way to deal with that cleanly.
-#
-#define targetboard assabet
-%define dashtargetboard %{?targetboard:-%{targetboard}}
-%define withtargetboard 0
-%{?targetboard: %{expand: %%define withtargetboard 1}}
-
-# Override generic defaults with per-arch defaults (which can
-# themselves be overridden with --with/--without). These must
-# ONLY be "0", never "1"
-
-%define buildbase 0
-%define buildbigmem 0
-%define buildBOOT 0
-%define buildjensen 0
-%define buildsmp 0
-%define buildbigsmp 0
-%define buildpseries64 0
-%define buildup 0
-%define buildsrc 0
-
-%ifarch @BASE_ARCHS@
-%define buildbase 1
-%endif
-
-%ifarch @BIGMEM_ARCHS@
-%define buildbigmem 1
-%endif
-
-%ifarch @BOOT_ARCHS@
-%define buildBOOT 1
-%endif
-
-%ifarch @JENSEN_ARCHS@
-%define buildjensen 1
-%endif
-
-%ifarch @SMP_ARCHS@
-%define buildsmp 1
-%endif
-
-%ifarch @BIGSMP_ARCHS@
-%define buildbigsmp 1
-%endif
-
-%ifarch @PSERIES64_ARCHS@
-%define buildpseries64 1
-%endif
-
-%ifarch @UP_ARCHS@
-%define buildup 1
-%endif
-
-# For board-specific kernels, build only the normal kernel (which may actually be smp, not up).
-%if %{withtargetboard}
-%define buildsmp 0
-%define buildbigsmp 0
-%define buildBOOT 0
-%define buildbigmem 0
-%define buildpseries64 0
-%define buildjensen 0
-%endif
-
-%if 0
-Second, per-architecture exclusions (ifarch)
-%ifarch i386
-%define buildsmp 0
-%endif
-%ifarch ia64
-%define buildBOOT 0
-%endif
-%endif
-
-# we can't test values inline, only whether a macro exists
-%{expand: %%define buildup_%{buildup} yadda}
-%{expand: %%define buildsmp_%{buildsmp} yadda}
-%{expand: %%define buildbigsmp_%{buildbigsmp} yadda}
-%{expand: %%define buildpseries64_%{buildpseries64} yadda}
-%{expand: %%define buildBOOT_%{buildBOOT} yadda}
-%{expand: %%define buildbigmem_%{buildbigmem} yadda}
-%{expand: %%define buildjensen_%{buildjensen} yadda}
-%{expand: %%define ikd_%{ikd} yadda}
-%{expand: %%define ibcs_%{ibcs} yadda}
-%{expand: %%define debuglevel_%{debugging} yadda}
-
-%{expand: %%define kernel_conflicts ppp <= 2.3.15, pcmcia-cs <= 3.1.20, isdn4k-utils <= 3.0, mount < 2.10r-5, nfs-utils < 0.3.1, cipe < 1.4.5, tux < 2.1.0, kudzu <= 0.92, e2fsprogs < 1.22, initscripts < 5.84, dev < 3.2-7, iptables < 1.2.5-3, bcm5820 < 1.81, nvidia-rh72 <= 1.0, oprofile < 0.4}
-
-%if %{rhbuild}
-%define BOOT_kernel_prereq fileutils, modutils >= 2.4.18
-%define kernel_prereq %{BOOT_kernel_prereq}, initscripts >= 5.83, mkinitrd >= 3.2.6
-%endif
-
-%ifarch ia64
-%define initrd_dir /boot/efi/redhat
-%else
-%define initrd_dir /boot
-%endif
-
-%ifarch %{all_x86} x86_64
-%define kernel_glob vmlinu?-%{KVERREL}
-%endif
-%ifarch ia64
-# <sigh>, no GLOB_BRACE for filelists, efi needs to be done separately
-%define kernel_glob vmlinuz-%{KVERREL}
-%endif
-%ifarch alpha
-%define kernel_glob vmlinu?-%{KVERREL}
-%endif
-%ifarch ppc ppc64
-%define kernel_glob vmlinu?-%{KVERREL}
-%endif
-
-Name: kernel-lustre
-Version: %{kversion}
-Release: %{release}%{?targetboard:%{targetboard}}%{?debuglevel_1:.dbg}
-%define KVERREL %{PACKAGE_VERSION}%{kextraverdelim}%{kextraver}%{?targetboard:%{targetboard}}%{?debuglevel_1:.dbg}
-License: GPL
-Group: System Environment/Kernel
-ExclusiveArch: %{all_x86} x86_64 ia64 ppc ppc64
-ExclusiveOS: Linux
-Obsoletes: kernel-modules, kernel-sparc
-Provides: kernel = %{kprovides}
-BuildConflicts: rhbuildsys(DiscFree) < 500Mb
-%ifarch %{all_x86} ia64 x86_64
-Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
-%endif
-Autoreqprov: no
-%if %{rhbuild}
-Prereq: %{kernel_prereq}
-Conflicts: %{kernel_conflicts}
-
-BuildPreReq: patch >= 2.5.4, bash >= 2.03, sh-utils, gnupg, tar
-BuildPreReq: bzip2, findutils, dev, gzip, m4
-%endif
-
-Vendor: Sun Microsystems, Inc.
-URL: http://www.kernel.org/
-Buildroot: %{_tmppath}/%{name}-%{version}-root
-
-Source0: @LUSTRE_SOURCE@
-Source1: @KERNEL_SOURCE@
-Source2: external-patches.tar.gz
-
-Source15: linux-rhconfig.h
-Source16: linux-merge-config.awk
-Source17: linux-merge-modules.awk
-
-Source25: suse-functions.sh
-Source26: suse-post.sh
-Source27: suse-postun.sh
-Source28: suse-trigger-script.sh.in
-Source29: sles8-post.sh
-Source30: sles8-postun.sh
-Source31: sles8-pre.sh
-Source32: sles8-update_INITRD_MODULES.sh
-Source33: sles8-update_rcfile_setting.sh
-
-%package source
-Summary: The source code for the Linux kernel.
-Group: Development/System
-Prereq: fileutils
-Requires: gawk
-Requires: gcc >= 2.96-98
-Autoreqprov: 0
-
-%package doc
-Summary: Various documentation bits found in the kernel source.
-Group: Documentation
-
-%description
-The kernel package contains the Linux kernel (vmlinuz), the core of a
-Linux operating system. The kernel handles the basic functions of the
-operating system: memory allocation, process allocation, device input
-and output, etc.
-
-%description source
-The kernel-source package contains the source code files for the Linux
-kernel. These source files are needed to build custom/third party device
-drivers. The source files can also be used to build a custom kernel that is
-better tuned to your particular hardware, if you are so inclined (and you
-know what you're doing).
-
-%description doc
-This package contains documentation files form the kernel
-source. Various bits of information about the Linux kernel and the
-device drivers shipped with it are documented in these files.
-
-You'll want to install this package if you need a reference to the
-options that can be passed to Linux kernel modules at load time.
-
-%package smp
-Summary: The Linux kernel compiled for SMP machines.
-Group: System Environment/Kernel
-Provides: module-info, kernel = %{kprovides}
-%ifarch %{all_x86} ia64 x86_64
-Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
-%endif
-%if %{rhbuild}
-Prereq: %{kernel_prereq}
-Conflicts: %{kernel_conflicts}
-%endif
-
-%description smp
-This package includes a SMP version of the Linux kernel. It is
-required only on machines with two or more CPUs, although it should
-work fine on single-CPU boxes.
-
-Install the kernel-smp package if your machine uses two or more CPUs.
-
-%package bigsmp
-Summary: The Linux kernel compiled for SMP machines.
-Group: System/Kernel
-Provides: module-info, kernel = %{kprovides}, k_smp4G
-Obsoletes: k_smp4G
-%ifarch %{all_x86} ia64 x86_64
-Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
-%endif
-%if %{rhbuild}
-Prereq: %{kernel_prereq}
-Conflicts: %{kernel_conflicts}
-%endif
-
-%description bigsmp
-This package includes a SMP version of the Linux kernel. It is
-required only on machines with two or more CPUs, although it should
-work fine on single-CPU boxes.
-
-Install the kernel-bigsmp package if your machine uses two or more CPUs.
-
-%package pseries64
-Summary: Standard Kernel for 64-bit Power based SMP and LPAR Machines
-Group: System/Kernel
-Provides: module-info, kernel = %{kprovides}, k_smp4G
-%ifarch %{all_x86} ia64 x86_64
-Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
-%endif
-%if %{rhbuild}
-Prereq: %{kernel_prereq}
-Conflicts: %{kernel_conflicts}
-%endif
-
-%description pseries64
-The standard kernel for Power3, Power4 and PowerPC 970 64-bit SMP
-machines.
-
-This kernel can be used for all 64bit RS/6000, pSeries and JS20
-machines.
-
-%package bigmem
-Summary: The Linux Kernel for machines with more than 4 Gigabyte of memory.
-Group: System Environment/Kernel
-Provides: module-info, kernel = %{kprovides}
-%ifarch %{all_x86} ia64 x86_64
-Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
-%endif
-%if %{rhbuild}
-Prereq: %{kernel_prereq}
-Conflicts: %{kernel_conflicts}
-Obsoletes: kernel-enterprise <= 2.4.10
-%endif
-
-%description bigmem
-This package includes a kernel that has appropriate configuration options
-enabled for Pentium III machines with 4 Gigabyte of memory or more.
-
-%package BOOT
-Summary: The version of the Linux kernel used on installation boot disks.
-Group: System Environment/Kernel
-Provides: kernel = %{kprovides}
-%if %{rhbuild}
-Prereq: %{BOOT_kernel_prereq}
-Conflicts: %{kernel_conflicts}
-%endif
-
-%description BOOT
-This package includes a trimmed down version of the Linux kernel.
-This kernel is used on the installation boot disks only and should not
-be used for an installed system, as many features in this kernel are
-turned off because of the size constraints.
-
-%package BOOTsmp
-Summary: The Linux kernel used on installation boot disks for SMP machines.
-Group: System Environment/Kernel
-Provides: kernel = %{kprovides}
-%if %{rhbuild}
-Prereq: %{BOOT_kernel_prereq}
-Conflicts: %{kernel_conflicts}
-%endif
-
-%description BOOTsmp
-This package includes a trimmed down version of the Linux kernel. This
-kernel is used on the installation boot disks only and should not be used
-for an installed system, as many features in this kernel are turned off
-because of the size constraints. This kernel is used when booting SMP
-machines that have trouble coming up to life with the uniprocessor kernel.
-
-%package jensen
-Summary: The Linux Kernel compiled for the Alpha Jensen platform.
-Group: System Environment/Kernel
-Provides: kernel = %{kprovides}
-%if %{rhbuild}
-Prereq: %{kernel_prereq}
-Conflicts: %{kernel_conflicts}
-%endif
-
-%description jensen
-This package includes a kernel that has appropriate configuration
-options enabled for use on the Alpha Jensen platform. The Jensen
-platform is not supported in the normal generic alpha kernel support.
-
-%package -n lustre-lite-utils
-Summary: Lustre utils for Linux
-Group: Applications/System
-
-%description -n lustre-lite-utils
-The Lustre Lite file system utilities. This includes the tools needed
-to configure, mount, and administer a Lustre filesystem. This package
-is necessary if you want to access a Lustre filesystem.
-
-# the lustre-doc files are just included as %doc with
-# lustre-lite-utils
-
-#%package -n lustre-doc
-#Summary: Sample Lustre configurations and documentation
-#Group: Documentation
-
-#%description -n lustre-doc
-#The Lustre book, sample configurations, and other documentation for
-#Lustre.
-
-# This is required in rpm >= 4.4.? and _should_ be set by the %setup macro
-# but isn't, at least for 4.4.2. Yay RPM.
-%define buildsubdir lustre-kernel-%{version}
-%define _buildsubdir lustre-kernel-%{version}
-
-%prep
-%setup -n lustre-kernel-%{version} -q -c
-if [ ! -d lustre ] ; then
- ln -sf lustre* lustre
-fi
-pushd lustre >/dev/null
-if [ -s "%{SOURCE2}" ] ; then
- tar zxf "%{SOURCE2}" -C lustre/kernel_patches
-fi
-bash -x ./build/lmake \
- --unpack-kernel \
- --target @LUSTRE_TARGET@ \
- --target-arch %{_target_cpu} \
- --kerneldir $RPM_SOURCE_DIR %{lmakeopts}
-popd >/dev/null
-
-# handle both SuSE and Red Hat's new-kernel-pkg bits
-for flavor in "" smp bigmem bigsmp pseries64 BOOT jensen ; do
- [ -n "$flavor" ] && delim_flavor="%{flavordelim}$flavor"
- for when in pre preun post postun ; do
- script="${when}${flavor}.sh"
- cat %{SOURCE25} %{SOURCE32} %{SOURCE33} > ${script}
- echo "if [ -d /etc/susehelp.d ] ; then" >> ${script}
- sed -e "s/@when@/$when/g" -e "s^%ver_str^%{KVERREL}${delim_flavor}^g" %{SOURCE28} >> ${script}
- case $when in
- pre)
- echo "if [ ! -f /etc/modprobe.conf ] ; then" >> ${script}
- cat %{SOURCE31} >> ${script}
- echo "fi" >> ${script}
- ;;
- post)
- # /sbin/update-modules.dep compares when the modules were built, rather
- # than installed, so force modules.dep to be recreated
- echo "rm -f /lib/modules/%{KVERREL}${delim_flavor}/modules.dep" >> ${script}
- echo "if [ -f /etc/modprobe.conf ] ; then" >> ${script}
- sed -e "s^%ver_str^%{KVERREL}${delim_flavor}^g" -e "s^%flavor^${flavor}^" %{SOURCE26} >> ${script}
-
- echo "else" >> ${script}
- sed -e "s^%ver_str^%{KVERREL}${delim_flavor}^g" -e "s^%%{cfg_name}^${delim_flavor}^g" %{SOURCE29} >> ${script}
- echo "fi" >> ${script}
- ;;
- postun)
- echo "if [ -f /etc/modprobe.conf ] ; then" >> ${script}
- sed -e "s^%ver_str^%{KVERREL}${delim_flavor}^g" %{SOURCE27} >> ${script}
-
- echo "else" >> ${script}
- sed -e "s^%ver_str^%{KVERREL}${delim_flavor}^g" %{SOURCE30} >> ${script}
- echo "fi" >> ${script}
- ;;
- esac
- echo "exit 0; fi" >> ${script}
- case $when in
- post)
- if [ -z "${flavor}" ] ; then
- cat >> ${script} <<EOF
-cd /boot
-%ifnarch ia64
-ln -sf vmlinuz-%{KVERREL} vmlinuz
-%endif
-ln -sf System.map-%{KVERREL} System.map
-ln -sf module-info-%{KVERREL} module-info
-EOF
- fi
- cat >> ${script} <<EOF
-[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade
-[ -x /sbin/mkkerneldoth ] && /sbin/mkkerneldoth
-if [ -x /sbin/new-kernel-pkg ] ; then
- if /sbin/new-kernel-pkg 2>&1 | grep package >/dev/null ; then
- PACKAGE_ARG="--package kernel-${flavor}"
- fi
- /sbin/new-kernel-pkg $PACKAGE_ARG --mkinitrd --depmod \
- --install %{KVERREL}${delim_flavor}
-fi
-EOF
- ;;
- postun)
- ;;
- pre)
- cat >> ${script} <<EOF
-/sbin/modprobe loop 2>/dev/null >/dev/null || :
-exit 0
-EOF
- ;;
- preun)
- cat >> ${script} <<EOF
-/sbin/modprobe loop 2> /dev/null > /dev/null || :
-rm -f /lib/modules/%{KVERREL}${delim_flavor}/modules.*
-if [ -x /sbin/new-kernel-pkg ] ; then
- /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}${delim_flavor}
-fi
-EOF
- ;;
- esac
- done
-
- cat > "kernel$flavor.files" <<EOF
-%%defattr(-, root, root)
-/boot/%{kernel_glob}${delim_flavor}
-/boot/System.map-%{KVERREL}${delim_flavor}
-/boot/config-%{KVERREL}${delim_flavor}
-%%dir /lib/modules
-%%dir /dev/shm
-/lib/modules/%{KVERREL}${delim_flavor}
-%ifarch ia64
-/boot/efi/redhat/%{kernel_glob}${delim_flavor}
-%endif
-%if %{linux26}
-%if %{susebuild}
-/boot/Kerntypes-%{KVERREL}${delim_flavor}
-%endif
-/boot/symvers-%{KVERREL}-%{_target_cpu}${delim_flavor}.gz
-%endif
-EOF
-
-done
-
-cat > kernel-source.files <<EOF
-%%defattr(-,root,root)
-%%dir /usr/src/linux-%{KVERREL}
-/usr/src/linux-%{KVERREL}/*
-%if %{linux26}
-%%dir /usr/src/linux-%{KVERREL}-obj
-/usr/src/linux-%{KVERREL}-obj/*
-%endif
-EOF
-
-%build
-# if RPM_BUILD_NCPUS unset, set it
-if [ -z "$RPM_BUILD_NCPUS" ] ; then
- RPM_BUILD_NCPUS=$(egrep -c "^cpu[0-9]+" /proc/stat || :)
- if [ $RPM_BUILD_NCPUS -eq 0 ] ; then
- RPM_BUILD_NCPUS=1
- fi
- if [ $RPM_BUILD_NCPUS -gt 8 ] ; then
- RPM_BUILD_NCPUS=8
- fi
-fi
-
-rm -rf $RPM_BUILD_ROOT
-mkdir -p $RPM_BUILD_ROOT
-
-DependKernel()
-{
- target_config=${1:+--target-config $1}
- bash -x ./build/lmake \
- --depend-kernel \
- --target @LUSTRE_TARGET@ \
- --target-arch %{_target_cpu} \
- ${target_config} \
- --extraversion %{kextraver} \
- -j $RPM_BUILD_NCPUS %{lmakeopts}
-}
-
-BuildKernel()
-{
- target_config=${1:+--target-config $1}
- bash -x ./build/lmake \
- --build-kernel --build-lustre \
- --install \
- --save-headers \
- --target @LUSTRE_TARGET@ \
- --target-arch %{_target_cpu} \
- ${target_config} \
- --extraversion %{kextraver} \
- --kerneldir $RPM_SOURCE_DIR \
- -j $RPM_BUILD_NCPUS \
- --destdir $RPM_BUILD_ROOT %{lmakeopts} \
- -- --enable-tests \
- @CONFIGURE_FLAGS@
-}
-
-BuildLustre()
-{
- target_config=${1:+--target-config $1}
- bash -x ./build/lmake \
- --build-lustre \
- --install-lustre \
- --target @LUSTRE_TARGET@ \
- --target-arch %{_target_cpu} \
- ${target_config} \
- --extraversion %{kextraver} \
- --kerneldir $RPM_SOURCE_DIR \
- -j $RPM_BUILD_NCPUS \
- --destdir $RPM_BUILD_ROOT %{lmakeopts} \
- -- --enable-utils \
- --disable-doc --disable-tests \
- --disable-modules --disable-liblustre \
- --sysconfdir=%{_sysconfdir} \
- --mandir=%{_mandir} \
- @CONFIGURE_FLAGS@
-}
-
-SaveHeaders()
-{
- bash -x ./build/lmake \
- --save-headers \
- --target @LUSTRE_TARGET@ \
- --target-arch %{_target_cpu} \
- --extraversion %{kextraver} \
- --destdir $RPM_BUILD_ROOT %{lmakeopts}
-}
-
-pushd lustre >/dev/null
-
-%if %{buildbigmem}
-BuildKernel bigmem
-%endif
-
-%if %{buildBOOT}
-BuildKernel BOOT
-%endif
-
-%if %{buildjensen}
-BuildKernel jensen
-%endif
-
-%if %{buildsmp}
-BuildKernel smp
-%endif
-
-%if %{buildbigsmp}
-BuildKernel bigsmp
-%endif
-
-%if %{buildpseries64}
-BuildKernel pseries64
-%endif
-
-%if %{buildup}
-BuildKernel
-%endif
-
-%if %{buildbase}
-# BuildLustre
-%endif
-
-popd >/dev/null
-
-%install
-pushd lustre >/dev/null
-# it's already installed, so just clean up some things that are rpm
-# specific
-for i in $RPM_BUILD_ROOT/lib/modules/* ; do
- rm -f $i/modules.*
-%ifarch %{ntplarchs}
- # remove legacy pcmcia symlink that's no longer useful
- rm -rf $i/pcmcia
-%endif
-done
-
-# mark the vmlinux* non-executable to fool strip-to-file
-chmod a-x $RPM_BUILD_ROOT/boot/vmlinux*
-
-BuildObj ()
-{
- flavor=$1
- if [ $flavor = "up" ] ; then
- flavext=""
- flavtgt=""
- else
- flavext="%{flavordelim}$flavor"
- flavtgt="$flavor"
- fi
- perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = %{kextraverdelim}%{kextraver}${flavext}/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile
- c="$RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}"
- o="${c}-obj/%{_target_cpu}/$flavor"
- mkdir -p $o
- # use the one we just built
- #cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@-%{_target_cpu}%{dashtargetboard}${flavext}.config \
- cp .config $o/.config
- for oc in oldconfig_nonint silentoldconfig oldconfig ; do
- if grep -q "$oc" Makefile ; then
- OLDCONFIG="$oc"
- break
- fi
- done
- MAKE="make -s O=$o -C ${c}"
- if [ "$CC" ] ; then
- MAKE_CC="CC=$CC"
- fi
- $MAKE "$MAKE_CC" $OLDCONFIG
- $MAKE clean
- rm -rf $o/.config.old $o/include/config
- # Replace the Makefile in the object directory with a version
- # that has relative path names. This is done by fixing the Makefile
- # after the fact to work with 2.6.17 and newer mkmakefile.
- read VERSION PATCHLEVEL SUBLEVEL <<-EOF
-$(set -- 2.6.5 ; echo ${*//./ })
-EOF
- rm -f $o/Makefile
- ARCH=%{_target_cpu} /bin/bash scripts/mkmakefile ../../../linux-%{KVERREL} $o \
- $VERSION $PATCHLEVEL > $o/Makefile.in
- if [ -f $o/Makefile ] ; then
- # will exist only for 2.6.17 and newer because mkmakefile
- # now writes the makefile to $o instead of stdout
- mv -f $o/Makefile $o/Makefile.in
- fi
- sed -e "s^$o^../linux-%{KVERREL}-obj/%{_target_cpu}/$flavor^" \
- $o/Makefile.in > $o/Makefile
- zcat "$RPM_BUILD_ROOT/boot/symvers-%{KVERREL}-%{_target_cpu}${flavext}.gz" \
- > $o/Module.symvers
-}
-
-##
-## do -source package cleanup/install
-##
-if [ "%{buildbase}" -ne 0 ] ; then
- pushd linux >/dev/null
- mkdir -p $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
- rm -f drivers/net/hamradio/soundmodem/gentbl scripts/mkdep
- tar cf - . | tar xf - -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
- ln -sf linux-%{KVERREL} $RPM_BUILD_ROOT/usr/src/linux
- # install -m 644 %{SOURCE10} $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
-
- #clean up the destination
- make -s mrproper -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
- rm -rf $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs
- mkdir -p $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs
- cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@*.config $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs
- if [ "%{linux26}" -ne 0 ] ; then
- # this only works because Sun only builds one kernel per target/arch per kernel-source rpm
- objdir=$RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}-obj
- mkdir -p $objdir
- if [ "%{buildbigmem}" -ne 0 ] ; then
- BuildObj bigmem
- fi
- if [ "%{buildBOOT}" -ne 0 ] ; then
- BuildObj BOOT
- fi
- if [ "%{buildjensen}" -ne 0 ] ; then
- BuildObj jensen
- fi
- if [ "%{buildsmp}" -ne 0 ] ; then
- BuildObj smp
- fi
- if [ "%{buildbigsmp}" -ne 0 ] ; then
- BuildObj bigsmp
- fi
- if [ "%{buildpseries64}" -ne 0 ] ; then
- BuildObj pseries64
- fi
- if [ "%{buildup}" -ne 0 ] ; then
- BuildObj up
- fi
- perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = %{kextraverdelim}%{kextraver}%{flavordelim}custom/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile
- # Remove $RPM_BUILD_ROOT prefix from symlinks.
- for link in $(find $objdir -type l); do
- target=$(readlink $link)
- rm -f $link
- ln -s ${target/$RPM_BUILD_ROOT/} $link
- done
- else # 2.4 rh-style
- perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = %{kextraverdelim}%{kextraver}%{flavordelim}custom/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile
- # get the one from the build we just completed as it might have picked
- # up new options
- #cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@-%{_target_cpu}%{dashtargetboard}.config $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/.config
- cp .config $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/.config
- for oc in oldconfig_nonint silentoldconfig oldconfig ; do
- if grep -q "$oc" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile ; then
- OLDCONFIG="$oc"
- break
- fi
- done
- if [ "$CC" ] ; then
- MAKE_CC="CC=$CC"
- fi
- make "$MAKE_CC" -s $OLDCONFIG -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
- make "$MAKE_CC" -s symlinks -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
- make "$MAKE_CC" -s include/linux/version.h -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
-
- #this generates modversions info which we want to include and we may as
- #well include the depends stuff as well, after we fix the paths
- make -s depend -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
- find $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL} -name ".*depend" | \
- while read file ; do
- mv $file $file.old
- sed -e "s|[^ ]*\(/usr/src/linux\)|\1|g" < $file.old > $file
- rm -f $file.old
- done
-
- # Try to put some smarter autoconf.h and version.h files in place
- pushd $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/include/linux ; {
- rm -rf modules modversions.h autoconf.h version.h
- cat > modversions.h <<EOF
-#ifndef _LINUX_MODVERSIONS_H
-#define _LINUX_MODVERSIONS_H
-#include <linux/rhconfig.h>
-#include <linux/modsetver.h>
-EOF
- echo '#include <linux/rhconfig.h>' > autoconf.h
- list=`find ../../savedheaders/* -name '*.ver' -exec basename '{}' \; | sort`
- mkdir modules
- for l in $list; do
- sed 's,$,modules/'$l, ../../savedheaders/list | awk -f %{SOURCE17} > modules/$l
- touch -r modules/$l modules/`basename $l .ver`.stamp
- echo '#include <linux/modules/'$l'>' >> modversions.h
- done
- echo '#endif' >> modversions.h
- sed 's,$,autoconf.h,' ../../savedheaders/list | awk -f %{SOURCE16} >> autoconf.h
- install -m 644 %{SOURCE15} rhconfig.h
- echo "#include <linux/rhconfig.h>" >> version.h
- keyword=if
- for i in smp BOOT BOOTsmp bigmem bigsmp pseries64 up ; do
- # When we build in an i386, we don't have an bigmem header directory
- # in savedheaders/i386/bigmem. We also don't have a BOOT directory
- # anywhere except in savedheaders/i386. So, we need to use this method
- # of determining if a kernel version string needs to be included in the
- # version.h file
- verh=`echo ../../savedheaders/*/$i/version.h | awk ' { print $1 } '`
- if [ -n "$verh" -a -f "$verh" ]; then
- if [ "$i" = up ]; then
- if [ "$keyword" = if ]; then
- echo "#if 0" >> version.h
- fi
- echo "#else" >> version.h
- else
- echo "#$keyword defined(__module__$i)" >> version.h
- keyword=elif
- fi
- grep UTS_RELEASE $verh >> version.h
- fi
- done
- echo "#endif" >> version.h
- if [ -f ../../savedheaders/%{_target_cpu}/up/version.h ] ; then
- # keep to a standard normally
- HEADER_FILE=../../savedheaders/%{_target_cpu}/up/version.h
- else
- # test build not including uniprocessor, must get info from somewhere
- HEADER_FILE=$(ls ../../savedheaders/*/*/version.h | head -n 1)
- fi
- grep -v UTS_RELEASE $HEADER_FILE >> version.h
- rm -rf ../../savedheaders
- } ; popd
- touch $RPM_BUILD_ROOT/boot/kernel.h-%{kversion}
-
- # rm -f $RPM_BUILD_ROOT/usr/include/linux
-
- rm -rf $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/savedheaders
-
- if [ "%{rhbuild}" -ne 0 ] ; then
- # fix up the tmp_include_depends file wrt the buildroot
- perl -p -i -e "s|$RPM_BUILD_ROOT||g" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/tmp_include_depends
- fi
- fi # linux26
- popd >/dev/null
-fi # buildbase
-
-popd >/dev/null
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-###
-### scripts
-###
-
-# do this for upgrades...in case the old modules get removed we have
-# loopback in the kernel so that mkinitrd will work.
-%pre -f pre.sh
-
-%pre smp -f presmp.sh
-
-%pre bigsmp -f prebigsmp.sh
-
-%pre pseries64 -f prepseries64.sh
-
-%pre bigmem -f prebigmem.sh
-
-%post -f post.sh
-
-%post pseries64 -f postpseries64.sh
-
-%post smp -f postsmp.sh
-
-%post bigsmp -f postbigsmp.sh
-
-%post bigmem -f postbigmem.sh
-
-%post jensen -f postjensen.sh
-
-%ifnarch ia64
-%post BOOT -f postBOOT.sh
-
-%endif
-
-%post -n lustre-lite-utils
-if [ -f /etc/init.d/lustre ] ; then
- /sbin/chkconfig --add lustre
- /sbin/chkconfig --add lustrefs
-fi
-
-# Allow clean removal of modules directory
-%preun -f preun.sh
-
-%preun pseries64 -f preunpseries64.sh
-
-%preun smp -f preunsmp.sh
-
-%preun bigsmp -f preunbigsmp.sh
-
-%preun bigmem -f preunbigmem.sh
-
-%preun BOOT -f preunBOOT.sh
-
-%preun jensen -f preunjensen.sh
-
-# suse needs these i guess
-%postun -f postun.sh
-
-%postun pseries64 -f postunpseries64.sh
-
-%postun smp -f postunsmp.sh
-
-%postun bigsmp -f postunbigsmp.sh
-
-%postun bigmem -f postunbigmem.sh
-
-%postun BOOT -f postunBOOT.sh
-
-%postun jensen -f postunjensen.sh
-
-# We need this here because we don't prereq kudzu; it could be
-# installed after the kernel
-%triggerin -- kudzu
-[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
-
-%triggerin smp -- kudzu
-[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
-
-%triggerin bigsmp -- kudzu
-[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
-
-%triggerin pseries64 -- kudzu
-[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
-
-%triggerin bigmem -- kudzu
-[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
-
-%triggerin BOOT -- kudzu
-[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
-
-%triggerin jensen -- kudzu
-[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
-
-
-# Old kernel-headers packages owned include symlinks; new
-# ones just make them so that we can have multiple kernel-headers
-# packages installed.
-
-%triggerpostun source -- kernel-headers < 2.2.16
-cd /usr/src
-rm -f %{kslnk}
-ln -snf linux-%{KVERREL} %{kslnk}
-exit 0
-
-%post source
-cd /usr/src
-rm -f %{kslnk}
-ln -snf linux-%{KVERREL} %{kslnk}
-
-%postun source
-if [ -L /usr/src/%{kslnk} ]; then
- if [ -L /usr/src/%{kslnk} -a `ls -ld /usr/src/%{kslnk} 2>/dev/null| awk '{ print $11 }'` = "linux-%{KVERREL}" ]; then
- [ $1 = 0 ] && rm -f /usr/src/%{kslnk}
- fi
-fi
-exit 0
-
-%preun -n lustre-lite-utils
-if [ $1 = 0 -a -f /etc/init.d/lustre ]; then
- /sbin/chkconfig --del lustre
- /sbin/chkconfig --del lustrefs
-fi
-
-###
-### file lists
-###
-
-%if %{buildup}
-%files -f kernel.files
-%endif
-
-%if %{buildsmp}
-%files smp -f kernelsmp.files
-%endif
-
-%if %{buildbigsmp}
-%files bigsmp -f kernelbigsmp.files
-%endif
-
-%if %{buildpseries64}
-%files pseries64 -f kernelpseries64.files
-%endif
-
-%if %{buildbigmem}
-%files bigmem -f kernelbigmem.files
-%endif
-
-%if %{buildBOOT}
-%files BOOT -f kernelBOOT.files
-%endif
-
-%if %{buildbase}
-%files source -f kernel-source.files
-%endif