# Openafs Spec $Revision$

%define afsvers @VERSION@
%define pkgvers @LINUX_PKGVER@
# for beta/rc releases make pkgrel 0.<tag>
# for real releases make pkgrel 1 (or more for extra releases)
%define pkgrel @LINUX_PKGREL@

%{!?build_dkmspkg: %define build_dkmspkg 1}

#
# Determine presence of rpmbuild command line --define arguments and set
# defaults if not present.
#
%define build_userspace_on_cmdline %{?build_userspace:1}%{!?build_userspace:0}
%define build_modules_on_cmdline %{?build_modules:1}%{!?build_modules:0}
%define debugspec_on_cmdline %{?debugspec:1}%{!?debugspec:0}

%if !%{build_userspace_on_cmdline}
%define build_userspace 1
%endif
%if !%{build_modules_on_cmdline}
%define build_modules 1
%endif
%if !%{debugspec_on_cmdline}
%define debugspec 0
%endif

# Specify '--with kauth' if you want to build packages containing the legacy
# kaserver and related programs.
%define kauth_support %{?_with_kauth:1}%{!?_with_kauth:0}

# Specify '--without authlibs' if you do not want to build the openafs-authlibs
# package.
%define build_authlibs %{?_without_authlibs:0}%{!?_without_authlibs:1}

# Specify '--without krb5' if you do not want to build the openafs-krb5 package
# to distribute aklog, asetkey, and akeyconvert.
%define krb5support %{?_without_krb5:0}%{!?_without_krb5:1}

# Specify '--with bootkernel' if you want to build the
# kernel module for Red Hat BOOT Kernels on x86.
%define bootkernelsupport %{?_with_bootkernel:1}%{!?_with_bootkernel:0}

#
# Definitions
#
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
%define depmod /usr/sbin/depmod
%else
%define depmod /sbin/depmod
%endif

%define kmodtool bash %{_sourcedir}/openafs-kmodtool

%define kmod_name openafs
%define kverrel %(%{kmodtool} verrel %{?kernvers} 2>/dev/null)

%define upvar ""
%{!?kvariants: %define kvariants %{?upvar}}

%if %{?ksrcdir:1}%{!?ksrcdir:0}
  if ( -d %{_usrsrc}/kernels/%{kverrel}-%{_target_cpu}) ; then
    %define ksrcdir %{_usrsrc}/kernels/%{kverrel}-%{_target_cpu}}
  else
    %define ksrcdir %{_usrsrc}/kernels/%{kverrel}.%{_target_cpu}}
  fi
%endif

%define dkms_version %{pkgvers}-%{pkgrel}%{?dist}

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

#determine if the kernel provides an arch-specific Provides
%define kprovidesarch %(%{kversis} provideskernelarch %{ksrcdir} %{_target_cpu})

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

Summary: OpenAFS distributed filesystem
Name: openafs
Version: %{pkgvers}
Release: %{pkgrel}%{?dist}
License: IBM Public License
URL: http://www.openafs.org
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Packager: OpenAFS Gatekeepers <openafs-gatekeepers@openafs.org>
Group: Networking/Filesystems
BuildRequires: %{?kdepend:%{kdepend}, } pam-devel, ncurses-devel, flex, bison
%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
BuildRequires: systemd-units
%endif
%if 0%{?fedora} >= 15 || 0%{?rhel} >= 6
BuildRequires: perl-devel, swig
%endif
BuildRequires: perl(ExtUtils::Embed)
%if %{krb5support}
BuildRequires: krb5-devel
%endif
%if %{build_modules}
BuildRequires: kernel-devel
%endif

ExclusiveArch: %{ix86} x86_64 ia64 s390 s390x sparc64 ppc ppc64 aarch64

#    http://dl.openafs.org/dl/openafs/candidate/%{afsvers}/...
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
%define srcdir openafs-%{afsvers}

Source10: http://www.openafs.org/dl/openafs/%{afsvers}/RELNOTES-%{afsvers}
Source11: http://www.openafs.org/dl/openafs/%{afsvers}/ChangeLog

Source20: https://www.central.org/dl/cellservdb/CellServDB.2018-05-14

Source996: openafs-kvers-is.sh
Source997: openafs-buildfedora.pl
Source998: openafs-buildall.sh
Source999: openafs-kmodtool

%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.

The OpenAFS SRPM can be rebuilt with the following options to control
what gets built:

 --define "kernvers 3.19.3-100.fc20.i686" Specify the specific kernel version
                                  to build modules against. The default is
                                  to build against the currently-running
                                  kernel.
 --define "kbase /lib/modules/"   The base location to look for kernel headers
 --define "kend /build"           The 'end' location to look for kernels
                                  The build will define ksrvdir as
                                  %%{kbase}<kernvers>%%{kend}

 --without authlibs               Disable authlibs package (default: with authlibs)
 --without krb5                   Disable krb5 support (default: with krb5)
 --with bitmap-later              Enable "bitmap later" support
 --with bos-restricted            Enable "bos restricted" mode
 --with supergroups               Enable "supergroups"
 --with kauth                     Build the openafs-kauth-server and openafs-kauth-client
                                  packages which contain the legacy kaserver and
                                  related programs. (default: --without kauth)

 --target=i386                    The target architecture to build for.

 --define "build_userspace 1"     Request building of userspace tools
 --define "build_modules 1"       Request building of kernel modules
                                  You probably never need to specify these.

 --define "kmoddir /lib/modules"  This is the base location where modules
                                  will be installed.  You probably don't
                                  need to change this ever.

 --define "kvariants <variants>"  When building Fedora style kernel modules,
                                  this defines the set of kernel variants
                                  to build.
                                  <variants> is a space seperated list which
                                  may contain one or more of
                                  '' (for the generic kernel), smp, PAE, xen
                                  or kdump

To a kernel module for your running kernel, just run:
  rpmbuild --rebuild --target=`uname -m` openafs-%{pkgvers}-%{pkgrel}%{?dist}.src.rpm

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

%package client
Requires: binutils, openafs = %{version}
%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
Requires: systemd-units
Requires(post): systemd-units, systemd-sysv
Requires(preun): systemd-units
Requires(postun): systemd-units
%endif

