From 50a30160e2f25863bdda49625ff1230bc23f6bba Mon Sep 17 00:00:00 2001
From: adilger <adilger>
Date: Thu, 29 Jan 2004 00:15:39 +0000
Subject: [PATCH] Kernel RPM build fixes from b1_0. b=2516

---
 lustre/scripts/Makefile.am               |  6 +++-
 lustre/scripts/lbuild                    | 36 +++++++++++++-----------
 lustre/scripts/lmake                     |  9 +++---
 lustre/scripts/lustre-kernel-2.4.spec.in | 15 ++++++----
 4 files changed, 38 insertions(+), 28 deletions(-)

diff --git a/lustre/scripts/Makefile.am b/lustre/scripts/Makefile.am
index a1c8feadfd..4da183e03c 100644
--- a/lustre/scripts/Makefile.am
+++ b/lustre/scripts/Makefile.am
@@ -3,7 +3,11 @@
 # This code is issued under the GNU General Public License.
 # See the file COPYING in this distribution
 
-EXTRA_DIST = license-status maketags.sh lustre.spec version_tag.pl $(initd_SCRIPTS)
+EXTRA_DIST = license-status maketags.sh lustre.spec version_tag.pl	\
+	$(initd_SCRIPTS) lustre.spec.in lustre-kernel-2.4.spec.in	\
+	lmake linux-merge-config.awk linux-merge-modules.awk		\
+	linux-rhconfig.h
+
 initddir = $(sysconfdir)/init.d
 initd_SCRIPTS = lustre
 
diff --git a/lustre/scripts/lbuild b/lustre/scripts/lbuild
index 327ae91c11..0e682c5674 100755
--- a/lustre/scripts/lbuild
+++ b/lustre/scripts/lbuild
@@ -136,7 +136,7 @@ check_options()
     [ -d "$KERNELDIR" ] || \
 	usage 1 "$KERNELDIR is not a directory."
 
-    if [ "$RELEASE" = "no" ] ; then
+    if ! (( $RELEASE )) ; then
 	[ "$TAG" ] || \
 	    usage 1 "When building a snapshot, a tag name must be used."
     fi
@@ -186,10 +186,10 @@ load_target()
 
     if [ "$EXTRA_VERSION_save" ] ; then
 	EXTRA_VERSION="$EXTRA_VERSION_save"
-    else
-	EXTRA_VERSION="${EXTRA_VERSION}_${TAG//_/}.${TIMESTAMP}"
+    elif ! (( $RELEASE )) ; then
+	EXTRA_VERSION="${EXTRA_VERSION}-${TAG//_/}.${TIMESTAMP}"
     fi
