[OpenAFS-devel] [PATCH] change OpenAFS-1.2.10 SRPM to work better with RedHat

David Howells dhowells@redhat.com
Fri, 22 Aug 2003 14:17:05 +0100


--Multipart_Fri_Aug_22_14:17:05_2003-1
Content-Type: text/plain; charset=US-ASCII


> Further command line define options could be made available to specify
> whether you desire the userspace and/or kernel modules to be built.

Okay, I've revised the SPEC I proposed earlier file so that rpmbuild can take
command line options to control which of userspace tools, kernel modules or
both get built. For example:

	rpmbuild -bb \
		--target=i686 \
		--define "krpmvers kernel-2.4.20-1.1931.2.231.2.11.ent" \
		--define "build_userspace 1" \
		--define "build_modules 1" \
		/usr/src/redhat/SPECS/openafs.spec

Note if either request is given then the other defaults to disabled unless
also specified.

If neither is given, then the defaults are invented by looking at the
architecture and the target.

David


--Multipart_Fri_Aug_22_14:17:05_2003-1
Content-Type: text/plain; charset=US-ASCII

%define afsvers 1.2.10
%define pkgrel 3

# Determine presence of rpmbuild command line --define arguments used for
# option specification
# These include:
# (*) Specify kernel RPM version to build modules against:
#	--define "krpmvers kernel-2.4.20-1.1931.2.231.2.11.ent"
# (*) Request building of userspace tools
#	--define "build_userspace 1"
# (*) Request building of kernel modules
#	--define "build_modules 1"
%define krpmvers_on_cmdline %{?krpmvers:1}%{!?krpmvers:0}
%define build_userspace_on_cmdline %{?build_userspace:1}%{!?build_userspace:0}
%define build_modules_on_cmdline %{?build_modules:1}%{!?build_modules:0}

# Determine the version of the RedHat kernel RPM to build against
# - automatically select the latest installed kernel
# - note that this can be overridden on the command line
#
%if !%{krpmvers_on_cmdline}
%define krpmvers %(rpm -q --whatprovides kernel | sort | tail -1)
%endif

%define kernvers %(expr %{krpmvers} : '[a-z-]*\\\([0-9].*\\\)')

# This is where to look for kernel-build includes files.
# Most likely you don't want to change this, but
# depending on your situation you may want:
#	Linux 2.4:
#		kbase = /lib/modules/
#		kend = /build
#
%define kbase /lib/modules/
%define ksrcdir %(rpm -ql %{krpmvers} | cut -d/ -f1-4 | grep %{kbase} | head -1)/build
%define kxmoddir %{kbase}/%{kernvers}

# Set 'debugspec' to 1 if you want to debug the spec file.  This will
# not remove the installed tree as part of the %clean operation
%define debugspec 0

# Set 'enterprisekernelsupport' to 1 if you want to build the
# kernel module for the enterprise kernel
# Note: This will only work for kernvers == 24 on i686
# Note: This option is redundant in Red Hat Enterprise Linux 3.0 onwards
%define enterprisekernelsupport 0

# Set 'krb5support' to 1 if you want to build the openafs-krb5 package
# to distribute aklog and asetkey
%define krb5support 1

# Set 'bootkernelsupport' to 1 if you want to build the
# kernel module for Red Hat BOOT Kernels on x86.
%define bootkernelsupport 0

# OpenAFS configuration options
%define enable_bitmap_later 0
%define enable_bos_restricted_mode 0
%define enable_fast_restart 0

# Define the location of your init.d directory
%define initdir /etc/init.d

# Set 'requires_pam_devel' to 0 if compiling for earlier than rh6.2
# (Newer versions of Red Hat require pam-devel in order to build)
%define requires_pam_devel 1

# Define the location of the PAM security module directory
%define pamdir /%{_lib}/security

# Define set of kernel module variations to be built
%define kvariations up smp bigmem

# Determine which elements of OpenAFS to build.  For non-x86 arches
# (subject to the ExclusiveArch setting, below), we build both userspace
# and modules.  For most x86 arches, we build just the kernel modules.  For
# i386, we build just the userspace.  If you're running an i386 kernel,
# you'll need to tweak that last bit.
%if !%{build_userspace_on_cmdline} && !%{build_modules_on_cmdline}
%ifarch x86_64 ia64
%define build_userspace 1
%define build_modules 1
%endif
%ifarch %{ix86}
%define build_userspace 0
%define build_modules 1
%endif
%ifarch i386
%define build_userspace 1
%define build_modules 0
%endif