Requires: %{name}-kmod >= %{version}
Provides: %{name}-kmod-common = %{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 = %{version}
Summary: OpenAFS Filesystem Server
Group: Networking/Filesystems
%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
Requires: systemd-units
Requires(post): systemd-units, systemd-sysv
Requires(preun): systemd-units
Requires(postun): systemd-units
%endif

%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.

%if %{build_dkmspkg}
%package -n dkms-%{name}
Summary:        DKMS-ready kernel source for AFS distributed filesystem
Group:          Development/Kernel
Provides:       openafs-kernel = %{version}
Provides: %{name}-kmod = %{version}
Requires(pre):  dkms
Requires(pre):  flex
Requires(post): dkms
Requires:	%{name}-kmod-common = %{version}

%description -n dkms-%{name}
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 allow DKMS to build an
AFS kernel module.
%endif

%if %{build_authlibs}
%package authlibs
Summary: OpenAFS authentication shared libraries
Group: Networking/Filesystems

%description authlibs
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 a shared version of libafsrpc and libafsauthent.
None of the programs included with OpenAFS currently use these shared
libraries; however, third-party software that wishes to perform AFS
authentication may link against them.
%endif

%package authlibs-devel
%if %{build_authlibs}
Requires: openafs-authlibs = %{version}-%{release}
%endif
Requires: openafs-devel = %{version}-%{release}
Summary: OpenAFS shared library development
Group: Development/Filesystems

%description authlibs-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 includes the static versions of libafsrpc and
libafsauthent, and symlinks required for building against the dynamic
libraries.

%package devel
Summary: OpenAFS Development Libraries and Headers
Group: Development/Filesystems
Requires: openafs = %{version}-%{release}

%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 docs
Summary: OpenAFS user and administrator documentation
Requires: openafs = %{version}-%{release}
Group: Networking/Filesystems

%description docs
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 HTML documentation for OpenAFS users and system
administrators.

%package kernel-source
Summary: OpenAFS Kernel Module source tree
Group: Networking/Filesystems
Provides: openafs-kernel = %{version}
Provides: %{name}-kmod = %{version}

%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 = %{version}, openafs-client = %{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.

%if %{kauth_support}
%package kauth-client
Summary: OpenAFS Kauth Client support
Requires: openafs
Group: Networking/Filesystems

%description kauth-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 the legacy KAServer client programs and the PAM module
for authentication with the OpenAFS KAserver; a deprecated authentication
service.  Generally you should not install this package for new cells or for
cells using Kerberos v5.

%package kauth-server
Summary: OpenAFS Kauth Server support
Requires: openafs
Group: Networking/Filesystems

%description kauth-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 the legacy OpenAFS KAServer; a deprecated authentication
service. Generally you should not install this package for new cells or for
cells using Kerberos v5.
%endif

%if %{krb5support}
%package krb5
Summary: OpenAFS programs to use with krb5
Requires: openafs = %{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}

%{expand:%(%{kmodtool} rpmtemplate %{kmod_name} %{kverrel} %{depmod} %{kvariants} 2>/dev/null)}

%endif

##############################################################################
#
# PREP
#
##############################################################################

%prep

: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
: @@@
: @@@ kernel version:     %{kverrel}
: @@@ kernel variations:  %{kvariants}
: @@@ PAM modules dir:    %{pamdir}
: @@@ build userspace:    %{build_userspace}
: @@@ build modules:      %{build_modules}
: @@@ arch:               %{_arch}
: @@@ target cpu:         %{_target_cpu}
: @@@
: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

# Install OpenAFS src and doc
#%setup -q -n %{srcdir}
%setup -q -b 1 -n %{srcdir}

##############################################################################
#
# building
#
##############################################################################
%build
case %{_arch} in
       x86_64)                         sysname=amd64_linux26        ;;
       alpha*)                         sysname=alpha_linux_26       ;;
       i386|i486|i586|i686|athlon)     sysname=i386_linux26         ;;
       aarch64)                        sysname=arm64_linux26        ;;
       *)                              sysname=%{_arch}_linux26     ;;
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
    largesmp=0
    ent=0
    bigmem=0
    hugemem=0
    boot=0
    bootsmp=0

    case "$2" in
       up)     up=1;;
       smp)    smp=1;;
       largesmp) largesmp=1;;
       bigmem) bigmem=1;;
       hugemem) hugemem=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_HUGEMEM    $hugemem und,def,nl $file
    PrintDefine __BOOT_KERNEL_SMP        $smp     und,def,nl $file
    PrintDefine __BOOT_KERNEL_LARGESMP   $largesmp 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 \
	%{?_with_kauth:--enable-kauth} \
	%{?_with_bitmap_later:--enable-bitmap-later} \
	%{?_with_bos_restricted:--enable-bos-restricted-mode} \
	%{?_with_supergroups:--enable-supergroups} \
	--enable-transarc-paths"

# Configure AFS

# If we're using Fedora kmods, work out which is the best kernel module to
# use for the userland configuration step. If no variants have been specified,
# then use the standard kernel. If variants are specified, use the standard kernel
# if it's listed, otherwise pick the first listed kernel.
ksrc=""
for kvariant in %{kvariants} ; do
  if [ -z "${kvariant}" -o -z "$ksrc" ] ; then
    if [ -d %{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}-%{_target_cpu} ] ; then
      ksrc=%{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}-%{_target_cpu}
    elif [ -d %{_usrsrc}/kernels/%{kverrel}.%{_target_cpu}${kvariant:++$kvariant} ] ; then
      ksrc=%{_usrsrc}/kernels/%{kverrel}.%{_target_cpu}${kvariant:++$kvariant}
    else
      ksrc=%{_usrsrc}/kernels/%{kverrel}.%{_target_cpu}${kvariant:+.$kvariant}
    fi
  fi
done
if [ -z "$ksrc" ] ; then
ksrc=%{ksrcdir}
fi

CFLAGS="$RPM_OPT_FLAGS"; export CFLAGS

%if %{krb5support}
%if %{?krb5config:1}%{!?krb5config:0}
KRB5_CONFIG="%{krb5config}"
export KRB5_CONFIG
%endif
%endif

./configure --with-afs-sysname=${sysname} \
       --prefix=%{_prefix} \
       --libdir=%{_libdir} \
       --bindir=%{_bindir} \
       --sbindir=%{_sbindir} \
       --disable-strip-binaries \
       --enable-debug \
       --with-linux-kernel-packaging \
%if %{build_modules}
       --with-linux-kernel-headers=${ksrc} \
%else
       --disable-kernel-module \
%endif
%if %{krb5support}
	--with-krb5 \
%endif
%if 0%{?fedora} >= 15 || 0%{?rhel} >= 6
    --with-swig \
%else
    --without-swig \
%endif
       $config_opts \
       || exit 1

# Build the libafs tree
make %{_smp_mflags} only_libafs_tree || exit 1

%if %{krb5support}
%if %{?krb5config:1}%{!?krb5config:0}
KRB5_CONFIG="%{krb5config}"
export KRB5_CONFIG
%endif
%endif

# Configure each of our kernel modules

%if %{build_modules}
for kvariant in %{kvariants} ; do
  if [ -n "${kvariant}" ] ; then

    if [ -d %{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}-%{_target_cpu} ] ; then
      ksrc=%{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}-%{_target_cpu}

    elif [ -d %{_usrsrc}/kernels/%{kverrel}.%{_target_cpu}${kvariant:++$kvariant} ] ; then
      # Fedora 20 started putting kernel sources in e.g.
      # 3.12.5-302.fc20.i686+PAE, instead of:
      # 3.12.5-302.fc20.i686.PAE
      ksrc=%{_usrsrc}/kernels/%{kverrel}.%{_target_cpu}${kvariant:++$kvariant}

    else
      ksrc=%{_usrsrc}/kernels/%{kverrel}.%{_target_cpu}${kvariant:+.$kvariant}
    fi

    cp -R libafs_tree _kmod_build_${kvariant}
    pushd _kmod_build_${kvariant}
    ./configure --with-afs-sysname=${sysname} \
  	--prefix=%{_prefix} \
	--libdir=%{_libdir} \
	--bindir=%{_bindir} \
	--sbindir=%{_sbindir} \
        --with-linux-kernel-packaging \
	--with-linux-kernel-headers=${ksrc} \
%if %{krb5support}
	--with-krb5 \
%endif
	$config_opts \
	|| exit 1
    popd
  fi
done
%endif

%if %{build_userspace}
# Build the user-space AFS stuff
make %{_smp_mflags} all_nolibafs
%endif

