5 # CVSROOT is inherited from the environment
52 [ "$1" ] && echo -e "\n${0##*/}: $1"
64 (( $PUBLISH )) || return 0
69 (( $RELEASE )) || return 0
74 echo -n "Available targets:"
75 for target in $TOPDIR/lustre/lustre/kernel_patches/targets/*.target ; do
76 target_file=${target##*/}
77 echo -n " ${target_file%%.target}"
85 Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
88 Specifies the CVS Root to use when pulling files from CVS. The
89 environment variable \$CVSROOT is used if this option is not
92 --external-patches=EXTERNAL_PATCHES
93 Directory similar to lustre/lustre/kernel_patches/ that lbuild should
94 look for seres and config files in before looking in the lustre
97 --extraversion=EXTRAVERSION
98 Text to use for the rpm release and kernel extraversion.
100 --kerneldir=KERNELDIR
101 Directory containing Linux source tarballs referenced by target
105 Path to an existing lustre source tarball to use instead of
109 Do not build a .src.rpm, a full kernel patch, or a patched kernel
113 Publish the packages, patches, and tarballs on the ftp server.
116 Specifies that the files generated do not include timestamps, and
117 that this is an official release.
120 A CVS branch/tag name to build from when pulling from CVS.
123 The name of the target to build. The available targets are listed
126 --target-archs=TARGET_ARCHS
127 A (space delimited) list of architectures to build. By default,
128 all of the archs supported by the TARGET will be built, in
129 addition to a .src.rpm. This option can limit those, for machines
130 that can only build certain archs or if you only want a certain
131 arch built (for testing, or a one-off kernel).
133 Also note that by using a non-"base" arch (eg, i386) only kernels
134 will be built - there will be no lustre-lite-utils package.
137 Prevents the datestamp flag (-D) from being passed to cvs for
138 checkouts. This is a workaround for a problem encountered when
139 using lbuild with tinderbox.
150 if [ "$LUSTRE" ] ; then
151 [ -r "$LUSTRE" ] || \
152 usage 1 "Could not find Lustre source tarball '$LUSTRE'."
155 usage 1 "Either specify a CVS Root with -d, or a Lustre source tarball with --lustre."
157 usage 1 "A branch/tag name must be specified with --tag when not building from a tarball."
160 [ "$KERNELDIR" ] || \
161 usage 1 "A kernel directory must be specified with --kerneldir."
163 [ -d "$KERNELDIR" ] || \
164 usage 1 "$KERNELDIR is not a directory."
166 if ! (( $RELEASE )) ; then
168 usage 1 "When building a snapshot, a tag name must be used."
171 TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M")
173 [ "$TARGET" ] || usage 1 "A target must be specified with --target."
174 # TARGET_FILE="$TOPDIR/lustre/kernel_patches/targets/$TARGET.target"
175 # [ -r "$TARGET_FILE" ] || \
176 # usage 1 "Target '$TARGET' was not found."
178 RPMBUILD=$(which rpmbuild 2>/dev/null | head -1)
179 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
180 RPMBUILD=$(which rpm 2>/dev/null | head -1)
181 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
182 usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)."
189 echo $(echo "$*" | xargs -n 1 | sort -u)
194 EXTRA_VERSION_save="$EXTRA_VERSION"
195 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
196 TARGET_FILE="$patchesdir/targets/$TARGET.target"
197 [ -r "$TARGET_FILE" ] && break
199 [ -r "$TARGET_FILE" ] || \
200 fatal 1 "Target $TARGET was not found."
202 echo "Loading target config file $TARGET.target..."
206 [ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel."
207 # [ "$SERIES" ] || fatal 1 "Target $TARGET did not specify a kernel patch series."
208 # [ "$CONFIG" ] || fatal 1 "Target $TARGET did not specify a kernel config."
209 [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify a kernel version."
211 if [ "$KERNELDIR" ] ; then
212 KERNEL_FILE="$KERNELDIR/$KERNEL"
213 [ -r "$KERNELDIR/$KERNEL" ] || \
214 fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR."
217 if [ "$SERIES" ] ; then
218 for series in $SERIES ; do
219 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
220 [ -r "$patchesdir/series/$series" ] && continue 2
222 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."
226 CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/$CONFIG"
227 [ -r "$CONFIG_FILE" ] || \
228 fatal 1 "Target $TARGET's config file $CONFIG missing from $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/."
230 if [ "$EXTRA_VERSION_save" ] ; then
231 EXTRA_VERSION="$EXTRA_VERSION_save"
232 elif ! (( $RELEASE )) ; then
233 EXTRA_VERSION="${EXTRA_VERSION}-${TAG}.${TIMESTAMP}"
235 # EXTRA_VERSION=${EXTRA_VERSION//-/_}
237 ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $BIGSMP_ARCHS $PSERIES64_ARCHS $UP_ARCHS"
240 for arch in $(uniqify "$ALL_ARCHS") ; do
241 if [ -z "$TARGET_ARCHS" ] || echo "$TARGET_ARCHS" | grep "$arch" >/dev/null 2>/dev/null ; then
242 BUILD_ARCHS="$BUILD_ARCHS $arch"
245 [ "$BUILD_ARCHS" ] || usage 1 "No available target archs to build."
246 echo "Building for: $BUILD_ARCHS"
253 fatal 1 "tarflags(): File name argument missing."
262 fatal 1 "tarflags(): Unrecognized tar extension in file: $1"
269 echo "Untarring ${1##*/}..."
270 tar $(tarflags "$1") "$1"
275 DIRNAME="lustre-$TAG-$TIMESTAMP"
276 if [ "$LUSTRE" ] ; then
278 [ -d lustre ] || ln -sf lustre* lustre
280 if [ "$USE_DATESTAMP" ]; then
281 DATESTAMP="-D '$DATE'"
286 cvs -d "$CVSROOT" -qz3 co $DATESTAMP -d "$DIRNAME" lustre || \
287 fatal 1 "There was an error checking out toplevel Lustre from CVS."
288 pushd "$DIRNAME" > /dev/null
289 ./lustrecvs "$TAG" || \
290 fatal 1 "There was an error checking out Lustre/Portals/Build from CVS."
291 echo "Creating lustre tarball..."
292 sh autogen.sh || fatal 1 "There was an error running autogen.sh."
293 ./configure --disable-{modules,utils,liblustre,tests,doc} || \
294 fatal 1 "There was an error running ./configure to create makefiles."
295 make dist || fatal 1 "There was an error running 'make dist'."
297 fname=`basename $DIRNAME/lustre-*.tar.gz`
298 cp $DIRNAME/$fname . || fatal 1 "There was an error copying lustre tarball."
300 ln -sf "$DIRNAME" lustre
307 [ -d linux ] || ln -sf linux* linux
312 [ "$SERIES" ] || return 0
313 FULL_PATCH="$PWD/lustre-kernel-${TARGET}-${EXTRA_VERSION}.patch"
314 [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH"
315 pushd linux >/dev/null
316 for series in $SERIES ; do
317 echo -n "Applying series $series:"
318 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
319 [ -r "$patchesdir/series/$series" ] || continue
320 SERIES_FILE="$patchesdir/series/$series"
321 for patch in $(<"$SERIES_FILE") ; do
323 PATCH_FILE="$patchesdir/patches/$patch"
324 [ -r "$PATCH_FILE" ] || \
325 fatal 1 "Patch $patch does not exist in Lustre tree."
326 cat "$PATCH_FILE" >> "$FULL_PATCH" || \
327 fatal 1 "Error adding patch $patch to full patch."
328 patch -s -p1 < "$PATCH_FILE" || fatal 1 "Error applying patch $patch."
335 echo "Full patch has been saved in ${FULL_PATCH##*/}."
336 echo "Replacing .config files..."
337 [ -d linux/configs ] || mkdir linux/configs || \
338 fatal 1 "Error creating configs directory."
339 rm -f linux/configs/*
341 for patchesdir in "$EXTERNAL_PATCHES" "lustre/lustre/kernel_patches" ; do
342 [ "$patchesdir" ] && \
343 cp -v $patchesdir/kernel_configs/kernel-${VERSION}-${TARGET}*.config linux/configs/ >/dev/null && copysuccess=1
345 [ "$copysuccess" = "1" ] || \
346 fatal 1 "Error copying in kernel configs."
351 TARBALL="$(readlink linux)-$EXTRA_VERSION.tar.gz"
352 echo "Creating patched linux tarball $TARBALL..."
353 tar zcf "$TARBALL" "$(readlink linux)" \
354 --exclude "CVS" --exclude ".cvsignore" || \
355 --exclude "*.orig" --exclude "*~" --exclude "*.rej" || \
356 fatal 1 "Error creating patched Linux tarball."
361 [ -d linux ] || return 0
362 echo "Cleaning linux..."
363 [ -L linux ] && rm -rf $(readlink linux)
370 if [ -f /etc/init.d/functions -a -f /etc/sysconfig/network ] ; then
371 ENABLE_INIT_SCRIPTS=""
373 ENABLE_INIT_SCRIPTS="# "
376 -e "s^@BASE_ARCHS@^$BASE_ARCHS^g" \
377 -e "s^@BIGMEM_ARCHS@^$BIGMEM_ARCHS^g" \
378 -e "s^@BIGSMP_ARCHS@^$BIGSMP_ARCHS^g" \
379 -e "s^@BOOT_ARCHS@^$BOOT_ARCHS^g" \
380 -e "s^@CONFIGURE_FLAGS@^$CONFIGURE_FLAGS^g" \
381 -e "s^@ENABLE_INIT_SCRIPTS@^$ENABLE_INIT_SCRIPTS^g" \
382 -e "s^@JENSEN_ARCHS@^$BOOT_ARCHS^g" \
383 -e "s^@KERNEL_EXTRA_VERSION@^$EXTRA_VERSION^g" \
384 -e "s^@KERNEL_RELEASE@^${EXTRA_VERSION//-/_}^g" \
385 -e "s^@KERNEL_SOURCE@^$KERNEL^g" \
386 -e "s^@KERNEL_VERSION@^$VERSION^g" \
387 -e "s^@LINUX26@^$LINUX26^g" \
388 -e "s^@LUSTRE_SOURCE@^${LUSTRE##*/}^g" \
389 -e "s^@LUSTRE_TARGET@^$TARGET^g" \
390 -e "s^@PSERIES64_ARCHS@^$PSERIES64_ARCHS^g" \
391 -e "s^@RHBUILD@^$RHBUILD^g" \
392 -e "s^@SMP_ARCHS@^$SMP_ARCHS^g" \
393 -e "s^@SUSEBUILD@^$SUSEBUILD^g" \
394 -e "s^@SUSEBUILD@^$SUSEBUILD^g" \
395 -e "s^@UP_ARCHS@^$UP_ARCHS^g" \
396 < $TOPDIR/lustre/build/lustre-kernel-2.4.spec.in \
397 > lustre-kernel-2.4.spec
398 [ -d SRPMS ] || mkdir SRPMS
399 [ -d RPMS ] || mkdir RPMS
400 [ -d BUILD ] || mkdir BUILD
401 [ -d SOURCES ] || mkdir SOURCES
402 for script in linux-{rhconfig.h,merge-config.awk,merge-modules.awk} \
403 suse-{functions.sh,post.sh,postun.sh,trigger-script.sh.in} ; do
404 cp $TOPDIR/lustre/build/$script SOURCES
406 cp "$LUSTRE" "$KERNEL_FILE" SOURCES
407 if [ "$EXTERNAL_PATCHES" -a -d "$EXTERNAL_PATCHES" ] ; then
408 tar zcf SOURCES/external-patches.tar.gz -C "$EXTERNAL_PATCHES" series targets patches kernel_configs
410 touch SOURCES/external-patches.tar.gz
416 [ -d lustre ] || return 0
417 echo "Cleaning lustre..."
418 [ -L lustre ] && rm -rf $(readlink lustre)
424 echo "Building rpms for: $BUILD_ARCHS..."
426 for arch in $BUILD_ARCHS ; do
427 targets="--target $arch $targets"
430 $RPMBUILD $targets -bb lustre-kernel-2.4.spec \
431 --define "_topdir $TOPDIR" || \
432 fatal 1 "Error building rpms for $arch."
434 if (( $DO_SRC )) ; then
435 $RPMBUILD -bs lustre-kernel-2.4.spec \
436 --define "_topdir $TOPDIR" || \
437 fatal 1 "Error building .src.rpm."
443 publishing || return 0
446 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
448 options=$(getopt -o d:D:h -l external-patches:,extraversion:,kerneldir:,lustre:,nosrc,publish,release,tag:,target:,target-archs:,disable-datestamp -- "$@")
450 eval set -- "$options"
518 usage 1 "Unrecognized option: $1"
528 if (( $DO_SRC )) ; then
535 # prep_build needs the .spec.in from the lustre source