Name: krbafs
Version: 1.1.1
Release: 9
Source: ftp://ftp.pdc.kth.se/pub/krb/src/krb4-%{version}.tar.gz
Source1: krbafs.versions
Patch0: krb4-1.1.1-dnsparse.patch
License: Freely Distributable
Group: System Environment/Libraries
Summary: A Kerberos to AFS bridging library, built against Kerberos 5.
Buildroot: %{_tmppath}/%{name}-root
BuildPrereq: krb5-devel

%define k5prefix /usr/kerberos
%define fake_aklog 0

%description
This package contains the krbafs shared library, which allows programs
to obtain AFS network filesystem tokens using Kerberos IV credentials,
without having to link with official AFS libraries which may not be
available for a given platform.

%package utils
Summary: Kerberos/AFS utilities.
Group: Applications/System
Requires: %{name} = %{version}-%{release}

%description utils
Kerberos is a network authentication system. The krbafs-utils package
contains versions of afslog, pagsh, and kstring2key that are linked
against libkrbafs (a Kerberos to AFS bridging library).

%package devel
Summary: Development files for use with the krbafs package.
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}

%description devel
This package contains header files and static libraries for use when
building applications which use the krbafs library.

%changelog
* Wed Jan 22 2003 Tim Powers <timp@redhat.com>
- rebuilt

* Tue Dec 03 2002 Elliot Lee <sopwith@redhat.com> 1.1.1-8
- Remove unpackaged files

* Tue Oct  9 2002 Nalin Dahyabhai <nalin@redhat.com> 1.1.1-7
- backport dns resolver from 1.2 to properly handle truncated responses
- fixup paths for multilib systems

* Mon Aug 12 2002 Nalin Dahyabhai <nalin@redhat.com> 1.1.1-6
- reference files in the source tree properly at build-time

* Wed Jul 17 2002 Nalin Dahyabhai <nalin@redhat.com> 1.1.1-5
- own the man page directory

* Fri Jun 21 2002 Tim Powers <timp@redhat.com>
- automated rebuild

* Sun May 26 2002 Tim Powers <timp@redhat.com>
- automated rebuild

* Thu May 16 2002 Nalin Dahyabhai <nalin@redhat.com> 1.1.1-2
- rebuild in new environment

* Fri Mar  1 2002 Nalin Dahyabhai <nalin@redhat.com> 1.1.1-1
- update to 1.1.1
- build shared only, and use a map file to only export symbols from the
  shared library which are declared in the header

* Fri Feb 22 2002 Nalin Dahyabhai <nalin@redhat.com> 1.1-4
- rebuild

* Wed Jan 09 2002 Tim Powers <timp@redhat.com>
- automated rebuild

* Tue Nov 13 2001 Nalin Dahyabhai <nalin@redhat.com> 1.1-2
- remove explicit dependency on krb5-libs

* Thu Oct 18 2001 Nalin Dahyabhai <nalin@redhat.com> 1.1-1
- update to 1.1

* Thu Aug 16 2001 Nalin Dahyabhai <nalin@redhat.com>
- obey RPM_OPT_FLAGS

* Tue Jul 24 2001 Nalin Dahyabhai <nalin@redhat.com>
- update to 1.0.9

* Wed Jul 11 2001 Nalin Dahyabhai <nalin@redhat.com>
- break out the -devel subpackage
- make the subpackages require the main package

* Thu Jul  5 2001 Nalin Dahyabhai <nalin@redhat.com>
- include sample krb.conf and krb.realms files from the source package
  in the binary package, tweaked for the EXAMPLE.COM realm
- add doc files

* Tue Apr 24 2001 Nalin Dahyabhai <nalin@redhat.com>
- update to 1.0.8

* Thu Dec 28 2000 Nalin Dahyabhai <nalin@redhat.com>
- update to 1.0.5

* Mon Dec 11 2000 Nalin Dahyabhai <nalin@redhat.com>
- update to 1.0.4

* Mon Oct 23 2000 Nalin Dahyabhai <nalin@redhat.com>
- update to 1.0.3

