X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=build%2Flbuild;h=52807a813bc7f0c3668bc101b7db6a7b4c152f13;hb=59dd795b653d1e105998ce575fa926889937d3eb;hp=453e563e59cbd161593a1c4b9f5d7854730350be;hpb=3fa8545b77fec1ffe89d7f7bbc5ce600020b282b;p=fs%2Flustre-release.git diff --git a/build/lbuild b/build/lbuild index 453e563..52807a8 100755 --- a/build/lbuild +++ b/build/lbuild @@ -4,16 +4,18 @@ TOPDIR=$PWD # CVSROOT is inherited from the environment KERNELDIR= +LINUX= LUSTRE= -PUBLISH=0 RELEASE=0 -DO_SRC=1 +DO_SRC=0 +DOWNLOAD=1 TAG= TARGET= TARGET_ARCHS= CONFIGURE_FLAGS= EXTERNAL_PATCHES= EXTRA_VERSION= +STAGEDIR= # from target file KERNEL= @@ -71,11 +73,6 @@ fatal() exit $1 } -publishing() -{ - (( $PUBLISH )) || return 0 -} - is_release() { (( $RELEASE )) || return 0 @@ -113,21 +110,36 @@ Usage: ${0##*/} [OPTION]... [-- ] Directory containing Linux source tarballs referenced by target files. + --linux=LINUX + Directory of Linux kernel sources. When this option is used, only + Lustre modules and userspace are built. + --lustre=LUSTRE Path to an existing lustre source tarball to use instead of pulling from CVS. + --nodownload + Do not try to download a kernel from ftp.lustre.org + --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. + Unused. --release Specifies that the files generated do not include timestamps, and that this is an official release. + --src + Build a .src.rpm, a full kernel patch, and a patched kernel tarball. + + --stage=DIR + Directory used to stage packages for release. RPMs will be placed + more or less in DIR/-, and the tarball will be + placed in DIR. + --tag=TAG A CVS branch/tag name to build from when pulling from CVS. @@ -169,23 +181,44 @@ check_options() 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." + if [ -z "$LINUX" ] ; then + [ "$KERNELDIR" ] || \ + usage 1 "A kernel directory must be specified with --kerneldir." - [ -d "$KERNELDIR" ] || \ - usage 1 "$KERNELDIR is not a directory." + [ -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." + if ! (( $RELEASE )) ; then + [ "$TAG" ] || \ + usage 1 "When building a snapshot, a tag name must be used." + fi + + [ "$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." fi - TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M") + case $TARGET in + 2.6-rhel4) + CANONICAL_TARGET="rhel-2.6" + ;; + 2.6-suse) + CANONICAL_TARGET="sles-2.6" + ;; + hp_pnnl-2.4) + CANONICAL_TARGET="hp-pnnl-2.4" + ;; + 2.6-vanilla \ + | suse-2.4.21-2 \ + | rh-2.4 \ + | rhel-2.4 \ + | sles-2.4) + CANONICAL_TARGET="$TARGET" + ;; + esac - [ "$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." + TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M") RPMBUILD=$(which rpmbuild 2>/dev/null | head -1) if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then @@ -222,8 +255,17 @@ load_target() if [ "$KERNELDIR" ] ; then KERNEL_FILE="$KERNELDIR/$KERNEL" - [ -r "$KERNELDIR/$KERNEL" ] || \ - fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR." + if [ ! -r "$KERNELDIR/$KERNEL" ] ; then + if (( $DOWNLOAD )) ; then + echo "Downloading http://ftp.lustre.org/kernels/$CANONICAL_TARGET/old/$KERNEL..." + if ! wget -nv "http://ftp.lustre.org/kernels/$CANONICAL_TARGET/old/$KERNEL" \ + -O "$KERNELDIR/$KERNEL" ; then + fatal 1 "Could not download target $TARGET's kernel file $KERNEL from ftp.lustre.org." + fi + else + fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR." + fi + fi fi if [ "$SERIES" ] ; then @@ -266,12 +308,15 @@ tarflags() '') fatal 1 "tarflags(): File name argument missing." ;; - *.tar.gz) + *.tar.gz | *.tgz) echo 'zxf' ;; *.tar.bz2) echo 'jxf' ;; + *.tar) + echo 'xf' + ;; *) fatal 1 "tarflags(): Unrecognized tar extension in file: $1" ;; @@ -378,7 +423,7 @@ clean_linux() rm -rf linux } -prep_build() +prep_kernel_build() { # make .spec file ENABLE_INIT_SCRIPTS="" @@ -425,14 +470,14 @@ prep_build() clean_lustre() { [ -d lustre ] || return 0 - echo "Cleaning lustre..." + echo "Cleaning Lustre..." [ -L lustre ] && rm -rf $(readlink lustre) rm -rf lustre } -build() +build_kernel() { - echo "Building rpms for: $BUILD_ARCHS..." + echo "Building kernel + Lustre RPMs for: $BUILD_ARCHS..." targets= for arch in $BUILD_ARCHS ; do targets="--target $arch $targets" @@ -440,23 +485,65 @@ build() $RPMBUILD $targets -bb lustre-kernel-2.4.spec \ --define "_topdir $TOPDIR" || \ - fatal 1 "Error building rpms for $arch." + fatal 1 "Error building rpms for $BUILD_ARCHS." - if false && (( $DO_SRC )) ; then + if (( $DO_SRC )) ; then $RPMBUILD -bs lustre-kernel-2.4.spec \ --define "_topdir $TOPDIR" || \ fatal 1 "Error building .src.rpm." fi } -publish() +build_lustre() +{ + [ -d SRPMS ] || mkdir SRPMS + [ -d RPMS ] || mkdir RPMS + [ -d BUILD ] || mkdir BUILD + [ -d SOURCES ] || mkdir SOURCES + + cp "$LUSTRE" SOURCES + + pushd lustre >/dev/null + + echo "Building Lustre RPMs for: $BUILD_ARCHS..." + targets= + for arch in $BUILD_ARCHS ; do + targets="--target $arch $targets" + done + + ./configure "--with-linux=${LINUX}" ${CONFIGURE_FLAGS} + + $RPMBUILD $targets -bb build/lustre.spec \ + --define "_topdir $TOPDIR" || \ + fatal 1 "Error building rpms for $BUILD_ARCHS." + + popd >/dev/null +} + +stage() { - publishing || return 0 + [ "$STAGEDIR" ] || return 0 + + for arch in $BUILD_ARCHS ; do + rpmdir="${STAGEDIR}/${CANONICAL_TARGET}-${arch}" + echo "${0##*/}: Copying RPMs into ${rpmdir}" + mkdir -p "${rpmdir}" + cp -v RPMS/${arch}/*.rpm "${rpmdir}" + if [ -d RPMS/noarch ] ; then + cp -v RPMS/noarch/*.rpm "${rpmdir}" + fi + done + + cp -v "$LUSTRE" "$STAGEDIR" } [ -r ~/.lbuildrc ] && . ~/.lbuildrc -options=$(getopt -o d:D:h -l external-patches:,extraversion:,kerneldir:,lustre:,nosrc,publish,release,tag:,target:,target-archs:,disable-datestamp -- "$@") +options=$(getopt -o d:D:h -l disable-datestamp,external-patches:,extraversion:,kerneldir:,linux:,lustre:,nodownload,nosrc,publish,release,stage:,tag:,target:,target-archs:,with-linux: -- "$@") + +if [ $? != 0 ] ; then + usage 1 +fi eval set -- "$options" @@ -488,22 +575,37 @@ while [ "$1" ] ; do KERNELDIR=$2 shift 2 ;; + --linux | --with-linux) + LINUX=$2 + shift 2 + ;; --lustre) LUSTRE=$2 shift 2 ;; + --nodownload) + DOWNLOAD=0 + shift 1 + ;; --nosrc) DO_SRC=0 shift 1 ;; --publish) - PUBLISH=1 shift ;; --release) RELEASE=1 shift ;; + --src) + DO_SRC=1 + shift 1 + ;; + --stage) + STAGEDIR=$2 + shift 2 + ;; --tag) TAG=$2 shift 2 @@ -534,18 +636,24 @@ 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 +if [ -z "$LINUX" ] ; then + load_target + + if (( $DO_SRC )) ; then + unpack_linux + patch_linux + pack_linux + clean_linux + fi + + prep_kernel_build + clean_lustre + + build_kernel +else + build_lustre +fi -build -publish +stage