From e64fa4496f50fbcb426da609b8c34b4c535a704e Mon Sep 17 00:00:00 2001
From: jacob <jacob>
Date: Fri, 22 Apr 2005 22:04:08 +0000
Subject: [PATCH] If the kernel file isn't in KERNELDIR then try to wget it
 from our ftp server.

---
 build/lbuild | 41 ++++++++++++++++++++++++++++++++++++++---
 1 file changed, 38 insertions(+), 3 deletions(-)

diff --git a/build/lbuild b/build/lbuild
index 03c415edc4..b6e071067b 100755
--- a/build/lbuild
+++ b/build/lbuild
@@ -8,6 +8,7 @@ LUSTRE=
 PUBLISH=0
 RELEASE=0
 DO_SRC=0
+DOWNLOAD=1
 TAG=
 TARGET=
 TARGET_ARCHS=
@@ -117,6 +118,9 @@ Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
     Path to an existing lustre source tarball to use instead of
     pulling from CVS.
 
+  --nodownload
+    Do not try to download a kernel from ftp.lustre.org
+
   --nosrc
     Do not build a .src.rpm, a full kernel patch, or a patched kernel
     tarball.
@@ -222,8 +226,35 @@ load_target()
 
     if [ "$KERNELDIR" ] ; then
 	KERNEL_FILE="$KERNELDIR/$KERNEL"
-	[ -r "$KERNELDIR/$KERNEL" ] || \
-	    fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR."
+	if [ ! -r "$KERNELDIR/$KERNEL" ] ; then
+	    case $TARGET in
+		2.6-rhel4)
+		    dldir="rhel-2.6"
+		    ;;
+		2.6-suse)
+		    dldir="suse-2.6"
+		    ;;
+		hp_pnnl-2.4)
+		    dldir="hp-pnnl-2.4"
+		    ;;
+		2.6-vanilla \
+		| suse-2.4.21-2 \
+		| rh-2.4 \
+		| rhel-2.4 \
+		| sles-2.4)
+		    dldir="$TARGET"
+		    ;;
+	    esac
+	    if (( $DOWNLOAD )) ; then
+		echo "Downloading http://ftp.lustre.org/kernels/$dldir/old/$KERNEL..."
+		if ! wget -nv "http://ftp.lustre.org/kernels/$dldir/old/$KERNEL" \
+		    -O "$KERNELDIR/$KERNEL" ; then
+		    fatal 1 "Could not download target $TARGET's kernel file $KERNEL from ftp.lustre.org."
+		fi
+	    else
+		fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR."
+	    fi
+	fi
     fi
 
     if [ "$SERIES" ] ; then
@@ -456,7 +487,7 @@ publish()
 
 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
 
-options=$(getopt -o d:D:h -l external-patches:,extraversion:,kerneldir:,lustre:,nosrc,publish,release,tag:,target:,target-archs:,disable-datestamp -- "$@")
+options=$(getopt -o d:D:h -l external-patches:,extraversion:,kerneldir:,lustre:,nodownload,nosrc,publish,release,tag:,target:,target-archs:,disable-datestamp -- "$@")
 
 eval set -- "$options"
     
@@ -492,6 +523,10 @@ while [ "$1" ] ; do
 	    LUSTRE=$2
 	    shift 2
 	    ;;
+	--nodownload)
+	    DOWNLOAD=0
+	    shift 1
+	    ;;
 	--nosrc)
 	    DO_SRC=0
 	    shift 1
-- 
GitLab