lbuild
来自「lustre 1.6.5 source code」· 代码 · 共 1,694 行 · 第 1/4 页
TXT
1,694 行
#!/bin/bash# vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:#set -xTOPDIR=$PWD# CVSROOT is inherited from the environmentKERNELDIR=LINUX=LUSTRE=RELEASE=falseDO_SRC=0DOWNLOAD=1TAG=CANONICAL_TARGET=TARGET=TARGET_ARCH=$(uname -m)TARGET_ARCHS=TARGET_ARCHS_ALL=$TARGET_ARCH[ "$TARGET_ARCH" = "i686" ] && TARGET_ARCHS_ALL="i686 i586 i386"CONFIGURE_FLAGS=EXTERNAL_PATCHES=EXTRA_VERSION=LUSTRE_EXTRA_VERSION=STAGEDIR=TMPDIR=${TMPDIR:-"/var/tmp"}TIMESTAMP=REUSERPM=REUSEBUILD=NORPM=falseLDISKFSRPM=trueSKIPLDISKFSRPM="v1_4_* b1_4"SMPTYPES="smp bigsmp default ''"KERNCONFSMPTYPE=PATCHLESS=falseLINUXOBJ=REUSEDKERNELMASK=DISTRO=KERNELTREE=# patchless buildKERNELRPMSBASE=KERNELRPM=KERNELSOURCERPM=RPMSMPTYPE=KERNELRPMCONFIG=KERNELRPMRELEASE=KERNELCOMPILEDIR=# from target fileKERNEL=SERIES=CONFIG=VERSION=RHBUILD=0SUSEBUILD=0LINUX26=0SUSEBUILD=0BASE_ARCHS=BIGMEM_ARCHS=BOOT_ARCHS=JENSEN_ARCHS=SMP_ARCHS=BIGSMP_ARCHS=PSERIES64_ARCHS=UP_ARCHS=DATE=$(date)USE_DATESTAMP=1RPMBUILD=export CC=${CC:-gcc}# 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}cleanup(){ true}error(){ [ "$1" ] && echo -e "\n${0##*/}: $1"}fatal(){ cleanup error "$2" exit $1}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 <<EOFUsage: ${0##*/} [OPTION]... [-- <lustre configure options>] -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. --timestamp=TIMESTAMP Date of building lustre in format YYYYMMDDhhmmss --reuserpm=DIR Try to reuse old kernel RPMs from DIR --reusebuild=DIR Try to reuse old kernel builds from DIR --kernelrpm=DIR Path to distro kernel RPM collection --ccache Use ccache --norpm Do not build RPMs (compile only mode) --patchless Build lustre client only --distro=DISTRO Which distro using. Autodetect by default --kerneltree=KERNELTREE Directory containing dirs with Linux source tarballs referenced by target files. Dir names in format kernel version ('2.6.9', etc.) --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 downloads.lustre.org --nosrc Do not build a .src.rpm, a full kernel patch, or a patched kernel tarball. --ldiskfs Do ldiskfs RPM. Now true by default --publish 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/<target>-<arch>, and the tarball will be placed in DIR. --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 if [ -z "$LINUX" ] ; then [ "$KERNELDIR" -o "$KERNELTREE" ] || \ usage 1 "A kernel directory must be specified with --kerneldir or --kerneltree." [ -d "$KERNELDIR" -o -d "$KERNELTREE" ] || \ usage 1 "$KERNELDIR and $KERNELTREE are not a directory." 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 case $TARGET in 2.6-rhel5) CANONICAL_TARGET="rhel5" ;; 2.6-rhel4) CANONICAL_TARGET="rhel-2.6" ;; 2.6-suse) CANONICAL_TARGET="sles-2.6" ;; 2.6-sles10) CANONICAL_TARGET="sles10-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 \ | 2.6-patchless) CANONICAL_TARGET="$TARGET" ;; esac local timestampnodig=$(echo $TIMESTAMP | sed -e s/[0-9]*//g) [ "$timestampnodig" = "" ] || TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M%S") local timestamplength="${#TIMESTAMP}" if [ $timestamplength -eq 12 ]; then TIMESTAMP="${TIMESTAMP}00" elif [ $timestamplength -ne 14 ]; then TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M%S") fi RPMBUILD=$(which rpmbuild 2>/dev/null | head -1) if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then RPMBUILD=$(which rpm 2>/dev/null | head -1) if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)." fi fi if [ -n "$CCACHE" ]; then which "$CCACHE" 2>/dev/null && export CCACHE && export CC="ccache gcc" which "$DISTCC" 2>/dev/null && export DISTCC RPM_BUILD_NCPUS local bindir="/cache/build/bin" [ -d $bindir ] || mkdir -p $bindir [ -d $bindir ] && rm ${bindir}/* > /dev/null 2>&1 which "$CCACHE" 2>/dev/null && [ -d $bindir ] && ln -s `which "$CCACHE"` ${bindir}/ccache which "$CCACHE" 2>/dev/null && [ -d $bindir ] && ln -s `which "$CCACHE"` ${bindir}/cc which "$CCACHE" 2>/dev/null && [ -d $bindir ] && ln -s `which "$CCACHE"` ${bindir}/gcc [ -d $bindir ] && export PATH=$bindir:$PATH fi [ -z "$DISTRO" ] && autodetect_distro}#autodetect used Distroautodetect_distro(){ if [ -f /etc/SuSE-release ]; then DISTRO=sles10 elif [ -f /etc/redhat-release ]; then local distroname=$(head -1 /etc/redhat-release | grep -e "CentOS\|Red") if [ ! "$distroname" = "" ]; then local version=$(echo "$distroname" | sed -e s/[^0-9.]*//g | sed -e s/\\..*// ) distroname="rhel" [ "$version" = "" ] || DISTRO="${distroname}${version}" fi fi [ "$DISTRO" = "" ] && DISTRO="sles9" #default distro}uniqify(){ echo $(echo "$*" | xargs -n 1 | sort -u)}build_tarball() { local TARGET=$1 local SRPM=$2 if [ "$TARGET" = "rhel-2.6" -o "$TARGET" = "rhel-2.4" ]; then local SPEC="" if [ "$TARGET" = "rhel-2.6" ]; then SPEC=kernel-2.6.spec OLDCONFIG=nonint_oldconfig elif [ "$TARGET" = "rhel-2.4" ]; then SPEC=kernel-2.4.spec OLDCONFIG=oldconfig fi RPMTOPDIR=$(mktemp -d $KERNELDIR/rpm_XXXXXX) mkdir $RPMTOPDIR/BUILD/ rpm -ivh $KERNELDIR/$SRPM --define "_topdir $RPMTOPDIR" || \ { rm -rf $RPMTOPDIR; fatal 1 "Error installing kernel SRPM."; } $RPMBUILD -bp --nodeps --target i686 $RPMTOPDIR/SPECS/$SPEC --define "_topdir $RPMTOPDIR" pushd $RPMTOPDIR/BUILD/kernel-${lnxmaj}/linux-${lnxmaj} && { make mrproper cp configs/kernel-${lnxmaj}-i686-smp.config .config if ! make $OLDCONFIG > /dev/null; then fatal 1 "error trying to make $OLDCONFIG while building a tarball from SRPM." fi make include/linux/version.h rm -f .config cd .. tar cjf $KERNEL_FILE linux-${lnxmaj} } popd rm -rf $RPMTOPDIR fi}download_and_build_tarball() { local target=$1 local kernel_file=$2 local srpm=kernel-${lnxmaj}-${lnxrel}.src.rpm echo "Downloading http://downloads.lustre.org/public/kernels/$target/old/$srpm..." if ! wget -nv "http://downloads.lustre.org/public/kernels/$target/old/$srpm" \ -O "$KERNELDIR/$srpm" ; then fatal 1 "Could not download target $kernel_file's kernel SRPM $srpm from downloads.lustre.org." fi [ -s "$KERNELDIR/$srpm" ] || { rm -rf $KERNELDIR/$srpm fatal 1 "Could not download target $kernel_file's kernel SRPM $srpm from downloads.lustre.org." } build_tarball $target $srpm}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." [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify a kernel version." #CC was overwriten in TARGET_FILE which "$CCACHE" 2>/dev/null && export CCACHE && export CC="ccache gcc" if [ ! "$KERNELTREE" = "" ] && [ -d "$KERNELTREE" ]; then KERNELDIR="$KERNELTREE/${lnxmaj}" [ -d "$KERNELDIR" ] || mkdir "$KERNELDIR" fi if [ "$KERNELDIR" ] ; then KERNEL_FILE="$KERNELDIR/$KERNEL" if [ ! -r "$KERNEL_FILE" ] ; then # see if we have an SRPM we can build a tarball for KERNEL_SRPM=kernel-${lnxmaj}-${lnxrel}.src.rpm if [ -r "$KERNELDIR/$KERNEL_SRPM" ] ; then build_tarball $CANONICAL_TARGET $KERNEL_SRPM
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?