%if %{build_modules}
for kvariant in %{kvariants}
do
  if [ -n "${kvariant}" ] ; then
    pushd _kmod_build_$kvariant;
    make %{_smp_mflags} all
    popd
  else
    make %{_smp_mflags} libafs
  fi
done
%endif


##############################################################################
###
### install
###
##############################################################################
%install

export DONT_GPRINTIFY=1 # Do not modify initscripts.

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

##############################################################################
###
### Install userspace
###
##############################################################################
%if %{build_userspace}

#-----------------------------------------------------------------------------
# Install userspace files
#-----------------------------------------------------------------------------
make %{_smp_mflags} install_nolibafs DESTDIR="$RPM_BUILD_ROOT"

# Set the executable bit on libraries in libdir, so rpmbuild knows to
# create "Provides" entries in the package metadata for the libraries
chmod +x $RPM_BUILD_ROOT%{_libdir}/*.so*

# Exclude duplicated files.
rm -f $RPM_BUILD_ROOT%{_prefix}/afs/bin/bos
rm -f $RPM_BUILD_ROOT%{_prefix}/afs/bin/fs
%if %{kauth_support}
rm -f $RPM_BUILD_ROOT%{_prefix}/afs/bin/kas
rm -f $RPM_BUILD_ROOT%{_prefix}/afs/bin/klog
rm -f $RPM_BUILD_ROOT%{_prefix}/afs/bin/klog.krb
rm -f $RPM_BUILD_ROOT%{_prefix}/afs/bin/kpwvalid
rm -f $RPM_BUILD_ROOT%{_prefix}/afs/bin/tokens.krb
rm -f $RPM_BUILD_ROOT%{_sbindir}/kpwvalid
%endif
rm -f $RPM_BUILD_ROOT%{_prefix}/afs/bin/pts
rm -f $RPM_BUILD_ROOT%{_prefix}/afs/bin/tokens
rm -f $RPM_BUILD_ROOT%{_prefix}/afs/bin/udebug
rm -f $RPM_BUILD_ROOT%{_prefix}/afs/bin/vos

# Exclude obsolete or unused files.
rm -f $RPM_BUILD_ROOT%{_bindir}/dlog
rm -f $RPM_BUILD_ROOT%{_bindir}/dpass
rm -f $RPM_BUILD_ROOT%{_bindir}/install
rm -f $RPM_BUILD_ROOT%{_bindir}/knfs
rm -f $RPM_BUILD_ROOT%{_bindir}/livesys
rm -f $RPM_BUILD_ROOT%{_prefix}/afs/bin/kdb
rm -f $RPM_BUILD_ROOT%{_sbindir}/rmtsysd
rm -rf $RPM_BUILD_ROOT%{_sbindir}/kdump*
%if !%{build_authlibs}
rm -f $RPM_BUILD_ROOT%{_libdir}/libafsauthent.so*
rm -f $RPM_BUILD_ROOT%{_libdir}/libafsrpc.so*
rm -f $RPM_BUILD_ROOT%{_libdir}/libkopenafs.so*
%endif
rm -f $RPM_BUILD_ROOT%{_sbindir}/afsd.fuse
%if !%{kauth_support}
rm -f $RPM_BUILD_ROOT%{_prefix}/afs/bin/tokens.krb
rm -f $RPM_BUILD_ROOT%{_bindir}/tokens.krb
rm -f $RPM_BUILD_ROOT%{_bindir}/pagsh.krb
%endif

# Relocate afsd to legacy path to match init scripts.
mv $RPM_BUILD_ROOT%{_sbindir}/afsd $RPM_BUILD_ROOT%{_prefix}/vice/etc/afsd

# Relocate admin utilities to a modern path.
%if %{kauth_support}
mv $RPM_BUILD_ROOT%{_prefix}/afs/bin/kadb_check $RPM_BUILD_ROOT%{_sbindir}/kadb_check
%endif
mv $RPM_BUILD_ROOT%{_prefix}/afs/bin/prdb_check $RPM_BUILD_ROOT%{_sbindir}/prdb_check
mv $RPM_BUILD_ROOT%{_prefix}/afs/bin/vldb_check $RPM_BUILD_ROOT%{_sbindir}/vldb_check
mv $RPM_BUILD_ROOT%{_prefix}/afs/bin/vldb_convert $RPM_BUILD_ROOT%{_sbindir}/vldb_convert
%if %{krb5support}
mv $RPM_BUILD_ROOT%{_prefix}/afs/bin/akeyconvert $RPM_BUILD_ROOT%{_sbindir}/akeyconvert
mv $RPM_BUILD_ROOT%{_prefix}/afs/bin/asetkey $RPM_BUILD_ROOT%{_sbindir}/asetkey
%endif

%if %{kauth_support}
# Relocate PAM files to the standard PAM module path.
mkdir -p $RPM_BUILD_ROOT%{pamdir}
mv $RPM_BUILD_ROOT%{_libdir}/pam_afs.krb.so $RPM_BUILD_ROOT%{pamdir}
mv $RPM_BUILD_ROOT%{_libdir}/pam_afs.so $RPM_BUILD_ROOT%{pamdir}
ln -sf pam_afs.so $RPM_BUILD_ROOT%{pamdir}/pam_afs.so.1
ln -sf pam_afs.krb.so $RPM_BUILD_ROOT%{pamdir}/pam_afs.krb.so.1

# Rename kpasswd to avoid conflicting with krb5 kpasswd.
mv $RPM_BUILD_ROOT%{_bindir}/kpasswd $RPM_BUILD_ROOT%{_bindir}/kapasswd
mv $RPM_BUILD_ROOT%{_mandir}/man1/kpasswd.1 $RPM_BUILD_ROOT%{_mandir}/man1/kapasswd.1
%endif

# Exclude obsolete or unused man pages.
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/afs_ftpd.1
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/afs_inetd.1
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/afs_login.1
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/afs_rcp.1
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/afs_rlogind.1
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/afs_rsh.1
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/dkload.1
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/knfs.1
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/package.1
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/runntp.1
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/symlink.1
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/symlink_list.1
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/symlink_make.1
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/symlink_remove.1
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/dlog.*
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/copyauth.*
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/dpass.*
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/livesys.*
rm -f $RPM_BUILD_ROOT%{_mandir}/man8/afsd.fuse.8
rm -f $RPM_BUILD_ROOT%{_mandir}/man8/rmtsysd.*
rm -f $RPM_BUILD_ROOT%{_mandir}/man8/aklog_dynamic_auth.*
rm -f $RPM_BUILD_ROOT%{_mandir}/man8/kdb.*
rm -f $RPM_BUILD_ROOT%{_mandir}/man8/xfs_size_check.*
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/package_test.*
rm -f $RPM_BUILD_ROOT%{_mandir}/man5/package.*
rm -f $RPM_BUILD_ROOT%{_mandir}/man8/package.*
%if !%{krb5support}
rm -f $RPM_BUILD_ROOT%{_mandir}/man8/akeyconvert.*
rm -f $RPM_BUILD_ROOT%{_mandir}/man8/asetkey.*
%endif
%if !%{kauth_support}
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/pagsh.krb.1
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/tokens.krb.1
rm -f $RPM_BUILD_ROOT%{_mandir}/man5/AuthLog.5
rm -f $RPM_BUILD_ROOT%{_mandir}/man5/AuthLog.dir.5
%endif
%if !(0%{?fedora} >= 15 || 0%{?rhel} >= 6)
rm -f $RPM_BUILD_ROOT%{_mandir}/man3/AFS::ukernel.3
%endif

#-----------------------------------------------------------------------------
# Install client and server initscripts/systemd files
#-----------------------------------------------------------------------------
mkdir -p $RPM_BUILD_ROOT/etc/sysconfig
install -m 755 src/packaging/RedHat/openafs.sysconfig $RPM_BUILD_ROOT/etc/sysconfig/openafs
%if 0%{?fedora} < 15 && 0%{?rhel} < 7
mkdir -p $RPM_BUILD_ROOT%{initdir}
install -m 755 src/packaging/RedHat/openafs-client.init $RPM_BUILD_ROOT%{initdir}/openafs-client
install -m 755 src/packaging/RedHat/openafs-server.init $RPM_BUILD_ROOT%{initdir}/openafs-server
%else
mkdir -p $RPM_BUILD_ROOT%{_unitdir}
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/modules
install -m 644 src/packaging/RedHat/openafs-client.service $RPM_BUILD_ROOT%{_unitdir}/openafs-client.service
install -m 755 src/packaging/RedHat/openafs-client.modules $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/modules/openafs-client.modules
install -m 644 src/packaging/RedHat/openafs-server.service $RPM_BUILD_ROOT%{_unitdir}/openafs-server.service
%endif

#-----------------------------------------------------------------------------
# Install server directories.
#-----------------------------------------------------------------------------
mkdir -p $RPM_BUILD_ROOT%{_prefix}/afs/etc
mkdir -p $RPM_BUILD_ROOT%{_prefix}/afs/logs

#-----------------------------------------------------------------------------
# Install client directories and config files.
#-----------------------------------------------------------------------------
mkdir -p $RPM_BUILD_ROOT%{_prefix}/vice/etc
mkdir -p $RPM_BUILD_ROOT%{_prefix}/vice/cache
chmod 700 $RPM_BUILD_ROOT%{_prefix}/vice/cache
install -p -m 644 src/packaging/RedHat/openafs-ThisCell $RPM_BUILD_ROOT%{_prefix}/vice/etc/ThisCell
install -p -m 644 %{SOURCE20} $RPM_BUILD_ROOT%{_prefix}/vice/etc/CellServDB.dist
install -p -m 644 src/packaging/RedHat/openafs-cacheinfo $RPM_BUILD_ROOT%{_prefix}/vice/etc/cacheinfo

#-----------------------------------------------------------------------------
# Install DKMS source.
#-----------------------------------------------------------------------------
install -d -m 755 $RPM_BUILD_ROOT%{_prefix}/src
cp -a libafs_tree $RPM_BUILD_ROOT%{_prefix}/src/%{name}-%{dkms_version}

cat > $RPM_BUILD_ROOT%{_prefix}/src/%{name}-%{dkms_version}/dkms.conf <<"EOF"

PACKAGE_VERSION="%{dkms_version}"

# Items below here should not have to change with each driver version.
PACKAGE_NAME="%{name}"
MAKE[0]='./configure --with-linux-kernel-headers=${kernel_source_dir} --with-linux-kernel-packaging && make && case "${kernelver_array[0]}${kernelver[0]}" in 2.4.*) mv src/libafs/MODLOAD-*/libafs-* openafs.o ;; *) mv src/libafs/MODLOAD-*/openafs.ko . ;; esac'
CLEAN="if [ -e src/libafs/Makefile ]; then make -C src/libafs clean; else true; fi"

