5 # CVSROOT is inherited from the environment
45 # Readlink is not present on some older distributions: emulate it.
49 if [ -L "$path" ]; then
50 ll="$(LC_ALL=C ls -l "$path" 2> /dev/null)" &&
64 [ "$1" ] && echo -e "\n${0##*/}: $1"
76 (( $PUBLISH )) || return 0
81 (( $RELEASE )) || return 0
86 echo -n "Available targets:"
87 for target in $TOPDIR/lustre/lustre/kernel_patches/targets/*.target ; do
88 target_file=${target##*/}
89 echo -n " ${target_file%%.target}"
97 Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
100 Specifies the CVS Root to use when pulling files from CVS. The
101 environment variable \$CVSROOT is used if this option is not
104 --external-patches=EXTERNAL_PATCHES
105 Directory similar to lustre/lustre/kernel_patches/ that lbuild should
106 look for seres and config files in before looking in the lustre
109 --extraversion=EXTRAVERSION
110 Text to use for the rpm release and kernel extraversion.
112 --kerneldir=KERNELDIR
113 Directory containing Linux source tarballs referenced by target
117 Path to an existing lustre source tarball to use instead of
121 Do not build a .src.rpm, a full kernel patch, or a patched kernel
125 Publish the packages, patches, and tarballs on the ftp server.
128 Specifies that the files generated do not include timestamps, and
129 that this is an official release.
132 A CVS branch/tag name to build from when pulling from CVS.
135 The name of the target to build. The available targets are listed
138 --target-archs=TARGET_ARCHS
139 A (space delimited) list of architectures to build. By default,
140 all of the archs supported by the TARGET will be built, in
141 addition to a .src.rpm. This option can limit those, for machines
142 that can only build certain archs or if you only want a certain
143 arch built (for testing, or a one-off kernel).
145 Also note that by using a non-"base" arch (eg, i386) only kernels
146 will be built - there will be no lustre-lite-utils package.
149 Prevents the datestamp flag (-D) from being passed to cvs for
150 checkouts. This is a workaround for a problem encountered when
151 using lbuild with tinderbox.
162 if [ "$LUSTRE" ] ; then
163 [ -r "$LUSTRE" ] || \
164 usage 1 "Could not find Lustre source tarball '$LUSTRE'."
167 usage 1 "Either specify a CVS Root with -d, or a Lustre source tarball with --lustre."
169 usage 1 "A branch/tag name must be specified with --tag when not building from a tarball."
172 [ "$KERNELDIR" ] || \
173 usage 1 "A kernel directory must be specified with --kerneldir."
175 [ -d "$KERNELDIR" ] || \
176 usage 1 "$KERNELDIR is not a directory."
178 if ! (( $RELEASE )) ; then
180 usage 1 "When building a snapshot, a tag name must be used."
183 TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M")
185 [ "$TARGET" ] || usage 1 "A target must be specified with --target."
186 # TARGET_FILE="$TOPDIR/lustre/kernel_patches/targets/$TARGET.target"
187 # [ -r "$TARGET_FILE" ] || \
188 # usage 1 "Target '$TARGET' was not found."
190 RPMBUILD=$(which rpmbuild 2>/dev/null | head -1)
191 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
192 RPMBUILD=$(which rpm 2>/dev/null | head -1)
193 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
194 usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)."
201 echo $(echo "$*" | xargs -n 1 | sort -u)
206 EXTRA_VERSION_save="$EXTRA_VERSION"
207 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
208 TARGET_FILE="$patchesdir/targets/$TARGET.target"
209 [ -r "$TARGET_FILE" ] && break
211 [ -r "$TARGET_FILE" ] || \
212 fatal 1 "Target $TARGET was not found."
214 echo "Loading target config file $TARGET.target..."
218 [ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel."
219 # [ "$SERIES" ] || fatal 1 "Target $TARGET did not specify a kernel patch series."
220 # [ "$CONFIG" ] || fatal 1 "Target $TARGET did not specify a kernel config."
221 [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify a kernel version."
223 if [ "$KERNELDIR" ] ; then
224 KERNEL_FILE="$KERNELDIR/$KERNEL"
225 [ -r "$KERNELDIR/$KERNEL" ] || \
226 fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR."
229 if [ "$SERIES" ] ; then
230 for series in $SERIES ; do
231 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
232 [ -r "$patchesdir/series/$series" ] && continue 2
234 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."
238 CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/$CONFIG"
239 [ -r "$CONFIG_FILE" ] || \
240 fatal 1 "Target $TARGET's config file $CONFIG missing from $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/."
242 if [ "$EXTRA_VERSION_save" ] ; then
243 EXTRA_VERSION="$EXTRA_VERSION_save"
244 elif ! (( $RELEASE )) ; then
245 #remove the @VERSION@ (lustre version)
246 EXTRA_VERSION=$(echo $EXTRA_VERSION | sed -e "s/\(.*_lustre\)\..*/\1/")
247 EXTRA_VERSION="${EXTRA_VERSION}-${TAG}.${TIMESTAMP}"
249 # EXTRA_VERSION=${EXTRA_VERSION//-/_}
251 ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $BIGSMP_ARCHS $PSERIES64_ARCHS $UP_ARCHS"
254 for arch in $(uniqify "$ALL_ARCHS") ; do
255 if [ -z "$TARGET_ARCHS" ] || echo "$TARGET_ARCHS" | grep "$arch" >/dev/null 2>/dev/null ; then
256 BUILD_ARCHS="$BUILD_ARCHS $arch"
259 [ "$BUILD_ARCHS" ] || usage 1 "No available target archs to build."
260 echo "Building for: $BUILD_ARCHS"
267 fatal 1 "tarflags(): File name argument missing."
276 fatal 1 "tarflags(): Unrecognized tar extension in file: $1"
283 echo "Untarring ${1##*/}..."
284 tar $(tarflags "$1") "$1"
289 DIRNAME="lustre-$TAG-$TIMESTAMP"
290 if [ "$LUSTRE" ] ; then
292 [ -d lustre ] || ln -sf lustre* lustre
294 if [ "$USE_DATESTAMP" ]; then
295 DATESTAMP="-D '$DATE'"
300 cvs -d "$CVSROOT" -qz3 co $DATESTAMP -d "$DIRNAME" lustre || \
301 fatal 1 "There was an error checking out toplevel Lustre from CVS."
302 pushd "$DIRNAME" > /dev/null
303 ./lustrecvs "$TAG" || \
304 fatal 1 "There was an error checking out Lustre/Portals/Build from CVS."
305 echo "Creating lustre tarball..."
306 sh autogen.sh || fatal 1 "There was an error running autogen.sh."
307 ./configure --disable-{modules,utils,liblustre,tests,doc} || \
308 fatal 1 "There was an error running ./configure to create makefiles."
309 make dist || fatal 1 "There was an error running 'make dist'."
311 fname=`basename $DIRNAME/lustre-*.tar.gz`
312 cp $DIRNAME/$fname . || fatal 1 "There was an error copying lustre tarball."
314 ln -sf "$DIRNAME" lustre
321 [ -d linux ] || ln -sf linux* linux
326 [ "$SERIES" ] || return 0
327 FULL_PATCH="$PWD/lustre-kernel-${TARGET}-${EXTRA_VERSION}.patch"
328 [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH"
329 pushd linux >/dev/null
330 for series in $SERIES ; do
331 echo -n "Applying series $series:"
332 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
333 [ -r "$patchesdir/series/$series" ] || continue
334 SERIES_FILE="$patchesdir/series/$series"
335 for patch in $(<"$SERIES_FILE") ; do
337 PATCH_FILE="$patchesdir/patches/$patch"
338 [ -r "$PATCH_FILE" ] || \
339 fatal 1 "Patch $patch does not exist in Lustre tree."
340 cat "$PATCH_FILE" >> "$FULL_PATCH" || \
341 fatal 1 "Error adding patch $patch to full patch."
342 patch -s -p1 < "$PATCH_FILE" || fatal 1 "Error applying patch $patch."
349 echo "Full patch has been saved in ${FULL_PATCH##*/}."
350 echo "Replacing .config files..."
351 [ -d linux/configs ] || mkdir linux/configs || \
352 fatal 1 "Error creating configs directory."
353 rm -f linux/configs/*
355 for patchesdir in "$EXTERNAL_PATCHES" "lustre/lustre/kernel_patches" ; do
356 [ "$patchesdir" ] && \
357 cp -v $patchesdir/kernel_configs/kernel-${VERSION}-${TARGET}*.config linux/configs/ >/dev/null && copysuccess=1
359 [ "$copysuccess" = "1" ] || \
360 fatal 1 "Error copying in kernel configs."
365 TARBALL="$(readlink linux)-$EXTRA_VERSION.tar.gz"
366 echo "Creating patched linux tarball $TARBALL..."
367 tar zcf "$TARBALL" "$(readlink linux)" \
368 --exclude "CVS" --exclude ".cvsignore" || \
369 --exclude "*.orig" --exclude "*~" --exclude "*.rej" || \
370 fatal 1 "Error creating patched Linux tarball."
375 [ -d linux ] || return 0
376 echo "Cleaning linux..."
377 [ -L linux ] && rm -rf $(readlink linux)
384 ENABLE_INIT_SCRIPTS=""
386 -e "s^@BASE_ARCHS@^$BASE_ARCHS^g" \
387 -e "s^@BIGMEM_ARCHS@^$BIGMEM_ARCHS^g" \
388 -e "s^@BIGSMP_ARCHS@^$BIGSMP_ARCHS^g" \
389 -e "s^@BOOT_ARCHS@^$BOOT_ARCHS^g" \
390 -e "s^@CONFIGURE_FLAGS@^$CONFIGURE_FLAGS^g" \
391 -e "s^@ENABLE_INIT_SCRIPTS@^$ENABLE_INIT_SCRIPTS^g" \
392 -e "s^@JENSEN_ARCHS@^$BOOT_ARCHS^g" \
393 -e "s^@KERNEL_EXTRA_VERSION@^$EXTRA_VERSION^g" \
394 -e "s^@KERNEL_RELEASE@^${EXTRA_VERSION//-/_}^g" \
395 -e "s^@KERNEL_SOURCE@^$KERNEL^g" \
396 -e "s^@KERNEL_VERSION@^$VERSION^g" \
397 -e "s^@LINUX26@^$LINUX26^g" \
398 -e "s^@LUSTRE_SOURCE@^${LUSTRE##*/}^g" \
399 -e "s^@LUSTRE_TARGET@^$TARGET^g" \
400 -e "s^@PSERIES64_ARCHS@^$PSERIES64_ARCHS^g" \
401 -e "s^@RHBUILD@^$RHBUILD^g" \
402 -e "s^@SMP_ARCHS@^$SMP_ARCHS^g" \
403 -e "s^@SUSEBUILD@^$SUSEBUILD^g" \
404 -e "s^@SUSEBUILD@^$SUSEBUILD^g" \
405 -e "s^@UP_ARCHS@^$UP_ARCHS^g" \
406 < $TOPDIR/lustre/build/lustre-kernel-2.4.spec.in \
407 > lustre-kernel-2.4.spec
408 [ -d SRPMS ] || mkdir SRPMS
409 [ -d RPMS ] || mkdir RPMS
410 [ -d BUILD ] || mkdir BUILD
411 [ -d SOURCES ] || mkdir SOURCES
412 for script in linux-{rhconfig.h,merge-config.awk,merge-modules.awk} \
413 suse-{functions.sh,post.sh,postun.sh,trigger-script.sh.in} \
414 sles8-{pre,post,postun,update_{INITRD_MODULES,rcfile_setting}}.sh ; do
415 cp $TOPDIR/lustre/build/$script SOURCES
417 cp "$LUSTRE" "$KERNEL_FILE" SOURCES
418 if [ "$EXTERNAL_PATCHES" -a -d "$EXTERNAL_PATCHES" ] ; then
419 tar zcf SOURCES/external-patches.tar.gz -C "$EXTERNAL_PATCHES" series targets patches kernel_configs
421 touch SOURCES/external-patches.tar.gz
427 [ -d lustre ] || return 0
428 echo "Cleaning lustre..."
429 [ -L lustre ] && rm -rf $(readlink lustre)
435 echo "Building rpms for: $BUILD_ARCHS..."
437 for arch in $BUILD_ARCHS ; do
438 targets="--target $arch $targets"
441 $RPMBUILD $targets -bb lustre-kernel-2.4.spec \
442 --define "_topdir $TOPDIR" || \
443 fatal 1 "Error building rpms for $arch."
445 if false && (( $DO_SRC )) ; then
446 $RPMBUILD -bs lustre-kernel-2.4.spec \
447 --define "_topdir $TOPDIR" || \
448 fatal 1 "Error building .src.rpm."
454 publishing || return 0
457 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
459 options=$(getopt -o d:D:h -l external-patches:,extraversion:,kerneldir:,lustre:,nosrc,publish,release,tag:,target:,target-archs:,disable-datestamp -- "$@")
461 eval set -- "$options"
529 usage 1 "Unrecognized option: $1"
539 if (( $DO_SRC )) ; then
546 # prep_build needs the .spec.in from the lustre source