File openafs16.spec of Package openafs16

#
# spec file for package openafs
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
# needssslcertforbuild


#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
  %define _fillupdir /var/adm/fillup-templates
%endif

#
#	TUNABLES
#

#
# define distribution and version
#

#distribution-definitions here

#kerberos5
# 0=MIT | 1=Heimdal
%define		option_heimdal		0

# clean build-root after build
%define		option_clean_buildroot	0

# build authlibs
%define build_authlibs 1

# build kernel modules
%define build_kernel_modules 1

# build fuse-based client
%define build_fuse_client 0

# create PAM libraries
%define build_pamlibs 1

# run regen to create new configure script
%define run_regen 1

# use systemd instead of legacy init-scripts
# not for SLES11
%if 0%{?suse_version} > 1110
%define use_systemd 1
%else 
%define use_systemd 0
%define build_kernel_modules 0
%endif

#
# auto-determined parameters
#
%define pamdir            /%{_lib}/security
%define libdir            %{_libdir}
%define libexecdir        %{_libdir}
%define bindir            %{_bindir}
%define sbindir           %{_sbindir}
%define includedir        %{_includedir}/openafs
%define mandir            %{_mandir}
%define afslogsdir        /var/log/openafs
%define sysconfdir        %{_sysconfdir}
%define afsconfdir        /etc/openafs/server
%define viceetcdir        /etc/openafs
%define vicecachedir	  /var/cache/openafs
%define afslocaldir       /var/lib/openafs

Name:           openafs

Version:        1.6.24
Release:        0
Summary:        OpenAFS Distributed File System
License:        IPL-1.0
Group:          System/Filesystems
Url:            http://www.openafs.org/

Source0:        openafs-%{version}-src.tar.bz2
Source1:        openafs-%{version}-doc.tar.bz2
Source4:        openafs-%{version}-src.tar.bz2.sha256
Source5:        openafs-%{version}-doc.tar.bz2.sha256
Source10:       README.SUSE.openafs
Source11:       rc.afs-server
Source12:       rc.afs-client
Source13:       sysconfig.openafs-client
Source14:       sysconfig.openafs-server
Source15:       logrotate.openafs-server
Source18:       RELNOTES-%{version}
Source19:       ChangeLog
Source20:       kernel-source.build-modules.sh
Source21:       rc.afs-fuse-client
Source22:       sysconfig.openafs-fuse-client
Source23:       openafs-client.service
Source25:       openafs-server.service
Source26:       openafs-fuse-client.service
Source27:       sysconfig.openafs-client-systemd
Source28:       sysconfig.openafs-server-systemd
Source29:       sysconfig.openafs-fuse-client-systemd
Source30:       preamble
Source55:       openafs.SuidCells
Source56:       openafs.CellAlias
Source57:       openafs.ThisCell
Source58:       openafs.cacheinfo
Source99:       openafs.changes
Patch1:         openafs-1.6.x.layout.patch
Patch2:         openafs-1.6.x.heimdal.patch
Patch3:         openafs-1.6.x.suse.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

#
#	GENERAL BuildRequires and Requires
#

%if %{_vendor} == "suse"
BuildRequires:  automake
BuildRequires:  bison
BuildRequires:  coreutils
BuildRequires:  fdupes
BuildRequires:  flex
BuildRequires:  git
BuildRequires:  libtirpc-devel
BuildRequires:  ncurses-devel
%if 0%{?suse_version} < 1210
Requires(post): %insserv_prereq
%endif
Requires(post): %fillup_prereq

%if %{build_pamlibs}
BuildRequires:  pam-devel
%endif

%if %{option_heimdal}
BuildRequires:  heimdal-devel
 %define krb5_config /usr/lib/heimdal/bin/krb5-config
%else
BuildRequires:  krb5-devel
   %define krb5_config /usr/lib/mit/bin/krb5-config
%endif

%if %{build_kernel_modules} 
BuildRequires:  %{kernel_module_package_buildreqs}
%endif

%if %{build_fuse_client}
BuildRequires:  fuse-devel
BuildRequires:  pkg-config
%endif
%endif

%description  
AFS is a cross-platform distributed file system product pioneered at
Carnegie Mellon University and supported and developed as a product by
Transarc Corporation (now IBM Pittsburgh Labs). It offers a
client-server architecture for file sharing, providing location
independence, scalability, and transparent migration capabilities for
data.

In addition, among its features are authentication, encryption,
caching, disconnected operations, replication for higher availability
and load balancing, and ACLs.

