5 # CVSROOT is inherited from the environment
41 [ "$2" ] && echo "${0##*/}: $2"
47 (( $PUBLISH )) || return 0
52 (( $RELEASE )) || return 0
57 echo -n "Available targets:"
58 for target in $TOPDIR/lustre/kernel_patches/targets/*.target ; do
59 target_file=${target##*/}
60 echo -n " ${target_file%%.target}"
68 Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
71 Specifies the CVS Root to use when pulling files from CVS. The
72 environment variable \$CVSROOT is used if this option is not
75 --extraversion=EXTRAVERSION
76 Text to use for the rpm release and kernel extraversion.
79 Directory containing Linux source tarballs referenced by target
83 Path to an existing lustre source tarball to use instead of
87 Do not build a .src.rpm, a full kernel patch, or a patched kernel
91 Publish the packages, patches, and tarballs on the ftp server.
94 Specifies that the files generated do not include timestamps, and
95 that this is an official release.
98 A CVS branch/tag name to build from when pulling from CVS.
101 The name of the target to build. The available targets are listed
104 --target-archs=TARGET_ARCHS
105 A (space delimited) list of architectures to build. By default,
106 all of the archs supported by the TARGET will be built, in
107 addition to a .src.rpm. This option can limit those, for machines
108 that can only build certain archs or if you only want a certain
109 arch built (for testing, or a one-off kernel).
111 Also note that by using a non-"base" arch (eg, i386) only kernels
112 will be built - there will be no lustre-lite-utils package.
123 if [ "$LUSTRE" ] ; then
124 [ -r "$LUSTRE" ] || \
125 usage 1 "Could not find Lustre source tarball '$LUSTRE'."
128 usage 1 "Either specify a CVS Root with -d, or a Lustre source tarball with --lustre."
130 usage 1 "A branch/tag name must be specified with --tag when not building from a tarball."
133 [ "$KERNELDIR" ] || \
134 usage 1 "A kernel directory must be specified with --kerneldir."
136 [ -d "$KERNELDIR" ] || \
137 usage 1 "$KERNELDIR is not a directory."
139 if ! (( $RELEASE )) ; then
141 usage 1 "When building a snapshot, a tag name must be used."
144 TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M")
146 [ "$TARGET" ] || usage 1 "A target must be specified with --target."
147 # TARGET_FILE="$TOPDIR/kernel_patches/targets/$TARGET.target"
148 # [ -r "$TARGET_FILE" ] || \
149 # usage 1 "Target '$TARGET' was not found."
154 echo $(echo "$*" | xargs -n 1 | sort -u)
159 EXTRA_VERSION_save="$EXTRA_VERSION"
160 TARGET_FILE="$TOPDIR/lustre/kernel_patches/targets/$TARGET.target"
161 [ -r "$TARGET_FILE" ] || \
162 fatal 1 "Target $TARGET was not found."
164 echo "Loading target config file $TARGET.target..."
168 [ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel."
169 [ "$SERIES" ] || fatal 1 "Target $TARGET did not specify a kernel patch series."
170 # [ "$CONFIG" ] || fatal 1 "Target $TARGET did not specify a kernel config."
171 [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify a kernel version."
173 if [ "$KERNELDIR" ] ; then
174 KERNEL_FILE="$KERNELDIR/$KERNEL"
175 [ -r "$KERNELDIR/$KERNEL" ] || \
176 fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR."
179 SERIES_FILE="$TOPDIR/lustre/kernel_patches/series/$SERIES"
180 [ -r "$SERIES_FILE" ] || \
181 fatal 1 "Target $TARGET's series $SERIES missing from $TOPDIR/lustre/kernel_patches/series."
183 CONFIG_FILE="$TOPDIR/lustre/kernel_patches/kernel_configs/$CONFIG"
184 [ -r "$CONFIG_FILE" ] || \
185 fatal 1 "Target $TARGET's config file $CONFIG missing from $TOPDIR/lustre/kernel_patches/kernel_configs/configs."
187 if [ "$EXTRA_VERSION_save" ] ; then
188 EXTRA_VERSION="$EXTRA_VERSION_save"
189 elif ! (( $RELEASE )) ; then
190 EXTRA_VERSION="${EXTRA_VERSION}-${TAG//_/}.${TIMESTAMP}"
192 # EXTRA_VERSION=${EXTRA_VERSION//-/_}
194 ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $UP_ARCHS"
197 for arch in $(uniqify "$ALL_ARCHS") ; do
198 if [ -z "$TARGET_ARCHS" ] || echo "$TARGET_ARCHS" | grep -s "$arch" ; then
199 BUILD_ARCHS="$BUILD_ARCHS $arch"
202 [ "$BUILD_ARCHS" ] || usage 1 "No available target archs to build."
203 echo "Building for: $BUILD_ARCHS"
210 fatal 1 "tarflags(): File name argument missing."
219 fatal 1 "tarflags(): Unrecognized tar extension in file: $1"
226 echo "Untarring ${1##*/}..."
227 tar $(tarflags "$1") "$1"
232 DIRNAME="lustre-$TAG-$TIMESTAMP"
233 if [ "$LUSTRE" ] ; then
235 [ -d lustre ] || ln -sf lustre* lustre
237 cvs -d "$CVSROOT" -qz3 co -D "$DATE" "-r$TAG" -d "$DIRNAME" lustre || \
238 fatal 1 "There was an error checking out Lustre from CVS."
239 echo "Creating lustre tarball..."
240 tar zcf "$DIRNAME.tar.gz" "$DIRNAME" \
241 --exclude "CVS" --exclude "*~" --exclude ".cvsignore" || \
242 fatal 1 "Could not create Lustre tarball."
243 LUSTRE="$PWD/$DIRNAME.tar.gz"
244 ln -sf "$DIRNAME" lustre
251 [ -d linux ] || ln -sf linux* linux
256 FULL_PATCH="$PWD/lustre-kernel-${TARGET}-${EXTRA_VERSION}.patch"
257 [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH"
258 pushd linux >/dev/null
259 echo -n "Applying patches:"
260 for patch in $(<"$SERIES_FILE") ; do
262 PATCH_FILE="$TOPDIR/lustre/kernel_patches/patches/$patch"
263 [ -r "$PATCH_FILE" ] || \
264 fatal 1 "Patch $patch does not exist in Lustre tree."
265 cat "$PATCH_FILE" >> "$FULL_PATCH" || \
266 fatal 1 "Error adding patch $patch to full patch."
267 patch -s -p1 < "$PATCH_FILE" || fatal 1 "Error applying patch $patch."
271 echo "Full patch has been saved in ${FULL_PATCH##*/}."
272 echo "Replacing .config files..."
273 rm -f linux/configs/*
274 cp -v lustre/kernel_patches/kernel_configs/kernel-${VERSION}-${TARGET}*.config linux/configs/
279 TARBALL="$(readlink linux)-$EXTRA_VERSION.tar.gz"
280 echo "Creating patched linux tarball $TARBALL..."
281 tar zcf "$TARBALL" "$(readlink linux)" \
282 --exclude "CVS" --exclude ".cvsignore" || \
283 --exclude "*.orig" --exclude "*~" --exclude "*.rej" || \
284 fatal 1 "Error creating patched Linux tarball."
289 [ -d linux ] || return 0
290 echo "Cleaning linux..."
291 [ -L linux ] && rm -rf $(readlink linux)
298 sed -e "s/@KERNEL_VERSION@/$VERSION/g" \
299 -e "s/@KERNEL_EXTRA_VERSION@/$EXTRA_VERSION/g" \
300 -e "s^@KERNEL_RELEASE@^${EXTRA_VERSION//-/_}^g" \
301 -e "s/@KERNEL_SOURCE@/$KERNEL/g" \
302 -e "s/@LUSTRE_SOURCE@/${LUSTRE##*/}/g" \
303 -e "s/@LUSTRE_TARGET@/$TARGET/g" \
304 -e "s/@CONFIGURE_FLAGS@/$CONFIGURE_FLAGS/g" \
305 -e "s/@BASE_ARCHS@/$BASE_ARCHS/g" \
306 -e "s/@BIGMEM_ARCHS@/$BIGMEM_ARCHS/g" \
307 -e "s/@BOOT_ARCHS@/$BOOT_ARCHS/g" \
308 -e "s/@JENSEN_ARCHS@/$BOOT_ARCHS/g" \
309 -e "s/@SMP_ARCHS@/$SMP_ARCHS/g" \
310 -e "s/@UP_ARCHS@/$UP_ARCHS/g" \
311 -e "s/@RHBUILD@/$RHBUILD/g" \
312 < $TOPDIR/lustre/scripts/lustre-kernel-2.4.spec.in \
313 > lustre-kernel-2.4.spec
314 [ -d SRPMS ] || mkdir SRPMS
315 [ -d RPMS ] || mkdir RPMS
316 [ -d BUILD ] || mkdir BUILD
317 [ -d SOURCES ] || mkdir SOURCES
318 cp $TOPDIR/lustre/scripts/linux-rhconfig.h SOURCES
319 cp $TOPDIR/lustre/scripts/linux-merge-config.awk SOURCES
320 cp $TOPDIR/lustre/scripts/linux-merge-modules.awk SOURCES
321 cp "$LUSTRE" "$KERNEL_FILE" SOURCES
326 [ -d lustre ] || return 0
327 echo "Cleaning lustre..."
328 [ -L lustre ] && rm -rf $(readlink lustre)
334 echo "Building rpms for: $BUILD_ARCHS..."
336 for arch in $BUILD_ARCHS ; do
337 targets="--target $arch $targets"
340 rpmbuild $targets -bb lustre-kernel-2.4.spec \
341 --define "_topdir $TOPDIR" || \
342 fatal 1 "Error building rpms for $arch."
344 (( $DO_SRC )) && rpmbuild -bs lustre-kernel-2.4.spec \
345 --define "_topdir $TOPDIR" || \
346 fatal 1 "Error building .src.rpm."
351 publishing || return 0
354 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
356 options=$(getopt -o d:D:h -l extraversion:,kerneldir:,lustre:,nosrc,publish,release,tag:,target:,target-archs: -- "$@")
358 eval set -- "$options"
418 usage 1 "Unrecognized option: $1"
428 if (( $DO_SRC )) ; then
435 # prep_build needs the .spec.in from the lustre source