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