lbuild

来自「lustre 1.6.5 source code」· 代码 · 共 1,694 行 · 第 1/4 页

TXT
1,694
字号
            else                if (( $DOWNLOAD )) ; then                    echo "Downloading http://downloads.lustre.org/public/kernels/$DISTRO/old/$KERNEL..."                    if ! wget -nv "http://downloads.lustre.org/public/kernels/$DISTRO/old/$KERNEL" -O "$KERNELDIR/$KERNEL" ; then                        # see if we can do it with an SRPM from the download site                        download_and_build_tarball $CANONICAL_TARGET $KERNEL_FILE                    else                        [ -s "$KERNELDIR/$KERNEL" ] || {                            rm -rf "$KERNELDIR/$KERNEL"                            fatal 1 "Target $TARGET's kernel $KERNEL not found in directory $KERNELDIR."                        }                    fi                else                    fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR."                fi            fi        fi        if [ -n "$OFED_VERSION" ] && \           [ ! -r "$KERNELTREE/../OFED-${OFED_VERSION}.tgz" ] ; then            if (( $DOWNLOAD )) ; then                local location="http://downloads.lustre.org/public/OFED/"                echo "Downloading $location/OFED-${OFED_VERSION}.tgz..."                if ! wget -nv "$location/OFED-${OFED_VERSION}.tgz" \                    -O "$KERNELTREE/../OFED-${OFED_VERSION}.tgz" ; then                    fatal 1 "Could not download OFED-${OFED_VERSION}.tgz from downloads.lustre.org."                fi            else                fatal 1 "OFED-${OFED_VERSION}.tgz not found in kernel directory $KERNELDIR."            fi        fi    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    if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config ]; then        CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config"    fi    local smptype    for smptype in $SMPTYPES; do        [ "$smptype" = "''" ] && smptype=        if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH-${smptype}.config ]; then        CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH-${smptype}.config"        KERNCONFSMPTYPE=$smptype    fi    done    local lnxrelnew=${lnxrel//-/_}    [ -f "$CONFIG_FILE" ] || \        fatal 1 "Config file for target $TARGET missing from $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/."    if [ "$EXTRA_VERSION_save" ] ; then        EXTRA_VERSION="$EXTRA_VERSION_save"    elif ! $RELEASE; then        # if there is no patch series, then this is not a lustre specific        # kernel.  don't make it look like one        if [ -n "$SERIES" ]; then            #remove the @VERSION@ (lustre version)#            EXTRA_VERSION=$(echo $EXTRA_VERSION | sed -e "s/\(.*_lustre\)\..*/\1/")#            EXTRA_VERSION="${EXTRA_VERSION}-${TAG}.${TIMESTAMP}"            ! ( $PATCHLESS ) && EXTRA_VERSION="${EXTRA_VERSION}.${TIMESTAMP}"        fi    fi    # EXTRA_VERSION=${EXTRA_VERSION//-/_}    [ -z $REUSEDKERNELMASK ] && \        # create mask for kernel RPM/builddir which could be reused        if $NORPM; then            REUSEDKERNELMASK=${KERNCONFSMPTYPE}-${lnxmaj}-${lnxrelnew}_lustre.${LUSTRE_VERSION}.*${TARGET_ARCH}        elif $RELEASE; then            REUSEDKERNELMASK=${KERNCONFSMPTYPE}-${lnxmaj}-${lnxrelnew}_lustre.${LUSTRE_VERSION}.${TARGET_ARCH}        else            REUSEDKERNELMASK=${KERNCONFSMPTYPE}-${lnxmaj}-${lnxrelnew}_lustre.${LUSTRE_VERSION}.${TIMESTAMP}.${TARGET_ARCH}        fi        # kernel-lustre-smp-2.6.9-55.0.2.EL_lustre.1.6.1.i686.rpm     ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $BIGSMP_ARCHS $PSERIES64_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 | *.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"}unpack_ofed(){    untar "$KERNELTREE/../OFED-${OFED_VERSION}.tgz"    [ -d OFED ] || ln -sf OFED-[0-9].[0-9]* OFED    pwd    ls -ld OFED OFED-[0-9].[0-9]*    ls -l OFED OFED-[0-9].[0-9]*}unpack_lustre(){    DIRNAME="lustre-$TAG-$TIMESTAMP"    if [ "$LUSTRE" ] ; then        untar "$LUSTRE"        [ -d lustre ] || ln -sf lustre-[0-9].[0-9]* lustre    else        if [ "$USE_DATESTAMP" ]; then            DATESTAMP="-D '$DATE'"        else            DATESTAMP=""        fi                    cvs -d "$CVSROOT" -qz3 co $DATESTAMP -d "$DIRNAME" lustre || \            fatal 1 "There was an error checking out toplevel Lustre from CVS."        pushd "$DIRNAME" > /dev/null        ./lustrecvs "$TAG" || \            fatal 1 "There was an error checking out Lustre/Portals/Build from CVS."        echo "Creating lustre tarball..."        sh autogen.sh || fatal 1 "There was an error running autogen.sh."        ./configure --disable-{modules,utils,liblustre,tests,doc} || \            fatal 1 "There was an error running ./configure to create makefiles."        make dist || fatal 1 "There was an error running 'make dist'."        popd > /dev/null        fname=$(basename $DIRNAME/lustre-*.tar.gz)        cp $DIRNAME/$fname . || fatal 1 "There was an error copying lustre tarball."        LUSTRE="$PWD/$fname"        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_DELIMITER}${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        [ "$patchesdir" ] && \            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_kernel_build(){    # make .spec file    ENABLE_INIT_SCRIPTS=""    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_EXTRA_VERSION_DELIMITER@^$EXTRA_VERSION_DELIMITER^g" \        -e "s^@KERNEL_TARGET_DELIMITER@^$TARGET_DELIMITER^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^@PSERIES64_ARCHS@^$PSERIES64_ARCHS^g" \        -e "s^@RHBUILD@^$RHBUILD^g" \        -e "s^@SMP_ARCHS@^$SMP_ARCHS^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} \        sles8-{pre,post,postun,update_{INITRD_MODULES,rcfile_setting}}.sh ; 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_kernel(){    echo "Building kernel + Lustre RPMs for: $BUILD_ARCHS..."    targets=    for arch in $BUILD_ARCHS ; do        targets="--target $arch $targets"    done    local rpmbuildopt='-bb'#    if $NORPM; then#        rpmbuildopt='-bc'#        echo NORPM mode. Only compiling.#        echo "XXX: need to fix lmake - add options to do rpmbuild -bc instead of -bb"#    fi    $RPMBUILD $targets $rpmbuildopt lustre-kernel-2.4.spec \        --define "_tmppath $TMPDIR" \        --define "_topdir $TOPDIR" || \        fatal 1 "Error building rpms for $BUILD_ARCHS."    if (( $DO_SRC )) ; then        $RPMBUILD -bs lustre-kernel-2.4.spec \            --define "_tmppath $TMPDIR" \            --define "_topdir $TOPDIR" || \            fatal 1 "Error building .src.rpm."    fi    ( $(skeep_ldiskfs_rpm $TAG) ) && return    pushd $TOPDIR/BUILD/lustre*/ldiskfs || return 255    make dist    if [ "$?" != "0" ] ; then        popd        return 255    fi    cp lustre-ldiskfs*.tar.gz $TOPDIR/SOURCES    gen_lustre_version    local ldiskfs_spec=lustre-ldiskfs.spec    [ -f "$ldiskfs_spec" ] && sed \    -e "s^Release: .*$^Release: $LUSTRE_EXTRA_VERSION^" \    < $ldiskfs_spec \    > ../lustre-ldiskfs.spec    $RPMBUILD $targets $rpmbuildopt ../lustre-ldiskfs.spec \        --define "_tmppath /var/tmp" \        --define "_topdir $TOPDIR"    if [ "$?" != "0" ] ; then        popd        return 255    fi    if (( $DO_SRC )) ; then            $RPMBUILD -bs ../lustre-ldiskfs.spec \            --define "_tmppath /var/tmp" \            --define "_topdir $TOPDIR"        if [ "$?" != "0" ] ; then            popd            return 255        fi    fi    popd}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    local confoptions="--with-linux=${LINUX}"    if $PATCHLESS; then        confoptions="--with-linux=${LINUX} --disable-server"    fi    if [ ! "$LINUXOBJ" = "" ]; then        confoptions="$confoptions --with-linux-obj=${LINUXOBJ}"     fi        ./configure $confoptions ${CONFIGURE_FLAGS}    if [ "$?" != "0" ] ; then        local saved_config="../config.log.$(date +%s)"        cp config.log $saved_config        chmod a+r $saved_config        echo "Saved config.log is at $saved_config"        popd        return 255    fi    gen_lustre_version    # hack. Somebody move build/lustre.spec to lustre.spec for b1_6    local lustre_spec=    [ -f lustre.spec ] && lustre_spec=lustre.spec    [ -f build/lustre.spec ] && lustre_spec=build/lustre.spec    [ -f "$lustre_spec" ] && sed \        -e "s^Release: .*$^Release: $LUSTRE_EXTRA_VERSION^" \        < $lustre_spec \        > ../lustre.spec    local rpmbuildopt='-bb'    if $NORPM; then        rpmbuildopt='-bc'        echo NORPM mode. Only compiling.    fi    $RPMBUILD $targets $rpmbuildopt ../lustre.spec \        --define "_tmppath $TMPDIR" \        --define "_topdir $TOPDIR" || \        fatal 1 "Error building rpms for $BUILD_ARCHS."    popd >/dev/null    ( $(skeep_ldiskfs_rpm $TAG) ) && return    pushd lustre/ldiskfs || return 255    make dist    if [ "$?" != "0" ] ; then        popd        return 255    fi    cp lustre-ldiskfs*.tar.gz $TOPDIR/SOURCES    gen_lustre_version    local ldiskfs_spec=lustre-ldiskfs.spec    [ -f "$ldiskfs_spec" ] && sed \    -e "s^Release: .*$^Release: $LUSTRE_EXTRA_VERSION^" \    < $ldiskfs_spec \    > ../lustre-ldiskfs.spec    $RPMBUILD $targets $rpmbuildopt ../lustre-ldiskfs.spec \        --define "_tmppath /var/tmp" \        --define "_topdir $TOPDIR"    if [ "$?" != "0" ] ; then        popd

⌨️ 快捷键说明

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