BUILT_MODULE_NAME[0]="$PACKAGE_NAME"
DEST_MODULE_LOCATION[0]="/extra/$PACKAGE_NAME/"
STRIP[0]=no
AUTOINSTALL=yes
NO_WEAK_MODULES="true"

EOF

#-----------------------------------------------------------------------------
# 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
install -m 644 LICENSE $RPM_BUILD_ROOT%{_prefix}/src/openafs-kernel-%{afsvers}/LICENSE.IBM
install -m 644 src/packaging/RedHat/openafs-LICENSE.Sun $RPM_BUILD_ROOT%{_prefix}/src/openafs-kernel-%{afsvers}/LICENSE.Sun
install -m 644 src/packaging/RedHat/openafs-README $RPM_BUILD_ROOT%{_prefix}/src/openafs-kernel-%{afsvers}/README

#-----------------------------------------------------------------------------
# Install documentation.
#-----------------------------------------------------------------------------
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}

#-----------------------------------------------------------------------------
# Install compatiblity links.
#-----------------------------------------------------------------------------
mkdir -p $RPM_BUILD_ROOT%{_prefix}/afsws/bin
mkdir -p $RPM_BUILD_ROOT%{_prefix}/afsws/etc
ln -sf %{_prefix}/bin/afsmonitor    $RPM_BUILD_ROOT%{_prefix}/afsws/bin/afsmonitor
ln -sf %{_prefix}/bin/bos           $RPM_BUILD_ROOT%{_prefix}/afsws/bin/bos
ln -sf %{_prefix}/bin/fs            $RPM_BUILD_ROOT%{_prefix}/afsws/bin/fs
%if %{kauth_support}
ln -sf %{_prefix}/bin/kapasswd      $RPM_BUILD_ROOT%{_prefix}/afsws/bin/kapasswd
ln -sf %{_prefix}/bin/klog          $RPM_BUILD_ROOT%{_prefix}/afsws/bin/klog
ln -sf %{_prefix}/bin/klog.krb      $RPM_BUILD_ROOT%{_prefix}/afsws/bin/klog.krb
ln -sf %{_prefix}/bin/pagsh.krb     $RPM_BUILD_ROOT%{_prefix}/afsws/bin/pagsh.krb
ln -sf %{_prefix}/bin/tokens.krb    $RPM_BUILD_ROOT%{_prefix}/afsws/bin/tokens.krb
%endif
ln -sf %{_prefix}/bin/pagsh         $RPM_BUILD_ROOT%{_prefix}/afsws/bin/pagsh
ln -sf %{_prefix}/bin/pts           $RPM_BUILD_ROOT%{_prefix}/afsws/bin/pts
ln -sf %{_prefix}/bin/restorevol    $RPM_BUILD_ROOT%{_prefix}/afsws/bin/restorevol
ln -sf %{_prefix}/bin/scout         $RPM_BUILD_ROOT%{_prefix}/afsws/bin/scout
ln -sf %{_prefix}/bin/sys           $RPM_BUILD_ROOT%{_prefix}/afsws/bin/sys
ln -sf %{_prefix}/bin/tokens        $RPM_BUILD_ROOT%{_prefix}/afsws/bin/tokens
ln -sf %{_prefix}/bin/translate_et  $RPM_BUILD_ROOT%{_prefix}/afsws/bin/translate_et
ln -sf %{_prefix}/bin/xstat_cm_test $RPM_BUILD_ROOT%{_prefix}/afsws/bin/xstat_cm_test
ln -sf %{_prefix}/bin/xstat_fs_test $RPM_BUILD_ROOT%{_prefix}/afsws/bin/xstat_fs_test
ln -sf %{_prefix}/bin/udebug        $RPM_BUILD_ROOT%{_prefix}/afsws/bin/udebug
ln -sf %{_prefix}/bin/unlog         $RPM_BUILD_ROOT%{_prefix}/afsws/bin/unlog
ln -sf %{_prefix}/sbin/backup       $RPM_BUILD_ROOT%{_prefix}/afsws/etc/backup
ln -sf %{_prefix}/sbin/butc         $RPM_BUILD_ROOT%{_prefix}/afsws/etc/butc
ln -sf %{_prefix}/sbin/fms          $RPM_BUILD_ROOT%{_prefix}/afsws/etc/fms
ln -sf %{_prefix}/sbin/fstrace      $RPM_BUILD_ROOT%{_prefix}/afsws/etc/fstrace
%if %{kauth_support}
ln -sf %{_prefix}/sbin/kas          $RPM_BUILD_ROOT%{_prefix}/afsws/etc/kas
%endif
ln -sf %{_prefix}/sbin/read_tape    $RPM_BUILD_ROOT%{_prefix}/afsws/etc/read_tape
ln -sf %{_prefix}/sbin/rxdebug      $RPM_BUILD_ROOT%{_prefix}/afsws/etc/rxdebug
ln -sf %{_prefix}/sbin/uss          $RPM_BUILD_ROOT%{_prefix}/afsws/etc/uss
ln -sf %{_prefix}/sbin/vos          $RPM_BUILD_ROOT%{_prefix}/afsws/etc/vos
ln -sf %{_prefix}/sbin/vsys         $RPM_BUILD_ROOT%{_prefix}/afsws/etc/vsys

