5 # CVSROOT is inherited from the environment
44 [ "$2" ] && echo "${0##*/}: $2"
50 (( $PUBLISH )) || return 0
55 (( $RELEASE )) || return 0
60 echo -n "Available targets:"
61 for target in $TOPDIR/lustre/kernel_patches/targets/*.target ; do
62 target_file=${target##*/}
63 echo -n " ${target_file%%.target}"
71 Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
74 Specifies the CVS Root to use when pulling files from CVS. The
75 environment variable \$CVSROOT is used if this option is not
78 --extraversion=EXTRAVERSION
79 Text to use for the rpm release and kernel extraversion.
82 Directory containing Linux source tarballs referenced by target
86 Path to an existing lustre source tarball to use instead of
90 Do not build a .src.rpm, a full kernel patch, or a patched kernel
94 Publish the packages, patches, and tarballs on the ftp server.
97 Specifies that the files generated do not include timestamps, and
98 that this is an official release.
101 A CVS branch/tag name to build from when pulling from CVS.
104 The name of the target to build. The available targets are listed
107 --target-archs=TARGET_ARCHS
108 A (space delimited) list of architectures to build. By default,
109 all of the archs supported by the TARGET will be built, in
110 addition to a .src.rpm. This option can limit those, for machines
111 that can only build certain archs or if you only want a certain
112 arch built (for testing, or a one-off kernel).
114 Also note that by using a non-"base" arch (eg, i386) only kernels
115 will be built - there will be no lustre-lite-utils package.
118 Prevents the datestamp flag (-D) from being passed to cvs for
119 checkouts. This is a workaround for a problem encountered when
120 using lbuild with tinderbox.
131 if [ "$LUSTRE" ] ; then
132 [ -r "$LUSTRE" ] || \
133 usage 1 "Could not find Lustre source tarball '$LUSTRE'."
136 usage 1 "Either specify a CVS Root with -d, or a Lustre source tarball with --lustre."
138 usage 1 "A branch/tag name must be specified with --tag when not building from a tarball."
141 [ "$KERNELDIR" ] || \
142 usage 1 "A kernel directory must be specified with --kerneldir."
144 [ -d "$KERNELDIR" ] || \
145 usage 1 "$KERNELDIR is not a directory."
147 if ! (( $RELEASE )) ; then
149 usage 1 "When building a snapshot, a tag name must be used."
152 TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M")
154 [ "$TARGET" ] || usage 1 "A target must be specified with --target."
155 # TARGET_FILE="$TOPDIR/kernel_patches/targets/$TARGET.target"
156 # [ -r "$TARGET_FILE" ] || \
157 # usage 1 "Target '$TARGET' was not found."
159 RPMBUILD=$(which rpmbuild 2>/dev/null | head -1)
160 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
161 RPMBUILD=$(which rpm 2>/dev/null | head -1)
162 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
163 usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)."
170 echo $(echo "$*" | xargs -n 1 | sort -u)
175 EXTRA_VERSION_save="$EXTRA_VERSION"
176 TARGET_FILE="$TOPDIR/lustre/kernel_patches/targets/$TARGET.target"
177 [ -r "$TARGET_FILE" ] || \
178 fatal 1 "Target $TARGET was not found."
180 echo "Loading target config file $TARGET.target..."
184 [ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel."
185 [ "$SERIES" ] || fatal 1 "Target $TARGET did not specify a kernel patch series."
186 # [ "$CONFIG" ] || fatal 1 "Target $TARGET did not specify a kernel config."
187 [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify a kernel version."
189 if [ "$KERNELDIR" ] ; then
190 KERNEL_FILE="$KERNELDIR/$KERNEL"
191 [ -r "$KERNELDIR/$KERNEL" ] || \
192 fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR."
195 SERIES_FILE="$TOPDIR/lustre/kernel_patches/series/$SERIES"
196 [ -r "$SERIES_FILE" ] || \
197 fatal 1 "Target $TARGET's series $SERIES missing from $TOPDIR/lustre/kernel_patches/series."
199 CONFIG_FILE="$TOPDIR/lustre/kernel_patches/kernel_configs/$CONFIG"
200 [ -r "$CONFIG_FILE" ] || \
201 fatal 1 "Target $TARGET's config file $CONFIG missing from $TOPDIR/lustre/kernel_patches/kernel_configs/configs."
203 if [ "$EXTRA_VERSION_save" ] ; then
204 EXTRA_VERSION="$EXTRA_VERSION_save"
205 elif ! (( $RELEASE )) ; then
206 EXTRA_VERSION="${EXTRA_VERSION}-${TAG//_/}.${TIMESTAMP}"
208 # EXTRA_VERSION=${EXTRA_VERSION//-/_}
210 ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $UP_ARCHS"
213 for arch in $(uniqify "$ALL_ARCHS") ; do
214 if [ -z "$TARGET_ARCHS" ] || echo "$TARGET_ARCHS" | grep -s "$arch" ; then
215 BUILD_ARCHS="$BUILD_ARCHS $arch"
218 [ "$BUILD_ARCHS" ] || usage 1 "No available target archs to build."
219 echo "Building for: $BUILD_ARCHS"
226 fatal 1 "tarflags(): File name argument missing."
235 fatal 1 "tarflags(): Unrecognized tar extension in file: $1"
242 echo "Untarring ${1##*/}..."
243 tar $(tarflags "$1") "$1"
248 DIRNAME="lustre-$TAG-$TIMESTAMP"
249 if [ "$LUSTRE" ] ; then
251 [ -d lustre ] || ln -sf lustre* lustre
253 if [ "$USE_DATESTAMP" ]; then
254 DATESTAMP="-D '$DATE'"
259 cvs -d "$CVSROOT" -qz3 co $DATESTAMP -r "$TAG" -d "$DIRNAME" lustre || \
260 fatal 1 "There was an error checking out Lustre from CVS."
261 echo "Creating lustre tarball..."
262 tar zcf "$DIRNAME.tar.gz" "$DIRNAME" \
263 --exclude "CVS" --exclude "*~" --exclude ".cvsignore" || \
264 fatal 1 "Could not create Lustre tarball."
265 LUSTRE="$PWD/$DIRNAME.tar.gz"
266 ln -sf "$DIRNAME" lustre
273 [ -d linux ] || ln -sf linux* linux
278 FULL_PATCH="$PWD/lustre-kernel-${TARGET}-${EXTRA_VERSION}.patch"
279 [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH"
280 pushd linux >/dev/null
281 echo -n "Applying patches:"
282 for patch in $(<"$SERIES_FILE") ; do
284 PATCH_FILE="$TOPDIR/lustre/kernel_patches/patches/$patch"
285 [ -r "$PATCH_FILE" ] || \
286 fatal 1 "Patch $patch does not exist in Lustre tree."
287 cat "$PATCH_FILE" >> "$FULL_PATCH" || \
288 fatal 1 "Error adding patch $patch to full patch."
289 patch -s -p1 < "$PATCH_FILE" || fatal 1 "Error applying patch $patch."
293 echo "Full patch has been saved in ${FULL_PATCH##*/}."
294 echo "Replacing .config files..."
295 [ -d linux/configs ] || mkdir linux/configs
296 rm -f linux/configs/*
297 cp -v lustre/kernel_patches/kernel_configs/kernel-${VERSION}-${TARGET}*.config linux/configs/
302 TARBALL="$(readlink linux)-$EXTRA_VERSION.tar.gz"
303 echo "Creating patched linux tarball $TARBALL..."
304 tar zcf "$TARBALL" "$(readlink linux)" \
305 --exclude "CVS" --exclude ".cvsignore" || \
306 --exclude "*.orig" --exclude "*~" --exclude "*.rej" || \
307 fatal 1 "Error creating patched Linux tarball."
312 [ -d linux ] || return 0
313 echo "Cleaning linux..."
314 [ -L linux ] && rm -rf $(readlink linux)
321 sed -e "s/@KERNEL_VERSION@/$VERSION/g" \
322 -e "s/@KERNEL_EXTRA_VERSION@/$EXTRA_VERSION/g" \
323 -e "s^@KERNEL_RELEASE@^${EXTRA_VERSION//-/_}^g" \
324 -e "s/@KERNEL_SOURCE@/$KERNEL/g" \
325 -e "s/@LUSTRE_SOURCE@/${LUSTRE##*/}/g" \
326 -e "s/@LUSTRE_TARGET@/$TARGET/g" \
327 -e "s#@CONFIGURE_FLAGS@#$CONFIGURE_FLAGS#g" \
328 -e "s/@BASE_ARCHS@/$BASE_ARCHS/g" \
329 -e "s/@BIGMEM_ARCHS@/$BIGMEM_ARCHS/g" \
330 -e "s/@BOOT_ARCHS@/$BOOT_ARCHS/g" \
331 -e "s/@JENSEN_ARCHS@/$BOOT_ARCHS/g" \
332 -e "s/@SMP_ARCHS@/$SMP_ARCHS/g" \
333 -e "s/@UP_ARCHS@/$UP_ARCHS/g" \
334 -e "s/@RHBUILD@/$RHBUILD/g" \
335 < $TOPDIR/lustre/scripts/lustre-kernel-2.4.spec.in \
336 > lustre-kernel-2.4.spec
337 [ -d SRPMS ] || mkdir SRPMS
338 [ -d RPMS ] || mkdir RPMS
339 [ -d BUILD ] || mkdir BUILD
340 [ -d SOURCES ] || mkdir SOURCES
341 cp $TOPDIR/lustre/scripts/linux-rhconfig.h SOURCES
342 cp $TOPDIR/lustre/scripts/linux-merge-config.awk SOURCES
343 cp $TOPDIR/lustre/scripts/linux-merge-modules.awk SOURCES
344 cp "$LUSTRE" "$KERNEL_FILE" SOURCES
349 [ -d lustre ] || return 0
350 echo "Cleaning lustre..."
351 [ -L lustre ] && rm -rf $(readlink lustre)
357 echo "Building rpms for: $BUILD_ARCHS..."
359 for arch in $BUILD_ARCHS ; do
360 targets="--target $arch $targets"
363 $RPMBUILD $targets -bb lustre-kernel-2.4.spec \
364 --define "_topdir $TOPDIR" || \
365 fatal 1 "Error building rpms for $arch."
367 (( $DO_SRC )) && $RPMBUILD -bs lustre-kernel-2.4.spec \
368 --define "_topdir $TOPDIR" || \
369 fatal 1 "Error building .src.rpm."
374 publishing || return 0
377 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
379 options=$(getopt -o d:D:h -l extraversion:,kerneldir:,lustre:,nosrc,publish,release,tag:,target:,target-archs:,disable-datestamp -- "$@")
381 eval set -- "$options"
445 usage 1 "Unrecognized option: $1"
455 if (( $DO_SRC )) ; then
462 # prep_build needs the .spec.in from the lustre source