Authors:
--------
    see http://www.openafs.org/credits.html

%package server
Summary:        OpenAFS File System Server
Group:          System/Filesystems
Requires:       %{name} = %{version}
Requires:       %{name}-docs = %{version}

%description server
AFS is a cross-platform distributed file system product pioneered at
Carnegie Mellon University and supported and developed as a product by
Transarc Corporation (now IBM Pittsburgh Labs). It offers a
client-server architecture for file sharing, providing location
independence, scalability, and transparent migration capabilities for
data.

In addition, among its features are authentication, encryption,
caching, disconnected operations, replication for higher availability
and load balancing, and ACLs. This package contains the static
libraries and header files needed to develop applications for OpenAFS.

Authors:
--------
    see http://www.openafs.org/credits.html


%if %{build_authlibs}
%package authlibs
Summary:        OpenAFS authentication shared libraries
Group:          Development/Libraries/C and C++

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

%package authlibs-devel
Summary:        OpenAFS shared library development
Group:          Development/Libraries/C and C++
Requires:       %{name}-authlibs = %{version}
Requires:       %{name}-devel = %{version}

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

%endif

%package devel
Summary:        OpenAFS Static Libraries and Header Files
Group:          Development/Libraries/Other
Requires:       %{name} = %{version}

%description devel
AFS is a cross-platform distributed file system product pioneered at
Carnegie Mellon University and supported and developed as a product by
Transarc Corporation (now IBM Pittsburgh Labs). It offers a
client-server architecture for file sharing, providing location
independence, scalability, and transparent migration capabilities for
data.

In addition, among its features are authentication, encryption,
caching, disconnected operations, replication for higher availability
and load balancing, and ACLs. This package contains the OpenAFS server.

Authors:
--------
    see http://www.openafs.org/credits.html


%package docs
Summary:        OpenAFS user and administrator documentation
Group:          System/Filesystems
Requires:       %{name} = %{version}

