5 # CVSROOT is inherited from the environment
43 [ "$2" ] && echo "${0##*/}: $2"
49 (( $PUBLISH )) || return 0
54 (( $RELEASE )) || return 0
59 echo -n "Available targets:"
60 for target in $TOPDIR/lustre/kernel_patches/targets/*.target ; do
61 target_file=${target##*/}
62 echo -n " ${target_file%%.target}"
70 Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
73 Specifies the CVS Root to use when pulling files from CVS. The
74 environment variable \$CVSROOT is used if this option is not
77 --extraversion=EXTRAVERSION
78 Text to use for the rpm release and kernel extraversion.
81 Directory containing Linux source tarballs referenced by target
85 Path to an existing lustre source tarball to use instead of
89 Do not build a .src.rpm, a full kernel patch, or a patched kernel
93 Publish the packages, patches, and tarballs on the ftp server.
96 Specifies that the files generated do not include timestamps, and
97 that this is an official release.
100 A CVS branch/tag name to build from when pulling from CVS.
103 The name of the target to build. The available targets are listed
106 --target-archs=TARGET_ARCHS
107 A (space delimited) list of architectures to build. By default,
108 all of the archs supported by the TARGET will be built, in
109 addition to a .src.rpm. This option can limit those, for machines
110 that can only build certain archs or if you only want a certain
111 arch built (for testing, or a one-off kernel).
113 Also note that by using a non-"base" arch (eg, i386) only kernels
114 will be built - there will be no lustre-lite-utils package.
125 if [ "$LUSTRE" ] ; then
126 [ -r "$LUSTRE" ] || \
127 usage 1 "Could not find Lustre source tarball '$LUSTRE'."
130 usage 1 "Either specify a CVS Root with -d, or a Lustre source tarball with --lustre."
132 usage 1 "A branch/tag name must be specified with --tag when not building from a tarball."
135 [ "$KERNELDIR" ] || \
136 usage 1 "A kernel directory must be specified with --kerneldir."
138 [ -d "$KERNELDIR" ] || \
139 usage 1 "$KERNELDIR is not a directory."
141 if ! (( $RELEASE )) ; then
143 usage 1 "When building a snapshot, a tag name must be used."
146 TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M")
148 [ "$TARGET" ] || usage 1 "A target must be specified with --target."
149 # TARGET_FILE="$TOPDIR/kernel_patches/targets/$TARGET.target"
150 # [ -r "$TARGET_FILE" ] || \
151 # usage 1 "Target '$TARGET' was not found."
153 RPMBUILD=`which rpmbuild`
154 if [ $? -ne 0 -o ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
156 if [ $? -ne 0 -o ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
157 usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)."
164 echo $(echo "$*" | xargs -n 1 | sort -u)
169 EXTRA_VERSION_save="$EXTRA_VERSION"
170 TARGET_FILE="$TOPDIR/lustre/kernel_patches/targets/$TARGET.target"
171 [ -r "$TARGET_FILE" ] || \
172 fatal 1 "Target $TARGET was not found."
174 echo "Loading target config file $TARGET.target..."
178 [ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel."
179 [ "$SERIES" ] || fatal 1 "Target $TARGET did not specify a kernel patch series."
180 # [ "$CONFIG" ] || fatal 1 "Target $TARGET did not specify a kernel config."
181 [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify a kernel version."
183 if [ "$KERNELDIR" ] ; then
184 KERNEL_FILE="$KERNELDIR/$KERNEL"
185 [ -r "$KERNELDIR/$KERNEL" ] || \
186 fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR."
189 SERIES_FILE="$TOPDIR/lustre/kernel_patches/series/$SERIES"
190 [ -r "$SERIES_FILE" ] || \
191 fatal 1 "Target $TARGET's series $SERIES missing from $TOPDIR/lustre/kernel_patches/series."
193 CONFIG_FILE="$TOPDIR/lustre/kernel_patches/kernel_configs/$CONFIG"
194 [ -r "$CONFIG_FILE" ] || \
195 fatal 1 "Target $TARGET's config file $CONFIG missing from $TOPDIR/lustre/kernel_patches/kernel_configs/configs."
197 if [ "$EXTRA_VERSION_save" ] ; then
198 EXTRA_VERSION="$EXTRA_VERSION_save"
199 elif ! (( $RELEASE )) ; then
200 EXTRA_VERSION="${EXTRA_VERSION}-${TAG//_/}.${TIMESTAMP}"
202 # EXTRA_VERSION=${EXTRA_VERSION//-/_}
204 ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $UP_ARCHS"
207 for arch in $(uniqify "$ALL_ARCHS") ; do
208 if [ -z "$TARGET_ARCHS" ] || echo "$TARGET_ARCHS" | grep -s "$arch" ; then
209 BUILD_ARCHS="$BUILD_ARCHS $arch"
212 [ "$BUILD_ARCHS" ] || usage 1 "No available target archs to build."
213 echo "Building for: $BUILD_ARCHS"
220 fatal 1 "tarflags(): File name argument missing."
229 fatal 1 "tarflags(): Unrecognized tar extension in file: $1"
236 echo "Untarring ${1##*/}..."
237 tar $(tarflags "$1") "$1"
242 DIRNAME="lustre-$TAG-$TIMESTAMP"
243 if [ "$LUSTRE" ] ; then
245 [ -d lustre ] || ln -sf lustre* lustre
247 cvs -d "$CVSROOT" -qz3 co -r "$TAG" -d "$DIRNAME" lustre || \
248 fatal 1 "There was an error checking out Lustre from CVS."
249 echo "Creating lustre tarball..."
250 tar zcf "$DIRNAME.tar.gz" "$DIRNAME" \
251 --exclude "CVS" --exclude "*~" --exclude ".cvsignore" || \
252 fatal 1 "Could not create Lustre tarball."
253 LUSTRE="$PWD/$DIRNAME.tar.gz"
254 ln -sf "$DIRNAME" lustre
261 [ -d linux ] || ln -sf linux* linux
266 FULL_PATCH="$PWD/lustre-kernel-${TARGET}-${EXTRA_VERSION}.patch"
267 [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH"
268 pushd linux >/dev/null
269 echo -n "Applying patches:"
270 for patch in $(<"$SERIES_FILE") ; do
272 PATCH_FILE="$TOPDIR/lustre/kernel_patches/patches/$patch"
273 [ -r "$PATCH_FILE" ] || \
274 fatal 1 "Patch $patch does not exist in Lustre tree."
275 cat "$PATCH_FILE" >> "$FULL_PATCH" || \
276 fatal 1 "Error adding patch $patch to full patch."
277 patch -s -p1 < "$PATCH_FILE" || fatal 1 "Error applying patch $patch."
281 echo "Full patch has been saved in ${FULL_PATCH##*/}."
282 echo "Replacing .config files..."
283 [ -d linux/configs ] || mkdir linux/configs
284 rm -f linux/configs/*
285 cp -v lustre/kernel_patches/kernel_configs/kernel-${VERSION}-${TARGET}*.config linux/configs/
290 TARBALL="$(readlink linux)-$EXTRA_VERSION.tar.gz"
291 echo "Creating patched linux tarball $TARBALL..."
292 tar zcf "$TARBALL" "$(readlink linux)" \
293 --exclude "CVS" --exclude ".cvsignore" || \
294 --exclude "*.orig" --exclude "*~" --exclude "*.rej" || \
295 fatal 1 "Error creating patched Linux tarball."
300 [ -d linux ] || return 0
301 echo "Cleaning linux..."
302 [ -L linux ] && rm -rf $(readlink linux)
309 sed -e "s/@KERNEL_VERSION@/$VERSION/g" \
310 -e "s/@KERNEL_EXTRA_VERSION@/$EXTRA_VERSION/g" \
311 -e "s^@KERNEL_RELEASE@^${EXTRA_VERSION//-/_}^g" \
312 -e "s/@KERNEL_SOURCE@/$KERNEL/g" \
313 -e "s/@LUSTRE_SOURCE@/${LUSTRE##*/}/g" \
314 -e "s/@LUSTRE_TARGET@/$TARGET/g" \
315 -e "s#@CONFIGURE_FLAGS@#$CONFIGURE_FLAGS#g" \
316 -e "s/@BASE_ARCHS@/$BASE_ARCHS/g" \
317 -e "s/@BIGMEM_ARCHS@/$BIGMEM_ARCHS/g" \
318 -e "s/@BOOT_ARCHS@/$BOOT_ARCHS/g" \
319 -e "s/@JENSEN_ARCHS@/$BOOT_ARCHS/g" \
320 -e "s/@SMP_ARCHS@/$SMP_ARCHS/g" \
321 -e "s/@UP_ARCHS@/$UP_ARCHS/g" \
322 -e "s/@RHBUILD@/$RHBUILD/g" \
323 < $TOPDIR/lustre/scripts/lustre-kernel-2.4.spec.in \
324 > lustre-kernel-2.4.spec
325 [ -d SRPMS ] || mkdir SRPMS
326 [ -d RPMS ] || mkdir RPMS
327 [ -d BUILD ] || mkdir BUILD
328 [ -d SOURCES ] || mkdir SOURCES
329 cp $TOPDIR/lustre/scripts/linux-rhconfig.h SOURCES
330 cp $TOPDIR/lustre/scripts/linux-merge-config.awk SOURCES
331 cp $TOPDIR/lustre/scripts/linux-merge-modules.awk SOURCES
332 cp "$LUSTRE" "$KERNEL_FILE" SOURCES
337 [ -d lustre ] || return 0
338 echo "Cleaning lustre..."
339 [ -L lustre ] && rm -rf $(readlink lustre)
345 echo "Building rpms for: $BUILD_ARCHS..."
347 for arch in $BUILD_ARCHS ; do
348 targets="--target $arch $targets"
351 $RPMBUILD $targets -bb lustre-kernel-2.4.spec \
352 --define "_topdir $TOPDIR" || \
353 fatal 1 "Error building rpms for $arch."
355 (( $DO_SRC )) && $RPMBUILD -bs lustre-kernel-2.4.spec \
356 --define "_topdir $TOPDIR" || \
357 fatal 1 "Error building .src.rpm."
362 publishing || return 0
365 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
367 options=$(getopt -o d:D:h -l extraversion:,kerneldir:,lustre:,nosrc,publish,release,tag:,target:,target-archs: -- "$@")
369 eval set -- "$options"
429 usage 1 "Unrecognized option: $1"
439 if (( $DO_SRC )) ; then
446 # prep_build needs the .spec.in from the lustre source