5 # CVSROOT is inherited from the environment
49 [ "$1" ] && echo -e "\n${0##*/}: $1"
61 (( $PUBLISH )) || return 0
66 (( $RELEASE )) || return 0
71 echo -n "Available targets:"
72 for target in $TOPDIR/lustre/lustre/kernel_patches/targets/*.target ; do
73 target_file=${target##*/}
74 echo -n " ${target_file%%.target}"
82 Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
85 Specifies the CVS Root to use when pulling files from CVS. The
86 environment variable \$CVSROOT is used if this option is not
89 --external-patches=EXTERNAL_PATCHES
90 Directory similar to lustre/lustre/kernel_patches/ that lbuild should
91 look for seres and config files in before looking in the lustre
94 --extraversion=EXTRAVERSION
95 Text to use for the rpm release and kernel extraversion.
98 Directory containing Linux source tarballs referenced by target
102 Path to an existing lustre source tarball to use instead of
106 Do not build a .src.rpm, a full kernel patch, or a patched kernel
110 Publish the packages, patches, and tarballs on the ftp server.
113 Specifies that the files generated do not include timestamps, and
114 that this is an official release.
117 A CVS branch/tag name to build from when pulling from CVS.
120 The name of the target to build. The available targets are listed
123 --target-archs=TARGET_ARCHS
124 A (space delimited) list of architectures to build. By default,
125 all of the archs supported by the TARGET will be built, in
126 addition to a .src.rpm. This option can limit those, for machines
127 that can only build certain archs or if you only want a certain
128 arch built (for testing, or a one-off kernel).
130 Also note that by using a non-"base" arch (eg, i386) only kernels
131 will be built - there will be no lustre-lite-utils package.
134 Prevents the datestamp flag (-D) from being passed to cvs for
135 checkouts. This is a workaround for a problem encountered when
136 using lbuild with tinderbox.
147 if [ "$LUSTRE" ] ; then
148 [ -r "$LUSTRE" ] || \
149 usage 1 "Could not find Lustre source tarball '$LUSTRE'."
152 usage 1 "Either specify a CVS Root with -d, or a Lustre source tarball with --lustre."
154 usage 1 "A branch/tag name must be specified with --tag when not building from a tarball."
157 [ "$KERNELDIR" ] || \
158 usage 1 "A kernel directory must be specified with --kerneldir."
160 [ -d "$KERNELDIR" ] || \
161 usage 1 "$KERNELDIR is not a directory."
163 if ! (( $RELEASE )) ; then
165 usage 1 "When building a snapshot, a tag name must be used."
168 TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M")
170 [ "$TARGET" ] || usage 1 "A target must be specified with --target."
171 # TARGET_FILE="$TOPDIR/lustre/kernel_patches/targets/$TARGET.target"
172 # [ -r "$TARGET_FILE" ] || \
173 # usage 1 "Target '$TARGET' was not found."
175 RPMBUILD=$(which rpmbuild 2>/dev/null | head -1)
176 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
177 RPMBUILD=$(which rpm 2>/dev/null | head -1)
178 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
179 usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)."
186 echo $(echo "$*" | xargs -n 1 | sort -u)
191 EXTRA_VERSION_save="$EXTRA_VERSION"
192 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
193 TARGET_FILE="$patchesdir/targets/$TARGET.target"
194 [ -r "$TARGET_FILE" ] && break
196 [ -r "$TARGET_FILE" ] || \
197 fatal 1 "Target $TARGET was not found."
199 echo "Loading target config file $TARGET.target..."
203 [ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel."
204 # [ "$SERIES" ] || fatal 1 "Target $TARGET did not specify a kernel patch series."
205 # [ "$CONFIG" ] || fatal 1 "Target $TARGET did not specify a kernel config."
206 [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify a kernel version."
208 if [ "$KERNELDIR" ] ; then
209 KERNEL_FILE="$KERNELDIR/$KERNEL"
210 [ -r "$KERNELDIR/$KERNEL" ] || \
211 fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR."
214 if [ "$SERIES" ] ; then
215 for series in $SERIES ; do
216 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
217 [ -r "$patchesdir/series/$series" ] && continue 2
219 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."
223 CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/$CONFIG"
224 [ -r "$CONFIG_FILE" ] || \
225 fatal 1 "Target $TARGET's config file $CONFIG missing from $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/."
227 if [ "$EXTRA_VERSION_save" ] ; then
228 EXTRA_VERSION="$EXTRA_VERSION_save"
229 elif ! (( $RELEASE )) ; then
230 EXTRA_VERSION="${EXTRA_VERSION}-${TAG}.${TIMESTAMP}"
232 # EXTRA_VERSION=${EXTRA_VERSION//-/_}
234 ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $BIGSMP_ARCHS $UP_ARCHS"
237 for arch in $(uniqify "$ALL_ARCHS") ; do
238 if [ -z "$TARGET_ARCHS" ] || echo "$TARGET_ARCHS" | grep "$arch" >/dev/null 2>/dev/null ; then
239 BUILD_ARCHS="$BUILD_ARCHS $arch"
242 [ "$BUILD_ARCHS" ] || usage 1 "No available target archs to build."
243 echo "Building for: $BUILD_ARCHS"
250 fatal 1 "tarflags(): File name argument missing."
259 fatal 1 "tarflags(): Unrecognized tar extension in file: $1"
266 echo "Untarring ${1##*/}..."
267 tar $(tarflags "$1") "$1"
272 DIRNAME="lustre-$TAG-$TIMESTAMP"
273 if [ "$LUSTRE" ] ; then
275 [ -d lustre ] || ln -sf lustre* lustre
277 if [ "$USE_DATESTAMP" ]; then
278 DATESTAMP="-D '$DATE'"
283 cvs -d "$CVSROOT" -qz3 co $DATESTAMP -r "$TAG" -d "$DIRNAME" lustre || \
284 fatal 1 "There was an error checking out Lustre from CVS."
285 echo "Creating lustre tarball..."
286 tar zcf "$DIRNAME.tar.gz" "$DIRNAME" \
287 --exclude "CVS" --exclude "*~" --exclude ".cvsignore" || \
288 fatal 1 "Could not create Lustre tarball."
289 LUSTRE="$PWD/$DIRNAME.tar.gz"
290 ln -sf "$DIRNAME" lustre
297 [ -d linux ] || ln -sf linux* linux
302 [ "$SERIES" ] || return 0
303 FULL_PATCH="$PWD/lustre-kernel-${TARGET}-${EXTRA_VERSION}.patch"
304 [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH"
305 pushd linux >/dev/null
306 for series in $SERIES ; do
307 echo -n "Applying series $series:"
308 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
309 [ -r "$patchesdir/series/$series" ] || continue
310 SERIES_FILE="$patchesdir/series/$series"
311 for patch in $(<"$SERIES_FILE") ; do
313 PATCH_FILE="$patchesdir/patches/$patch"
314 [ -r "$PATCH_FILE" ] || \
315 fatal 1 "Patch $patch does not exist in Lustre tree."
316 cat "$PATCH_FILE" >> "$FULL_PATCH" || \
317 fatal 1 "Error adding patch $patch to full patch."
318 patch -s -p1 < "$PATCH_FILE" || fatal 1 "Error applying patch $patch."
325 echo "Full patch has been saved in ${FULL_PATCH##*/}."
326 echo "Replacing .config files..."
327 [ -d linux/configs ] || mkdir linux/configs || \
328 fatal 1 "Error creating configs directory."
329 rm -f linux/configs/*
331 for patchesdir in "$EXTERNAL_PATCHES" "lustre/lustre/kernel_patches" ; do
332 cp -v $patchesdir/kernel_configs/kernel-${VERSION}-${TARGET}*.config linux/configs/ >/dev/null && copysuccess=1
334 [ "$copysuccess" = "1" ] || \
335 fatal 1 "Error copying in kernel configs."
340 TARBALL="$(readlink linux)-$EXTRA_VERSION.tar.gz"
341 echo "Creating patched linux tarball $TARBALL..."
342 tar zcf "$TARBALL" "$(readlink linux)" \
343 --exclude "CVS" --exclude ".cvsignore" || \
344 --exclude "*.orig" --exclude "*~" --exclude "*.rej" || \
345 fatal 1 "Error creating patched Linux tarball."
350 [ -d linux ] || return 0
351 echo "Cleaning linux..."
352 [ -L linux ] && rm -rf $(readlink linux)
359 if [ -f /etc/init.d/functions -a -f /etc/sysconfig/network ] ; then
360 ENABLE_INIT_SCRIPTS=""
362 ENABLE_INIT_SCRIPTS="# "
365 -e "s^@BASE_ARCHS@^$BASE_ARCHS^g" \
366 -e "s^@BIGMEM_ARCHS@^$BIGMEM_ARCHS^g" \
367 -e "s^@BIGSMP_ARCHS@^$BIGSMP_ARCHS^g" \
368 -e "s^@BOOT_ARCHS@^$BOOT_ARCHS^g" \
369 -e "s^@CONFIGURE_FLAGS@^$CONFIGURE_FLAGS^g" \
370 -e "s^@ENABLE_INIT_SCRIPTS@^$ENABLE_INIT_SCRIPTS^g" \
371 -e "s^@JENSEN_ARCHS@^$BOOT_ARCHS^g" \
372 -e "s^@KERNEL_EXTRA_VERSION@^$EXTRA_VERSION^g" \
373 -e "s^@KERNEL_RELEASE@^${EXTRA_VERSION//-/_}^g" \
374 -e "s^@KERNEL_SOURCE@^$KERNEL^g" \
375 -e "s^@KERNEL_VERSION@^$VERSION^g" \
376 -e "s^@LINUX26@^$LINUX26^g" \
377 -e "s^@LUSTRE_SOURCE@^${LUSTRE##*/}^g" \
378 -e "s^@LUSTRE_TARGET@^$TARGET^g" \
379 -e "s^@RHBUILD@^$RHBUILD^g" \
380 -e "s^@SMP_ARCHS@^$SMP_ARCHS^g" \
381 -e "s^@SUSEBUILD@^$SUSEBUILD^g" \
382 -e "s^@SUSEBUILD@^$SUSEBUILD^g" \
383 -e "s^@UP_ARCHS@^$UP_ARCHS^g" \
384 < $TOPDIR/lustre/build/lustre-kernel-2.4.spec.in \
385 > lustre-kernel-2.4.spec
386 [ -d SRPMS ] || mkdir SRPMS
387 [ -d RPMS ] || mkdir RPMS
388 [ -d BUILD ] || mkdir BUILD
389 [ -d SOURCES ] || mkdir SOURCES
390 for script in linux-{rhconfig.h,merge-config.awk,merge-modules.awk} \
391 suse-{functions.sh,post.sh,postun.sh,trigger-script.sh.in} ; do
392 cp $TOPDIR/lustre/build/$script SOURCES
394 cp "$LUSTRE" "$KERNEL_FILE" SOURCES
395 if [ "$EXTERNAL_PATCHES" -a -d "$EXTERNAL_PATCHES" ] ; then
396 tar zcf SOURCES/external-patches.tar.gz -C "$EXTERNAL_PATCHES" series targets patches kernel_configs
398 touch SOURCES/external-patches.tar.gz
404 [ -d lustre ] || return 0
405 echo "Cleaning lustre..."
406 [ -L lustre ] && rm -rf $(readlink lustre)
412 echo "Building rpms for: $BUILD_ARCHS..."
414 for arch in $BUILD_ARCHS ; do
415 targets="--target $arch $targets"
418 $RPMBUILD $targets -bb lustre-kernel-2.4.spec \
419 --define "_topdir $TOPDIR" || \
420 fatal 1 "Error building rpms for $arch."
422 if (( $DO_SRC )) ; then
423 $RPMBUILD -bs lustre-kernel-2.4.spec \
424 --define "_topdir $TOPDIR" || \
425 fatal 1 "Error building .src.rpm."
431 publishing || return 0
434 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
436 options=$(getopt -o d:D:h -l external-patches:,extraversion:,kerneldir:,lustre:,nosrc,publish,release,tag:,target:,target-archs:,disable-datestamp -- "$@")
438 eval set -- "$options"
506 usage 1 "Unrecognized option: $1"
516 if (( $DO_SRC )) ; then
523 # prep_build needs the .spec.in from the lustre source