%else
# deal with cmdline specification
%if !%{build_userspace_on_cmdline}
%define build_userspace 0
%endif
%if !%{build_modules_on_cmdline}
%define build_modules 0
%endif
%endif

#######################################################################
# You probably don't need to change anything beyond this line
# NOTE: If you do, please email me!!!

# Make sure RPM doesn't complain about installed but non-packaged files.
%define __check_files  %{nil}

Summary: OpenAFS distributed filesystem
Name: openafs
Version: %{afsvers}
Release: %{pkgrel}
License: IBM Public Licence
URL: http://www.openafs.org
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Group: Networking/Filesystems
BuildRequires: kernel-source, autoconf
ExclusiveArch: %{ix86} x86_64

%if %{requires_pam_devel}
BuildRequires: pam-devel
%else
BuildRequires: %{_includedir}/security/pam_modules.h
%endif

Source0: http://www.openafs.org/dl/openafs/${afsvers}/openafs-%{afsvers}-src.tar.bz2
Source1: http://www.openafs.org/dl/openafs/${afsvers}/openafs-%{afsvers}-doc.tar.bz2
Source2: openafs-ThisCell
# http://grand.central.org/dl/cellservdb/CellServDB
Source3: openafs-CellServDB
Source4: openafs-SuidCells
Source5: openafs-cacheinfo
Source7: openafs-LICENSE.Sun
Source8: openafs-README
#Source10: http://www.openafs.org/dl/openafs/${afsvers}/RELNOTES-%{afsvers}
Source11: http://www.openafs.org/dl/openafs/${afsvers}/ChangeLog

Source20: openafs-krb5-1.3.tar.gz

Patch0: openafs-%{afsvers}-rc.patch

Patch20: openafs-krb5-1.3-1.2.1.diff.gz
Patch21: openafs-krb5-1.3-configure.patch

Patch105: openafs-hashverify.patch
Patch106: openafs-build.patch
Patch107: openafs-module.patch

Patch200: openafs-krb5-1.3-krb5-1.3.patch
Patch201: openafs-krb5-1.3-lib64.patch
Patch202: openafs-1.2.10-cflags.patch
Patch203: openafs-1.2.10-pam-x86_64.patch

%description
The AFS distributed filesystem.  AFS is a distributed filesystem
allowing cross-platform sharing of files among multiple computers.
Facilities are provided for access control, authentication, backup and
administrative management.

This package provides common files shared across all the various
OpenAFS packages but are not necessarily tied to a client or server.

###############################################################################
#
# build the userspace side of things if so requested
#
###############################################################################
%if %{build_userspace}

%package client
Requires: binutils, openafs-kernel, openafs = %{PACKAGE_VERSION}
Summary: OpenAFS Filesystem Client
Group: Networking/Filesystem

%description client
The AFS distributed filesystem.  AFS is a distributed filesystem
allowing cross-platform sharing of files among multiple computers.
Facilities are provided for access control, authentication, backup and
administrative management.

This package provides basic client support to mount and manipulate
AFS.

%package server
Requires: openafs-kernel, openafs = %{PACKAGE_VERSION}
Summary: OpenAFS Filesystem Server
Group: Networking/Filesystems

%description server
The AFS distributed filesystem.  AFS is a distributed filesystem
allowing cross-platform sharing of files among multiple computers.
Facilities are provided for access control, authentication, backup and
administrative management.

This package provides basic server support to host files in an AFS
Cell.

%package devel
Summary: OpenAFS Development Libraries and Headers
Group: Development/Filesystems

%description devel
The AFS distributed filesystem.  AFS is a distributed filesystem
allowing cross-platform sharing of files among multiple computers.
Facilities are provided for access control, authentication, backup and
administrative management.

This package provides static development libraries and headers needed
to compile AFS applications.  Note: AFS currently does not provide
shared libraries.

%package kernel-source
Summary: OpenAFS Kernel Module source tree
Group: Networking/Filesystems

