Whamcloud - gitweb
Branch HEAD
[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         hp_pnnl-2.4)
213             CANONICAL_TARGET="hp-pnnl-2.4"
214             ;;
215         2.6-vanilla \
216             | suse-2.4.21-2 \
217             | rh-2.4 \
218             | rhel-2.4 \
219             | sles-2.4 \
220             | 2.6-patchless)
221                 CANONICAL_TARGET="$TARGET"
222                 ;;
223     esac
224
225     TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M")
226
227     RPMBUILD=$(which rpmbuild 2>/dev/null | head -1)
228     if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
229         RPMBUILD=$(which rpm 2>/dev/null | head -1)
230         if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
231             usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)."
232         fi
233     fi
234 }
235
236 uniqify()
237 {
238     echo $(echo "$*" | xargs -n 1 | sort -u)
239 }
240
241 build_tarball() {
242     local TARGET=$1
243     local SRPM=$2
244
245     if [ "$TARGET" = "rhel-2.6" -o "$TARGET" = "rhel-2.4" ]; then
246         local SPEC=""
247         if [ "$TARGET" = "rhel-2.6" ]; then
248             SPEC=kernel-2.6.spec
249             OLDCONFIG=nonint_oldconfig
250         elif [ "$TARGET" = "rhel-2.4" ]; then
251             SPEC=kernel-2.4.spec
252             OLDCONFIG=oldconfig
253         fi
254
255         RPMTOPDIR=$(mktemp -d $KERNELDIR/rpm_XXXXXX)
256         mkdir $RPMTOPDIR/BUILD/
257         rpm -ivh $KERNELDIR/$SRPM --define "_topdir $RPMTOPDIR" || \
258             { rm -rf $RPMTOPDIR; fatal 1 "Error installing kernel SRPM."; }
259         $RPMBUILD -bp --nodeps --target i686 $RPMTOPDIR/SPECS/$SPEC --define "_topdir $RPMTOPDIR"
260         pushd $RPMTOPDIR/BUILD/kernel-${lnxmaj}/linux-${lnxmaj} && {
261             make mrproper
262             cp configs/kernel-${lnxmaj}-i686-smp.config .config
263             if ! make $OLDCONFIG > /dev/null; then
264                 fatal 1 "error trying to make $OLDCONFIG while building a tarball from SRPM."
265             fi
266             make include/linux/version.h 
267             rm -f .config
268             cd ..
269             tar cjf $KERNEL_FILE linux-${lnxmaj}
270         }
271         popd
272         rm -rf $RPMTOPDIR
273     fi
274 }
275
276 download_and_build_tarball() {
277     local TARGET=$1
278     local KERNEL_FILE=$2
279
280     local SRPM=kernel-${lnxmaj}-${lnxrel}.src.rpm
281
282     echo "Downloading http://ftp.lustre.org/kernels/$TARGET/old/$SRPM..."
283     if ! wget -nv "http://ftp.lustre.org/kernels/$TARGET/old/$SRPM" \
284         -O "$KERNELDIR/$SRPM" ; then
285         fatal 1 "Could not download target $TARGET's kernel SRPM $SRPM from ftp.lustre.org."
286     fi
287
288     build_tarball $TARGET $SRPM
289 }
290
291 load_target()
292 {
293     EXTRA_VERSION_save="$EXTRA_VERSION"
294     for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
295         TARGET_FILE="$patchesdir/targets/$TARGET.target"
296         [ -r "$TARGET_FILE" ] && break
297     done
298     [ -r "$TARGET_FILE" ] || \
299         fatal 1 "Target $TARGET was not found."
300
301     echo "Loading target config file $TARGET.target..."        
302
303     . "$TARGET_FILE"
304
305     [ "$KERNEL"  ] || fatal 1 "Target $TARGET did not specify a kernel."
306     [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify a kernel version."
307
308     if [ "$KERNELDIR" ] ; then
309         KERNEL_FILE="$KERNELDIR/$KERNEL"
310         if [ ! -r "$KERNELDIR/$KERNEL" ] ; then
311             # see if we have an SRPM we can build a tarball for
312             KERNEL_SRPM=kernel-${lnxmaj}-${lnxrel}.src.rpm
313             if [ -r "$KERNELDIR/$KERNEL_SRPM" ] ; then
314                 build_tarball $CANONICAL_TARGET $KERNEL_SRPM
315             else
316                 if (( $DOWNLOAD )) ; then
317                     echo "Downloading http://ftp.lustre.org/kernels/$CANONICAL_TARGET/old/$KERNEL..."
318                     if ! wget -nv "http://ftp.lustre.org/kernels/$CANONICAL_TARGET/old/$KERNEL" -O "$KERNELDIR/$KERNEL" ; then
319                         # see if we can do it with an SRPM from the download site
320                         download_and_build_tarball $CANONICAL_TARGET $KERNEL_FILE
321                     fi
322                 else
323                     fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR."
324                 fi
325             fi
326         fi
327     fi
328
329     if [ "$SERIES" ] ; then
330         for series in $SERIES ; do
331             for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
332                 [ -r "$patchesdir/series/$series" ] && continue 2
333             done
334             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."
335         done
336     fi
337
338     CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/$CONFIG"
339     [ -r "$CONFIG_FILE" ] || \
340         fatal 1 "Target $TARGET's config file $CONFIG missing from $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/."
341
342     if [ "$EXTRA_VERSION_save" ] ; then
343         EXTRA_VERSION="$EXTRA_VERSION_save"
344     elif ! (( $RELEASE )) ; then
345         # if there is no patch series, then this is not a lustre specific
346         # kernel.  don't make it look like one
347         if [ -n "$SERIES" ]; then
348             #remove the @VERSION@ (lustre version)
349             EXTRA_VERSION=$(echo $EXTRA_VERSION | sed -e "s/\(.*_lustre\)\..*/\1/")
350             EXTRA_VERSION="${EXTRA_VERSION}-${TAG}.${TIMESTAMP}"
351         fi
352     fi
353     # EXTRA_VERSION=${EXTRA_VERSION//-/_}
354
355     ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $BIGSMP_ARCHS $PSERIES64_ARCHS $UP_ARCHS"
356
357     BUILD_ARCHS=
358     for arch in $(uniqify "$ALL_ARCHS") ; do
359         if [ -z "$TARGET_ARCHS" ] || echo "$TARGET_ARCHS" | grep "$arch" >/dev/null 2>/dev/null ; then
360             BUILD_ARCHS="$BUILD_ARCHS $arch"
361         fi
362     done
363     [ "$BUILD_ARCHS" ] || usage 1 "No available target archs to build."
364     echo "Building for: $BUILD_ARCHS"
365 }
366
367 tarflags()
368 {
369     case "$1" in
370         '')
371             fatal 1 "tarflags(): File name argument missing."
372             ;;
373         *.tar.gz | *.tgz)
374             echo 'zxf'
375             ;;
376         *.tar.bz2)
377             echo 'jxf'
378             ;;
379         *.tar)
380             echo 'xf'
381             ;;
382         *)
383             fatal 1 "tarflags(): Unrecognized tar extension in file: $1"
384             ;;
385     esac
386 }
387
388 untar()
389 {
390     echo "Untarring ${1##*/}..."
391     tar $(tarflags "$1") "$1"
392 }
393
394 unpack_lustre()
395 {
396     DIRNAME="lustre-$TAG-$TIMESTAMP"
397     if [ "$LUSTRE" ] ; then
398         untar "$LUSTRE"
399         [ -d lustre ] || ln -sf lustre-[0-9].[0-9]* lustre
400     else
401         if [ "$USE_DATESTAMP" ]; then
402             DATESTAMP="-D '$DATE'"
403         else
404             DATESTAMP=""
405         fi            
406
407         cvs -d "$CVSROOT" -qz3 co $DATESTAMP -d "$DIRNAME" lustre || \
408             fatal 1 "There was an error checking out toplevel Lustre from CVS."
409         pushd "$DIRNAME" > /dev/null
410         ./lustrecvs "$TAG" || \
411             fatal 1 "There was an error checking out Lustre/Portals/Build from CVS."
412         echo "Creating lustre tarball..."
413         sh autogen.sh || fatal 1 "There was an error running autogen.sh."
414         ./configure --disable-{modules,utils,liblustre,tests,doc} || \
415             fatal 1 "There was an error running ./configure to create makefiles."
416         make dist || fatal 1 "There was an error running 'make dist'."
417         popd > /dev/null
418         fname=`basename $DIRNAME/lustre-*.tar.gz`
419         cp $DIRNAME/$fname . || fatal 1 "There was an error copying lustre tarball."
420         LUSTRE="$PWD/$fname"
421         ln -sf "$DIRNAME" lustre
422     fi
423 }
424
425 unpack_linux()
426 {
427     untar "$KERNEL_FILE"
428     [ -d linux ] || ln -sf linux* linux
429 }
430
431 patch_linux()
432 {
433     [ "$SERIES" ] || return 0
434     FULL_PATCH="$PWD/lustre-kernel-${TARGET}-${EXTRA_VERSION}.patch"
435     [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH"
436     pushd linux >/dev/null
437     for series in $SERIES ; do
438         echo -n "Applying series $series:"
439         for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
440             [ -r "$patchesdir/series/$series" ] || continue
441             SERIES_FILE="$patchesdir/series/$series"
442             for patch in $(<"$SERIES_FILE") ; do
443                 echo -n " $patch"
444                 PATCH_FILE="$patchesdir/patches/$patch"
445                 [ -r "$PATCH_FILE" ] || \
446                     fatal 1 "Patch $patch does not exist in Lustre tree."
447                 cat "$PATCH_FILE" >> "$FULL_PATCH" || \
448                     fatal 1 "Error adding patch $patch to full patch."
449                 patch -s -p1 < "$PATCH_FILE" || fatal 1 "Error applying patch $patch."
450             done
451             break
452         done
453         echo
454     done
455     popd >/dev/null
456     echo "Full patch has been saved in ${FULL_PATCH##*/}."
457     echo "Replacing .config files..."
458     [ -d linux/configs ] || mkdir linux/configs || \
459         fatal 1 "Error creating configs directory."
460     rm -f linux/configs/*
461     copysuccess=0
462     for patchesdir in "$EXTERNAL_PATCHES" "lustre/lustre/kernel_patches" ; do
463         [ "$patchesdir" ] && \
464             cp -v $patchesdir/kernel_configs/kernel-${VERSION}-${TARGET}*.config linux/configs/ >/dev/null && copysuccess=1
465     done
466     [ "$copysuccess" = "1" ] || \
467         fatal 1 "Error copying in kernel configs."
468 }
469
470 pack_linux()
471 {
472     TARBALL="$(readlink linux)-$EXTRA_VERSION.tar.gz"
473     echo "Creating patched linux tarball $TARBALL..."
474     tar zcf "$TARBALL" "$(readlink linux)" \
475         --exclude "CVS" --exclude ".cvsignore" || \
476         --exclude "*.orig" --exclude "*~" --exclude "*.rej" || \
477         fatal 1 "Error creating patched Linux tarball."
478 }
479
480 clean_linux()
481 {
482     [ -d linux ] || return 0
483     echo "Cleaning linux..."
484     [ -L linux ] && rm -rf $(readlink linux)
485     rm -rf linux
486 }
487
488 prep_kernel_build()
489 {
490     # make .spec file
491     ENABLE_INIT_SCRIPTS=""
492     sed \
493         -e "s^@BASE_ARCHS@^$BASE_ARCHS^g" \
494         -e "s^@BIGMEM_ARCHS@^$BIGMEM_ARCHS^g" \
495         -e "s^@BIGSMP_ARCHS@^$BIGSMP_ARCHS^g" \
496         -e "s^@BOOT_ARCHS@^$BOOT_ARCHS^g" \
497         -e "s^@CONFIGURE_FLAGS@^$CONFIGURE_FLAGS^g" \
498         -e "s^@ENABLE_INIT_SCRIPTS@^$ENABLE_INIT_SCRIPTS^g" \
499         -e "s^@JENSEN_ARCHS@^$BOOT_ARCHS^g" \
500         -e "s^@KERNEL_EXTRA_VERSION@^$EXTRA_VERSION^g" \
501         -e "s^@KERNEL_RELEASE@^${EXTRA_VERSION//-/_}^g" \
502         -e "s^@KERNEL_SOURCE@^$KERNEL^g" \
503         -e "s^@KERNEL_VERSION@^$VERSION^g" \
504         -e "s^@LINUX26@^$LINUX26^g" \
505         -e "s^@LUSTRE_SOURCE@^${LUSTRE##*/}^g" \
506         -e "s^@LUSTRE_TARGET@^$TARGET^g" \
507         -e "s^@PSERIES64_ARCHS@^$PSERIES64_ARCHS^g" \
508         -e "s^@RHBUILD@^$RHBUILD^g" \
509         -e "s^@SMP_ARCHS@^$SMP_ARCHS^g" \
510         -e "s^@SUSEBUILD@^$SUSEBUILD^g" \
511         -e "s^@SUSEBUILD@^$SUSEBUILD^g" \
512         -e "s^@UP_ARCHS@^$UP_ARCHS^g" \
513         < $TOPDIR/lustre/build/lustre-kernel-2.4.spec.in \
514         > lustre-kernel-2.4.spec
515     [ -d SRPMS ] || mkdir SRPMS
516     [ -d RPMS ] || mkdir RPMS
517     [ -d BUILD ] || mkdir BUILD
518     [ -d SOURCES ] || mkdir SOURCES
519     for script in linux-{rhconfig.h,merge-config.awk,merge-modules.awk} \
520         suse-{functions.sh,post.sh,postun.sh,trigger-script.sh.in} \
521         sles8-{pre,post,postun,update_{INITRD_MODULES,rcfile_setting}}.sh ; do
522         cp $TOPDIR/lustre/build/$script SOURCES
523     done
524     cp "$LUSTRE" "$KERNEL_FILE" SOURCES
525     if [ "$EXTERNAL_PATCHES" -a -d "$EXTERNAL_PATCHES" ] ; then
526         tar zcf SOURCES/external-patches.tar.gz -C "$EXTERNAL_PATCHES" series targets patches kernel_configs
527     else
528         touch SOURCES/external-patches.tar.gz
529     fi
530 }
531
532 clean_lustre()
533 {
534     [ -d lustre ] || return 0
535     echo "Cleaning Lustre..."
536     [ -L lustre ] && rm -rf $(readlink lustre)
537     rm -rf lustre
538 }
539
540 build_kernel()
541 {
542     echo "Building kernel + Lustre RPMs for: $BUILD_ARCHS..."
543     targets=
544     for arch in $BUILD_ARCHS ; do
545         targets="--target $arch $targets"
546     done
547
548     $RPMBUILD $targets -bb lustre-kernel-2.4.spec \
549         --define "_tmppath $TMPDIR" \
550         --define "_topdir $TOPDIR" || \
551         fatal 1 "Error building rpms for $BUILD_ARCHS."
552
553     if (( $DO_SRC )) ; then
554         $RPMBUILD -bs lustre-kernel-2.4.spec \
555             --define "_tmppath $TMPDIR" \
556             --define "_topdir $TOPDIR" || \
557             fatal 1 "Error building .src.rpm."
558     fi
559 }
560
561 build_lustre()
562 {
563     [ -d SRPMS ] || mkdir SRPMS
564     [ -d RPMS ] || mkdir RPMS
565     [ -d BUILD ] || mkdir BUILD
566     [ -d SOURCES ] || mkdir SOURCES
567
568     cp "$LUSTRE" SOURCES
569
570     pushd lustre >/dev/null
571
572     echo "Building Lustre RPMs for: $BUILD_ARCHS..."
573     targets=
574     for arch in $BUILD_ARCHS ; do
575         targets="--target $arch $targets"
576     done
577
578     ./configure "--with-linux=${LINUX}" ${CONFIGURE_FLAGS}
579
580     $RPMBUILD $targets -bb build/lustre.spec \
581         --define "_tmppath $TMPDIR" \
582         --define "_topdir $TOPDIR" || \
583         fatal 1 "Error building rpms for $BUILD_ARCHS."
584
585     popd >/dev/null
586 }
587
588 stage()
589 {
590     [ "$STAGEDIR" ] || return 0
591
592     for arch in $BUILD_ARCHS ; do
593         rpmdir="${STAGEDIR}/${CANONICAL_TARGET}-${arch}"
594         echo "${0##*/}: Copying RPMs into ${rpmdir}"
595         mkdir -p "${rpmdir}"
596         cp -v RPMS/${arch}/*.rpm "${rpmdir}"
597         if [ -d RPMS/noarch ] ; then
598             cp -v RPMS/noarch/*.rpm "${rpmdir}"
599         fi
600     done
601
602     cp -v "$LUSTRE" "$STAGEDIR"
603 }
604
605 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
606
607 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: -- "$@")
608
609 if [ $? != 0 ] ; then
610     usage 1
611 fi
612
613 eval set -- "$options"
614     
615 while [ "$1" ] ; do
616     case "$1" in
617         '')
618             usage 1
619             ;;
620         -d)
621             CVSROOT=$2
622             shift 2
623             ;;
624         -D)
625             DATE=$2
626             shift 2
627             ;;
628         --external-patches)
629             EXTERNAL_PATCHES=$2
630             shift 2
631             ;;
632         --extraversion)
633             EXTRA_VERSION=$2
634             shift 2
635             ;;
636         --help | -h)
637             usage 0
638             ;;
639         --kerneldir)
640             KERNELDIR=$2
641             shift 2
642             ;;
643         --linux | --with-linux)
644             LINUX=$2
645             shift 2
646             ;;
647         --lustre)
648             LUSTRE=$2
649             shift 2
650             ;;
651         --nodownload)
652             DOWNLOAD=0
653             shift 1
654             ;;
655         --nosrc)
656             DO_SRC=0
657             shift 1
658             ;;
659         --publish)
660             shift
661             ;;
662         --release)
663             RELEASE=1
664             shift
665             ;;
666         --src)
667             DO_SRC=1
668             shift 1
669             ;;
670         --stage)
671             STAGEDIR=$2
672             shift 2
673             ;;
674         --tag)
675             TAG=$2
676             shift 2
677             ;;
678         --target)
679             TARGET=$2
680             shift 2
681             ;;
682         --target-archs)
683             TARGET_ARCHS=$2
684             shift 2
685             ;;
686         --disable-datestamp)
687             USE_DATESTAMP=
688             shift
689             ;;
690         --)
691             shift
692             CONFIGURE_FLAGS=$@
693             break
694             ;; 
695         *)
696             usage 1 "Unrecognized option: $1"
697             ;;
698     esac
699 done
700
701 check_options
702
703 unpack_lustre
704
705 # prep_build needs the .spec.in from the lustre source
706 if [ -z "$LINUX" ] ; then
707     load_target
708     if (( $DO_SRC )) ; then
709         unpack_linux
710         patch_linux
711         pack_linux
712         clean_linux
713     fi
714
715     prep_kernel_build
716     clean_lustre
717
718     build_kernel
719 else
720     build_lustre
721 fi
722
723 stage