-    EXTRA_VERSION=${EXTRA_VERSION//-/_/}
+    # EXTRA_VERSION=${EXTRA_VERSION//-/_}
 
     ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $UP_ARCHS"
 
@@ -253,7 +253,7 @@ unpack_linux()
 
 patch_linux()
 {
-    FULL_PATCH="$PWD/lustre-kernel-${target}-${EXTRA_VERSION}.patch"
+    FULL_PATCH="$PWD/lustre-kernel-${TARGET}-${EXTRA_VERSION}.patch"
     [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH"
     pushd linux >/dev/null
     echo -n "Applying patches:"
@@ -295,24 +295,26 @@ clean_linux()
 prep_build()
 {
     # make .spec file
-    sed -e s/@KERNEL_VERSION@/$VERSION/g \
-	-e s/@KERNEL_RELEASE@/$EXTRA_VERSION/g \
-	-e s/@KERNEL_SOURCE@/$KERNEL/g \
-	-e s/@LUSTRE_SOURCE@/${LUSTRE##*/}/g \
-	-e s/@LUSTRE_TARGET@/$TARGET/g \
-	-e s/@CONFIGURE_FLAGS@/$CONFIGURE_FLAGS/g \
-	-e s/@BASE_ARCHS@/$BASE_ARCHS/g \
-	-e s/@BIGMEM_ARCHS@/$BIGMEM_ARCHS/g \
-	-e s/@BOOT_ARCHS@/$BOOT_ARCHS/g \
-	-e s/@JENSEN_ARCHS@/$BOOT_ARCHS/g \
-	-e s/@SMP_ARCHS@/$SMP_ARCHS/g \
-	-e s/@UP_ARCHS@/$UP_ARCHS/g \
+    sed -e "s/@KERNEL_VERSION@/$VERSION/g" \
+	-e "s/@KERNEL_EXTRA_VERSION@/$EXTRA_VERSION/g" \
+	-e "s^@KERNEL_RELEASE@^${EXTRA_VERSION//-/_}^g" \
+	-e "s/@KERNEL_SOURCE@/$KERNEL/g" \
+	-e "s/@LUSTRE_SOURCE@/${LUSTRE##*/}/g" \
+	-e "s/@LUSTRE_TARGET@/$TARGET/g" \
+	-e "s/@CONFIGURE_FLAGS@/$CONFIGURE_FLAGS/g" \
+	-e "s/@BASE_ARCHS@/$BASE_ARCHS/g" \
+	-e "s/@BIGMEM_ARCHS@/$BIGMEM_ARCHS/g" \
+	-e "s/@BOOT_ARCHS@/$BOOT_ARCHS/g" \
+	-e "s/@JENSEN_ARCHS@/$BOOT_ARCHS/g" \
+	-e "s/@SMP_ARCHS@/$SMP_ARCHS/g" \
+	-e "s/@UP_ARCHS@/$UP_ARCHS/g" \
 	< $TOPDIR/lustre/scripts/lustre-kernel-2.4.spec.in \
 	> lustre-kernel-2.4.spec
     [ -d SRPMS ] || mkdir SRPMS
     [ -d RPMS ] || mkdir RPMS
     [ -d BUILD ] || mkdir BUILD
     [ -d SOURCES ] || mkdir SOURCES
+    cp $TOPDIR/lustre/scripts/linux-rhconfig.h SOURCES
     cp $TOPDIR/lustre/scripts/linux-merge-config.awk SOURCES
     cp $TOPDIR/lustre/scripts/linux-merge-modules.awk SOURCES
     cp "$LUSTRE" "$KERNEL_FILE" SOURCES
diff --git a/lustre/scripts/lmake b/lustre/scripts/lmake
index addbe4f5df..3a851a8567 100755
--- a/lustre/scripts/lmake
+++ b/lustre/scripts/lmake
@@ -6,7 +6,7 @@ KERNELDIR=
 TARGET=
 # Not sure what to put here
 # TARGET_ARCH=$(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
-TARGET_ARCH="i386"
+TARGET_ARCH=
 TARGET_CONFIG=
 JOBS=1
 CONFIGURE_FLAGS=
@@ -208,10 +208,11 @@ load_target()
     [ -r "$SERIES_FILE" ] || \
 	fatal 1 "Target $TARGET's series $SERIES missing from $TOPDIR/kernel_patches/series."
 
-    CONFIG_TARGET="$TARGET${TARGET_ARCH:+-$TARGET_ARCH}${TARGET_CONFIG:+-$TARGET_CONFIG}"
+    TARGET_ARCH=${TARGET_ARCH:-$BASE_ARCHS}
+    CONFIG_TARGET="$TARGET-${TARGET_ARCH}${TARGET_CONFIG:+-$TARGET_CONFIG}"
     CONFIG_FILE="$TOPDIR/kernel_patches/kernel_configs/kernel-$VERSION-$CONFIG_TARGET.config"
-    [ -r "$CONFIG_FILE" ] || \
-	fatal 1 "Target $TARGET's config file $CONFIG missing from $TOPDIR/kernel_patches/configs."
+    [ -r "$CONFIG_FILE" ] ||
+	fatal 1 "Target $TARGET's config file $CONFIG_FILE missing from $TOPDIR/kernel_patches/configs."
 
     if [ "$EXTRA_VERSION_save" ] ; then
 	EXTRA_VERSION="$EXTRA_VERSION_save"
diff --git a/lustre/scripts/lustre-kernel-2.4.spec.in b/lustre/scripts/lustre-kernel-2.4.spec.in
index 27463b0839..0999212edf 100644
--- a/lustre/scripts/lustre-kernel-2.4.spec.in
+++ b/lustre/scripts/lustre-kernel-2.4.spec.in
@@ -9,6 +9,7 @@ Summary: The Linux kernel (the core of the Linux operating system)
 # adding some text to the end of the version number.
 #
 %define kversion @KERNEL_VERSION@
+%define kextraver @KERNEL_EXTRA_VERSION@
 %define release @KERNEL_RELEASE@
 # /usr/src/%{kslnk} -> /usr/src/linux-%{KVERREL}
 %define kslnk linux-2.4
@@ -125,7 +126,7 @@ Second, per-architecture exclusions (ifarch)
 Name: kernel
 Version: %{kversion}
 Release: %{release}%{?targetboard:%{targetboard}}%{?debuglevel_1:.dbg}
-%define KVERREL %{PACKAGE_VERSION}-%{PACKAGE_RELEASE}
+%define KVERREL %{PACKAGE_VERSION}-%{kextraver}%{?targetboard:%{targetboard}}%{?debuglevel_1:.dbg}
 License: GPL
 Group: System Environment/Kernel
 ExclusiveArch: %{all_x86} x86_64
@@ -150,6 +151,7 @@ Buildroot: /var/tmp/%{name}-%{PACKAGE_VERSION}-root
 Source0: @LUSTRE_SOURCE@
 Source1: @KERNEL_SOURCE@
 
+Source15: linux-rhconfig.h
 Source16: linux-merge-config.awk
 Source17: linux-merge-modules.awk
 
@@ -319,7 +321,7 @@ DependKernel()
 	--target @LUSTRE_TARGET@ \
 	--target-arch %{_target_cpu} \
 	${target_config} \
-	--extraversion %{release} \
+	--extraversion %{kextraver} \
 	-j $RPM_BUILD_NCPUS
 }
 
@@ -332,7 +334,7 @@ BuildKernel()
 	--target @LUSTRE_TARGET@ \
 	--target-arch %{_target_cpu} \
 	${target_config} \
-	--extraversion %{release} \
+	--extraversion %{kextraver} \
 	--kerneldir $RPM_SOURCE_DIR \
 	-j $RPM_BUILD_NCPUS \
 	--destdir $RPM_BUILD_ROOT \
@@ -360,7 +362,7 @@ SaveHeaders()
   sh -x ./scripts/lmake \
 	--save-headers \
 	--target @LUSTRE_TARGET@ \
-	--extraversion %{release} \
+	--extraversion %{kextraver} \
 	--destdir $RPM_BUILD_ROOT
 }
 
@@ -420,7 +422,7 @@ pushd linux >/dev/null
 mkdir -p $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
 rm -f drivers/net/hamradio/soundmodem/gentbl scripts/mkdep
 tar cf - . | tar xf - -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
-perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{release}custom/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile
+perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{kextraver}custom/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile
 ln -sf linux-%{KVERREL} $RPM_BUILD_ROOT/usr/src/linux
 # install -m 644 %{SOURCE10}  $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
 
@@ -462,7 +464,7 @@ for l in $list; do
 done
 echo '#endif' >> modversions.h
 sed 's,$,autoconf.h,' ../../savedheaders/list | awk -f %{SOURCE16} >> autoconf.h
-# install -m 644 %{SOURCE15} rhconfig.h
+install -m 644 %{SOURCE15} rhconfig.h
 echo "#include <linux/rhconfig.h>" >> version.h
 keyword=if
 for i in smp BOOT BOOTsmp bigmem  up ; do
@@ -772,6 +774,7 @@ exit 0
 %files -n lustre-lite-utils
 %defattr(-, root, root)
 %doc lustre/COPYING lustre/BUGS lustre/ChangeLog lustre/README lustre/doc/lustre.pdf
+/sbin/*
 %{_sbindir}/*
 %{_bindir}/*
 %{_libdir}/lustre/python
-- 
GitLab