%description kernel-source
The AFS distributed filesystem.  AFS is a distributed filesystem
allowing cross-platform sharing of files among multiple computers.
Facilities are provided for access control, authentication, backup and
administrative management.

This package provides the source code to build your own AFS kernel
module.

%package compat
Summary: OpenAFS client compatibility symlinks
Requires: openafs = %{PACKAGE_VERSION}, openafs-client = %{PACKAGE_VERSION}
Group: Networking/Filesystems
Obsoletes: openafs-client-compat

%description compat
The AFS distributed filesystem.  AFS is a distributed filesystem
allowing cross-platform sharing of files among multiple computers.
Facilities are provided for access control, authentication, backup and
administrative management.

This package provides compatibility symlinks in /usr/afsws.  It is
completely optional, and is only necessary to support legacy
applications and scripts that hard-code the location of AFS client
programs.

%package kpasswd
Summary: OpenAFS KA kpasswd support
Requires: openafs
Group: Networking/Filesystems

%description kpasswd
The AFS distributed filesystem.  AFS is a distributed filesystem
allowing cross-platform sharing of files among multiple computers.
Facilities are provided for access control, authentication, backup and
administrative management.

This package provides the compatibility symlink for kpasswd, in case
you are using KAserver instead of Krb5.

%if %{krb5support}
%package krb5
Summary: OpenAFS programs to use with krb5
Requires: openafs = %{PACKAGE_VERSION}
Group: Networking/Filesystems
BuildRequires: krb5-devel

%description krb5
The AFS distributed filesystem.  AFS is a distributed filesystem
allowing cross-platform sharing of files among multiple computers.
Facilities are provided for access control, authentication, backup and
administrative management.

This package provides compatibility programs so you can use krb5
to authenticate to AFS services, instead of using AFS's homegrown
krb4 lookalike services.
%endif

%endif

###############################################################################
#
# build the kernel modules if so requested
#
###############################################################################
%if %{build_modules}

%define modkversion %(echo %{kernvers} | cut -d- -f1)
%define modkrelease %(echo %{kernvers} | cut -d- -f2)
%define modpkgrel %{modkversion}_%{modkrelease}_%{pkgrel}

%package kernel
Summary: OpenAFS Kernel Module (compiled for UP)
Release: %{modpkgrel}
Provides: openafs-kernel = %{PACKAGE_VERSION}
Requires: openafs = %{PACKAGE_VERSION}
Requires: kernel = %{kernvers}
Group: Networking/Filesystems

%description kernel
The AFS distributed filesystem.  AFS is a distributed filesystem
allowing cross-platform sharing of files among multiple computers.
Facilities are provided for access control, authentication, backup and
administrative management.

This package provides precompiled AFS kernel modules for various
kernels.  It requires kernel %{kernvers}.

%package kernel-smp
Summary: OpenAFS Kernel Module (compiled for SMP)
Release: %{modpkgrel}
Provides: openafs-kernel = %{PACKAGE_VERSION}
Requires: openafs = %{PACKAGE_VERSION}
Requires: kernel-smp = %{kernvers}
Group: Networking/Filesystems

%description kernel-smp
The AFS distributed filesystem.  AFS is a distributed filesystem
allowing cross-platform sharing of files among multiple computers.
Facilities are provided for access control, authentication, backup and
administrative management.

This package provides precompiled AFS kernel modules for various
kernels.  It requires kernel %{kernvers}.

%package kernel-bigmem
Summary: OpenAFS Kernel Module (compiled for SMP & big memory support)
Release: %{modpkgrel}
Provides: openafs-kernel = %{PACKAGE_VERSION}
Requires: openafs = %{PACKAGE_VERSION}
Requires: kernel-bigmem = %{kernvers}
Group: Networking/Filesystems

%description kernel-bigmem
The AFS distributed filesystem.  AFS is a distributed filesystem
allowing cross-platform sharing of files among multiple computers.
Facilities are provided for access control, authentication, backup and
administrative management.

This package provides precompiled AFS kernel modules for various
kernels.  It requires kernel %{kernvers}.
%endif

###############################################################################
#
# preparation
#
###############################################################################
%prep