%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:          System/Filesystems
Requires:       bison
Requires:       flex
Requires:       gcc
Requires:       kernel-devel
Provides:       openafs-kernel = %{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.

%if %{option_heimdal}
%package krb5-heimdal
Summary:        OpenAFS programs to use with krb5
Group:          System/Filesystems
Requires:       %{name} = %{version}
Requires:       heimdal-lib
Requires:       heimdal-tools

%description krb5-heimdal
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.
This is using the  implementation of krb5.
Requires:       heimdal-lib
Requires:       heimdal-tools
%else 

%package krb5-mit
Summary:        OpenAFS programs to use with krb5
Group:          System/Filesystems
Requires:       %{name} = %{version}
Requires:       krb5-client

%description krb5-mit
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.
This is using the MIT implementation of krb5.

%endif

%if %{build_kernel_modules}
%package KMP
Summary:        OpenAFS Distributed File System - kernel module
Group:          System/Kernel
Requires:       %{kernel_module_package_buildreqs}

%suse_kernel_module_package lockdep um pae -p %_sourcedir/preamble

%description KMP
This package contains the kernel module for OpenAFS. For details see
the openafs package.

Authors:
--------
    see http://www.openafs.org/credits.html


%endif

%if %{build_fuse_client}
%package fuse_client
Summary:        OpenAFS FUSE File System Client
Group:          System/Filesystems
Requires:       %{name} = %{version}
Requires:       %{name}-docs = %{version}
Requires:       %{name}-krb5-mit = %{version}
Conflicts:      %{name}-client
Requires:       coreutils
Requires:       diffutils
Requires:       fillup
Requires:       grep
Requires:       sed

%description fuse_client
AFS is a cross-platform distributed file system product pioneered at
Carnegie Mellon University and supported and developed as a product by
Transarc Corporation (now IBM Pittsburgh Labs). It offers a
client-server architecture for file sharing, providing location
independence, scalability, and transparent migration capabilities for
data.

This client is using the EXPERIMENTAL FUSE interface on LINUX.
It does not offer authentication etc. 

Authors:
--------
    see http://www.openafs.org/credits.html
%else 

%package client
Summary:        OpenAFS File System Client
Group:          System/Filesystems
Requires:       %{name} = %{version}
Requires:       %{name}-docs = %{version}
Requires:       %{name}-kmp
Requires:       %{name}-krb5-mit = %{version}
Requires:       coreutils
Requires:       diffutils
Requires:       fillup
Requires:       grep
Requires:       sed

%description client
AFS is a cross-platform distributed file system product pioneered at
Carnegie Mellon University and supported and developed as a product by
Transarc Corporation (now IBM Pittsburgh Labs). It offers a
client-server architecture for file sharing, providing location
independence, scalability, and transparent migration capabilities for
data.

In addition, among its features are authentication, encryption,
caching, disconnected operations, replication for higher availability
and load balancing, and ACLs. This package contains the OpenAFS client.

Authors:
--------
    see http://www.openafs.org/credits.html

%endif

%prep

: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
: @@@
: @@@ package-name:       %{name}
: @@@ file-layout:	  fsh
: @@@ PAM modules dir:    %{pamdir}
: @@@ lib dir:    	  %{libdir}
: @@@ libexec dir:    	  %{libexecdir}
: @@@ bin dir:    	  %{bindir}
: @@@ sbin dir:    	  %{sbindir}
: @@@ include dir:    	  %{includedir}
: @@@ sysconf dir:    	  %{sysconfdir}
: @@@ man dir:    	  %{mandir}
: @@@ build modules:      %{build_kernel_modules}
: @@@ build fuse client:  %{build_fuse_client}
%if %{option_heimdal}
: @@@ krb5 : heimdal
%else
: @@@ krb5 : mit
%endif
: @@@ linux_make_arch:    %{?linux_make_arch}
: @@@ ARCH:               %{_arch}
: @@@ target cpu:         %{_target_cpu}
: @@@
: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

# check source-file integrity

for src_file in %{S:0}  %{S:1}; do
    if [ "`sha256sum $src_file | awk '{print $1}'`" != "`cat $src_file.sha256 | awk '{print $1}'`" ]; then 
        echo "ERROR: SHA256-Integrity check for $src_file failed."; 
        exit 1
    fi
done

%setup -q -n openafs-%{version} -T -b 0 -b 1

cp src/config/param.s390_linux24.h src/config/param.s390_linux26.h

%patch1 -p1
%if %{option_heimdal}
%patch2 -p1
%endif
%patch3 -p1

%if %{run_regen}
 ./regen.sh
%endif

%build
sysbase=%{_arch}
%ifarch ppc
	perl -pi -e 's,^(XCFLAGS.*),\1 -fPIC,' src/config/Makefile.ppc_linux24.in
%endif
%ifarch ppc64
	sysbase=ppc64
%endif
%ifarch s390x
	sysbase=s390
%endif
%ifarch x86_64
	sysbase=amd64
	perl -pi -e 's,^(XCFLAGS.*),\1 -fPIC,' src/config/Makefile.amd64_linux24.in
	perl -pi -e 's,^(XLIBS.*),\1 -lresolv,' src/config/Makefile.amd64_linux24.in
%endif
afs_sysname=${sysbase}_linux26
# there are mixed static and shared libs, using -fPIC everywhere is the most safe.
#

RPM_OPT_FLAGS=`echo ${RPM_OPT_FLAGS} | sed s/-D_FORTIFY_SOURCE=2//`
export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -fPIC" 

%if %{option_heimdal}
export CFLAGS="$CFLAGS -I/usr/include/heimdal" 
%else
export KRB5LIBS='-lcom_err -lkrb5'
%endif
export PATH_KRB5_CONFIG=%{krb5_config}

%ifarch ppc64
export LDFLAGS="$LDFLAGS -m64"
%endif

./configure \
		--prefix=/usr \
		--disable-transarc-paths \
%if %{build_pamlibs} == 0
               --disable-pam \
%endif
		--bindir=%{bindir} \
		--sbindir=%{sbindir} \
		--libdir=%{libdir} \
		--libexecdir=%{libexecdir} \
		--includedir=%{includedir} \
		--sysconfdir=%{sysconfdir} \
		--mandir=%{mandir} \
		--with-afs-sysname=$afs_sysname \
		--disable-kernel-module

make CCFLAGS="$CFLAGS" XCFLAGS="$CFLAGS" PAM_CFLAGS="$CFLAGS" KOPTS="$CFLAGS" all_nolibafs
make CCFLAGS="$CFLAGS" XCFLAGS="$CFLAGS" PAM_CFLAGS="$CFLAGS" KOPTS="$CFLAGS" only_libafs_tree

# the test suite need a configured KDC
#make -C src/tests all

# Kernel-module

%if %{build_kernel_modules}
mkdir obj

for flavor in %flavors_to_build; do
    rm -rf obj/$flavor
    cp -a libafs_tree obj/$flavor
    pushd obj/$flavor
    find . -name *.c -print0 | xargs -0 sed -i '/MODULE_LICENSE(/a MODULE_INFO(retpoline, "Y");'
    ./configure  --with-linux-kernel-build=/usr/src/linux-obj/%{_target_cpu}/$flavor --with-linux-kernel-headers=/usr/src/linux \
		--disable-transarc-paths
    export EXTRA_CFLAGS='-DVERSION=\"%version\"'
    export KCFLAGS='-mindirect-branch=thunk-inline -mindirect-branch-register'
    export LINUX_MAKE_ARCH="ARCH=%{_arch}"
    make
    popd
done
%endif

%install

# cleanup buildroot
if [ -n "$RPM_BUILD_ROOT" ] ; then
   [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
fi
mkdir ${RPM_BUILD_ROOT}

#
# install build binaries using  make 

make DESTDIR=$RPM_BUILD_ROOT install_nolibafs

#
# man-pages 

OLD_PWD=`pwd`
cd doc/man-pages
make DESTDIR=$RPM_BUILD_ROOT install
cd $OLD_PWD

# remove unused man pages
for x in afs_ftpd afs_inetd afs_login afs_rcp afs_rlogind afs_rsh \
    dkload knfs package runntp symlink symlink_list symlink_make \
    symlink_remove; do
        rm -f $RPM_BUILD_ROOT%{mandir}/man1/${x}.1
done

# compress man pages
OLD_PWD=`pwd`
for d in $RPM_BUILD_ROOT%{_mandir}/man*;do
    cd $d
    for f in *;do
        if [ -h $f ]; then
            mv $f $f.gz
        elif [ -f $f ];then
            gzip -9 $f
        else 
            echo "Unknown thing to compress : $f"
        fi
    done
done
cd $OLD_PWD

#
# create directories
%if %{use_systemd}
mkdir -p $RPM_BUILD_ROOT/%_unitdir
%else
mkdir -p $RPM_BUILD_ROOT/etc/init.d
%endif
mkdir -p $RPM_BUILD_ROOT/%{afslogsdir}/old
mkdir -p $RPM_BUILD_ROOT/%{_fillupdir}
mkdir -p $RPM_BUILD_ROOT/%{vicecachedir}
mkdir -p $RPM_BUILD_ROOT/%{viceetcdir}
mkdir -p $RPM_BUILD_ROOT/usr/share/openafs/C
mkdir -p $RPM_BUILD_ROOT/%{afsconfdir}
mkdir -p $RPM_BUILD_ROOT/%{afslocaldir}

# pam-libs
%if %{build_pamlibs}
mkdir -p %{buildroot}/%{pamdir}
mkdir -p $RPM_BUILD_ROOT/%{mandir}/man5
install -m 644 src/pam/pam_afs.5 $RPM_BUILD_ROOT/%{mandir}/man5
gzip -9 $RPM_BUILD_ROOT/%{mandir}/man5/pam_afs.5
%endif

#
# client
cp -a src/afsd/CellServDB $RPM_BUILD_ROOT%{viceetcdir}/CellServDB
cp -a %{S:55} $RPM_BUILD_ROOT%{viceetcdir}/SuidCells
cp -a %{S:56} $RPM_BUILD_ROOT%{viceetcdir}/CellAlias
cp -a %{S:57} $RPM_BUILD_ROOT%{viceetcdir}/ThisCell
cp -a %{S:58} $RPM_BUILD_ROOT%{viceetcdir}/cacheinfo
cp -a src/afs/afszcm.cat $RPM_BUILD_ROOT/usr/share/openafs/C
%if %{use_systemd}
install -m 644 %{S:27} $RPM_BUILD_ROOT/%{_fillupdir}/sysconfig.openafs-client
install -m 644 %{S:23} $RPM_BUILD_ROOT/%_unitdir
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcopenafs-client
%else
install -m 644 %{S:13} $RPM_BUILD_ROOT/%{_fillupdir}/sysconfig.openafs-client
install -m 755 $RPM_SOURCE_DIR/rc.afs-client $RPM_BUILD_ROOT/etc/init.d/openafs-client
ln -s ../../etc/init.d/openafs-client $RPM_BUILD_ROOT/usr/sbin/rcopenafs-client
%endif

#
# fuse client package

%if %{build_fuse_client}
%if %{use_systemd}
install -m 644 %{S:29} $RPM_BUILD_ROOT/%{_fillupdir}/sysconfig.openafs-fuse-client
install -m 644 %{S:26} $RPM_BUILD_ROOT/%_unitdir
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcopenafs-fuse-client
%else
install -m 644 %{S:22} $RPM_BUILD_ROOT/%{_fillupdir}/sysconfig.openafs-fuse-client
install -m 755 %{S:21} $RPM_BUILD_ROOT/etc/init.d/openafs-fuse-client
ln -s ../../etc/init.d/openafs-fuse-client $RPM_BUILD_ROOT/usr/sbin/rcopenafs-fuse-client
%endif
%endif

# 
# server
%if %{use_systemd}
install -m 644 %{S:28} $RPM_BUILD_ROOT/%{_fillupdir}/sysconfig.openafs-server
install -m 644 %{S:25} $RPM_BUILD_ROOT/%_unitdir
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcopenafs-server
%else
install -m 644 %{S:14} $RPM_BUILD_ROOT/%{_fillupdir}/sysconfig.openafs-server
install -m 755 $RPM_SOURCE_DIR/rc.afs-server $RPM_BUILD_ROOT/etc/init.d/openafs-server
ln -s ../../etc/init.d/openafs-server $RPM_BUILD_ROOT/usr/sbin/rcopenafs-server
%endif

#
# common: pam, kpasswd

# conflicts with kpasswd from heimdal package
mv $RPM_BUILD_ROOT/usr/bin/kpasswd $RPM_BUILD_ROOT/usr/bin/afs_kpasswd
mv $RPM_BUILD_ROOT/%{mandir}/man1/kpasswd.1.gz $RPM_BUILD_ROOT/%{mandir}/man1/afs_kpasswd.1.gz
%if %{build_pamlibs}
  mv %{buildroot}/%{libdir}/pam* %{buildroot}/%{pamdir}
  ln -sf pam_afs.so.1	%{buildroot}/%{pamdir}/pam_afs.so
  ln -sf pam_afs.krb.so.1	%{buildroot}/%{pamdir}/pam_afs.krb.so
%endif

#
# kernel-source 
mkdir -p $RPM_BUILD_ROOT/usr/src/kernel-modules/openafs
chmod -R o-w src/libafs
chmod -R o-w libafs_tree
cp -a libafs_tree $RPM_BUILD_ROOT/usr/src/kernel-modules/openafs
cp -av %{S:20} $RPM_BUILD_ROOT/usr/src/kernel-modules/openafs/build-modules.sh
install -m 644 src/LICENSE $RPM_BUILD_ROOT/usr/src/kernel-modules/openafs/LICENSE

# KMP
%if %{build_kernel_modules}
  export INSTALL_MOD_PATH=$RPM_BUILD_ROOT
  export INSTALL_MOD_DIR=updates
  export LINUX_MAKE_ARCH="ARCH=%{_arch}"

  for flavor in %flavors_to_build; do
    make -C /usr/src/linux-obj/%{_target_cpu}/$flavor $LINUX_MAKE_ARCH modules_install \
         M=$PWD/`find obj/$flavor/ -name MODLOAD-\* -type d`
  done
%endif

#
# main package
cp -a %{S:10} README.SUSE
cp -a %{S:18} RELNOTES
cp -a %{S:19} ChangeLog

# krb5
mv $RPM_BUILD_ROOT%{bindir}/asetkey $RPM_BUILD_ROOT%{sbindir}/asetkey
mv $RPM_BUILD_ROOT%{bindir}/bos $RPM_BUILD_ROOT%{sbindir}/bos
mv $RPM_BUILD_ROOT%{bindir}/udebug $RPM_BUILD_ROOT%{sbindir}/udebug

# avoid conflict with scout
mv $RPM_BUILD_ROOT/usr/bin/scout $RPM_BUILD_ROOT/usr/bin/afs_scout
mv $RPM_BUILD_ROOT/%{_mandir}/man1/scout.1.gz $RPM_BUILD_ROOT/%{_mandir}/man1/afs_scout.1.gz

# move  %%{libdir}/afs-stuff to %%{libdir}/openafs
mv $RPM_BUILD_ROOT/%{libdir}/afs/* $RPM_BUILD_ROOT/%{libdir}/openafs
rm -rf $RPM_BUILD_ROOT/%{libdir}/afs

#
# general cleanup
#

# it's already in /usr/bin
rm -f $RPM_BUILD_ROOT/usr/sbin/kpwvalid
# we supposedly don't need this one on linux
rm -f $RPM_BUILD_ROOT/usr/sbin/rmtsysd
rm -f $RPM_BUILD_ROOT/usr/share/man/man8/rmtsysd.8.gz
%if %{build_authlibs} == 0
 rm -f $RPM_BUILD_ROOT/%{libdir}/openafs/libafsauthent.so.*
 rm -f $RPM_BUILD_ROOT/%{libdir}/openafs/libafsrpc.so.*
 rm -f $RPM_BUILD_ROOT/%{libdir}/openafs/libkopenafs.so.*
 rm -f $RPM_BUILD_ROOT/%{libdir}/openafs/libafsauthent.a
 rm -f $RPM_BUILD_ROOT/%{libdir}/openafs/libafsauthent_pic.a
 rm -f $RPM_BUILD_ROOT/%{libdir}/openafs/libafsrpc.a
 rm -f $RPM_BUILD_ROOT/%{libdir}/openafs/libafsrpc_pic.a
 rm -f $RPM_BUILD_ROOT/%{libdir}/openafs/libkopenafs.a
 rm -f $RPM_BUILD_ROOT/%{libdir}/openafs/libafsauthent.so
 rm -f $RPM_BUILD_ROOT/%{libdir}/openafs/libafsrpc.so
 rm -f $RPM_BUILD_ROOT/%{libdir}/openafs/libkopenafs.so
%endif

#check for duplicates, remove them and hard-link them 
# we need hardlinks since the instances are scattered over different
# packages
%fdupes $RPM_BUILD_ROOT

%clean
%if %{option_clean_buildroot}
if [ -n "$RPM_BUILD_ROOT" ] ; then
	[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
fi
%endif

#
# kernel-source

%post kernel-source
echo To install the kernel-module, do:
echo cd /usr/src/kernel-modules/openafs
echo sh ./build-modules.sh build
echo sh ./build-modules.sh install

#
# fuse client

%if %{build_fuse_client}

%if %{use_systemd}
%pre fuse_client
%service_add_pre openafs-client.service
%endif

%post fuse_client
%{fillup_only -n openafs-fuse-client}
%if %{use_systemd}
%service_add_post openafs-client.service
%endif
/sbin/ldconfig

if [ "x$1" = "x" ]; then
   my_operation=0
else
   my_operation=$1
fi

if [ $my_operation -gt 1 ]; then
    echo Not stopping the possibly running client.
    echo You must restart the client to put the upgrade into effect.
else
    echo This is the experimental FUSE implementation of the openafs-client
    echo Please configure your cell like with the in-kernel openafs-client
    echo authentication etc. is not implemented yet in this version.
fi

%preun fuse_client
%if %{use_systemd}
%service_del_preun openafs-client.service
%endif
%{stop_on_removal}

%postun fuse_client
%if %{use_systemd}
 %service_del_postun openafs-client.service
%else
%{insserv_cleanup}
%endif
/sbin/ldconfig

%else

#
# client

%if %{use_systemd}
%pre client
%service_add_pre openafs-client.service
%endif

%post client
if [ ! -d /afs ]; then
    mkdir /afs
fi
/sbin/ldconfig
%{fillup_only -n openafs-client}
%if %{use_systemd}
%service_add_post openafs-client.service
%endif

if [ "x$1" = "x" ]; then
   my_operation=0
else
   my_operation=$1
fi
if [ $my_operation -gt 1 ]; then
    echo Not stopping the possibly running client.
    echo You must restart the client to put the upgrade into effect.
else 
    echo For configuring the client, please check /etc/sysconfig/openafs-client
    echo and/or follow the instructions found on http://www.openafs.org  how to install an openafs-client. 
fi

%preun client
%{stop_on_removal}
%if %{use_systemd}
%service_del_preun openafs-client.service
%endif

%postun client
if [ -d /afs ]; then
    echo make sure to remove directory /afs if unwanted.
fi
/sbin/ldconfig
%if %{use_systemd}
%service_del_postun openafs-client.service
%else
%{insserv_cleanup}
%endif

#fuse-client
%endif

#
# server

%if %{use_systemd}
%pre server
%service_add_pre openafs-server.service
%endif

%post server
/sbin/ldconfig
%{fillup_only -n openafs-server}
%if %{use_systemd}
%service_add_post openafs-server.service
%endif

if [ "x$1" = "x" ]; then
   my_operation=0
else
   my_operation=$1
fi
if [ $my_operation -gt 1 ]; then
    echo Not stopping the possibly running services.
    echo You must restart the service to put the upgrade into effect.
else 
    echo For configuring the server, please check /etc/sysconfig/openafs-server
    echo and/or follow the instructions found on http://www.openafs.org to install an openafs-client. 
fi

%preun server
%if %{use_systemd}
%service_del_preun openafs-server.service
%endif
%{stop_on_removal}

%postun server
%if %{use_systemd}
%service_del_postun openafs-server.service
%else
%{insserv_cleanup}
%endif

#
# devel

%post devel
/sbin/ldconfig

%postun devel
/sbin/ldconfig

#
# authlibs

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

%postun authlibs
/sbin/ldconfig
%endif

#
#	FILES
#

%files           
%defattr(-,root,root)
%{bindir}/afsmonitor
%{bindir}/afs_compile_et
%{bindir}/afs_kpasswd
%{bindir}/afs_scout
%{bindir}/sys
%{bindir}/translate_et
%{bindir}/xstat_cm_test
%{bindir}/xstat_fs_test
%{sbindir}/backup
%{sbindir}/butc
%{sbindir}/fms
%{bindir}/pts
%{sbindir}/kas
%{sbindir}/kdb
%{sbindir}/vos
%{sbindir}/bos
%{bindir}/afsio
%{bindir}/fs
%{sbindir}/udebug
%{sbindir}/state_analyzer 
%{sbindir}/salvsync-debug 
%{sbindir}/fssync-debug 
%{sbindir}/dafssync-debug
%{sbindir}/read_tape
%{bindir}/restorevol
%{sbindir}/rxdebug
%{sbindir}/uss
%{sbindir}/vsys
%dir %{viceetcdir}
%config(noreplace) %{viceetcdir}/CellServDB

%files    docs   
%defattr(-,root,root)
%doc %{mandir}/man1/*
%doc %{mandir}/man5/*
%doc %{mandir}/man8/*
%doc NEWS README* RELNOTES ChangeLog

%if %{build_fuse_client}
%files fuse_client
%defattr(-,root,root)
 %{sbindir}/afsd.fuse
%config(noreplace) %{viceetcdir}/SuidCells
%config(noreplace) %{viceetcdir}/CellAlias
%config(noreplace) %{viceetcdir}/ThisCell
%config(noreplace) %{viceetcdir}/cacheinfo
%if %{use_systemd}
  %_unitdir/openafs-fuse-client.service
%else
  /etc/init.d/openafs-fuse-client
%endif
 %{sbindir}/rcopenafs-fuse-client
 %{_fillupdir}/sysconfig.openafs-fuse-client
 /%{vicecachedir}
%else
%files client
%defattr(-,root,root)
 %{bindir}/cmdebug
 %{bindir}/klog
 %{bindir}/klog.krb
 %{bindir}/unlog
 %{bindir}/klog.krb5
 %{bindir}/up
 %{sbindir}/afsd
 %{sbindir}/fstrace
 %{bindir}/kpwvalid
 %{bindir}/pagsh
 %{bindir}/pagsh.krb	
 %{sbindir}/ka-forwarder
 %{bindir}/tokens
 %{bindir}/tokens.krb
%if %{build_pamlibs}
  %{pamdir}/pam_afs.krb.so.1
  %{pamdir}/pam_afs.krb.so
  %{pamdir}/pam_afs.so.1
  %{pamdir}/pam_afs.so
%endif
%if %{use_systemd}
  %_unitdir/openafs-client.service
%else
  /etc/init.d/openafs-client
%endif
%dir /usr/share/openafs
%dir /usr/share/openafs/C
 /usr/share/openafs/C/afszcm.cat
%config(noreplace) %{viceetcdir}/SuidCells
%config(noreplace) %{viceetcdir}/CellAlias
%config(noreplace) %{viceetcdir}/ThisCell
%config(noreplace) %{viceetcdir}/cacheinfo
 /usr/sbin/rcopenafs-client
 %{_fillupdir}/sysconfig.openafs-client
 /%{vicecachedir}
%endif

%files server 
%defattr(-,root,root)
%if %{use_systemd}
%_unitdir/openafs-server.service
%else
 /etc/init.d/openafs-server
%endif
%{_sbindir}/rcopenafs-server
%attr(770,root,root) %dir %{afslocaldir}
%attr(775,root,root) %dir %{afslogsdir}
%{sbindir}/voldump
%{bindir}/knfs
%config %{viceetcdir}/server
%{_fillupdir}/sysconfig.openafs-server
%dir %{libdir}/openafs
 %{libdir}/openafs/ptserver
 %{libdir}/openafs/kaserver
 %{libdir}/openafs/salvager
 %{libdir}/openafs/vlserver
 %{libdir}/openafs/fileserver
 %{libdir}/openafs/buserver
 %{libdir}/openafs/upclient
 %{libdir}/openafs/upserver
 %{libdir}/openafs/volserver
 %{libdir}/openafs/dafileserver
 %{libdir}/openafs/davolserver
 %{libdir}/openafs/dasalvager
 %{libdir}/openafs/salvageserver
 %{sbindir}/bosserver
 %{sbindir}/kadb_check
 %{sbindir}/prdb_check
 %{sbindir}/volinfo
 %{sbindir}/vldb_convert
 %{sbindir}/vldb_check
 %{sbindir}/bos_util
 %{sbindir}/pt_util
 %{sbindir}/volscan

%files devel  
%defattr(-,root,root)
 %{includedir}
 %dir %{libdir}/openafs
 %{libdir}/openafs/libacl.a
 %{libdir}/openafs/libafscp.a
 %{libdir}/openafs/libafsadminutil.a
 %{libdir}/openafs/libafsint.a
 %{libdir}/openafs/libafsutil.a
 %{libdir}/openafs/libaudit.a
 %{libdir}/openafs/libauth.a
 %{libdir}/openafs/libauth.krb.a
 %{libdir}/openafs/libbos.a
 %{libdir}/openafs/libbosadmin.a
 %{libdir}/openafs/libbubasics.a
 %{libdir}/openafs/libbudb.a
 %{libdir}/openafs/libbutm.a
 %{libdir}/openafs/libbxdb.a
 %{libdir}/openafs/libcfgadmin.a
 %{libdir}/openafs/libclientadmin.a
 %{libdir}/openafs/libcmd.a
 %{libdir}/openafs/libafscom_err.a
 %{libdir}/openafs/libdes.a
 %{libdir}/openafs/libdir.a
 %{libdir}/openafs/libfsprobe.a
 %{libdir}/openafs/libgtx.a
 %{libdir}/openafs/libjuafs.a
 %{libdir}/openafs/libkasadmin.a
 %{libdir}/openafs/libkauth.a
 %{libdir}/openafs/libkauth.krb.a
 %{libdir}/openafs/liblwp.a
 %{libdir}/openafs/libprocmgmt.a
 %{libdir}/openafs/libprot.a
 %{libdir}/openafs/libptsadmin.a
 %{libdir}/openafs/librx.a
 %{libdir}/openafs/librxkad.a
 %{libdir}/openafs/librxstat.a
 %{libdir}/openafs/libsys.a
 %{libdir}/openafs/libuafs.a
 %{libdir}/openafs/libubik.a
 %{libdir}/openafs/libusd.a
 %{libdir}/openafs/libvldb.a
 %{libdir}/openafs/libvlib.a
 %{libdir}/openafs/libvolser.a
 %{libdir}/openafs/libvosadmin.a
 %{libdir}/openafs/libxstat_cm.a
 %{libdir}/openafs/libxstat_fs.a
 %{libdir}/openafs/util.a
 %{libdir}/openafs/vlib.a
%{bindir}/livesys
%{bindir}/rxgen

%files  kernel-source 
%defattr(-,root,root)
%dir /usr/src/kernel-modules
%dir /usr/src/kernel-modules/openafs
/usr/src/kernel-modules/openafs/*

%if %{option_heimdal}
%files krb5-heimdal
%defattr(-,root,root)
%else 
%files krb5-mit
%defattr(-,root,root)
%endif
%{bindir}/aklog
%{sbindir}/asetkey

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

%files authlibs-devel
%defattr(-,root,root)
%{libdir}/openafs/libafsauthent.a
%{libdir}/openafs/libafsauthent_pic.a
%{libdir}/openafs/libafsrpc.a
%{libdir}/openafs/libafsrpc_pic.a
%{libdir}/openafs/libkopenafs.a
%{libdir}/openafs/libafsauthent.so
%{libdir}/openafs/libafsrpc.so
%{libdir}/openafs/libkopenafs.so
%endif

#
#	CHANGELOG
#

%changelog
openSUSE Build Service is sponsored by