From 87a2010dd6dc319922325739995b4233518328db Mon Sep 17 00:00:00 2001 From: jacob Date: Thu, 2 Dec 2004 23:55:22 +0000 Subject: [PATCH] Fix lbuild building and 2.6 --- .cvsignore | 1 + build/.cvsignore | 1 + build/autoMakefile.am | 6 +- build/build.ac | 1 + build/lbuild | 528 +++++++++++++++++++++ build/linux-merge-config.awk | 317 +++++++++++++ build/linux-merge-modules.awk | 125 +++++ build/linux-rhconfig.h | 229 ++++++++++ build/lmake | 658 +++++++++++++++++++++++++++ build/lustre-kernel-2.4.spec.in | 983 ++++++++++++++++++++++++++++++++++++++++ build/lustre.spec.in | 235 ++++++++++ build/suse-functions.sh | 22 + build/suse-post.sh | 46 ++ build/suse-postun.sh | 43 ++ build/suse-trigger-script.sh.in | 9 + lustrecvs | 64 +-- 16 files changed, 3227 insertions(+), 41 deletions(-) create mode 100755 build/lbuild create mode 100644 build/linux-merge-config.awk create mode 100644 build/linux-merge-modules.awk create mode 100644 build/linux-rhconfig.h create mode 100755 build/lmake create mode 100644 build/lustre-kernel-2.4.spec.in create mode 100644 build/lustre.spec.in create mode 100644 build/suse-functions.sh create mode 100644 build/suse-post.sh create mode 100644 build/suse-postun.sh create mode 100644 build/suse-trigger-script.sh.in diff --git a/.cvsignore b/.cvsignore index bb3bc99..386b60d 100644 --- a/.cvsignore +++ b/.cvsignore @@ -30,3 +30,4 @@ install-sh .tmp_versions config.h config.h.in +stamp-h1 diff --git a/build/.cvsignore b/build/.cvsignore index 11e6d18..dfc9da2 100644 --- a/build/.cvsignore +++ b/build/.cvsignore @@ -6,3 +6,4 @@ Rules autoMakefile.in autoMakefile +lustre.spec diff --git a/build/autoMakefile.am b/build/autoMakefile.am index 97b8d07..2802978 100644 --- a/build/autoMakefile.am +++ b/build/autoMakefile.am @@ -1 +1,5 @@ -EXTRA_DIST := Makefile +EXTRA_DIST := Makefile lbuild linux-merge-config.awk \ + linux-merge-modules.awk linux-rhconfig.h lmake \ + lustre-kernel-2.4.spec.in lustre.spec lustre.spec \ + suse-functions.sh suse-post.sh suse-postun.sh \ + suse-trigger-script.sh.in diff --git a/build/build.ac b/build/build.ac index 1412ef1..f538e55 100644 --- a/build/build.ac +++ b/build/build.ac @@ -434,4 +434,5 @@ AC_SUBST(ENABLE_INIT_SCRIPTS) AC_CONFIG_FILES([ build/autoMakefile build/Rules +build/lustre.spec ]) diff --git a/build/lbuild b/build/lbuild new file mode 100755 index 0000000..846f1c1 --- /dev/null +++ b/build/lbuild @@ -0,0 +1,528 @@ +#!/bin/sh + +TOPDIR=$PWD + +# CVSROOT is inherited from the environment +KERNELDIR= +LUSTRE= +PUBLISH=0 +RELEASE=0 +DO_SRC=1 +TAG= +TARGET= +TARGET_ARCHS= +CONFIGURE_FLAGS= +EXTERNAL_PATCHES= +EXTRA_VERSION= + +# from target file +KERNEL= +SERIES= +CONFIG= +VERSION= + +RHBUILD=0 +SUSEBUILD=0 +LINUX26=0 +SUSEBUILD=0 + +BASE_ARCHS= +BIGMEM_ARCHS= +BOOT_ARCHS= +JENSEN_ARCHS= +SMP_ARCHS= +BIGSMP_ARCHS= +UP_ARCHS= + +DATE=$(date) + +USE_DATESTAMP=1 +RPMBUILD= + +cleanup() +{ + true +} + +error() +{ + [ "$1" ] && echo -e "\n${0##*/}: $1" +} + +fatal() +{ + cleanup + error "$2" + exit $1 +} + +publishing() +{ + (( $PUBLISH )) || return 0 +} + +is_release() +{ + (( $RELEASE )) || return 0 +} + +list_targets() +{ + echo -n "Available targets:" + for target in $TOPDIR/lustre/lustre/kernel_patches/targets/*.target ; do + target_file=${target##*/} + echo -n " ${target_file%%.target}" + done + echo +} + +usage() +{ + cat <] + + -d CVSROOT + Specifies the CVS Root to use when pulling files from CVS. The + environment variable \$CVSROOT is used if this option is not + present. + + --external-patches=EXTERNAL_PATCHES + Directory similar to lustre/lustre/kernel_patches/ that lbuild should + look for seres and config files in before looking in the lustre + tree. + + --extraversion=EXTRAVERSION + Text to use for the rpm release and kernel extraversion. + + --kerneldir=KERNELDIR + Directory containing Linux source tarballs referenced by target + files. + + --lustre=LUSTRE + Path to an existing lustre source tarball to use instead of + pulling from CVS. + + --nosrc + Do not build a .src.rpm, a full kernel patch, or a patched kernel + tarball. + + --publish + Publish the packages, patches, and tarballs on the ftp server. + + --release + Specifies that the files generated do not include timestamps, and + that this is an official release. + + --tag=TAG + A CVS branch/tag name to build from when pulling from CVS. + + --target=TARGET + The name of the target to build. The available targets are listed + below. + + --target-archs=TARGET_ARCHS + A (space delimited) list of architectures to build. By default, + all of the archs supported by the TARGET will be built, in + addition to a .src.rpm. This option can limit those, for machines + that can only build certain archs or if you only want a certain + arch built (for testing, or a one-off kernel). + + Also note that by using a non-"base" arch (eg, i386) only kernels + will be built - there will be no lustre-lite-utils package. + + --disable-datestamp + Prevents the datestamp flag (-D) from being passed to cvs for + checkouts. This is a workaround for a problem encountered when + using lbuild with tinderbox. + +EOF + +# list_targets + + fatal "$1" "$2" +} + +check_options() +{ + if [ "$LUSTRE" ] ; then + [ -r "$LUSTRE" ] || \ + usage 1 "Could not find Lustre source tarball '$LUSTRE'." + else + [ "$CVSROOT" ] || \ + usage 1 "Either specify a CVS Root with -d, or a Lustre source tarball with --lustre." + [ "$TAG" ] || \ + usage 1 "A branch/tag name must be specified with --tag when not building from a tarball." + fi + + [ "$KERNELDIR" ] || \ + usage 1 "A kernel directory must be specified with --kerneldir." + + [ -d "$KERNELDIR" ] || \ + usage 1 "$KERNELDIR is not a directory." + + if ! (( $RELEASE )) ; then + [ "$TAG" ] || \ + usage 1 "When building a snapshot, a tag name must be used." + fi + + TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M") + + [ "$TARGET" ] || usage 1 "A target must be specified with --target." +# TARGET_FILE="$TOPDIR/lustre/kernel_patches/targets/$TARGET.target" +# [ -r "$TARGET_FILE" ] || \ +# usage 1 "Target '$TARGET' was not found." + + 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 +} + +uniqify() +{ + echo $(echo "$*" | xargs -n 1 | sort -u) +} + +load_target() +{ + EXTRA_VERSION_save="$EXTRA_VERSION" + for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do + TARGET_FILE="$patchesdir/targets/$TARGET.target" + [ -r "$TARGET_FILE" ] && break + done + [ -r "$TARGET_FILE" ] || \ + fatal 1 "Target $TARGET was not found." + + echo "Loading target config file $TARGET.target..." + + . "$TARGET_FILE" + + [ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel." +# [ "$SERIES" ] || fatal 1 "Target $TARGET did not specify a kernel patch series." +# [ "$CONFIG" ] || fatal 1 "Target $TARGET did not specify a kernel config." + [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify a 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 + for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do + [ -r "$patchesdir/series/$series" ] && continue 2 + done + fatal 1 "Target $TARGET's series $SERIES could not be found.\nSearched:\n\t$EXTERNAL_PATCHES/series\n\t$TOPDIR/lustre/lustre/kernel_patches/series." + done + fi + + CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/$CONFIG" + [ -r "$CONFIG_FILE" ] || \ + fatal 1 "Target $TARGET's config file $CONFIG missing from $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/." + + if [ "$EXTRA_VERSION_save" ] ; then + EXTRA_VERSION="$EXTRA_VERSION_save" + elif ! (( $RELEASE )) ; then + EXTRA_VERSION="${EXTRA_VERSION}-${TAG}.${TIMESTAMP}" + fi + # EXTRA_VERSION=${EXTRA_VERSION//-/_} + + ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $BIGSMP_ARCHS $UP_ARCHS" + + BUILD_ARCHS= + for arch in $(uniqify "$ALL_ARCHS") ; do + if [ -z "$TARGET_ARCHS" ] || echo "$TARGET_ARCHS" | grep "$arch" >/dev/null 2>/dev/null ; then + BUILD_ARCHS="$BUILD_ARCHS $arch" + fi + done + [ "$BUILD_ARCHS" ] || usage 1 "No available target archs to build." + echo "Building for: $BUILD_ARCHS" +} + +tarflags() +{ + case "$1" in + '') + fatal 1 "tarflags(): File name argument missing." + ;; + *.tar.gz) + echo 'zxf' + ;; + *.tar.bz2) + echo 'jxf' + ;; + *) + fatal 1 "tarflags(): Unrecognized tar extension in file: $1" + ;; + esac +} + +untar() +{ + echo "Untarring ${1##*/}..." + tar $(tarflags "$1") "$1" +} + +unpack_lustre() +{ + DIRNAME="lustre-$TAG-$TIMESTAMP" + if [ "$LUSTRE" ] ; then + untar "$LUSTRE" + [ -d lustre ] || ln -sf lustre* lustre + else + if [ "$USE_DATESTAMP" ]; then + DATESTAMP="-D '$DATE'" + else + DATESTAMP="" + fi + + cvs -d "$CVSROOT" -qz3 co $DATESTAMP -r "$TAG" -d "$DIRNAME" lustre || \ + fatal 1 "There was an error checking out Lustre from CVS." + echo "Creating lustre tarball..." + tar zcf "$DIRNAME.tar.gz" "$DIRNAME" \ + --exclude "CVS" --exclude "*~" --exclude ".cvsignore" || \ + fatal 1 "Could not create Lustre tarball." + LUSTRE="$PWD/$DIRNAME.tar.gz" + ln -sf "$DIRNAME" lustre + fi +} + +unpack_linux() +{ + untar "$KERNEL_FILE" + [ -d linux ] || ln -sf linux* linux +} + +patch_linux() +{ + [ "$SERIES" ] || return 0 + FULL_PATCH="$PWD/lustre-kernel-${TARGET}-${EXTRA_VERSION}.patch" + [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH" + pushd linux >/dev/null + for series in $SERIES ; do + echo -n "Applying series $series:" + for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do + [ -r "$patchesdir/series/$series" ] || continue + SERIES_FILE="$patchesdir/series/$series" + for patch in $(<"$SERIES_FILE") ; do + echo -n " $patch" + PATCH_FILE="$patchesdir/patches/$patch" + [ -r "$PATCH_FILE" ] || \ + fatal 1 "Patch $patch does not exist in Lustre tree." + cat "$PATCH_FILE" >> "$FULL_PATCH" || \ + fatal 1 "Error adding patch $patch to full patch." + patch -s -p1 < "$PATCH_FILE" || fatal 1 "Error applying patch $patch." + done + break + done + echo + done + popd >/dev/null + echo "Full patch has been saved in ${FULL_PATCH##*/}." + echo "Replacing .config files..." + [ -d linux/configs ] || mkdir linux/configs || \ + fatal 1 "Error creating configs directory." + rm -f linux/configs/* + copysuccess=0 + for patchesdir in "$EXTERNAL_PATCHES" "lustre/lustre/kernel_patches" ; do + cp -v $patchesdir/kernel_configs/kernel-${VERSION}-${TARGET}*.config linux/configs/ >/dev/null && copysuccess=1 + done + [ "$copysuccess" = "1" ] || \ + fatal 1 "Error copying in kernel configs." +} + +pack_linux() +{ + TARBALL="$(readlink linux)-$EXTRA_VERSION.tar.gz" + echo "Creating patched linux tarball $TARBALL..." + tar zcf "$TARBALL" "$(readlink linux)" \ + --exclude "CVS" --exclude ".cvsignore" || \ + --exclude "*.orig" --exclude "*~" --exclude "*.rej" || \ + fatal 1 "Error creating patched Linux tarball." +} + +clean_linux() +{ + [ -d linux ] || return 0 + echo "Cleaning linux..." + [ -L linux ] && rm -rf $(readlink linux) + rm -rf linux +} + +prep_build() +{ + # make .spec file + if [ -f /etc/init.d/functions -a -f /etc/sysconfig/network ] ; then + ENABLE_INIT_SCRIPTS="" + else + ENABLE_INIT_SCRIPTS="# " + fi + sed \ + -e "s^@BASE_ARCHS@^$BASE_ARCHS^g" \ + -e "s^@BIGMEM_ARCHS@^$BIGMEM_ARCHS^g" \ + -e "s^@BIGSMP_ARCHS@^$BIGSMP_ARCHS^g" \ + -e "s^@BOOT_ARCHS@^$BOOT_ARCHS^g" \ + -e "s^@CONFIGURE_FLAGS@^$CONFIGURE_FLAGS^g" \ + -e "s^@ENABLE_INIT_SCRIPTS@^$ENABLE_INIT_SCRIPTS^g" \ + -e "s^@JENSEN_ARCHS@^$BOOT_ARCHS^g" \ + -e "s^@KERNEL_EXTRA_VERSION@^$EXTRA_VERSION^g" \ + -e "s^@KERNEL_RELEASE@^${EXTRA_VERSION//-/_}^g" \ + -e "s^@KERNEL_SOURCE@^$KERNEL^g" \ + -e "s^@KERNEL_VERSION@^$VERSION^g" \ + -e "s^@LINUX26@^$LINUX26^g" \ + -e "s^@LUSTRE_SOURCE@^${LUSTRE##*/}^g" \ + -e "s^@LUSTRE_TARGET@^$TARGET^g" \ + -e "s^@RHBUILD@^$RHBUILD^g" \ + -e "s^@SMP_ARCHS@^$SMP_ARCHS^g" \ + -e "s^@SUSEBUILD@^$SUSEBUILD^g" \ + -e "s^@SUSEBUILD@^$SUSEBUILD^g" \ + -e "s^@UP_ARCHS@^$UP_ARCHS^g" \ + < $TOPDIR/lustre/build/lustre-kernel-2.4.spec.in \ + > lustre-kernel-2.4.spec + [ -d SRPMS ] || mkdir SRPMS + [ -d RPMS ] || mkdir RPMS + [ -d BUILD ] || mkdir BUILD + [ -d SOURCES ] || mkdir SOURCES + for script in linux-{rhconfig.h,merge-config.awk,merge-modules.awk} \ + suse-{functions.sh,post.sh,postun.sh,trigger-script.sh.in} ; do + cp $TOPDIR/lustre/build/$script SOURCES + done + cp "$LUSTRE" "$KERNEL_FILE" SOURCES + if [ "$EXTERNAL_PATCHES" -a -d "$EXTERNAL_PATCHES" ] ; then + tar zcf SOURCES/external-patches.tar.gz -C "$EXTERNAL_PATCHES" series targets patches kernel_configs + else + touch SOURCES/external-patches.tar.gz + fi +} + +clean_lustre() +{ + [ -d lustre ] || return 0 + echo "Cleaning lustre..." + [ -L lustre ] && rm -rf $(readlink lustre) + rm -rf lustre +} + +build() +{ + echo "Building rpms for: $BUILD_ARCHS..." + targets= + for arch in $BUILD_ARCHS ; do + targets="--target $arch $targets" + done + + $RPMBUILD $targets -bb lustre-kernel-2.4.spec \ + --define "_topdir $TOPDIR" || \ + fatal 1 "Error building rpms for $arch." + + if (( $DO_SRC )) ; then + $RPMBUILD -bs lustre-kernel-2.4.spec \ + --define "_topdir $TOPDIR" || \ + fatal 1 "Error building .src.rpm." + fi +} + +publish() +{ + publishing || return 0 +} + +[ -r ~/.lbuildrc ] && . ~/.lbuildrc + +options=$(getopt -o d:D:h -l external-patches:,extraversion:,kerneldir:,lustre:,nosrc,publish,release,tag:,target:,target-archs:,disable-datestamp -- "$@") + +eval set -- "$options" + +while [ "$1" ] ; do + case "$1" in + '') + usage 1 + ;; + -d) + CVSROOT=$2 + shift 2 + ;; + -D) + DATE=$2 + shift 2 + ;; + --external-patches) + EXTERNAL_PATCHES=$2 + shift 2 + ;; + --extraversion) + EXTRA_VERSION=$2 + shift 2 + ;; + --help | -h) + usage 0 + ;; + --kerneldir) + KERNELDIR=$2 + shift 2 + ;; + --lustre) + LUSTRE=$2 + shift 2 + ;; + --nosrc) + DO_SRC=0 + shift 1 + ;; + --publish) + PUBLISH=1 + shift + ;; + --release) + RELEASE=1 + shift + ;; + --tag) + TAG=$2 + shift 2 + ;; + --target) + TARGET=$2 + shift 2 + ;; + --target-archs) + TARGET_ARCHS=$2 + shift 2 + ;; + --disable-datestamp) + USE_DATESTAMP= + shift + ;; + --) + shift + CONFIGURE_FLAGS=$@ + break + ;; + *) + usage 1 "Unrecognized option: $1" + ;; + esac +done + +check_options + +unpack_lustre +load_target + +if (( $DO_SRC )) ; then + unpack_linux + patch_linux + pack_linux + clean_linux +fi + +# prep_build needs the .spec.in from the lustre source +prep_build +clean_lustre + +build +publish diff --git a/build/linux-merge-config.awk b/build/linux-merge-config.awk new file mode 100644 index 0000000..9a9338c --- /dev/null +++ b/build/linux-merge-config.awk @@ -0,0 +1,317 @@ +#!/bin/awk -f +BEGIN { + nsects = 0 +} +{ + ARCH = $1 + ARCHES[ARCH] = 1 + TYPE = $2 + TYPES[TYPE] = 1 + NTOTAL++ + ARCHTYPES[ARCH ":" TYPE] = 1 + NARCHES[TYPE]++ + if (NARCHES[TYPE] == 1) + NTOTALTYPES++ + NTYPES[ARCH]++ + if (NTYPES[ARCH] == 1) + NTOTALARCHES++ + FILE = $3 + cursects = nsects + while ((getline < FILE) > 0) { + if ($0 ~ /^\/\*/ || $0 ~ /^ \*\// || $0 ~ /^[ ]*$/) + continue + if ($0 ~ /^ * /) { + SECTION = gensub(/^ \* /,"",$0) + if (!(SECTION in sectno)) { + sectno[SECTION] = nsects + counts[SECTION] = 0 + nsects++ + } else if (cursects && cursects != nsects) { + no = sectno[SECTION] + diff = nsects - cursects + for (s in sectno) { + if (sectno[s] >= cursects) + sectno[s] = sectno[s] - cursects + no + else if (sectno[s] >= no) + sectno[s] += diff + } + } + cursects = nsect + cursym[SECTION] = counts[SECTION] + continue + } + if ($1 != "#define" && $1 != "#undef") + exit 1 + SYMBOL = $2 + n = index($0,SYMBOL)+length(SYMBOL) + if ($1 == "#define") { + n = index($0,SYMBOL)+length(SYMBOL) + VALUE = gensub(/^[ ]*/,"","",substr($0,n)) + if (VALUE == "") VALUE = "__novalue__" + } else + VALUE = "__undefined__" + if (values[SYMBOL]) { + if (present[SYMBOL,ARCH,TYPE]) continue + present[SYMBOL,ARCH,TYPE] = 1 + values[SYMBOL] = values[SYMBOL] SUBSEP ARCH ":" TYPE ":" VALUE + if (SECTION == sections[SYMBOL] && cursym[SECTION] && cursym[SECTION] != counts[SECTION]) { + no = pos[SYMBOL] + diff = counts[SECTION]-cursym[SECTION] + for (s in pos) + if (sections[s] == SECTION) { + if (pos[s] >= cursym[SECTION]) + pos[s] = pos[s] - cursym[SECTION] + no + else if (pos[s] >= no) + pos[s] += diff + } + cursym[SECTION] = counts[SECTION] + } + } else { + present[SYMBOL,ARCH,TYPE] = 1 + values[SYMBOL] = ARCH ":" TYPE ":" VALUE + sections[SYMBOL] = SECTION + pos[SYMBOL] = counts[SECTION] + counts[SECTION]++ + } + } + close(FILE) +} +END { + for (SECTION in sectno) + x[sectno[SECTION]] = SECTION + for (i = 0; i < nsects; i++) { + SECTION = x[i] + if (i > 0) + printf "\n" + printf "/*\n * %s\n */\n", SECTION + split("",lines) + lastelse = "" + for (SYMBOL in sections) + if (sections[SYMBOL] == SECTION) + y[pos[SYMBOL]] = SYMBOL + for (j = 0; j < counts[SECTION]; j++) { + SYMBOL = y[j] + split("",ntype) + split("",total) + split(values[SYMBOL],z,SUBSEP) + split("",val) + totalsum = 0 + for (k in z) { + split(z[k],l,":") + ARCH = l[1] + TYPE = l[2] + VALUE = substr(z[k],length(ARCH)+length(TYPE)+3) + if (val[VALUE]) + val[VALUE] = val[VALUE] " " + val[VALUE] = val[VALUE] ARCH ":" TYPE + ntype[VALUE,TYPE] += 1 + total[VALUE] += 1 + totalsum += 1 + } + split("",curlines) + append = 1 + for (VALUE in val) { + if (total[VALUE] == NTOTAL) { + if (VALUE == "__undefined__") + curlines["1"] = "#undef " SYMBOL "\n" + else if (VALUE == "__novalue__") + curlines["1"] = "#define " SYMBOL "\n" + else + curlines["1"] = "#define " SYMBOL " " VALUE "\n" + if (!lines["1"]) + append = 0 + break + } + shorteststr = "" + curcount = 0 + for (m = 0; m < 4; m++) { + str = "" + split(val[VALUE],yy) + if (total[VALUE] > 1 && total[VALUE] == NTOTAL - 1) { + found = 0 + for (arch in ARCHES) { + for (type in TYPES) { + archtype = arch ":" type + if (ARCHTYPES [archtype] == 1) { + for (n in yy) + if (yy[n] == archtype) + break + if (yy[n] != archtype) { + found = 1 + break + } + } + } + if (found) + break + } + if (NARCHES[type] > 1 && NTYPES[arch] > 1) { + str = "!defined(__module__" arch "_" type ")" + shorteststr = str + break + } + } + if (m == 0 || m == 2) { + nfull = 0 + split("",yysave) + for (type in TYPES) + if (ntype[VALUE,type] == NARCHES[type]) { + if (str) str = str " || " + str = str "defined(__module__" type ")" + for (k in yy) { + split(yy[k], z, ":") + if (z[2] == type) { + yysave[k] = yy[k] + delete yy[k] + } + } + nfull++ + } else + NOTYPE = type + if (m < 2 && nfull > 1 && nfull == NTOTALTYPES - 1) { + str = "!defined(__module__" NOTYPE ")" + for (k in yysave) + yy[k] = yysave[k] + for (k in yy) { + split(yy[k], z, ":") + if (z[2] != NOTYPE) + delete yy[k] + } + } + } + savestr = str + nfull = 0 + split("",yysave) + for (arch in ARCHES) { + narch = 0 + for (k in yy) { + split(yy[k], z, ":") + if (z[1] == arch) + narch++ + } + if (narch == NTYPES[arch]) { + if (str) str = str " || " + str = str "defined(__module__" arch ")" + for (k in yy) { + split(yy[k], z, ":") + if (z[1] == arch) { + yysave[k] = yy[k] + delete yy[k] + } + } + nfull++ + } else + NOARCH = arch + } + if (m < 2 && nfull > 1 && nfull == NTOTALARCHES - 1) { + str = savestr + for (k in yysave) + yy[k] = yysave[k] + if (str) str = str " || " + str = str "!defined(__module__" NOARCH ")" + for (k in yy) { + split(yy[k], z, ":") + if (z[1] != NOARCH) + delete yy[k] + } + } + if (m == 1 || m == 3) { + savestr = str + nfull = 0 + split("",yysave) + for (type in TYPES) { + ntypex = 0 + for (k in yy) { + split(yy[k], z, ":") + if (z[2] == type) + ntypex++ + } + if (ntypex == NARCHES[type]) { + if (str) str = str " || " + str = str "defined(__module__" type ")" + for (k in yy) { + split(yy[k], z, ":") + if (z[2] == type) { + yysave[k] = yy[k] + delete yy[k] + } + } + nfull++ + } else + NOTYPE = type + } + if (m < 2 && nfull > 1 && nfull == NTOTALTYPES - 1) { + str = savestr + for (k in yysave) + yy[k] = yysave[k] + if (str) str = str " || " + str = "!defined(__module__" NOTYPE ")" + for (k in yy) { + split(yy[k], z, ":") + if (z[2] != NOTYPE) + delete yy[k] + } + } + } + for (k in yy) { + split(yy[k], z, ":") + if (str) str = str " || " + str = str "defined(__module__" z[1] "_" z[2] ")" + } + if (m == 0 || length(str) < length(shorteststr)) + shorteststr = str + } + str = shorteststr + if (VALUE == "__undefined__") + curlines[str] = "#undef " SYMBOL "\n" + else if (VALUE == "__novalue__") + curlines[str] = "#define " SYMBOL "\n" + else + curlines[str] = "#define " SYMBOL " " VALUE "\n" + if (!lines[str]) + append = 0 + } + if (append) { + for (str in curlines) + if (curlines[str]) + lines[str] = lines[str] curlines[str] + } else { + if (lines["1"]) + printf "%s", lines["1"] + else if (j > 0) { + ifstr = "#if " + for (str in lines) + if (lines[str] && str != lastelse) { + printf "%s %s\n%s", ifstr, str, lines[str] + ifstr = "#elif " + } + if (lastelse != "") + printf "#else\n%s", lines[lastelse] + printf "#endif\n" + } + split("",lines) + lastelse = "" + for (str in curlines) + if (curlines[str]) { + lines[str] = curlines[str] + if (totalsum == NTOTAL && length(str) > length(lastelse)) { + lastelse = str + } + } + } + } + if (lines["1"]) + printf "%s", lines["1"] + else if (j > 0) { + ifstr = "#if " + for (str in lines) + if (lines[str] && str != lastelse) { + printf "%s %s\n%s", ifstr, str, lines[str] + ifstr = "#elif " + } + if (lastelse != "") + printf "#else\n%s", lines[lastelse] + printf "#endif\n" + } + } +} diff --git a/build/linux-merge-modules.awk b/build/linux-merge-modules.awk new file mode 100644 index 0000000..babc815 --- /dev/null +++ b/build/linux-merge-modules.awk @@ -0,0 +1,125 @@ +#!/bin/awk -f +{ + # lines in input look like ARCH TYPE path/to/TYPE/ARCH/modules/foo.ver + ARCH=$1 + ARCHES[ARCH]=1 + TYPE=$2 + TYPES[TYPE]=1 + NTOTAL++ + NARCHES[TYPE]++ + NTYPES[ARCH]++ + FILE=$3 + + # read files that look like pairs of repeating + # #define __ver_foo hexstring + # #define foo _set_ver(foo) + while ((getline < FILE) > 0) { + if ($0 ~ /^[ ]*$/) + continue + if ($1 != "#define" || $2 !~ /^__ver_/) + exit 1 + + # this is a "#define __ver_foo somehex" line + SYMBOL=gensub(/^__ver_/,"","",$2) + VALUE=gensub(/^(smp_|2gig_|smp2gig_)/,"","",$3) + VALUE=gensub(/^(smp|2gig|smp2gig)/,"","",VALUE) + values[SYMBOL,ARCH,TYPE]=VALUE + + # skip the "#define foo _set_ver(foo)" line + if ((getline < FILE) <= 0) + exit 2 + if ($1 != "#define" || $2 != SYMBOL || $3 != "_set_ver(" SYMBOL ")") + exit 3 + } + close(FILE) +} +END { + count=0 + for (key in values) + if (values[key]) { + count++ + split(key,x,SUBSEP) + SYMBOL=x[1] + ARCH=x[2] + TYPE=x[3] + + # (re)initialize a few arrays to have no elements + split("",x) + split("",ntype) + split("",total) + + totalsum=0 + for (arch in ARCHES) + for (type in TYPES) + if (values[SYMBOL,arch,type]) { + VALUE = values[SYMBOL,arch,type] + values[SYMBOL,arch,type] = "" + ntype[VALUE,type] += 1 + total[VALUE] += 1 + if (x[VALUE]) + x[VALUE] = x[VALUE] " " + x[VALUE] = x[VALUE] arch ":" type + } + ifstr="#if " + for (VALUE in x) { + if (total[VALUE] == NTOTAL) { + # there is only one checksum for this symbol + printf "#define __ver_%s\t_ver_str(%s)\n", SYMBOL, VALUE + printf "#define %s _set_ver(%s)\n", SYMBOL, SYMBOL + break + } + + totalsum += total[VALUE] + if (totalsum == NTOTAL && ifstr == "#elif") { + # this is the last unique checksum for this symbol + printf "#else\n#define __ver_%s\t_ver_str(%s)\n", SYMBOL, VALUE + printf "#define %s _set_ver(%s)\n", SYMBOL, SYMBOL + break + } + + # there must be more than one checksum still to + # print for this symbol + str="" + split(x[VALUE],y) + for (type in TYPES) + if (ntype[VALUE,type] == NARCHES[type]) { + if (str) str = str " || " + str = str "defined(__module__" type ")" + for (k in y) { + split(y[k], z, ":") + if (z[2] == type) + delete y[k] + } + } + for (arch in ARCHES) { + narch=0 + for (k in y) { + split(y[k], z, ":") + if (z[1] == arch) + narch++ + } + if (narch == NTYPES[arch]) { + if (str) str = str " || " + str = str "defined(__module__" arch ")" + for (k in y) { + split(y[k], z, ":") + if (z[1] == arch) + delete y[k] + } + } + } + for (k in y) { + split(y[k], z, ":") + if (str) str = str " || " + str = str "defined(__module__" z[1] "_" z[2] ")" + } + printf "%s %s\n#define __ver_%s\t_ver_str(%s)\n", ifstr, str, SYMBOL, VALUE + printf "#define %s _set_ver(%s)\n", SYMBOL, SYMBOL + ifstr="#elif " + } + if (ifstr == "#elif ") + printf "#endif\n" + } + if (!count) + printf "\n" +} diff --git a/build/linux-rhconfig.h b/build/linux-rhconfig.h new file mode 100644 index 0000000..a7aa424 --- /dev/null +++ b/build/linux-rhconfig.h @@ -0,0 +1,229 @@ +/* + * Try to be a little smarter about which kernel are we currently running + */ + +#ifndef __rh_config_h__ +#define __rh_config_h__ + +/* + * First, get the version string for the running kernel from + * /boot/kernel.h - initscripts should create it for us + */ + +#include "/boot/kernel.h" + +#if defined(__BOOT_KERNEL_SMP) && (__BOOT_KERNEL_SMP == 1) +#define __module__smp +#endif /* __BOOT_KERNEL_SMP */ + +#if defined(__BOOT_KERNEL_BOOT) && (__BOOT_KERNEL_BOOT == 1) +#define __module__BOOT +#endif /* __BOOT_KERNEL_BOOT */ + +#if defined(__BOOT_KERNEL_BOOTSMP) && (__BOOT_KERNEL_BOOTSMP == 1) +#define __module__BOOTsmp +#endif /* __BOOT_KERNEL_BOOTSMP */ + +#if defined(__BOOT_KERNEL_ENTERPRISE) && (__BOOT_KERNEL_ENTERPRISE == 1) +#define __module__enterprise +#endif /* __BOOT_KERNEL_ENTERPRISE */ + +#if defined(__BOOT_KERNEL_BIGMEM) && (__BOOT_KERNEL_BIGMEM == 1) +#define __module__bigmem +#endif /* __BOOT_KERNEL_BIGMEM */ + +#if defined(__BOOT_KERNEL_DEBUG) && (__BOOT_KERNEL_DEBUG == 1) +#define __module__debug +#endif /* __BOOT_KERNEL_DEBUG */ + +#if !defined(__module__smp) && !defined(__module__BOOT) && !defined(__module__BOOTsmp) && !defined(__module__enterprise) && !defined(__module__bigmem) && !defined(__module__debug) +#define __module__up +#endif /* default (BOOT_KERNEL_UP) */ + +#ifdef __i386__ +# if defined(__MODULE_KERNEL_i586) && (__MODULE_KERNEL_i586 == 1) +# define __module__i586 +# ifdef __module__up +# define __module__i586_up +# endif +# ifdef __module__smp +# define __module__i586_smp +# endif +# ifdef __module__BOOT +# define __module__i586_BOOT +# endif +# ifdef __module__BOOTsmp +# define __module__i586_BOOTsmp +# endif +# ifdef __module__enterprise +# define __module__i586_enterprise +# endif +# ifdef __module__debug +# define __module_i586_debug +# endif +# elif defined(__MODULE_KERNEL_i686) && (__MODULE_KERNEL_i686 == 1) +# define __module__i686 +# ifdef __module__up +# define __module__i686_up +# endif +# ifdef __module__smp +# define __module__i686_smp +# endif +# ifdef __module__BOOT +# define __module__i686_BOOT +# endif +# ifdef __module__BOOTsmp +# define __module__i686_BOOTsmp +# endif +# ifdef __module__enterprise +# define __module__i686_enterprise +# endif +# ifdef __module__bigmem +# define __module__i686_bigmem +# endif +# ifdef __module__debug +# define __module_i686_debug +# endif +# elif defined(__MODULE_KERNEL_athlon) && (__MODULE_KERNEL_athlon == 1) +# define __module__athlon +# ifdef __module__up +# define __module__athlon_up +# endif +# ifdef __module__smp +# define __module__athlon_smp +# endif +# ifdef __module__BOOT +# define __module__athlon_BOOT +# endif +# ifdef __module__BOOTsmp +# define __module__athlon_BOOTsmp +# endif +# ifdef __module__enterprise +# define __module__athlon_enterprise +# endif +# ifdef __module__bigmem +# define __module__athlon_bigmem +# endif +# ifdef __module__debug +# define __module__athlon_debug +# endif +# else +# define __module__i386 +# ifdef __module__up +# define __module__i386_up +# endif +# ifdef __module__smp +# define __module__i386_smp +# endif +# ifdef __module__BOOT +# define __module__i386_BOOT +# endif +# ifdef __module__BOOTsmp +# define __module__i386_BOOTsmp +# endif +# ifdef __module__enterprise +# define __module__i386_enterprise +# endif +# ifdef __module__debug +# define __module__i386_debug +# endif +# endif +#endif + +#ifdef __sparc__ +# ifdef __arch64__ +# define __module__sparc64 +# ifdef __module__up +# define __module__sparc64_up +# endif +# ifdef __module__smp +# define __module__sparc64_smp +# endif +# ifdef __module__BOOT +# define __module__sparc64_BOOT +# endif +# ifdef __module__BOOTsmp +# define __module__sparc64_BOOTsmp +# endif +# ifdef __module__enterprise +# define __module__sparc64_enterprise +# endif +# ifdef __module__debug +# define __module__sparc64_debug +# endif +# else +# define __module__sparc +# ifdef __module__up +# define __module__sparc_up +# endif +# ifdef __module__smp +# define __module__sparc_smp +# endif +# ifdef __module__BOOT +# define __module__sparc_BOOT +# endif +# ifdef __module__BOOTsmp +# define __module__sparc_BOOTsmp +# endif +# ifdef __module__enterprise +# define __module__sparc_enterprise +# endif +# ifdef __module__debug +# define __module__sparc_debug +# endif +# endif +#endif + +#ifdef __alpha__ +# define __module__alpha +# ifdef __module__up +# define __module__alpha_up +# endif +# ifdef __module__smp +# define __module__alpha_smp +# endif +# ifdef __module__BOOT +# define __module__alpha_BOOT +# endif +# ifdef __module__BOOTsmp +# define __module__alpha_BOOTsmp +# endif +# ifdef __module__enterprise +# define __module__alpha_enterprise +# endif +# ifdef __module__debug +# define __module__alpha_debug +# endif +#endif + +#ifdef __ia64__ +# define __module__ia64 +# ifdef __module__up +# define __module__ia64_up +# endif +# ifdef __module__smp +# define __module__ia64_smp +# endif +# ifdef __module__BOOT +# define __module__ia64_BOOT +# endif +# ifdef __module__BOOTsmp +# define __module__ia64_BOOTsmp +# endif +# ifdef __module__enterprise +# define __module__ia64_enterprise +# endif +# ifdef __module__debug +# define __module__ia64_debug +# endif +#endif + +#if defined(__module__smp) || defined(__module__BOOTsmp) || defined(__module__enterprise) || defined(__module__bigmem) +#define _ver_str(x) smp_ ## x +#else +#define _ver_str(x) x +#endif + +#define RED_HAT_LINUX_KERNEL 1 + +#endif /* __rh_config_h__ */ diff --git a/build/lmake b/build/lmake new file mode 100755 index 0000000..c110acf --- /dev/null +++ b/build/lmake @@ -0,0 +1,658 @@ +#!/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= + +# 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= +UP_ARCHS= + +RHBUILD=0 +SUSEBUILD=0 + +# flat-out globals +TOPDIR= +TARGET_FILE= +KERNEL_FILE= +SERIES_FILE= +CONFIG_FILE= + +canon() +{ + pushd $1 >/dev/null + echo $PWD + popd >/dev/null +} +TOPDIR=$(canon "${0%%${0##*/}}/..") + +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 <] + +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. + + 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 +} + +get_lustre_version() +{ + lustre_patch=$(grep lustre_version "$SERIES_FILE" 2>/dev/null) + [ "$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" + + [ "$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 + 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." + fi + + TARGET_ARCH=${TARGET_ARCH:-$BASE_ARCHS} + CONFIG_TARGET="$TARGET-${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 +} + +tarflags() +{ + case "$1" in + '') + fatal 1 "tarflags(): File name argument missing." + ;; + *.tar.gz) + echo 'zxf' + ;; + *.tar.bz2) + echo 'jxf' + ;; + *) + 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" + [ -d linux ] || ln -sf linux* linux + popd >/dev/null +} + +patch_kernel() +{ + (( $UNPACK_KERNEL )) || return 0 + [ "$SERIES" ] || return 0 + pushd "$TOPDIR/linux" >/dev/null + echo -n "Applying patch" + 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 + popd >/dev/null +} + +set_make() +{ + MAKE="make -s" + if [ "$CC" ] ; then + MAKE="$MAKE 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" +} + +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..." + perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -${EXTRA_VERSION}${TARGET_CONFIG}/" Makefile + echo "Making depend in $PWD..." + $MAKE mrproper || fatal 1 "Error running make mrproper" + cp "$CONFIG_FILE" .config + for oc in oldconfig_nonint silentoldconfig oldconfig ; do + if grep -q "$oc" Makefile ; then + OLDCONFIG="$oc" + break + fi + done + $MAKE $OLDCONFIG || fatal 1 "Error running make oldconfig" + case "$VERSION" in + 2.6*) + SYMLINKS="include/asm" + ;; + 2.4*) + SYMLINKS="symlinks" + ;; + esac + $MAKE $SYMLINKS + $MAKE_J dep || fatal 1 "Error running make dep" + $MAKE 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..." + case "$TARGET_ARCH" in + i386 | i586 | i686 | athlon | x86_64) + $MAKE_J bzImage || fatal 1 "Error making bzImage." + ;; + ppc | ppc64) + $MAKE_J vmlinux || fatal 1 "Error making vmlinux." + ;; + *) + $MAKE_J boot || fatal 1 "Error making boot." + ;; + esac + $MAKE_J modules || fatal 1 "Error building modules." + + popd >/dev/null +} + +configure_lustre() +{ + (( $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 + $MAKE_J || fatal 1 "Error building Lustre." + popd >/dev/null +} + +install_kernel() +{ + (( $INSTALL_KERNEL )) || return 0 + set_make + FULL_VERSION="${VERSION}-${EXTRA_VERSION}${TARGET_CONFIG}" + 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 INSTALL_MOD_PATH="$DESTDIR" KERNELRELEASE="$FULL_VERSION" \ + -s modules_install || \ + fatal 1 "Error installing modules." + + 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 + if [ -e init/kerntypes.o ] ; then + cp init/kerntypes.o "$DESTDIR/boot/Kerntypes-${FULL_VERSION}" + fi + + popd >/dev/null +} + +install_lustre() +{ + (( $INSTALL_LUSTRE )) || return 0 + set_make + FULL_VERSION="${VERSION}-${EXTRA_VERSION}${TARGET_CONFIG}" + pushd "$TOPDIR" >/dev/null + $MAKE -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 + FULL_VERSION="${VERSION}-${EXTRA_VERSION}${TARGET_CONFIG}" + 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 -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 + (( $SUSEBUILD )) || return 0 + set_make + FULL_VERSION="${VERSION}-${EXTRA_VERSION}${TARGET_CONFIG}" + for build_dir in "${TOPDIR}/modules-${FULL_VERSION}/*" ; do + [ -d $build_dir ] || continue + # these modules are terrible, and don't all build + $MAKE -C $build_dir KERNEL_SOURCE="${TOPDIR}/linux" INSTALL_MOD_PATH="$DESTDIR" + done + ( 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 > "${DESTDIR}/boot/symvers-${VERSION}-${EXTRA_VERSION}-${TARGET_ARCH}${TARGET_CONFIG}.gz" +} + +save_headers() +{ + echo "Saving headers for $1 $2..." + pushd linux >/dev/null + + KVERREL="${VERSION}-${EXTRA_VERSION}" + # deal with the kernel headers that are version specific + + saveddir="$RPM_BUILD_ROOT/usr/src/linux-${KVERREL}/savedheaders/$2/$1" + 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 $2 $1 ../../savedheaders/$2/$1/ >> $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 $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" + +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 + ;; + --) + shift + CONFIGURE_FLAGS=$@ + break + ;; + *) + usage 1 "Unrecognized option: $1" + ;; + esac +done + +check_options +load_target + +extract_kernel +patch_kernel + +depend_kernel +build_kernel + +configure_lustre +build_lustre + +build_kms + +install_kernel +install_lustre + +install_kms + +save_all_headers + +exit 0 diff --git a/build/lustre-kernel-2.4.spec.in b/build/lustre-kernel-2.4.spec.in new file mode 100644 index 0000000..1c4e3af --- /dev/null +++ b/build/lustre-kernel-2.4.spec.in @@ -0,0 +1,983 @@ +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 release @KERNEL_RELEASE@ +# /usr/src/%{kslnk} -> /usr/src/linux-%{KVERREL} +%define kslnk linux-2.4 + +# 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@ + +# 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 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 @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 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 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 +# , 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 + +Name: kernel +Version: %{kversion} +Release: %{release}%{?targetboard:%{targetboard}}%{?debuglevel_1:.dbg} +%define KVERREL %{PACKAGE_VERSION}-%{kextraver}%{?targetboard:%{targetboard}}%{?debuglevel_1:.dbg} +License: GPL +Group: System Environment/Kernel +ExclusiveArch: %{all_x86} x86_64 ia64 ppc +ExclusiveOS: Linux +Obsoletes: kernel-modules, kernel-sparc +Provides: kernel = %{version} +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: Cluster File Systems, Inc. +URL: http://www.kernel.org/ +Buildroot: /var/tmp/%{name}-%{PACKAGE_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 + +%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 = %{version} +%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 = %{version}, 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 bigmem +Summary: The Linux Kernel for machines with more than 4 Gigabyte of memory. +Group: System Environment/Kernel +Provides: module-info, kernel = %{version} +%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 = %{version} +%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 = %{version} +%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 = %{version} +%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 wiht +# 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. + +%package -n lustre-ldap +Summary: LDAP schema files for Lustre +Group: System Environment/Daemons + +%description -n lustre-ldap +LDAP schema files for Lustre. These are needed if you plan to store +your Lustre configuration in LDAP, rather than on disk. + +%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 +sh -x ./build/lmake \ + --unpack-kernel \ + --target @LUSTRE_TARGET@ \ + --target-arch %{_target_cpu} \ + --kerneldir $RPM_SOURCE_DIR +popd >/dev/null + +# handle both SuSE and Red Hat's new-kernel-pkg bits +for flavor in "" smp bigmem bigsmp BOOT jensen ; do + for when in pre preun post postun ; do + script="${when}${flavor}.sh" + echo "if [ -f /etc/SuSE-release ] ; then" > ${script} + sed -e "s/@when@/$when/g" -e "s^%ver_str^%{KVERREL}${flavor}^g" %{SOURCE28} >> ${script} + cat %{SOURCE25} >> ${script} + case $when in + post) + sed -e "s^%ver_str^%{KVERREL}${flavor}^g" %{SOURCE26} >> ${script} + ;; + postun) + sed -e "s^%ver_str^%{KVERREL}${flavor}^g" %{SOURCE27} >> ${script} + ;; + esac + echo "exit 0; fi" >> ${script} + case $when in + post) + if [ -z "${flavor}" ] ; then + cat >> ${script} <> ${script} <> ${script} </dev/null >/dev/null || : +exit 0 +EOF + ;; + preun) + cat >> ${script} < /dev/null > /dev/null || : +rm -f /lib/modules/%{KVERREL}${flavor}/modules.* +if [ -x /sbin/new-kernel-pkg ] ; then + /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}${flavor} +fi +EOF + ;; + esac + done +done + +%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} + sh -x ./build/lmake \ + --depend-kernel \ + --target @LUSTRE_TARGET@ \ + --target-arch %{_target_cpu} \ + ${target_config} \ + --extraversion %{kextraver} \ + -j $RPM_BUILD_NCPUS +} + +BuildKernel() +{ + target_config=${1:+--target-config $1} + sh -x ./build/lmake \ + --build-kernel --build-lustre \ + --install \ + --target @LUSTRE_TARGET@ \ + --target-arch %{_target_cpu} \ + ${target_config} \ + --extraversion %{kextraver} \ + --kerneldir $RPM_SOURCE_DIR \ + -j $RPM_BUILD_NCPUS \ + --destdir $RPM_BUILD_ROOT \ + -- --enable-modules \ + --disable-doc --disable-tests \ + --disable-utils --disable-liblustre \ + --sysconfdir=%{_sysconfdir} \ + --mandir=%{_mandir} \ + @CONFIGURE_FLAGS@ +} + +BuildLustre() +{ + target_config=${1:+--target-config $1} + sh -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 \ + -- --enable-utils \ + --disable-doc --disable-tests \ + --disable-modules --disable-liblustre \ + --sysconfdir=%{_sysconfdir} \ + --mandir=%{_mandir} \ + @CONFIGURE_FLAGS@ +} + +SaveHeaders() +{ + sh -x ./build/lmake \ + --save-headers \ + --target @LUSTRE_TARGET@ \ + --target-arch %{_target_cpu} \ + --extraversion %{kextraver} \ + --destdir $RPM_BUILD_ROOT +} + +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 %{buildup} +BuildKernel +%endif + +%if %{buildbase} +BuildLustre +SaveHeaders +%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.* + rm -f $i/build + ln -sf ../../../usr/src/linux-%{KVERREL} $i/build +%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="" + else + flavext="-$flavor" + fi + c="$RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}" + o="${c}-obj/%{_target_cpu}/$flavor" + mkdir -p $o + cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@-%{_target_cpu}%{dashtargetboard}${flavext}.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}" + $MAKE $OLDCONFIG + $MAKE prepare-all + $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. + read VERSION PATCHLEVEL SUBLEVEL <<-EOF +$(set -- 2.6.5 ; echo ${*//./ }) +EOF + source scripts/mkmakefile \ + ../../../linux-%{KVERREL} \ + ../linux-%{KVERREL}-obj/%{_target_cpu}/$flavor \ + $VERSION \ + $PATCHLEVEL \ + > $o/Makefile + zcat "$RPM_BUILD_ROOT/boot/symvers-%{KVERREL}-%{_target_cpu}${flavor}.gz" \ + > $o/Module.symvers +} + +## +## do -source package cleanup/install +## +%if %{buildbase} + 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} + perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{kextraver}custom/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile + 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} + # this only works because CFS 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} + BuildObj bigmem + %endif + %if %{buildBOOT} + BuildObj BOOT + %endif + %if %{buildjensen} + BuildObj jensen + %endif + %if %{buildsmp} + BuildObj smp + %endif + %if %{buildbigsmp} + BuildObj bigsmp + %endif + %if %{buildup} + BuildObj up + %endif + # 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 + cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@-%{_target_cpu}%{dashtargetboard}.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 + make -s $OLDCONFIG -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL} + %if %{linux26} + make -s include/asm -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL} + %else + make -s symlinks -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL} + %endif + make -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 < +#include +EOF + echo '#include ' > 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 ' >> 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 " >> version.h + keyword=if + for i in smp BOOT BOOTsmp bigmem bigsmp 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} + # 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 + %endif + %endif # linux26 + popd >/dev/null +%endif # 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 bigmem -f prebigmem.sh + +%post -f post.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 [ ! -e /dev/obd ]; then + mknod /dev/obd c 10 241 +fi +if [ ! -e /dev/portals ]; then + mknod /dev/portals c 10 240 +fi +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 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 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 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 +%defattr(-, root, root) +/boot/%{kernel_glob} +%ifarch ia64 +/boot/efi/redhat/%{kernel_glob} +%endif +/boot/System.map-%{KVERREL} +/boot/config-%{KVERREL} +%dir /lib/modules +%dir /dev/shm +/lib/modules/%{KVERREL} +%if %{linux26} +/boot/Kerntypes-%{KVERREL} +/boot/symvers-%{KVERREL}-%{_target_cpu}.gz +%endif # linux26 +%endif + +%if %{buildsmp} +%files smp +%defattr(-, root, root) +/boot/%{kernel_glob}smp +%ifarch ia64 +/boot/efi/redhat/%{kernel_glob}smp +%endif +/boot/System.map-%{KVERREL}smp +/boot/config-%{KVERREL}smp +%dir /lib/modules +%dir /dev/shm +/lib/modules/%{KVERREL}smp +%if %{linux26} +/boot/Kerntypes-%{KVERREL}smp +/boot/symvers-%{KVERREL}-%{_target_cpu}smp.gz +%endif # linux26 +%endif + +%if %{buildbigsmp} +%files bigsmp +%defattr(-, root, root) +/boot/%{kernel_glob}bigsmp +%ifarch ia64 +/boot/efi/redhat/%{kernel_glob}bigsmp +%endif +/boot/System.map-%{KVERREL}bigsmp +/boot/config-%{KVERREL}bigsmp +%dir /lib/modules +%dir /dev/shm +/lib/modules/%{KVERREL}bigsmp +%if %{linux26} +/boot/Kerntypes-%{KVERREL}bigsmp +/boot/symvers-%{KVERREL}-%{_target_cpu}bigsmp.gz +%endif # linux26 +%endif + +%if %{buildbigmem} +%files bigmem +%defattr(-, root, root) +/boot/%{kernel_glob}bigmem +%ifarch ia64 +/boot/efi/redhat/%{kernel_glob}bigmem +%endif +/boot/System.map-%{KVERREL}bigmem +/boot/config-%{KVERREL}bigmem +%dir /lib/modules +%dir /dev/shm +/lib/modules/%{KVERREL}bigmem +%if %{linux26} +/boot/Kerntypes-%{KVERREL}bigmem +/boot/symvers-%{KVERREL}-%{_target_cpu}bigmem.gz +%endif # linux26 +%endif + +%if %{buildBOOT} +%files BOOT +%defattr(-, root, root) +/boot/%{kernel_glob}BOOT +%ifarch ia64 +/boot/efi/redhat/%{kernel_glob}BOOT +%endif +/boot/System.map-%{KVERREL}BOOT +/boot/config-%{KVERREL}BOOT +%dir /lib/modules +%dir /dev/shm +/lib/modules/%{KVERREL}BOOT +%if %{linux26} +/boot/Kerntypes-%{KVERREL}BOOT +/boot/symvers-%{KVERREL}-%{_target_cpu}BOOT.gz +%endif # linux26 +%endif + +%if %{buildbase} + +%if 1 +%files source +%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 # linux26 +%endif + +%files doc +%defattr(-,root,root) +%doc lustre/linux/Documentation/* + +%files -n lustre-lite-utils +%defattr(-, root, root) +%doc lustre/COPYING lustre/BUGS lustre/ChangeLog lustre/README lustre/doc/lustre.pdf +/sbin/* +/usr/sbin/* +/usr/bin/* +/usr/lib/lustre/python +@ENABLE_INIT_SCRIPTS@/etc/init.d/lustre +@ENABLE_INIT_SCRIPTS@/etc/init.d/lustrefs +/usr/include/lustre/* +/usr/include/portals/* +/usr/include/linux/* +/usr/lib/lib*.a +/usr/share/man/man?/* + +#%files -n lustre-doc +#%defattr(-, root, root) +#/usr/share/doc/lustre/COPYING +#/usr/share/doc/lustre/lustre.pdf +#/usr/share/doc/lustre/COPYING + +/usr/share/lustre/examples + +%files -n lustre-ldap +%defattr(-, root, root) +/etc/openldap/slapd-lustre.conf +/etc/openldap/schema/lustre.schema +/usr/lib/lustre/lustre2ldif.xsl +/usr/lib/lustre/top.ldif + +%endif # %{buildbase} diff --git a/build/lustre.spec.in b/build/lustre.spec.in new file mode 100644 index 0000000..6215e7a --- /dev/null +++ b/build/lustre.spec.in @@ -0,0 +1,235 @@ +# lustre.spec +%define version @VERSION@ +%define kversion @LINUXRELEASE@ +%define linuxdir @LINUX@ +%define enable_doc @ENABLE_DOC@ + +Summary: Lustre Lite File System +Name: lustre-lite +Version: %{version} +Release: @RELEASE@ +Copyright: GPL +Group: Utilities/System +Requires: lustre-modules, PyXML +Source: ftp://ftp.lustre.com/pub/lustre/lustre-%{version}.tar.gz +BuildRoot: /var/tmp/lustre-%{version}-root + +%description +The Lustre Lite Cluster File System: kernel drivers for file system, +servers and utilities. + +%package -n lustre-modules +Summary: Kernel Lustre drivers for Linux %{kversion} +Requires: modutils >= 2.4.10 +Group: Development/Kernel + +%description -n lustre-modules +Lustre file System, server and network drivers for Linux %{kversion}. + +%package -n lustre-source +Summary: Object-Based Disk storage driver source +Group: Development/Kernel + +%description -n lustre-source +Lustre Lite Source for further development + +%package -n lustre-doc +Summary: Documentation and sample configuration files +Group: Documentation +# FIXME: BuildArch overrides all the packages in rpm 4.0.4-7x +#BuildArch: noarch + +%description -n lustre-doc +Documentation and sample configuration files for Lustre + +%package -n lustre-ldap +Summary: Configures openldap server for LDAP Lustre config database +Group: Configuration +Requires: openldap-servers, openldap-clients, python-ldap, 4Suite + +%description -n lustre-ldap +Configures openldap server for LDAP Lustre config database + + +#%package -n liblustre +#Summary: Lustre Lib +#Group: Development/Kernel + +#%description -n liblustre +#Lustre lib binary package. + +%prep +%setup -qn lustre-%{version} +#%setup -c -n lustre-%{version}-lib +%if %{enable_doc} + %define disable_doc '' +%else + %define disable_doc --disable-doc +%endif + +%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 + +# Set an explicit path to our Linux tree, if we can. +cd $RPM_BUILD_DIR/lustre-%{version} +./configure \ + --with-linux='%{linuxdir}' \ + %{disable_doc} --disable-liblustre \ + --sysconfdir=%{_sysconfdir} \ + --mandir=%{_mandir} +make -j $RPM_BUILD_NCPUS -s + +%install +cd $RPM_BUILD_DIR/lustre-%{version} +make install DESTDIR=$RPM_BUILD_ROOT + +%ifarch alpha +# this hurts me + conf_flag= + linuxdir=%{linuxdir} + test -d $linuxdir && conf_flag=--with-linux=$linuxdir + make clean + ./configure --enable-rtscts-myrinet $conf_flag %{disable_doc} + make + cp linux/rtscts/rtscts.o $RPM_BUILD_ROOT/lib/modules/%{kversion}/kernel/net/lustre/rtscts_myrinet.o + cp user/myrinet_utils/mcpload $RPM_BUILD_ROOT/usr/sbin/mcpload +%endif + +# Create the pristine source directory. +cd $RPM_BUILD_DIR/lustre-%{version} +mkdir -p $RPM_BUILD_ROOT/usr/src +rm -f lustre-source +ln -s $RPM_BUILD_ROOT/usr/src lustre-source +make distdir distdir=lustre-source/lustre-%{version} + +# ldap database directory +mkdir -p $RPM_BUILD_ROOT/var/lib/ldap/lustre + +%files +%attr(-, root, root) /sbin/mount.lustre +%attr(-, root, root) /usr/sbin/lmc +%attr(-, root, root) /usr/sbin/lctl +%attr(-, root, root) /usr/sbin/lconf +%attr(-, root, root) /usr/sbin/lrun +%attr(-, root, root) /usr/sbin/llmount +%attr(-, root, root) /usr/sbin/lwizard +%attr(-, root, root) /usr/sbin/wiretest +%attr(-, root, root) /usr/sbin/lactive +%attr(-, root, root) /usr/sbin/llanalyze +%attr(-, root, root) /usr/sbin/gmnalnid +%attr(-, root, root) /usr/sbin/llstat.pl +%attr(-, root, root) /usr/sbin/llobdstat.pl +%attr(-, root, root) /usr/sbin/load_ldap.sh +%attr(-, root, root) /usr/sbin/acceptor +%attr(-, root, root) /usr/sbin/ptlctl +%attr(-, root, root) /usr/sbin/debugctl +%attr(-, root, root) /usr/sbin/lload +%attr(-, root, root) /usr/sbin/obdbarrier +%attr(-, root, root) /usr/sbin/obdio +%attr(-, root, root) /usr/sbin/routerstat +%attr(-, root, root) /usr/sbin/wirecheck +%attr(-, root, root) /usr/bin/lfs +%attr(-, root, root) /usr/bin/lfind +%attr(-, root, root) /usr/bin/lstripe +%attr(-, root, root) /usr/bin/mcreate +%attr(-, root, root) /usr/bin/munlink +%attr(-, root, root) /usr/lib/lustre/python +%attr(-, root, root) /usr/share/lustre/examples + +%attr(-, root, root) /etc/init.d/lustre +%attr(-, root, root) /etc/init.d/lustrefs +%attr(-, root, root) /usr/lib/libptlctl.a +%attr(-, root, root) /usr/lib/liblustreapi.a +%attr(-, root, root) /usr/include/lustre +%attr(-, root, root) /usr/include/portals +%attr(-, root, root) /usr/include/linux/lustre_idl.h + +%attr(-, root, root) /usr/share/man/man?/* + +%ifarch alpha +%attr(-, root, root) /usr/sbin/mcpload +%endif + +%files -n lustre-doc +%attr(-, root, root) %doc COPYING FDL +%if %{enable_doc} +%attr(-, root, root) %doc doc/lustre.pdf doc/lustre-HOWTO.txt +%endif +#%attr(-, root, root) %doc tests/client-echo.cfg tests/client-mount.cfg +#%attr(-, root, root) %doc tests/client-mount2.cfg +#%attr(-, root, root) %doc tests/elan-client.cfg tests/elan-server.cfg +#%attr(-, root, root) %doc tests/ldlm.cfg tests/lustre.cfg +#%attr(-, root, root) %doc tests/mds.cfg tests/net-client.cfg +#%attr(-, root, root) %doc tests/net-local.cfg tests/net-server.cfg +#%attr(-, root, root) %doc tests/obdecho.cfg tests/obdfilter.cfg + +%files -n lustre-modules +%attr(-, root, root) %doc COPYING +%attr(-, root, root) /lib/modules/%{kversion}/kernel/fs/lustre +#portals modules +%attr(-, root, root) /lib/modules/%{kversion}/kernel/net/lustre + +%files -n lustre-source +%attr(-, root, root) /usr/src/lustre-%{version} + +#%ifarch i386 +#%files -n liblustre +#%attr(-, root, root) /lib/lustre +#%attr(-, root, root) /usr/sbin/lctl +#%attr(-, root, root) /usr/sbin/lfind +#%attr(-, root, root) /usr/sbin/lstripe +#%attr(-, root, root) /usr/sbin/obdio +#%attr(-, root, root) /usr/sbin/obdbarrier +#%attr(-, root, root) /usr/sbin/obdstat +#%attr(-, root, root) /usr/sbin/lload +#%attr(-, root, root) /usr/sbin/lconf +#%attr(-, root, root) /usr/sbin/lmc +#%attr(-, root, root) /usr/sbin/llanalyze +#%endif + + +%files -n lustre-ldap +%attr(-, root, root) /etc/openldap/slapd-lustre.conf +%attr(-, root, root) /etc/openldap/schema/lustre.schema +%attr(-, root, root) /usr/lib/lustre/lustre2ldif.xsl +%attr(-, root, root) /usr/lib/lustre/top.ldif +#%dir /var/lib/ldap/lustre +%attr(700, ldap, ldap) /var/lib/ldap/lustre + +%post +/sbin/chkconfig --add lustre +/sbin/chkconfig --add lustrefs + +%preun +if [ $1 = 0 ]; then + /sbin/chkconfig --del lustre + /sbin/chkconfig --del lustrefs +fi + +%post -n lustre-modules +if [ ! -e /dev/obd ]; then + mknod /dev/obd c 10 241 +fi +if [ ! -e /dev/portals ]; then + mknod /dev/portals c 10 240 +fi +depmod -ae || exit 0 + +%postun -n lustre-modules +depmod -ae || exit 0 + +%clean +#rm -rf $RPM_BUILD_ROOT + +# end of file diff --git a/build/suse-functions.sh b/build/suse-functions.sh new file mode 100644 index 0000000..a7e421d --- /dev/null +++ b/build/suse-functions.sh @@ -0,0 +1,22 @@ +# Readlink is not present on some older distributions: emulate it. +readlink() { + local path=$1 ll + + if [ -L "$path" ]; then + ll="$(LC_ALL=C ls -l "$path" 2> /dev/null)" && + echo "${ll/* -> }" + else + return 1 + fi +} +relink() { + if [ -h "$2" ]; then + local old=$(readlink "$2") + [ "$old" = "$1" ] && return 0 + echo "Changing symlink $2 from $old to $1" + elif [ -e "$2" ]; then + echo "Replacing file $2 with symlink to $1" + fi + rm -f "$2" \ + && ln -s "$1" "$2" +} diff --git a/build/suse-post.sh b/build/suse-post.sh new file mode 100644 index 0000000..ec38664 --- /dev/null +++ b/build/suse-post.sh @@ -0,0 +1,46 @@ +if [ -f /boot/vmlinuz-%ver_str ]; then + image=vmlinuz +elif [ -f /boot/image-%ver_str ]; then + image=image +elif [ -f /boot/vmlinux-%ver_str ]; then + image=vmlinux +else + # nothing to do (UML kernels for example). + exit 0 +fi + +# If we have old symlinks, rename them to *.previous +if [ -L /boot/$image -a -L /boot/initrd -a \ + "$(readlink /boot/$image)" != $image-%ver_str -a \ + "$(readlink /boot/initrd)" != initrd-%ver_str ]; then + mv /boot/$image /boot/$image.previous + mv /boot/initrd /boot/initrd.previous +fi + +# update /boot/vmlinuz symlink +relink $image-%ver_str /boot/$image + +if test "$YAST_IS_RUNNING" != instsys ; then + if [ -f /etc/fstab ]; then + echo Setting up /lib/modules/%ver_str + /sbin/update-modules.dep -v %ver_str + cd /boot + /sbin/mkinitrd -k $image-%ver_str -i initrd-%ver_str + + if [ -e /boot/initrd-%ver_str ]; then + relink initrd-%ver_str /boot/initrd + else + rm -f /boot/initrd + fi + else + echo "please run mkinitrd as soon as your system is complete" + fi +fi + +if [ "$YAST_IS_RUNNING" != instsys -a -x /sbin/new-kernel-pkg ]; then + # Notify boot loader that a new kernel image has been installed. + # (during initial installation the boot loader configuration does not + # yet exist when the kernel is installed, but yast kicks the boot + # loader itself later.) + /sbin/new-kernel-pkg %ver_str +fi diff --git a/build/suse-postun.sh b/build/suse-postun.sh new file mode 100644 index 0000000..eb86d03 --- /dev/null +++ b/build/suse-postun.sh @@ -0,0 +1,43 @@ +if [ -L /boot/vmlinux ]; then + image=vmlinux +elif [ -L /boot/vmlinuz ]; then + image=vmlinuz +elif [ -L /boot/image ]; then + image=image +else + # nothing to do (UML kernels for example). + exit 0 +fi + +if [ "$(readlink /boot/$image)" = $image-%ver_str ]; then + # This may be the last kernel RPM on the system, or it may + # be an update. In both of those cases the symlinks will + # eventually be correct. Only if this kernel + # is removed and other kernel rpms remain installed, + # find the most recent of the remaining kernels, and make + # the symlinks point to it. This makes sure that the boot + # manager will always have a kernel to boot in its default + # configuration. + shopt -s nullglob + for image in $(cd /boot ; ls -dt $image-*); do + initrd=initrd-${image#*-} + if [ -f /boot/$image -a -f /boot/$initrd ]; then + relink $image /boot/${image%%%%-*} + relink $initrd /boot/${initrd%%%%-*} + break + fi + done + shopt -u nullglob +fi + +# Created in the other kernel's %post +case "$(readlink /boot/$image.previous)" in +$image-%ver_str|$(readlink /boot/$image)) + rm -f /boot/$image.previous ;; +esac +case "$(readlink /boot/initrd.previous)" in +initrd-%ver_str|$(readlink /boot/initrd)) + rm -f /boot/initrd.previous ;; +esac +# created in %post +rm -f /boot/initrd-%ver_str diff --git a/build/suse-trigger-script.sh.in b/build/suse-trigger-script.sh.in new file mode 100644 index 0000000..0ead9e8 --- /dev/null +++ b/build/suse-trigger-script.sh.in @@ -0,0 +1,9 @@ +old_shopt=$(shopt -p nullglob || :) +shopt -s nullglob +for script in /lib/modules/scripts/* ; do + if [ -f "$script" -a -x "$script" ] \ + && ! "$script" --@when@ %ver_str $1 ; then + echo "$script failed." + fi +done +eval $old_shopt diff --git a/lustrecvs b/lustrecvs index e9c8b9a..433c616 100755 --- a/lustrecvs +++ b/lustrecvs @@ -18,32 +18,16 @@ fatal () usage () { cat <&2 - exit 1 - ;; - --help | -h) - usage - exit 0 - ;; - checkout | co | get | rtag | rt | rfreeze | tag | ta | freeze | update | up | upd) - cvscommand="$1" - ;; - *) - usage >&2 - exit 1 - ;; -esac +# portalstag="HEAD" +portalstag="b1_4" +buildtag="HEAD" -case "$2" in +case "$1" in '') warn "a lustretag is required." usage >&2 @@ -57,27 +41,27 @@ case "$2" in # this is the branch table # keep this list sorted alphabetically! - b1_4) - portalstag="HEAD" - lustretag="b1_4" - ;; b1_4_bgl) portalstag="b1_4_bgl" - lustretag="b1_4_bgl" - ;; - b_cray) - portalstag="HEAD" - lustretag="b_cray" - ;; - HEAD) - portalstag="HEAD" - lustretag="HEAD" ;; - *) - fatal 1 "This script does not contain branch information for $2. Please update the branch table if necessary." - ;; esac -cvs $cvscommand -r $portalstag portals -cvs $cvscommand -r $lustretag -d lustre lustre-core +cvs_cmd () +{ + local dir="$1" + local module="$2" + local tag="$3" + + if [ -d "$dir" ] ; then + echo "$progname: Updating $dir to -r $tag" + ( cd "$dir" && cvs up -r "$tag" ) + else + echo "$progname: Checking out $dir from -r $tag" + cvs co -r "$tag" -d "$dir" "$module" + fi +} + +cvs_cmd build build "$buildtag" +cvs_cmd portals portals "$portalstag" +cvs_cmd lustre lustre-core "$lustretag" -- 1.8.3.1