: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
: @@@
: @@@ kernel RPM version: %{krpmvers}
: @@@ kernel version:     %{kernvers}
: @@@ kernel modules dir: %{kxmoddir}
: @@@ PAM modules dir:    %{pamdir}
: @@@ build userspace:    %{build_userspace}
: @@@ build modules:      %{build_modules}
: @@@ arch:               %{_arch}
: @@@ target cpu:         %{_target_cpu}
: @@@
: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

%setup -q -b 1
%setup -q -T -D -a 20

%patch0 -p0 -b .rc

%patch20 -p0 -b .krb5
%patch21 -p0 -b .config

%patch105 -p1 -b .hashverify
%patch106 -p1 -b .build
%patch107 -p1 -b .module

pushd openafs-krb5-1.3
%patch200 -p0 -b .krb5-1.3
%patch201 -p1 -b .lib64
popd
%patch202 -p1 -b .cflags
%patch203 -p1 -b .pam-x86_64

###############################################################################
#
# building
#
###############################################################################
%build

case %{kernvers} in
   2.4.*)
	kv='24'
	;;
   *)
	echo "I don't know how to build linux-`expr ${kernvers} : \(^[0-9]*[.][0-9]*\)`"
	exit 1
	;;
esac

case %{_arch} in
x86_64) sysname=amd64_linux${kv} ;;
alpha*) sysname=alpha_linux_${kv} ;;
i386|i486|i586|i686|athlon) sysname=i386_linux${kv} ;;
*) sysname=%{_arch}_linux${kv} ;;
esac

%ifarch %{ix86}
archlist="i386 i586 i686 athlon"
%if %{bootkernelsupport}
  archlist="${archlist} BOOT"
%endif
%else
archlist=%{_arch}
%endif

#
# PrintDefine var value statements file
#
PrintDefine() {
    case $3 in
    *ifn*)
	echo "#ifndef $1" >> $4
	;;
    esac
    case $3 in
    *und*)
	echo "#undef $1" >> $4
	;;
    esac
    case $3 in
    *def*)
	echo "#define $1 $2" >> $4
	;;
    esac
    case $3 in
    *end*)
	echo "#endif" >> $4
	;;
    esac
    case $3 in
    *inc*)
	echo "#include $1" >> $4
	;;
    esac
    case $3 in
    *nl*)
	echo "" >> $4
	;;
    esac
}

# PrintRedhatKernelFix arch mp file
PrintRedhatKernelFix() {
    arch="$1"
    up=0
    smp=0
    ent=0
    bigmem=0
    boot=0
    bootsmp=0

    case "$2" in
	up)	up=1;;
	smp)	smp=1;;
	bigmem)	bigmem=1;;
	*)
		echo "$2 not supported"
		exit 2;;
    esac

    file="$3"

    rm -f $file
    touch $file

    PrintDefine "REDHAT_FIX_H" "" ifn,def,nl $file

    PrintDefine __BOOT_KERNEL_ENTERPRISE $ent	und,def,nl $file
    PrintDefine __BOOT_KERNEL_BIGMEM	$bigmem	und,def,nl $file
    PrintDefine __BOOT_KERNEL_SMP	$smp	und,def,nl $file
    PrintDefine __BOOT_KERNEL_UP	$up	und,def,nl $file
    PrintDefine __BOOT_KERNEL_BOOT	$boot	und,def,nl $file
    PrintDefine __BOOT_KERNEL_BOOTSMP	$bootsmp und,def,nl $file

    PrintDefine '"/boot/kernel.h"' "" inc,nl $file	# include file

    for ar in $archlist ; do
	if [ "$ar" = "$arch" ]; then
	    PrintDefine "__MODULE_KERNEL_$ar" "1" ifn,def,end $file
	else
	    PrintDefine "__MODULE_KERNEL_$ar" "" und $file	# undef
        fi
    done
    echo "" >> $file

    PrintDefine "" "" end $file

    if [ %{debugspec} = 1 ] ; then
	echo "Kernel Configuration File for Red Hat kernels:"
	cat $file
    fi
}

config_opts="--enable-redhat-buildsys \
%if %{enable_bitmap_later}
	--enable-bitmap-later \
%endif
%if %{enable_bos_restricted_mode}
	--enable-bos-restricted-mode \
%endif
%if %{enable_fast_restart}
	--enable-fast-restart \
