Whamcloud - gitweb
d6e95ca403a666cee99e9657fcb30b438f57bb85
[fs/lustre-release.git] / build / lbuild
1 #!/bin/sh
2
3 TOPDIR=$PWD
4
5 # CVSROOT is inherited from the environment
6 KERNELDIR=
7 LINUX=
8 LUSTRE=
9 RELEASE=0
10 DO_SRC=0
11 DOWNLOAD=1
12 TAG=
13 TARGET=
14 TARGET_ARCHS=
15 CONFIGURE_FLAGS=
16 EXTERNAL_PATCHES=
17 EXTRA_VERSION=
18 STAGEDIR=
19
20 # from target file
21 KERNEL=
22 SERIES=
23 CONFIG=
24 VERSION=
25
26 RHBUILD=0
27 SUSEBUILD=0
28 LINUX26=0
29 SUSEBUILD=0
30
31 BASE_ARCHS=
32 BIGMEM_ARCHS=
33 BOOT_ARCHS=
34 JENSEN_ARCHS=
35 SMP_ARCHS=
36 BIGSMP_ARCHS=
37 PSERIES64_ARCHS=
38 UP_ARCHS=
39
40 DATE=$(date)
41
42 USE_DATESTAMP=1
43 RPMBUILD=
44
45 export CC=${CC:-gcc}
46
47 # Readlink is not present on some older distributions: emulate it.
48 readlink() {
49     local path=$1 ll
50
51     if [ -L "$path" ]; then
52         ll="$(LC_ALL=C ls -l "$path" 2> /dev/null)" &&
53         echo "${ll/* -> }"
54     else
55         return 1
56     fi
57 }
58
59 cleanup()
60 {
61     true
62 }
63
64 error()
65 {
66     [ "$1" ] && echo -e "\n${0##*/}: $1"
67 }
68
69 fatal()
70 {
71     cleanup
72     error "$2"
73     exit $1
74 }
75
76 is_release()
77 {
78     (( $RELEASE )) || return 0
79 }
80
81 list_targets()
82 {
83     echo -n "Available targets:"
84     for target in $TOPDIR/lustre/lustre/kernel_patches/targets/*.target ; do
85         target_file=${target##*/}
86         echo -n " ${target_file%%.target}"
87     done
88     echo
89 }
90
91 usage()
92 {
93     cat <<EOF
94 Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
95
96   -d CVSROOT
97     Specifies the CVS Root to use when pulling files from CVS.  The
98     environment variable \$CVSROOT is used if this option is not
99     present.
100
101   --external-patches=EXTERNAL_PATCHES
102     Directory similar to lustre/lustre/kernel_patches/ that lbuild should
103     look for seres and config files in before looking in the lustre
104     tree.
105
106   --extraversion=EXTRAVERSION
107     Text to use for the rpm release and kernel extraversion.
108
109   --kerneldir=KERNELDIR
110     Directory containing Linux source tarballs referenced by target
111     files.
112
113   --linux=LINUX
114     Directory of Linux kernel sources.  When this option is used, only
115     Lustre modules and userspace are built.
116
117   --lustre=LUSTRE
118     Path to an existing lustre source tarball to use instead of
119     pulling from CVS.
120
121   --nodownload
122     Do not try to download a kernel from ftp.lustre.org
123
124   --nosrc
125     Do not build a .src.rpm, a full kernel patch, or a patched kernel
126     tarball.
127
128   --publish
129     Unused.
130
131   --release
132     Specifies that the files generated do not include timestamps, and
133     that this is an official release.
134
135   --src
136     Build a .src.rpm, a full kernel patch, and a patched kernel tarball.
137
138   --stage=DIR
139     Directory used to stage packages for release.  RPMs will be placed
140     more or less in DIR/<target>-<arch>, and the tarball will be
141     placed in DIR.
142
143   --tag=TAG
144     A CVS branch/tag name to build from when pulling from CVS.
145
146   --target=TARGET
147     The name of the target to build.  The available targets are listed
148     below.
149
150   --target-archs=TARGET_ARCHS
151     A (space delimited) list of architectures to build.  By default,
152     all of the archs supported by the TARGET will be built, in
153     addition to a .src.rpm.  This option can limit those, for machines
154     that can only build certain archs or if you only want a certain
155     arch built (for testing, or a one-off kernel).
156
157     Also note that by using a non-"base" arch (eg, i386) only kernels
158     will be built - there will be no lustre-lite-utils package.
159
160   --disable-datestamp
161     Prevents the datestamp flag (-D) from being passed to cvs for 
162     checkouts. This is a workaround for a problem encountered when 
163     using lbuild with tinderbox.
164
165 EOF
166
167 #   list_targets
168
169     fatal "$1" "$2"
170 }
171
172 check_options()
173 {
174     if [ "$LUSTRE" ] ; then
175         [ -r "$LUSTRE" ] || \
176             usage 1 "Could not find Lustre source tarball '$LUSTRE'."
177     else
178         [ "$CVSROOT" ] || \
179             usage 1 "Either specify a CVS Root with -d, or a Lustre source tarball with --lustre."
180         [ "$TAG" ] || \
181             usage 1 "A branch/tag name must be specified with --tag when not building from a tarball."
182     fi
183
184     if [ -z "$LINUX" ] ; then
185         [ "$KERNELDIR" ] || \
186             usage 1 "A kernel directory must be specified with --kerneldir."
187
188         [ -d "$KERNELDIR" ] || \
189             usage 1 "$KERNELDIR is not a directory."
190
191         if ! (( $RELEASE )) ; then
192             [ "$TAG" ] || \
193                 usage 1 "When building a snapshot, a tag name must be used."
194         fi
195
196         [ "$TARGET" ] || usage 1 "A target must be specified with --target."
197 #       TARGET_FILE="$TOPDIR/lustre/kernel_patches/targets/$TARGET.target"
198 #       [ -r "$TARGET_FILE" ] || \
199 #               usage 1 "Target '$TARGET' was not found."
200     fi
201
202     case $TARGET in
203         2.6-rhel4)
204             CANONICAL_TARGET="rhel-2.6"
205             ;;
206         2.6-suse)
207             CANONICAL_TARGET="sles-2.6"
208             ;;
209         hp_pnnl-2.4)
210             CANONICAL_TARGET="hp-pnnl-2.4"
211             ;;
212         2.6-vanilla \
213             | suse-2.4.21-2 \
214             | rh-2.4 \
215             | rhel-2.4 \
216             | sles-2.4)
217                 CANONICAL_TARGET="$TARGET"
218                 ;;
219     esac
220
221     TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M")
222
223     RPMBUILD=$(which rpmbuild 2>/dev/null | head -1)
224     if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
225         RPMBUILD=$(which rpm 2>/dev/null | head -1)
226         if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
227             usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)."
228         fi
229     fi
230 }
231
232 uniqify()
233 {
234     echo $(echo "$*" | xargs -n 1 | sort -u)
235 }
236
237 download_and_build_tarball() {
238     local TARGET=$1
239     local KERNEL_FILE=$2
240
241     local SRPM=kernel-${lnxmaj}-${lnxrel}.src.rpm
242
243     echo "Downloading http://ftp.lustre.org/kernels/$TARGET/old/$SRPM..."
244     if ! wget -nv "http://ftp.lustre.org/kernels/$TARGET/old/$SRPM" \
245         -O "$KERNELDIR/$SRPM" ; then
246         fatal 1 "Could not download target $TARGET's kernel SRPM $SRPM from ftp.lustre.org."
247     fi
248
249     if [ "$TARGET" = "rhel-2.6" ]; then
250         RPMTOPDIR=$(mktemp -d $KERNELDIR/rpm_XXXXXX)
251         mkdir $RPMTOPDIR/BUILD/
252         rpm -ivh $KERNELDIR/$SRPM --define "_topdir $RPMTOPDIR" || \
253             { rm -rf $RPMTOPDIR; fatal 1 "Error installing kernel SRPM."; }
254         $RPMBUILD -bp --nodeps --target i686 $RPMTOPDIR/SPECS/kernel-2.6.spec --define "_topdir $RPMTOPDIR"
255         pushd $RPMTOPDIR/BUILD/kernel-${lnxmaj}/linux-${lnxmaj} && {
256             make mrproper
257             cp configs/kernel-${lnxmaj}-i686-smp.config .config
258             make nonint_oldconfig > /dev/null
259             make include/linux/version.h 
260             rm -f .config
261             cd ..
262             tar cjf $KERNEL_FILE linux-${lnxmaj}
263         }
264         popd
265         rm -rf $RPMTOPDIR
266     fi
267 }
268
269 load_target()
270 {
271     EXTRA_VERSION_save="$EXTRA_VERSION"
272     for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
273         TARGET_FILE="$patchesdir/targets/$TARGET.target"
274         [ -r "$TARGET_FILE" ] && break
275     done
276     [ -r "$TARGET_FILE" ] || \
277         fatal 1 "Target $TARGET was not found."
278
279     echo "Loading target config file $TARGET.target..." 
280
281     . "$TARGET_FILE"
282
283     [ "$KERNEL"  ] || fatal 1 "Target $TARGET did not specify a kernel."
284 #    [ "$SERIES"  ] || fatal 1 "Target $TARGET did not specify a kernel patch series."
285 #    [ "$CONFIG"  ] || fatal 1 "Target $TARGET did not specify a kernel config."
286     [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify a kernel version."
287
288     if [ "$KERNELDIR" ] ; then
289         KERNEL_FILE="$KERNELDIR/$KERNEL"
290         if [ ! -r "$KERNELDIR/$KERNEL" ] ; then
291             if (( $DOWNLOAD )) ; then
292                 echo "Downloading http://ftp.lustre.org/kernels/$CANONICAL_TARGET/old/$KERNEL..."
293                 if ! wget -nv "http://ftp.lustre.org/kernels/$CANONICAL_TARGET/old/$KERNEL" -O "$KERNELDIR/$KERNEL" ; then
294                     # see if we can do it with an SRPM from the download site
295                     download_and_build_tarball $CANONICAL_TARGET $KERNEL_FILE
296                 fi
297             else
298                 fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR."
299             fi
300         fi
301     fi
302
303     if [ "$SERIES" ] ; then
304         for series in $SERIES ; do
305             for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
306                 [ -r "$patchesdir/series/$series" ] && continue 2
307             done
308             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."
309         done
310     fi
311
312     CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/$CONFIG"
313     [ -r "$CONFIG_FILE" ] || \
314         fatal 1 "Target $TARGET's config file $CONFIG missing from $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/."
315
316     if [ "$EXTRA_VERSION_save" ] ; then
317         EXTRA_VERSION="$EXTRA_VERSION_save"
318     elif ! (( $RELEASE )) ; then
319         #remove the @VERSION@ (lustre version)
320         EXTRA_VERSION=$(echo $EXTRA_VERSION | sed -e "s/\(.*_lustre\)\..*/\1/")
321         EXTRA_VERSION="${EXTRA_VERSION}-${TAG}.${TIMESTAMP}"
322     fi
323     # EXTRA_VERSION=${EXTRA_VERSION//-/_}
324
325     ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $BIGSMP_ARCHS $PSERIES64_ARCHS $UP_ARCHS"
326
327     BUILD_ARCHS=
328     for arch in $(uniqify "$ALL_ARCHS") ; do
329         if [ -z "$TARGET_ARCHS" ] || echo "$TARGET_ARCHS" | grep "$arch" >/dev/null 2>/dev/null ; then
330             BUILD_ARCHS="$BUILD_ARCHS $arch"
331         fi
332     done
333     [ "$BUILD_ARCHS" ] || usage 1 "No available target archs to build."
334     echo "Building for: $BUILD_ARCHS"
335 }
336
337 tarflags()
338 {
339     case "$1" in
340         '')
341             fatal 1 "tarflags(): File name argument missing."
342             ;;
343         *.tar.gz | *.tgz)
344             echo 'zxf'
345             ;;
346         *.tar.bz2)
347             echo 'jxf'
348             ;;
349         *.tar)
350             echo 'xf'
351             ;;
352         *)
353             fatal 1 "tarflags(): Unrecognized tar extension in file: $1"
354             ;;
355     esac
356 }
357
358 untar()
359 {
360     echo "Untarring ${1##*/}..."
361     tar $(tarflags "$1") "$1"
362 }
363
364 unpack_lustre()
365 {
366     DIRNAME="lustre-$TAG-$TIMESTAMP"
367     if [ "$LUSTRE" ] ; then
368         untar "$LUSTRE"
369         [ -d lustre ] || ln -sf lustre* lustre
370     else
371         if [ "$USE_DATESTAMP" ]; then
372             DATESTAMP="-D '$DATE'"
373         else
374             DATESTAMP=""
375         fi          
376
377         cvs -d "$CVSROOT" -qz3 co $DATESTAMP -d "$DIRNAME" lustre || \
378             fatal 1 "There was an error checking out toplevel Lustre from CVS."
379         pushd "$DIRNAME" > /dev/null
380         ./lustrecvs "$TAG" || \
381             fatal 1 "There was an error checking out Lustre/Portals/Build from CVS."
382         echo "Creating lustre tarball..."
383         sh autogen.sh || fatal 1 "There was an error running autogen.sh."
384         ./configure --disable-{modules,utils,liblustre,tests,doc} || \
385             fatal 1 "There was an error running ./configure to create makefiles."
386         make dist || fatal 1 "There was an error running 'make dist'."
387         popd > /dev/null
388         fname=`basename $DIRNAME/lustre-*.tar.gz`
389         cp $DIRNAME/$fname . || fatal 1 "There was an error copying lustre tarball."
390         LUSTRE="$PWD/$fname"
391         ln -sf "$DIRNAME" lustre
392     fi
393 }
394
395 unpack_linux()
396 {
397     untar "$KERNEL_FILE"
398     [ -d linux ] || ln -sf linux* linux
399 }
400
401 patch_linux()
402 {
403     [ "$SERIES" ] || return 0
404     FULL_PATCH="$PWD/lustre-kernel-${TARGET}-${EXTRA_VERSION}.patch"
405     [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH"
406     pushd linux >/dev/null
407     for series in $SERIES ; do
408         echo -n "Applying series $series:"
409         for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
410             [ -r "$patchesdir/series/$series" ] || continue
411             SERIES_FILE="$patchesdir/series/$series"
412             for patch in $(<"$SERIES_FILE") ; do
413                 echo -n " $patch"
414                 PATCH_FILE="$patchesdir/patches/$patch"
415                 [ -r "$PATCH_FILE" ] || \
416                     fatal 1 "Patch $patch does not exist in Lustre tree."
417                 cat "$PATCH_FILE" >> "$FULL_PATCH" || \
418                     fatal 1 "Error adding patch $patch to full patch."
419                 patch -s -p1 < "$PATCH_FILE" || fatal 1 "Error applying patch $patch."
420             done
421             break
422         done
423         echo
424     done
425     popd >/dev/null
426     echo "Full patch has been saved in ${FULL_PATCH##*/}."
427     echo "Replacing .config files..."
428     [ -d linux/configs ] || mkdir linux/configs || \
429         fatal 1 "Error creating configs directory."
430     rm -f linux/configs/*
431     copysuccess=0
432     for patchesdir in "$EXTERNAL_PATCHES" "lustre/lustre/kernel_patches" ; do
433         [ "$patchesdir" ] && \
434             cp -v $patchesdir/kernel_configs/kernel-${VERSION}-${TARGET}*.config linux/configs/ >/dev/null && copysuccess=1
435     done
436     [ "$copysuccess" = "1" ] || \
437         fatal 1 "Error copying in kernel configs."
438 }
439
440 pack_linux()
441 {
442     TARBALL="$(readlink linux)-$EXTRA_VERSION.tar.gz"
443     echo "Creating patched linux tarball $TARBALL..."
444     tar zcf "$TARBALL" "$(readlink linux)" \
445         --exclude "CVS" --exclude ".cvsignore" || \
446         --exclude "*.orig" --exclude "*~" --exclude "*.rej" || \
447         fatal 1 "Error creating patched Linux tarball."
448 }
449
450 clean_linux()
451 {
452     [ -d linux ] || return 0
453     echo "Cleaning linux..."
454     [ -L linux ] && rm -rf $(readlink linux)
455     rm -rf linux
456 }
457
458 prep_kernel_build()
459 {
460     # make .spec file
461     ENABLE_INIT_SCRIPTS=""
462     sed \
463         -e "s^@BASE_ARCHS@^$BASE_ARCHS^g" \
464         -e "s^@BIGMEM_ARCHS@^$BIGMEM_ARCHS^g" \
465         -e "s^@BIGSMP_ARCHS@^$BIGSMP_ARCHS^g" \
466         -e "s^@BOOT_ARCHS@^$BOOT_ARCHS^g" \
467         -e "s^@CONFIGURE_FLAGS@^$CONFIGURE_FLAGS^g" \
468         -e "s^@ENABLE_INIT_SCRIPTS@^$ENABLE_INIT_SCRIPTS^g" \
469         -e "s^@JENSEN_ARCHS@^$BOOT_ARCHS^g" \
470         -e "s^@KERNEL_EXTRA_VERSION@^$EXTRA_VERSION^g" \
471         -e "s^@KERNEL_RELEASE@^${EXTRA_VERSION//-/_}^g" \
472         -e "s^@KERNEL_SOURCE@^$KERNEL^g" \
473         -e "s^@KERNEL_VERSION@^$VERSION^g" \
474         -e "s^@LINUX26@^$LINUX26^g" \
475         -e "s^@LUSTRE_SOURCE@^${LUSTRE##*/}^g" \
476         -e "s^@LUSTRE_TARGET@^$TARGET^g" \
477         -e "s^@PSERIES64_ARCHS@^$PSERIES64_ARCHS^g" \
478         -e "s^@RHBUILD@^$RHBUILD^g" \
479         -e "s^@SMP_ARCHS@^$SMP_ARCHS^g" \
480         -e "s^@SUSEBUILD@^$SUSEBUILD^g" \
481         -e "s^@SUSEBUILD@^$SUSEBUILD^g" \
482         -e "s^@UP_ARCHS@^$UP_ARCHS^g" \
483         < $TOPDIR/lustre/build/lustre-kernel-2.4.spec.in \
484         > lustre-kernel-2.4.spec
485     [ -d SRPMS ] || mkdir SRPMS
486     [ -d RPMS ] || mkdir RPMS
487     [ -d BUILD ] || mkdir BUILD
488     [ -d SOURCES ] || mkdir SOURCES
489     for script in linux-{rhconfig.h,merge-config.awk,merge-modules.awk} \
490         suse-{functions.sh,post.sh,postun.sh,trigger-script.sh.in} \
491         sles8-{pre,post,postun,update_{INITRD_MODULES,rcfile_setting}}.sh ; do
492         cp $TOPDIR/lustre/build/$script SOURCES
493     done
494     cp "$LUSTRE" "$KERNEL_FILE" SOURCES
495     if [ "$EXTERNAL_PATCHES" -a -d "$EXTERNAL_PATCHES" ] ; then
496         tar zcf SOURCES/external-patches.tar.gz -C "$EXTERNAL_PATCHES" series targets patches kernel_configs
497     else
498         touch SOURCES/external-patches.tar.gz
499     fi
500 }
501
502 clean_lustre()
503 {
504     [ -d lustre ] || return 0
505     echo "Cleaning Lustre..."
506     [ -L lustre ] && rm -rf $(readlink lustre)
507     rm -rf lustre
508 }
509
510 build_kernel()
511 {
512     echo "Building kernel + Lustre RPMs for: $BUILD_ARCHS..."
513     targets=
514     for arch in $BUILD_ARCHS ; do
515         targets="--target $arch $targets"
516     done
517
518     $RPMBUILD $targets -bb lustre-kernel-2.4.spec \
519         --define "_topdir $TOPDIR" || \
520         fatal 1 "Error building rpms for $BUILD_ARCHS."
521
522     if (( $DO_SRC )) ; then
523         $RPMBUILD -bs lustre-kernel-2.4.spec \
524             --define "_topdir $TOPDIR" || \
525             fatal 1 "Error building .src.rpm."
526     fi
527 }
528
529 build_lustre()
530 {
531     [ -d SRPMS ] || mkdir SRPMS
532     [ -d RPMS ] || mkdir RPMS
533     [ -d BUILD ] || mkdir BUILD
534     [ -d SOURCES ] || mkdir SOURCES
535
536     cp "$LUSTRE" SOURCES
537
538     pushd lustre >/dev/null
539
540     echo "Building Lustre RPMs for: $BUILD_ARCHS..."
541     targets=
542     for arch in $BUILD_ARCHS ; do
543         targets="--target $arch $targets"
544     done
545
546     ./configure "--with-linux=${LINUX}" ${CONFIGURE_FLAGS}
547
548     $RPMBUILD $targets -bb build/lustre.spec \
549         --define "_topdir $TOPDIR" || \
550         fatal 1 "Error building rpms for $BUILD_ARCHS."
551
552     popd >/dev/null
553 }
554
555 stage()
556 {
557     [ "$STAGEDIR" ] || return 0
558
559     for arch in $BUILD_ARCHS ; do
560         rpmdir="${STAGEDIR}/${CANONICAL_TARGET}-${arch}"
561         echo "${0##*/}: Copying RPMs into ${rpmdir}"
562         mkdir -p "${rpmdir}"
563         cp -v RPMS/${arch}/*.rpm "${rpmdir}"
564         if [ -d RPMS/noarch ] ; then
565             cp -v RPMS/noarch/*.rpm "${rpmdir}"
566         fi
567     done
568
569     cp -v "$LUSTRE" "$STAGEDIR"
570 }
571
572 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
573
574 options=$(getopt -o d:D:h -l disable-datestamp,external-patches:,extraversion:,kerneldir:,linux:,lustre:,nodownload,nosrc,publish,release,stage:,tag:,target:,target-archs:,with-linux: -- "$@")
575
576 if [ $? != 0 ] ; then
577     usage 1
578 fi
579
580 eval set -- "$options"
581     
582 while [ "$1" ] ; do
583     case "$1" in
584         '')
585             usage 1
586             ;;
587         -d)
588             CVSROOT=$2
589             shift 2
590             ;;
591         -D)
592             DATE=$2
593             shift 2
594             ;;
595         --external-patches)
596             EXTERNAL_PATCHES=$2
597             shift 2
598             ;;
599         --extraversion)
600             EXTRA_VERSION=$2
601             shift 2
602             ;;
603         --help | -h)
604             usage 0
605             ;;
606         --kerneldir)
607             KERNELDIR=$2
608             shift 2
609             ;;
610         --linux | --with-linux)
611             LINUX=$2
612             shift 2
613             ;;
614         --lustre)
615             LUSTRE=$2
616             shift 2
617             ;;
618         --nodownload)
619             DOWNLOAD=0
620             shift 1
621             ;;
622         --nosrc)
623             DO_SRC=0
624             shift 1
625             ;;
626         --publish)
627             shift
628             ;;
629         --release)
630             RELEASE=1
631             shift
632             ;;
633         --src)
634             DO_SRC=1
635             shift 1
636             ;;
637         --stage)
638             STAGEDIR=$2
639             shift 2
640             ;;
641         --tag)
642             TAG=$2
643             shift 2
644             ;;
645         --target)
646             TARGET=$2
647             shift 2
648             ;;
649         --target-archs)
650             TARGET_ARCHS=$2
651             shift 2
652             ;;
653         --disable-datestamp)
654             USE_DATESTAMP=
655             shift
656             ;;
657         --)
658             shift
659             CONFIGURE_FLAGS=$@
660             break
661             ;; 
662         *)
663             usage 1 "Unrecognized option: $1"
664             ;;
665     esac
666 done
667
668 check_options
669
670 unpack_lustre
671
672 # prep_build needs the .spec.in from the lustre source
673 if [ -z "$LINUX" ] ; then
674     load_target
675
676     if (( $DO_SRC )) ; then
677         unpack_linux
678         patch_linux
679         pack_linux
680         clean_linux
681     fi
682
683     prep_kernel_build
684     clean_lustre
685
686     build_kernel
687 else
688     build_lustre
689 fi
690
691 stage