%endif

##############################################################################
###
### Install modules
###
##############################################################################
%if %{build_modules}

for kvariant in %{kvariants}
do
  if [ -n "$kvariant" ] ; then
    if [ -d _kmod_build_$kvariant/src/libafs/MODLOAD-%{kverrel}${kvariant}-SP ] ; then
      srcdir=_kmod_build_$kvariant/src/libafs/MODLOAD-%{kverrel}${kvariant}-SP
      dstdir=$RPM_BUILD_ROOT/lib/modules/%{kverrel}${kvariant}/extra/openafs
    elif [ -d _kmod_build_$kvariant/src/libafs/MODLOAD-%{kverrel}.%{_target_cpu}+${kvariant}-SP ] ; then
      srcdir=_kmod_build_$kvariant/src/libafs/MODLOAD-%{kverrel}.%{_target_cpu}+${kvariant}-SP
      dstdir=$RPM_BUILD_ROOT/lib/modules/%{kverrel}.%{_target_cpu}+${kvariant}/extra/openafs
    else
      srcdir=_kmod_build_$kvariant/src/libafs/MODLOAD-%{kverrel}.%{_target_cpu}.${kvariant}-SP
      dstdir=$RPM_BUILD_ROOT/lib/modules/%{kverrel}.%{_target_cpu}.${kvariant}/extra/openafs
    fi
  else
    if [ -d src/libafs/MODLOAD-%{kverrel}-SP ] ; then
      srcdir=src/libafs/MODLOAD-%{kverrel}-SP
      dstdir=$RPM_BUILD_ROOT/lib/modules/%{kverrel}/extra/openafs
    else
      srcdir=src/libafs/MODLOAD-%{kverrel}.%{_target_cpu}-SP
      dstdir=$RPM_BUILD_ROOT/lib/modules/%{kverrel}.%{_target_cpu}/extra/openafs
    fi
  fi

  mkdir -p ${dstdir}
  install -m 755 ${srcdir}/openafs.ko ${dstdir}/openafs.ko
done
%endif