%endif
	--enable-transarc-paths"

# Configure AFS

CFLAGS="$RPM_OPT_FLAGS"; export CFLAGS

# On some platforms, static libraries must be built with -fPIC before we can
# link them into shared objects.  Because the PAM module uses the libraries,
# we need to build them with -fPIC.  This is one way to do it.
%ifarch x86_64
CFLAGS="$CFLAGS -fPIC"
%endif

./configure --with-afs-sysname=${sysname} \
	--prefix=%{_prefix} \
	--libdir=%{_libdir} \
	--bindir=%{_bindir} \
	--sbindir=%{_sbindir} \
	--with-linux-kernel-headers=%{ksrcdir} \
	$config_opts \
	|| exit 1

%if %{build_userspace}
# Build the user-space AFS stuff
make dest_nolibafs || exit 1

# Build the libafs tree
make only_libafs_tree || exit 1

%if %{krb5support}
# Now build aklog/asetkey
(cd openafs-krb5-1.3/src &&
	(autoconf-2.13 || autoconf) &&
	./configure --prefix=%{_prefix} --with-krb5=%{_prefix}/kerberos \
		--libdir=%{_libdir} \
		--bindir=%{_bindir} \
		--sbindir=%{_sbindir} \
		--with-afs=`pwd`/../../${sysname}/dest/ && \
	make all && \
	make install DESTDIR=`pwd`/../../${sysname}/dest/ INSTALL_BIN=/bin \
		INSTALL_SBIN=/etc) || exit 1
%endif
%endif

%if %{build_modules}
# Now build all the kernel modules
for variation in %{kvariations}
do
    if [ ${variation} = up ]
    then
	local_smp_def=-DREDHAT_FIX
	suffix=
    else
	local_smp_def="-DAFS_SMP -DREDHAT_FIX"
	suffix=${variation}
    fi

    PrintRedhatKernelFix %{_target_cpu} $variation src/config/redhat-fix.h
    make dest_only_libafs LOCAL_SMP_DEF="${local_smp_def}" LINUX_MODULE_VARIETY="$variation" KMODDIR="%{kxmoddir}${suffix}/kernel/fs/openafs"
done

rm -f src/config/redhat-fix.h
%endif


###############################################################################
#
# installation
#
###############################################################################
%install

export DONT_GPRINTIFY=1

[ $RPM_BUILD_ROOT != / ] && rm -rf $RPM_BUILD_ROOT

case %{kernvers} in
   2.4.*)
	kv='24'
	;;
   *)
	echo "I don't know how to build linux-`expr ${kernvers} : \(^[0-9]*[.][0-9]*\)`"
	exit 1
	;;
esac

case %{_arch} in
x86_64) sysname=amd64_linux${kv} ;;
alpha*) sysname=alpha_linux_${kv} ;;
i386|i486|i586|i686|athlon) sysname=i386_linux${kv} ;;
*) sysname=%{_arch}_linux${kv} ;;
esac

# Build install tree
%if %{build_userspace}
mkdir -p $RPM_BUILD_ROOT%{_sbindir}
mkdir -p $RPM_BUILD_ROOT%{_libdir}
mkdir -p $RPM_BUILD_ROOT/etc/sysconfig
mkdir -p $RPM_BUILD_ROOT%{initdir}
mkdir -p $RPM_BUILD_ROOT/etc/openafs
mkdir -p $RPM_BUILD_ROOT%{pamdir}
mkdir -p $RPM_BUILD_ROOT%{_prefix}/afs/logs
mkdir -p $RPM_BUILD_ROOT%{_prefix}/vice/etc
mkdir -p $RPM_BUILD_ROOT%{_prefix}/vice/cache
chmod 700 $RPM_BUILD_ROOT%{_prefix}/vice/cache

# Copy files from dest to the appropriate places in BuildRoot
tar cf - -C ${sysname}/dest bin include | tar xf - -C $RPM_BUILD_ROOT%{_prefix}
tar cf - -C ${sysname}/dest/lib . | tar xf - -C $RPM_BUILD_ROOT%{_libdir}
tar cf - -C ${sysname}/dest/etc . | tar xf - -C $RPM_BUILD_ROOT%{_sbindir}
tar cf - -C ${sysname}/dest/root.server%{_prefix}/afs bin | tar xf - -C $RPM_BUILD_ROOT%{_prefix}/afs
tar cf - -C ${sysname}/dest/root.client%{_prefix}/vice/etc afsd | tar xf - -C $RPM_BUILD_ROOT%{_prefix}/vice/etc

