5 # CVSROOT is inherited from the environment
48 [ "$2" ] && echo "${0##*/}: $2"
54 (( $PUBLISH )) || return 0
59 (( $RELEASE )) || return 0
64 echo -n "Available targets:"
65 for target in $TOPDIR/lustre/kernel_patches/targets/*.target ; do
66 target_file=${target##*/}
67 echo -n " ${target_file%%.target}"
75 Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
78 Specifies the CVS Root to use when pulling files from CVS. The
79 environment variable \$CVSROOT is used if this option is not
82 --extraversion=EXTRAVERSION
83 Text to use for the rpm release and kernel extraversion.
86 Directory containing Linux source tarballs referenced by target
90 Path to an existing lustre source tarball to use instead of
94 Do not build a .src.rpm, a full kernel patch, or a patched kernel
98 Publish the packages, patches, and tarballs on the ftp server.
101 Specifies that the files generated do not include timestamps, and
102 that this is an official release.
105 A CVS branch/tag name to build from when pulling from CVS.
108 The name of the target to build. The available targets are listed
111 --target-archs=TARGET_ARCHS
112 A (space delimited) list of architectures to build. By default,
113 all of the archs supported by the TARGET will be built, in
114 addition to a .src.rpm. This option can limit those, for machines
115 that can only build certain archs or if you only want a certain
116 arch built (for testing, or a one-off kernel).
118 Also note that by using a non-"base" arch (eg, i386) only kernels
119 will be built - there will be no lustre-lite-utils package.
122 Prevents the datestamp flag (-D) from being passed to cvs for
123 checkouts. This is a workaround for a problem encountered when
124 using lbuild with tinderbox.
135 if [ "$LUSTRE" ] ; then
136 [ -r "$LUSTRE" ] || \
137 usage 1 "Could not find Lustre source tarball '$LUSTRE'."
140 usage 1 "Either specify a CVS Root with -d, or a Lustre source tarball with --lustre."
142 usage 1 "A branch/tag name must be specified with --tag when not building from a tarball."
145 [ "$KERNELDIR" ] || \
146 usage 1 "A kernel directory must be specified with --kerneldir."
148 [ -d "$KERNELDIR" ] || \
149 usage 1 "$KERNELDIR is not a directory."
151 if ! (( $RELEASE )) ; then
153 usage 1 "When building a snapshot, a tag name must be used."
156 TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M")
158 [ "$TARGET" ] || usage 1 "A target must be specified with --target."
159 # TARGET_FILE="$TOPDIR/kernel_patches/targets/$TARGET.target"
160 # [ -r "$TARGET_FILE" ] || \
161 # usage 1 "Target '$TARGET' was not found."
163 RPMBUILD=$(which rpmbuild 2>/dev/null | head -1)
164 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
165 RPMBUILD=$(which rpm 2>/dev/null | head -1)
166 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
167 usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)."
174 echo $(echo "$*" | xargs -n 1 | sort -u)
179 EXTRA_VERSION_save="$EXTRA_VERSION"
180 TARGET_FILE="$TOPDIR/lustre/kernel_patches/targets/$TARGET.target"
181 [ -r "$TARGET_FILE" ] || \
182 fatal 1 "Target $TARGET was not found."
184 echo "Loading target config file $TARGET.target..."
188 [ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel."
189 [ "$SERIES" ] || fatal 1 "Target $TARGET did not specify a kernel patch series."
190 # [ "$CONFIG" ] || fatal 1 "Target $TARGET did not specify a kernel config."
191 [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify a kernel version."
193 if [ "$KERNELDIR" ] ; then
194 KERNEL_FILE="$KERNELDIR/$KERNEL"
195 [ -r "$KERNELDIR/$KERNEL" ] || \
196 fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR."
199 SERIES_FILE="$TOPDIR/lustre/kernel_patches/series/$SERIES"
200 [ -r "$SERIES_FILE" ] || \
201 fatal 1 "Target $TARGET's series $SERIES missing from $TOPDIR/lustre/kernel_patches/series."
203 CONFIG_FILE="$TOPDIR/lustre/kernel_patches/kernel_configs/$CONFIG"
204 [ -r "$CONFIG_FILE" ] || \
205 fatal 1 "Target $TARGET's config file $CONFIG missing from $TOPDIR/lustre/kernel_patches/kernel_configs/."
207 if [ "$EXTRA_VERSION_save" ] ; then
208 EXTRA_VERSION="$EXTRA_VERSION_save"
209 elif ! (( $RELEASE )) ; then
210 EXTRA_VERSION="${EXTRA_VERSION}-${TAG}.${TIMESTAMP}"
212 # EXTRA_VERSION=${EXTRA_VERSION//-/_}
214 ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $UP_ARCHS"
217 for arch in $(uniqify "$ALL_ARCHS") ; do
218 if [ -z "$TARGET_ARCHS" ] || echo "$TARGET_ARCHS" | grep "$arch" >/dev/null 2>/dev/null ; then
219 BUILD_ARCHS="$BUILD_ARCHS $arch"
222 [ "$BUILD_ARCHS" ] || usage 1 "No available target archs to build."
223 echo "Building for: $BUILD_ARCHS"
230 fatal 1 "tarflags(): File name argument missing."
239 fatal 1 "tarflags(): Unrecognized tar extension in file: $1"
246 echo "Untarring ${1##*/}..."
247 tar $(tarflags "$1") "$1"
252 DIRNAME="lustre-$TAG-$TIMESTAMP"
253 if [ "$LUSTRE" ] ; then
255 [ -d lustre ] || ln -sf lustre* lustre
257 if [ "$USE_DATESTAMP" ]; then
258 DATESTAMP="-D '$DATE'"
263 cvs -d "$CVSROOT" -qz3 co $DATESTAMP -r "$TAG" -d "$DIRNAME" lustre || \
264 fatal 1 "There was an error checking out Lustre from CVS."
265 echo "Creating lustre tarball..."
266 tar zcf "$DIRNAME.tar.gz" "$DIRNAME" \
267 --exclude "CVS" --exclude "*~" --exclude ".cvsignore" || \
268 fatal 1 "Could not create Lustre tarball."
269 LUSTRE="$PWD/$DIRNAME.tar.gz"
270 ln -sf "$DIRNAME" lustre
277 [ -d linux ] || ln -sf linux* linux
282 FULL_PATCH="$PWD/lustre-kernel-${TARGET}-${EXTRA_VERSION}.patch"
283 [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH"
284 pushd linux >/dev/null
285 echo -n "Applying patches:"
286 for patch in $(<"$SERIES_FILE") ; do
288 PATCH_FILE="$TOPDIR/lustre/kernel_patches/patches/$patch"
289 [ -r "$PATCH_FILE" ] || \
290 fatal 1 "Patch $patch does not exist in Lustre tree."
291 cat "$PATCH_FILE" >> "$FULL_PATCH" || \
292 fatal 1 "Error adding patch $patch to full patch."
293 patch -s -p1 < "$PATCH_FILE" || fatal 1 "Error applying patch $patch."
297 echo "Full patch has been saved in ${FULL_PATCH##*/}."
298 echo "Replacing .config files..."
299 [ -d linux/configs ] || mkdir linux/configs || \
300 fatal 1 "Error creating configs directory."
301 rm -f linux/configs/*
302 cp -v lustre/kernel_patches/kernel_configs/kernel-${VERSION}-${TARGET}*.config linux/configs/ || \
303 fatal 1 "Error copying in kernel configs."
308 TARBALL="$(readlink linux)-$EXTRA_VERSION.tar.gz"
309 echo "Creating patched linux tarball $TARBALL..."
310 tar zcf "$TARBALL" "$(readlink linux)" \
311 --exclude "CVS" --exclude ".cvsignore" || \
312 --exclude "*.orig" --exclude "*~" --exclude "*.rej" || \
313 fatal 1 "Error creating patched Linux tarball."
318 [ -d linux ] || return 0
319 echo "Cleaning linux..."
320 [ -L linux ] && rm -rf $(readlink linux)
327 sed -e "s/@KERNEL_VERSION@/$VERSION/g" \
328 -e "s/@KERNEL_EXTRA_VERSION@/$EXTRA_VERSION/g" \
329 -e "s^@KERNEL_RELEASE@^${EXTRA_VERSION//-/_}^g" \
330 -e "s/@KERNEL_SOURCE@/$KERNEL/g" \
331 -e "s/@LUSTRE_SOURCE@/${LUSTRE##*/}/g" \
332 -e "s/@LUSTRE_TARGET@/$TARGET/g" \
333 -e "s#@CONFIGURE_FLAGS@#$CONFIGURE_FLAGS#g" \
334 -e "s/@BASE_ARCHS@/$BASE_ARCHS/g" \
335 -e "s/@BIGMEM_ARCHS@/$BIGMEM_ARCHS/g" \
336 -e "s/@BOOT_ARCHS@/$BOOT_ARCHS/g" \
337 -e "s/@JENSEN_ARCHS@/$BOOT_ARCHS/g" \
338 -e "s/@SMP_ARCHS@/$SMP_ARCHS/g" \
339 -e "s/@UP_ARCHS@/$UP_ARCHS/g" \
340 -e "s/@RHBUILD@/$RHBUILD/g" \
341 -e "s/@LINUX26@/$LINUX26/g" \
342 -e "s/@SUSEBUILD@/$SUSEBUILD/g" \
343 < $TOPDIR/lustre/scripts/lustre-kernel-2.4.spec.in \
344 > lustre-kernel-2.4.spec
345 [ -d SRPMS ] || mkdir SRPMS
346 [ -d RPMS ] || mkdir RPMS
347 [ -d BUILD ] || mkdir BUILD
348 [ -d SOURCES ] || mkdir SOURCES
349 cp $TOPDIR/lustre/scripts/linux-rhconfig.h SOURCES
350 cp $TOPDIR/lustre/scripts/linux-merge-config.awk SOURCES
351 cp $TOPDIR/lustre/scripts/linux-merge-modules.awk SOURCES
352 cp "$LUSTRE" "$KERNEL_FILE" SOURCES
357 [ -d lustre ] || return 0
358 echo "Cleaning lustre..."
359 [ -L lustre ] && rm -rf $(readlink lustre)
365 echo "Building rpms for: $BUILD_ARCHS..."
367 for arch in $BUILD_ARCHS ; do
368 targets="--target $arch $targets"
371 $RPMBUILD $targets -bb lustre-kernel-2.4.spec \
372 --define "_topdir $TOPDIR" || \
373 fatal 1 "Error building rpms for $arch."
375 (( $DO_SRC )) && $RPMBUILD -bs lustre-kernel-2.4.spec \
376 --define "_topdir $TOPDIR" || \
377 fatal 1 "Error building .src.rpm."
382 publishing || return 0
385 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
387 options=$(getopt -o d:D:h -l extraversion:,kerneldir:,lustre:,nosrc,publish,release,tag:,target:,target-archs:,disable-datestamp -- "$@")
389 eval set -- "$options"
453 usage 1 "Unrecognized option: $1"
463 if (( $DO_SRC )) ; then
470 # prep_build needs the .spec.in from the lustre source