##############################################################################
###
### clean
###
##############################################################################
%clean
[ "$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 client
%if 0%{?fedora} < 15 && 0%{?rhel} < 7
chkconfig --add openafs-client
%else
if [ $1 -eq 1 ] ; then
    # Initial installation
    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
%endif
if [ ! -d /afs ]; then
	mkdir /afs
	chown root.root /afs
	chmod 0755 /afs
	[ -x /sbin/restorecon ] && /sbin/restorecon /afs
fi

# Create the CellServDB
[ -f /usr/vice/etc/CellServDB.local ] || touch /usr/vice/etc/CellServDB.local

( cd /usr/vice/etc ; \
  if [ -h CellServDB ]; then \
    rm -f CellServDB; \
  fi; \
  cat CellServDB.local CellServDB.dist > CellServDB ; \
  chmod 644 CellServDB )

%post server
#on an upgrade, don't enable if we were disabled
%if 0%{?fedora} < 15 && 0%{?rhel} < 7
if [ $1 = 1 ] ; then
  chkconfig --add openafs-server
fi
%{initdir}/openafs-server condrestart
%else
if [ $1 -eq 1 ] ; then
    # Initial installation
    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
%endif

%if %{build_authlibs}
%post authlibs
/sbin/ldconfig

%postun authlibs
/sbin/ldconfig
%endif

%preun
if [ $1 = 0 ] ; then
	[ -d /afs ] && rmdir /afs
	:
fi

%preun client
%if 0%{?fedora} < 15 && 0%{?rhel} < 7
if [ $1 = 0 ] ; then
        %{initdir}/openafs-client stop
        chkconfig --del openafs-client
fi
%else
if [ $1 -eq 0 ] ; then
    	# Package removal, not upgrade
    	/bin/systemctl --no-reload disable openafs-client.service > /dev/null 2>&1 || :
    	/bin/systemctl stop openafs-client.service > /dev/null 2>&1 || :
fi
%endif

%preun server
%if 0%{?fedora} < 15 && 0%{?rhel} < 7
if [ $1 = 0 ] ; then
        %{initdir}/openafs-server stop
        chkconfig --del openafs-server
fi
%else
if [ $1 -eq 0 ] ; then
    	/bin/systemctl --no-reload disable openafs-server.service > /dev/null 2>&1 || :
    	/bin/systemctl stop openafs-server.service > /dev/null 2>&1 || :
fi
%endif

%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
%postun client
/bin/systemctl daemon-reload >/dev/null 2>&1 || :

%postun server
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
%endif

%if %{build_dkmspkg}
%post -n dkms-%{name}
dkms add -m %{name} -v %{dkms_version} --rpm_safe_upgrade
dkms build -m %{name} -v %{dkms_version} --rpm_safe_upgrade
dkms install -m %{name} -v %{dkms_version} --rpm_safe_upgrade

%preun -n dkms-%{name}
dkms remove -m %{name} -v %{dkms_version} --rpm_safe_upgrade --all ||:
%endif
%endif

%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
%triggerun -- openafs-client < 1.6.0-1
# Save the current service runlevel info
# User must manually run systemd-sysv-convert --apply httpd
# to migrate them to systemd targets
/usr/bin/systemd-sysv-convert --save openafs-client >/dev/null 2>&1 ||:

# Run this because the SysV package being removed won't do it
/sbin/chkconfig --del openafs-client >/dev/null 2>&1 || :

%triggerun -- openafs-server < 1.6.0-1
# Save the current service runlevel info
# User must manually run systemd-sysv-convert --apply httpd
# to migrate them to systemd targets
/usr/bin/systemd-sysv-convert --save openafs-server >/dev/null 2>&1 ||:

# Run this because the SysV package being removed won't do it
/sbin/chkconfig --del openafs-server >/dev/null 2>&1 || :
%endif

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

%files
%defattr(-,root,root)
%config(noreplace) /etc/sysconfig/openafs
%doc %{_docdir}/openafs-%{afsvers}/LICENSE
%{_bindir}/afsmonitor
%{_bindir}/bos
%{_bindir}/fs
%{_bindir}/pagsh
%{_bindir}/pts
%{_bindir}/restorevol
%{_bindir}/scout
%{_bindir}/sys
%{_bindir}/tokens
%{_bindir}/translate_et
%{_bindir}/xstat_cm_test
%{_bindir}/xstat_fs_test
%{_bindir}/udebug
%{_bindir}/unlog
%{_sbindir}/backup
%{_sbindir}/butc
%{_sbindir}/fms
%{_sbindir}/fstrace
%{_sbindir}/read_tape
%{_sbindir}/rxdebug
%{_sbindir}/uss
%{_sbindir}/vos
%{_sbindir}/vsys
%{_libdir}/libafshcrypto.so.*
%{_libdir}/librokenafs.so.*
%{_mandir}/man1/afs.1.gz
%{_mandir}/man1/afsmonitor.1.gz
%{_mandir}/man1/fs.1.gz
%{_mandir}/man1/fs_*.1.gz
%{_mandir}/man1/pagsh.1.gz
%{_mandir}/man1/pts.1.gz
%{_mandir}/man1/pts_*.1.gz
%{_mandir}/man1/restorevol.1.gz
%{_mandir}/man1/rxdebug.1.gz
%{_mandir}/man1/scout.1.gz
%{_mandir}/man1/sys.1.gz
%{_mandir}/man1/tokens.1.gz
%{_mandir}/man1/translate_et.1.gz
%{_mandir}/man1/udebug.1.gz
%{_mandir}/man1/unlog.1.gz
%{_mandir}/man1/vos.1.gz
%{_mandir}/man1/vos_*.1.gz
%{_mandir}/man1/xstat_cm_test.1.gz
%{_mandir}/man1/xstat_fs_test.1.gz
%{_mandir}/man5/CellServDB.5.gz
%{_mandir}/man5/ThisCell.5.gz
%{_mandir}/man5/afsmonitor.5.gz
%{_mandir}/man5/butc.5.gz
%{_mandir}/man5/butc_logs.5.gz
%{_mandir}/man5/uss.5.gz
%{_mandir}/man5/uss_bulk.5.gz
%{_mandir}/man8/backup.8.gz
%{_mandir}/man8/backup_*.8.gz
%{_mandir}/man8/bos.8.gz
%{_mandir}/man8/bos_*.8.gz
%{_mandir}/man8/butc.8.gz
%{_mandir}/man8/fms.8.gz
%{_mandir}/man8/fstrace.8.gz
%{_mandir}/man8/fstrace_*.8.gz
%{_mandir}/man8/read_tape.8.gz
%{_mandir}/man8/uss.8.gz
%{_mandir}/man8/uss_*.8.gz

%files docs
%defattr(-,root,root)
%docdir %{_docdir}/openafs-%{afsvers}
%dir %{_docdir}/openafs-%{afsvers}
%{_docdir}/openafs-%{afsvers}/ChangeLog
%{_docdir}/openafs-%{afsvers}/RELNOTES-%{afsvers}
%{_docdir}/openafs-%{afsvers}/pdf

%files client
%defattr(-,root,root)
%dir %{_prefix}/vice
%dir %{_prefix}/vice/cache
%dir %{_prefix}/vice/etc
%dir %{_prefix}/vice/etc/C
%{_prefix}/vice/etc/CellServDB.dist
%config(noreplace) %{_prefix}/vice/etc/ThisCell
%config(noreplace) %{_prefix}/vice/etc/cacheinfo
%{_bindir}/afsio
%{_bindir}/cmdebug
%{_bindir}/up
%{_prefix}/vice/etc/afsd
%{_prefix}/vice/etc/C/afszcm.cat
%{_libdir}/libuafs.a
%{_libdir}/libuafs_pic.a
%if 0%{?fedora} < 15 && 0%{?rhel} < 7
%{initdir}/openafs-client
%else
%{_unitdir}/openafs-client.service
%{_sysconfdir}/sysconfig/modules/openafs-client.modules
%endif
%{_mandir}/man1/cmdebug.1.gz
%{_mandir}/man1/up.1.gz
%{_mandir}/man5/afs.5.gz
%{_mandir}/man5/afs_cache.5.gz
%{_mandir}/man5/afs_volume_header.5.gz
%{_mandir}/man5/afszcm.cat.5.gz
%{_mandir}/man5/cacheinfo.5.gz
%{_mandir}/man8/afsd.8.gz
%{_mandir}/man8/vsys.8.gz
%{_mandir}/man5/CellAlias.5.gz

%files server
%defattr(-,root,root)
%dir %{_prefix}/afs
%dir %{_prefix}/afs/bin
%dir %{_prefix}/afs/etc
%dir %{_prefix}/afs/logs
%{_prefix}/afs/bin/bosserver
%{_prefix}/afs/bin/bos_util
%{_prefix}/afs/bin/buserver
%{_prefix}/afs/bin/dafileserver
%{_prefix}/afs/bin/dafssync-debug
%{_prefix}/afs/bin/dasalvager
%{_prefix}/afs/bin/davolserver
%{_prefix}/afs/bin/fileserver
%{_prefix}/afs/bin/fssync-debug
%{_prefix}/afs/bin/pt_util
%{_prefix}/afs/bin/ptserver
%{_prefix}/afs/bin/salvager
%{_prefix}/afs/bin/salvageserver
%{_prefix}/afs/bin/salvsync-debug
%{_prefix}/afs/bin/state_analyzer
%{_prefix}/afs/bin/upclient
%{_prefix}/afs/bin/upserver
%{_prefix}/afs/bin/vlserver
%{_prefix}/afs/bin/volinfo
%{_prefix}/afs/bin/volscan
%{_prefix}/afs/bin/volserver
%{_sbindir}/prdb_check
%{_sbindir}/vldb_check
%{_sbindir}/vldb_convert
%{_sbindir}/voldump
%if 0%{?fedora} < 15 && 0%{?rhel} < 7
%{initdir}/openafs-server
%else
%{_unitdir}/openafs-server.service
%endif
%{_mandir}/man5/BackupLog.5.gz
%{_mandir}/man5/BosConfig.5.gz
%{_mandir}/man5/BosLog.5.gz
%{_mandir}/man5/FORCESALVAGE.5.gz
%{_mandir}/man5/FileLog.5.gz
%{_mandir}/man5/KeyFile.5.gz
%{_mandir}/man5/KeyFileExt.5.gz
%{_mandir}/man5/NetInfo.5.gz
%{_mandir}/man5/NetRestrict.5.gz
%{_mandir}/man5/NoAuth.5.gz
%{_mandir}/man5/PtLog.5.gz
%{_mandir}/man5/SALVAGE.fs.5.gz
%{_mandir}/man5/SalvageLog.5.gz
%{_mandir}/man5/sysid.5.gz
%{_mandir}/man5/UserList.5.gz
%{_mandir}/man5/VLLog.5.gz
%{_mandir}/man5/VolserLog.5.gz
%{_mandir}/man5/bdb.DB0.5.gz
%{_mandir}/man5/fms.log.5.gz
%{_mandir}/man5/krb.conf.5.gz
%{_mandir}/man5/krb.excl.5.gz
%{_mandir}/man5/prdb.DB0.5.gz
%{_mandir}/man5/salvage.lock.5.gz
%{_mandir}/man5/tapeconfig.5.gz
%{_mandir}/man5/vldb.DB0.5.gz
%{_mandir}/man8/bosserver.8.gz
%{_mandir}/man8/buserver.8.gz
%{_mandir}/man8/fileserver.8.gz
%{_mandir}/man8/dafileserver.8.gz
%{_mandir}/man8/dafssync-debug.8.gz
%{_mandir}/man8/dafssync-debug_*.8.gz
%{_mandir}/man8/dasalvager.8.gz
%{_mandir}/man8/davolserver.8.gz
%{_mandir}/man8/fssync-debug.8.gz
%{_mandir}/man8/fssync-debug_*.8.gz
%{_mandir}/man8/prdb_check.8.gz
%{_mandir}/man8/ptserver.8.gz
%{_mandir}/man8/pt_util.8.gz
%{_mandir}/man8/salvager.8.gz
%{_mandir}/man8/salvageserver.8.gz
%{_mandir}/man8/state_analyzer.8.gz
%{_mandir}/man8/upclient.8.gz
%{_mandir}/man8/upserver.8.gz
%{_mandir}/man8/vldb_check.8.gz
%{_mandir}/man8/vldb_convert.8.gz
%{_mandir}/man8/vlserver.8.gz
%{_mandir}/man8/voldump.8.gz
%{_mandir}/man8/volinfo.8.gz
%{_mandir}/man8/volscan.8.gz
%{_mandir}/man8/volserver.8.gz

%if %{build_authlibs}
%files authlibs
%defattr(-,root,root)
%{_libdir}/libafsauthent.so.*
%{_libdir}/libafsrpc.so.*
%{_libdir}/libkopenafs.so.*
%endif

%files authlibs-devel
%defattr(-,root,root)
%{_includedir}/kopenafs.h
%{_libdir}/libafsauthent.a
%{_libdir}/libafscp.a
%{_libdir}/libafsrpc.a
%{_libdir}/libafsauthent_pic.a
%{_libdir}/libafsrpc_pic.a
%{_libdir}/libkopenafs.a
%if %{build_authlibs}
%{_libdir}/libafsauthent.so
%{_libdir}/libafsrpc.so
%{_libdir}/libkopenafs.so
%endif

%files devel
%defattr(-,root,root)
%{_bindir}/afs_compile_et
%{_bindir}/rxgen
%{_includedir}/afs
%{_includedir}/lock.h
%{_includedir}/lwp.h
%{_includedir}/rx
%{_includedir}/timer.h
%{_includedir}/ubik.h
%{_includedir}/ubik_int.h
%{_includedir}/opr/lock.h
%{_includedir}/opr/queue.h
%{_libdir}/afs
%{_libdir}/libafshcrypto.a
%{_libdir}/libafshcrypto.so
%{_libdir}/libafsrfc3961.a
%{_libdir}/liblwp.a
%{_libdir}/libopr.a
%{_libdir}/librokenafs.a
%{_libdir}/librokenafs.so
%{_libdir}/librx.a
%{_libdir}/librxkad.a
%{_libdir}/librxstat.a
%{_libdir}/libubik.a
%{_mandir}/man1/rxgen.1.gz
%{_mandir}/man1/afs_compile_et.1.gz
%if 0%{?fedora} >= 15 || 0%{?rhel} >= 6
%{_libdir}/perl/AFS/ukernel.pm
%{_libdir}/perl/ukernel.so
%{_mandir}/man3/AFS::ukernel.3.gz
%endif

%if %{build_dkmspkg}
%files -n dkms-%{name}
%defattr(-,root,root)
%{_prefix}/src/%{name}-%{dkms_version}
%endif

%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/bin/afsmonitor
%{_prefix}/afsws/bin/bos
%{_prefix}/afsws/bin/fs
%{_prefix}/afsws/bin/pagsh
%{_prefix}/afsws/bin/pts
%{_prefix}/afsws/bin/restorevol
%{_prefix}/afsws/bin/scout
%{_prefix}/afsws/bin/sys
%{_prefix}/afsws/bin/tokens
%{_prefix}/afsws/bin/translate_et
%{_prefix}/afsws/bin/udebug
%{_prefix}/afsws/bin/unlog
%{_prefix}/afsws/bin/xstat_cm_test
%{_prefix}/afsws/bin/xstat_fs_test
%{_prefix}/afsws/etc/backup
%{_prefix}/afsws/etc/butc
%{_prefix}/afsws/etc/fms
%{_prefix}/afsws/etc/fstrace
%{_prefix}/afsws/etc/read_tape
%{_prefix}/afsws/etc/rxdebug
%{_prefix}/afsws/etc/uss
%{_prefix}/afsws/etc/vos
%{_prefix}/afsws/etc/vsys
%if %{kauth_support}
%{_prefix}/afsws/bin/pagsh.krb
%{_prefix}/afsws/bin/tokens.krb
%endif

%if %{kauth_support}
%files kauth-client
%defattr(-,root,root)
%{_sbindir}/kas
%{_bindir}/klog
%{_bindir}/klog.krb
%{pamdir}/pam_afs.krb.so.1
%{pamdir}/pam_afs.krb.so
%{pamdir}/pam_afs.so.1
%{pamdir}/pam_afs.so
%{_bindir}/kapasswd
%{_bindir}/kpwvalid
%{_bindir}/pagsh.krb
%{_bindir}/tokens.krb
%{_prefix}/afsws/bin/kapasswd
%{_prefix}/afsws/bin/klog
%{_prefix}/afsws/bin/klog.krb
%{_prefix}/afsws/etc/kas
%{_mandir}/man1/kapasswd.1.gz
%{_mandir}/man1/klog.1.gz
%{_mandir}/man1/klog.krb.1.gz
%{_mandir}/man1/pagsh.krb.1.gz
%{_mandir}/man1/tokens.krb.1.gz
%{_mandir}/man8/kpwvalid.8.gz
%{_mandir}/man8/kas.8.gz
%{_mandir}/man8/kas_*.8.gz

%files kauth-server
%defattr(-,root,root)
%{_prefix}/afs/bin/kaserver
%{_prefix}/afs/bin/ka-forwarder
%{_sbindir}/kadb_check
%{_mandir}/man5/AuthLog.5.gz
%{_mandir}/man5/AuthLog.dir.5.gz
%{_mandir}/man5/kaserver.DB0.5.gz
%{_mandir}/man5/kaserverauxdb.5.gz
%{_mandir}/man8/kadb_check.8.gz
%{_mandir}/man8/ka-forwarder.8.gz
%{_mandir}/man8/kaserver.8.gz
%endif

%if %{krb5support}
%files krb5
%defattr(-,root,root)
%{_bindir}/aklog
%{_bindir}/klog.krb5
%{_sbindir}/akeyconvert
%{_sbindir}/asetkey
%{_mandir}/man1/aklog.1.gz
%{_mandir}/man1/klog.krb5.1.gz
%{_mandir}/man8/akeyconvert.8.gz
%{_mandir}/man8/asetkey.8.gz
%endif
%endif  # build_userspace

##############################################################################
###
### openafs.spec change log
###
##############################################################################
%changelog
* Wed Dec 12 2007  Simon Wilkinson <simon@sxw.org.uk> 1.4.5
- Make the RPM mockable

* Mon Oct 29 2007  Simon Wilkinson <simon@sxw.org.uk> 1.4.5
- Update to match the shipped 1.4.5 RPMS
- Fix the kvariant stuff to only configure the 'standard' case once
- Add openafs-kvers.sh back in

* Wed Oct 10 2007  Simon Wilkinson <simon@sxw.org.uk> 1.4.5pre1-1
- Use Fedora style kmods, which allows us to install multiple kernel types

* Thu Jun 07 2007  Simon Wilkinson <simon@sxw.org.uk> 1.4.4-3
- Use distributed files, rather than those in packager's SOURCE directory
- Remove SuidCells stuff, which was unused

* Fri Dec 01 2006  Derrick Brashear <shadow@dementia.org> 1.4.2-2
- integrate s390x changes
- allow for building libafs*.a and not libafs*.so into packages, for platforms
  that won't build the .so files.

* Wed Aug 23 2006  Derrick Brashear <shadow@dementia.org> 1.4.2-1
- update to 1.4.2
- use installed aklog manpage.
- moduleparam patch obsoleted.

* Tue Aug 22 2006  Derek Atkins <warlord@MIT.EDU> 1.4.2-0.1.rc1
- update to 1.4.2-rc1
- hand-apply lee damon's changes to support largesmp kernels from RHEL4
  (but only add support for 2.6 kernels.  No need for the 2.4 kernels).
- don't need the posixlock patch anymore.

* Wed Jul 12 2006  Derek Atkins <warlord@MIT.EDU> 1.4.2-0.beta2
- update to 1.4.2-beta2
- add linux2.4 posixlock API patch

* Mon Jun 26 2006  Derek Atkins <warlord@MIT.EDU>
- moduleparam and krb524 patches no longer required in OA-CVS

* Wed May 17 2006  Derek Atkins <warlord@MIT.EDU>
- change non-target-cpu kernel dep to a file dep
- make sure we use the proper kernel version for the dependency.

* Tue May 16 2006  Derek Atkins <warlord@MIT.EDU>
- allow users to specify local CellServDB and SuidCells entries
  don't overwrite user's changes.  Provide a .dist an let users
  make entries in a ".local"
- build the CellServDB and SuidCells at client startup and at
  client install-time
- add provideskernelarch functionality to openafs-kvers-is.sh
- use that functionality to Require kernel{,-<type>}-targetcpu
  to get better package safety due to RPM bugs where the kernel
  release isn't used so you can install the kernel module against
  any kernel of the same major version.

* Mon May 15 2006  Derek Atkins <warlord@MIT.EDU>
- update the README in openafs-kernel-source
- fix openafs-kvers-is.sh from Alexander Bergolth's patch.
- move kernel module from .../kernel/fs/openafs to .../fs/openafs/

* Fri Apr 21 2006  Derek Atkins <warlord@MIT.EDU>
- build requires autoconf and automake for krb5support
  and autoconf for standard package
- dont setup the krb5 migration kit (or patches) if we don't care.
- require ncurses-devel to build

* Wed Apr 19 2006  Derek Atkins <warlord@MIT.EDU> 1.4.1-3
- look for krb524 functions in libkrb524 if we can't find them
  in the standard locations.

* Tue Apr 18 2006  Derek Atkins <warlord@MIT.EDU> 1.4.1-2
- fix the module_param_array macro for Linux 2.6.9.

* Sat Apr 15 2006  Derek Atkins <warlord@MIT.EDU> 1.4.1-1
- update to 1.4.1 release.
- distribute asetkey from openafs instead of krb5-migration kit
- don't need to apply the FC5 patches because they are part of the distro.
- install asetkey into the "proper" place
- dont list a manpage twice.
- package asetkey man page.  delete it when not needed.

* Thu Apr  6 2006  Derek Atkins <warlord@MIT.EDU>
- turn authlibs back on, because RT #18767 was applied to CVS.

* Wed Mar 29 2006  Derek Atkins <warlord@MIT.EDU> 1.4.1rc10-1
- update to 1.4.1rc10, build on FC5
- fix the man pages (distribute into various packages)
- include patches for FC5, RT #29112 and #29122

* Mon Dec 19 2005  Derek Atkins <warlord@MIT.EDU>
- openafs-server shouldn't depend on the kernel module.

* Thu Nov 17 2005  Derek Atkins <warlord@MIT.EDU>
- patch from Mike Polek <mike at pictage.com> to run depmod for
  the target kernel and not the running kernel.

* Tue Nov  8 2005  Derek Atkins <warlord@MIT.EDU>
- build aklog from the openafs sources, not from the krb5 migration kit.

* Fri Nov  4 2005  Derek Atkins <warlord@MIT.EDU>
- set openafs-kernel-source to Provide openafs-kernel

* Thu Oct 20 2005  Derek Atkins <warlord@MIT.EDU> 1.4.0-1
- update afs-krb5 res_search patch: look for res_search and __res_search
- update to 1.4.0 final

* Mon Oct 10 2005  Derek Atkins <warlord@MIT.EDU>
- remove all kdump builds.

* Thu Oct  6 2005  Derek Atkins <warlord@MIT.EDU>
- fix openafs-kernel-version.sh so it will build an RPM for the
  currently-running kernel even if it's smp on 2.6.

* Tue Sep 27 2005  Derek Atkins <warlord@MIT.EDU> 1.4.0rc5-1
- upgrade to 1.4.0rc5
- turn off authlibs packages

* Fri Sep 23 2005  Derek Atkins <warlord@MIT.EDU> 1.4.0rc4-2
- add kmodule26 patch: fix the kernel module name on 2.6 kernels so
  it's called "openafs" and not "libafs".  This fixes the shutdown
  problem.

* Thu Sep 22 2005  Derek Atkins <warlord@MIT.EDU>
- update kversis script, add 'kvers' operation
- fix bug that 2.6 smp/hugemem kernels don't provide
  kernel-foo = %{kernvers} with 'smp', 'hugemem', etc.
- add patch to remove res_search from the afs-krb5 configure

* Thu Sep 15 2005  Derek Atkins <warlord@MIT.EDU> 1.4.0rc4-1
- Update to 1.4.0rc4
- Update the afs-krb5 krb524 patch so it actually works on
  some older systems like RHEL3 that still need -lkrb524.
- Update the buildall script so choose better architecture support,
  e.g. don't build i586 on RHEL.
- Update the rebuild information in the SPEC file.
- Add support for finding .EL kernels in openafs-kvers-is.sh
- Add additional error messages when kernel version/type parsing fails.
- Update the buildall script to use the kernel srcdir directly.

* Wed Sep 14 2005  Derek Atkins <warlord@MIT.EDU> 1.4.0rc3-2
- Add "hugemem" to 2.4 configs
- Add checks to support scripts to determine whether to build
  the bigmem and/or hugemem kernels for 2.4.

* Mon Sep 12 2005  Derek Atkins <warlord@MIT.EDU> 1.4.0rc3-1
- Added some afs-krb5 patches to get the migration kit to build
  on modern AFS and modern Kerberos.
- Added authlibs and authlibs-devel packages as per UMich changes.

* Sun Sep 11 2005  Derek Atkins <warlord@MIT.EDU>
- Merged in some of the 2.6 changes from wingc@engin.umich.edu

* Sat Sep 10 2005  Derek Atkins <warlord@MIT.EDU>
- Merged in lots of changes from David Howells and Nalin Dahyabhai
  from Red Hat.   Initial attempt at a release of 1.4.  Still need
  to work in a 2.6 build system.