# Link kpasswd to kapasswd
ln -f $RPM_BUILD_ROOT%{_bindir}/kpasswd $RPM_BUILD_ROOT%{_bindir}/kapasswd

# Copy root.client config files
install -m 755 ${sysname}/dest/root.client%{_prefix}/vice/etc/afs.conf $RPM_BUILD_ROOT/etc/sysconfig/afs
install -m 755 ${sysname}/dest/root.client%{_prefix}/vice/etc/afs.rc $RPM_BUILD_ROOT%{initdir}/afs

# Copy PAM modules
install -m 755 ${sysname}/dest/lib/pam* $RPM_BUILD_ROOT%{pamdir}

# PAM symlinks
ln -sf pam_afs.so.1 $RPM_BUILD_ROOT%{pamdir}/pam_afs.so
ln -sf pam_afs.krb.so.1 $RPM_BUILD_ROOT%{pamdir}/pam_afs.krb.so

# Populate /usr/vice/etc
uve=$RPM_BUILD_ROOT%{_prefix}/vice/etc
install -p -m 644 %{SOURCE2} $uve/ThisCell
install -p -m 644 %{SOURCE3} $uve/CellServDB
install -p -m 644 %{SOURCE4} $uve/SuidCells
install -p -m 644 %{SOURCE5} $uve/cacheinfo

#
# install kernel-source
#

# Install the kernel module source tree
mkdir -p $RPM_BUILD_ROOT%{_prefix}/src/openafs-kernel-%{afsvers}/src
tar cf - -C libafs_tree . | \
	tar xf - -C $RPM_BUILD_ROOT%{_prefix}/src/openafs-kernel-%{afsvers}/src

# Next, copy the LICENSE Files, README
install -m 644 src/LICENSE $RPM_BUILD_ROOT%{_prefix}/src/openafs-kernel-%{afsvers}/LICENSE.IBM
install -m 644 %{SOURCE7} $RPM_BUILD_ROOT%{_prefix}/src/openafs-kernel-%{afsvers}/LICENSE.Sun
install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_prefix}/src/openafs-kernel-%{afsvers}/README

#
# Install DOCUMENTATION
#

# Build the DOC directory
mkdir -p $RPM_BUILD_ROOT/$RPM_DOC_DIR/openafs-%{afsvers}
tar cf - -C doc LICENSE html pdf | \
    tar xf - -C $RPM_BUILD_ROOT/$RPM_DOC_DIR/openafs-%{afsvers}
#install -m 644 %{SOURCE10} $RPM_BUILD_ROOT/$RPM_DOC_DIR/openafs-%{afsvers}
install -m 644 %{SOURCE11} $RPM_BUILD_ROOT/$RPM_DOC_DIR/openafs-%{afsvers}

#
# create filelist
#
grep -v "^#" >openafs-file-list <<EOF-openafs-file-list
%{_bindir}/afsmonitor
%{_bindir}/bos
%{_bindir}/fs
%{_bindir}/kapasswd
%{_bindir}/kpasswd
%{_bindir}/klog
%{_bindir}/klog.krb
%{_bindir}/pagsh
%{_bindir}/pagsh.krb
%{_bindir}/pts
%{_bindir}/scout
%{_bindir}/sys
%{_bindir}/tokens
%{_bindir}/tokens.krb
%{_bindir}/translate_et
%{_bindir}/udebug
%{_bindir}/unlog
%{_sbindir}/backup
%{_sbindir}/butc
%{_sbindir}/fms
%{_sbindir}/fstrace
%{_sbindir}/kas
%{_sbindir}/read_tape
%{_sbindir}/restorevol
%{_sbindir}/rxdebug
%{_sbindir}/uss
%{_sbindir}/vos
EOF-openafs-file-list