* Mon Oct  9 2000 Nalin Dahyabhai <nalin@redhat.com>
- drop dangling symlink (#18750)

* Wed Aug 16 2000 Nalin Dahyabhai <nalin@redhat.com>
- fix summary and description

* Thu Jul 13 2000 Prospector <bugzilla@redhat.com>
- automatic rebuild

* Thu Jun 29 2000 Nalin Dahyabhai <nalin@redhat.com>
- update to 1.0.2

* Tue Jun 27 2000 Nalin Dahyabhai <nalin@redhat.com>
- rebuild in new build environment (release 3)

* Sun Jun  4 2000 Nalin Dahyabhai <nalin@redhat.com>
- fix for compiling with new gcc

* Tue Mar 14 2000 Nalin Dahyabhai <nalin@redhat.com>
- update to 1.0.1

* Tue Mar  7 2000 Jeff Johnson <jbj@redhat.com>
- rebuild for sparc baud rates > 38400.

* Thu Mar 02 2000 Nalin Dahyabhai <nalin@redhat.com>
- add Requires: krb5-libs and BuildPrereq: krb5-devel

* Thu Jan 06 2000 Nalin Dahyabhai <nalin@redhat.com>
- make prefix changeable in case we decide to move it later

* Wed Dec 16 1999 Nalin Dahyabhai <nsdahya1@pobox.com>
- update to 1.0 (whee!)

* Mon Dec 13 1999 Nalin Dahyabhai <nsdahya1@pobox.com>
- link shared lib against libresolv and libcrypt to help resolve symbols in
  configure tests
- make %ifarch ppc parts %ifnarch i386

* Thu Dec 02 1999 Jeremy Katz <jlkatz@unity.ncsu.edu>
- Build the static lib for libkrbafs as well as linking against all the necessary libs
  with the shared lib
* Wed Dec 01 1999 Jeremy Katz <jlkatz@unity.ncsu.edu>
- Added ppc-specific symlinking afslog as replacement for aklog

* Tue Nov 30 1999 Nalin Dahyabhai <nalin.dahyabhai@pobox.com>
- initial version

%prep
%setup -q -n krb4-%{version}
%patch0 -p1 -b .dnsparse
# Do a large amount of renaming to keep from conflicting with versions of
# libkafs in the wild.
find . -type f | xargs perl -pi -e 's,kafs,krbafs,g'
find . -type d -name "*kafs*" | xargs rename kafs krbafs
find . -type f -name "*kafs*" | xargs rename kafs krbafs
sed 's,MY.REALM.NAME,EXAMPLE.COM,g' etc/krb.realms > krb.realms
sed 's,MY.REALM.NAME,EXAMPLE.COM,g' etc/krb.conf   > krb.conf

%build
# First, configure the source tree.
CFLAGS="$RPM_OPT_FLAGS -fPIC" \
LIBS="-lcrypt" \
./configure --prefix=%{k5prefix} --libdir=%{k5prefix}/%{_lib} \
        --enable-shared --disable-static \
        --without-readline \
        --without-hesiod \
        --without-openssl

# We define this macro to override settings to allow us to use headers and
# libraries from an installed krb5 setup.
%define makesub make INCLUDE_krb4="-I%{k5prefix}/include -I%{k5prefix}/include/kerberosIV" INCLUDE_des="-I%{k5prefix}/include -I%{k5prefix}/include/kerberosIV -I`pwd`/lib/krbafs" LIB_krb4="-L%{k5prefix}/%{_lib} -lkrb4" LIB_des="-L%{k5prefix}/%{_lib} -ldes425 -lk5crypto" LIB_roken=

# Generate needed header files and libraries.
%makesub -C include protos.h
%makesub -C lib/roken roken.h
%makesub -C lib/krb krb.h

for subdir in lib/krbafs appl/afsutil ; do
        # Copy over headers which will need to be used by additional modules.
        cp -f lib/krb/krb_locl.h ${subdir}
        cp -f lib/krb/krb_log.h ${subdir}
        cp -f lib/krb/krb-protos.h ${subdir}
        cp -f lib/krb/prot.h ${subdir}
        cp -f include/protos.h ${subdir}

        # Copy some of the modules from libkrb to the library.
        krbc="get_default_principal lifetime str2key"
        krbo="get_default_principal.o lifetime.o str2key.o"
        krblo="get_default_principal.lo lifetime.lo str2key.lo"
        for krb in $krbc ; do
                cp -f lib/krb/${krb}.c ${subdir}
                %makesub -C ${subdir} ${krb}.lo
        done

        # Copy some of the modules from libroken to the library.
        rokenc="esetenv getprogname k_getpwuid setprogname strlwr"
        rokeno="esetenv.o getprogname.o k_getpwuid.o setprogname.o strlwr.o"
        rokenlo="esetenv.lo getprogname.lo k_getpwuid.lo setprogname.lo strlwr.lo"
        for roken in $rokenc ; do
                cp -f lib/roken/${roken}.c ${subdir}
                %makesub -C ${subdir} ${roken}.lo
        done
done

# Build the shared library, adding in the modules needed to keep the library
# from having undesirable undefined symbols.
%makesub -C lib/krbafs libkrbafs.la \
        libkrbafs_la_DEPENDENCIES= \
        libkrbafs_la_LIBADD="${krblo} ${rokenlo}" \
        libkrbafs_la_LDFLAGS="-Wl,-version-script=%{SOURCE1}"

# Build the bundled apps.
cp -f lib/roken/strlcpy.c appl/afsutil
%makesub -C appl/afsutil strlcpy.lo
%makesub -C appl/afsutil \
        LDADD="../../lib/krbafs/libkrbafs.la ${krblo} ${rokenlo} strlcpy.lo "'$(LIB_krb4)'

%clean
[ "$RPM_BUILD_ROOT" != "/" ] && rm -fr $RPM_BUILD_ROOT

%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -fr $RPM_BUILD_ROOT
%makesub -C lib/krbafs install DESTDIR=$RPM_BUILD_ROOT libkrbafs_la_DEPENDENCIES=
%makesub -C appl/afsutil install DESTDIR=$RPM_BUILD_ROOT
test -d $RPM_BUILD_ROOT%{_sysconfdir} || mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}
install -m644 krb.conf krb.realms $RPM_BUILD_ROOT%{_sysconfdir}

%if %{fake_aklog}
%ifnarch i386
# CMU's aklog can't be built against Arla... not yet, anyway.
(mkdir -p $RPM_BUILD_ROOT/usr/athena/etc; \
 ln -s ../../kerberos/bin/afslog $RPM_BUILD_ROOT/usr/athena/etc/aklog)
%endif
%endif

rm -rf $RPM_BUILD_ROOT%{k5prefix}/%{_lib}/*.la \
        $RPM_BUILD_ROOT%{k5prefix}/man/cat*

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root)
%doc COPYRIGHT lib/krbafs/ChangeLog
%config(noreplace) %{_sysconfdir}/*
%{k5prefix}/%{_lib}/*.so.*.*

%files devel
%defattr(-,root,root)
%{k5prefix}/include/*
%{k5prefix}/%{_lib}/*.so
%dir %{k5prefix}/man/man3
%{k5prefix}/man/man3/*.3*

%files utils
%defattr(-,root,root)
%{k5prefix}/bin/*
%{k5prefix}/man/man1/*.1*

%if %{fake_aklog}
%ifnarch %{ix86}
/usr/athena/etc/*
%endif
%endif