#
# Install compatiblity links
#
for d in bin:bin etc:sbin; do
  olddir=`echo $d | sed 's/:.*$//'`
  newdir=`echo $d | sed 's/^.*://'`
  mkdir -p $RPM_BUILD_ROOT%{_prefix}/afsws/$olddir
  for f in `cat openafs-file-list`; do
    if echo $f | grep -q /$newdir/; then
      fb=`basename $f`
      ln -sf %{_prefix}/$newdir/$fb $RPM_BUILD_ROOT%{_prefix}/afsws/$olddir/$fb
    fi
  done
done

%endif

%if %{build_modules}
for variation in %{kvariations}
do
    if [ ${variation} = up ]
    then
	kvar=%{kxmoddir}
    else
	kvar=%{kxmoddir}${variation}
    fi

    srcdir=${sysname}/dest/root.client/${kvar}/kernel/fs/openafs
    dstdir=$RPM_BUILD_ROOT/${kvar}/kernel/fs/openafs

    mkdir -p ${dstdir}

    install -m 644 ${srcdir}/openafs.o ${dstdir}
done
%endif

###############################################################################
###
### clean
###
###############################################################################
%clean
rm -f openafs-file-list
[ "$RPM_BUILD_ROOT" != "/" -a "x%{debugspec}" != "x1" ] && \
	rm -fr $RPM_BUILD_ROOT


###############################################################################
###
### scripts
###
###############################################################################
%if %{build_userspace}

%pre compat
if [ -e %{_prefix}/afsws ]; then
        /bin/rm -fr %{_prefix}/afsws
fi

%post
chkconfig --add afs

%post client
if [ ! -d /afs ]; then
	mkdir /afs
	chown root.root /afs
	chmod 0755 /afs
fi

echo
echo The AFS cache is configured for 100 MB. Edit the
echo /usr/vice/etc/cacheinfo file to change this before
echo running AFS for the first time. You should also
echo set your home cell in /usr/vice/etc/ThisCell.
echo
echo Also, you may want to edit /etc/pam.d/login and
echo possibly others there to get an AFS token on login.
echo Put the line:
echo
echo    auth	   sufficient   %{pamdir}/pam_afs.so try_first_pass ignore_root
echo
echo before the one for pwdb.
echo

%post server
if [ -f /etc/sysconfig/afs ] ; then
	srv=`grep ^AFS_SERVER /etc/sysconfig/afs | sed 's/^AFS_SERVER[\s]*=[\s]*//'`
	if [ "x$srv" = "xon" ] ; then
		exit 0
	fi
fi

echo
echo Be sure to edit /etc/sysconfig/afs and turn AFS_SERVER on
echo

%preun
if [ $1 = 0 ] ; then
        %{initdir}/afs stop
        chkconfig --del afs
	[ -d /afs ] && rmdir /afs
fi

%endif

%if %{build_modules}

%post kernel
/sbin/depmod -ae

%post kernel-smp
/sbin/depmod -ae

%post kernel-bigmem
/sbin/depmod -ae

%postun kernel
/sbin/depmod -ae

%postun kernel-smp
/sbin/depmod -ae

%postun kernel-bigmem
/sbin/depmod -ae

%endif

###############################################################################
###
### file lists
###
###############################################################################
%if %{build_userspace}

%files -f openafs-file-list
%defattr(-,root,root)
%config /etc/sysconfig/afs
%doc %{_docdir}/openafs-%{afsvers}
%{initdir}/afs

%files client
%defattr(-,root,root)
%dir %{_prefix}/vice
%dir %{_prefix}/vice/cache
%dir %{_prefix}/vice/etc
%config %{_prefix}/vice/etc/CellServDB
%config %{_prefix}/vice/etc/SuidCells
%config %{_prefix}/vice/etc/ThisCell
%config %{_prefix}/vice/etc/cacheinfo
%{_bindir}/cmdebug
%{_bindir}/up
%{_prefix}/vice/etc/afsd
%{pamdir}/pam_afs.krb.so.1
%{pamdir}/pam_afs.krb.so
%{pamdir}/pam_afs.so.1
%{pamdir}/pam_afs.so

%files server
%defattr(-,root,root)
%dir %{_prefix}/afs
%dir %{_prefix}/afs/bin
%dir %{_prefix}/afs/logs
%{_prefix}/afs/bin/bosserver
%{_prefix}/afs/bin/buserver
%{_prefix}/afs/bin/fileserver
# Should we support KAServer?
%{_prefix}/afs/bin/kaserver
%{_prefix}/afs/bin/kpwvalid
%{_prefix}/afs/bin/pt_util
%{_prefix}/afs/bin/ptserver
%{_prefix}/afs/bin/salvager
%{_prefix}/afs/bin/upclient
%{_prefix}/afs/bin/upserver
%{_prefix}/afs/bin/vlserver
%{_prefix}/afs/bin/volinfo
%{_prefix}/afs/bin/volserver
%{_sbindir}/prdb_check
%{_sbindir}/vldb_check
%{_sbindir}/vldb_convert

%files devel
%defattr(-,root,root)
%{_bindir}/rxgen
%{_includedir}/afs
%{_includedir}/des.h
%{_includedir}/des_conf.h
%{_includedir}/des_odd.h
%{_includedir}/lock.h
%{_includedir}/lwp.h
%{_includedir}/mit-cpyright.h
%{_includedir}/potpourri.h
%{_includedir}/preempt.h
%{_includedir}/rx
%{_includedir}/timer.h
%{_includedir}/ubik.h
%{_includedir}/ubik_int.h
%{_libdir}/afs
%{_libdir}/libafsauthent.a
%{_libdir}/libafsrpc.a
%{_libdir}/libdes.a
%{_libdir}/liblwp.a
%{_libdir}/librx.a
%{_libdir}/librxkad.a
%{_libdir}/librxstat.a
%{_libdir}/libubik.a

%files kernel-source
%defattr(-,root,root)
%{_prefix}/src/openafs-kernel-%{afsvers}/LICENSE.IBM
%{_prefix}/src/openafs-kernel-%{afsvers}/LICENSE.Sun
%{_prefix}/src/openafs-kernel-%{afsvers}/README
%{_prefix}/src/openafs-kernel-%{afsvers}/src

%files compat
%defattr(-,root,root)
%{_prefix}/afsws

%files kpasswd
%defattr(-,root,root)
%{_bindir}/kpasswd
%{_bindir}/kpwvalid

%if %{krb5support}
%files krb5
%defattr(-,root,root)
%{_bindir}/aklog
%{_sbindir}/asetkey
%endif

%endif

%if %{build_modules}

%files kernel
%defattr(-,root,root)
%{kxmoddir}/kernel/fs/openafs/openafs.o

%files kernel-smp
%defattr(-,root,root)
%{kxmoddir}smp/kernel/fs/openafs/openafs.o

%files kernel-bigmem
%defattr(-,root,root)
%{kxmoddir}bigmem/kernel/fs/openafs/openafs.o

%endif


###############################################################################
###
### openafs.spec change log
###
###############################################################################
%changelog
* Fri Aug 22 2003  David Howells <dhowells@redhat.com> 1.2.10-3
- added rpmbuild cmdline defines to control which bits to build

* Wed Aug 20 2003  Nalin Dahyabhai <nalin@redhat.com>
- obey CFLAGS set at configure-time on i386/x86_64 linux
- openafs-krb5: look in $krb5_prefix/lib64 for Kerberos libraries if they are
  not found in $krb5_prefix/lib
- build the modules for PAM on x86_64
- when checking for res_search, try to link with it instead of checking for it
  in libraries, in case it's a macro or redefined by a macro
- use %%{ix86} instead of %%{all_x86} where appropriate
- install AFS libraries into %%{_libdir} instead of %%{_prefix}/lib

* Fri Aug 15 2003  <David Howells <dhowells@redhat.com>> 1.2.10-3
- permit the kernel-to-build-against to be selected by cmdline argument to
  rpmbuild if preferred

* Thu Aug 14 2003  Nalin Dahyabhai <nalin@redhat.com>
- fix compilation of openafs-krb5 bits against krb5 1.3

* Mon Aug 11 2003  <David Howells <dhowells@redhat.com>> 1.2.10-2
- got rid of all rpmlint errors
- delete certain tags (Packager/Vendor/Distribution)

* Fri Aug  8 2003  <David Howells <dhowells@redhat.com>> 1.2.10-1
- Adapted OpenAFS version 1.2.10 to compile in beehive

--Multipart_Fri_Aug_22_14:17:05_2003-1--