File libtune.spec of Package libtune

#
# spec file for package libtune (Version 0.11)
#
# Copyright (c) 2003 SuSE Linux AG, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
# Please submit bug fixes or comments via http://www.suse.de/feedback/
#

# norootforbuild
# neededforbuild  bison flex libtool gcc glibc


BuildRequires:  bison >= 1.75
BuildRequires:  flex >= 2.5.3
BuildRequires:  libtool gcc

%define major 0
%define libname libtune

Name:           %{libname}%{major}
Version:        0.11
Release:        1
Summary:        Library that Standardizes the Access to Kernel Tunables

Group:          Development/Libraries/C and C++
License:        GPL/LGPL
URL:            http://libtune.sourceforge.net
Source:         %{libname}-%{version}.tar.bz2
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

Autoreqprov:    on

Requires:       tunables-generic-data = %{version}
Requires:       tunables-family-data = %{version}



%description
The libtune library aims at providing a standard API to unify the various ways
Linux developers have to access kernel tunables, system information and
resource consumptions.

This API is built on top of the existing mechanisms (in order not to break
backward compatibility), and can be used by the applications to manipulate the
information and tunables from the kernel.

Using a single interface you can get the value of a tunable wherever it is
located (sysfs or procfs), whether its value is the unique content of a file
or a field within a file.
This is also true for setting a tunable value.

This package supplies only the library.


%package devel
Summary: Libtune development
Group:   Development/Libraries/C and C++
Provides: %{libname}-devel = %{version}
Requires: %{name} = %{version}
Requires(post): insserv
Requires(preun): insserv

%description devel
This package supplies the header files to use with the library, as well as the
header files used to generate the tunables databases. It also supplies the
scripts needed for manipulating the tunables databases.


%package -n tunables-data-2.6.5
Summary: Kernel-dependent tunables database
Group:   Development/Libraries/C and C++
Provides: tunables-generic-data = %{version}

%description -n tunables-data-2.6.5
This package supplies the tunables database for kernel release 2.6.5


%package -n tunables-data-2.6.11
Summary: Kernel-dependent tunables database
Group:   Development/Libraries/C and C++
Provides: tunables-generic-data = %{version}

%description -n tunables-data-2.6.11
This package supplies the tunables database for kernel release 2.6.11


%package -n tunables-data-2.6.16
Summary: Kernel-dependent tunables database
Group:   Development/Libraries/C and C++
Provides: tunables-generic-data = %{version}

%description -n tunables-data-2.6.16
This package supplies the tunables database for kernel release 2.6.16


%package -n tunables-data-SLES9-2.6.5
Summary:  Distro-dependent tunables database
Group:    Development/Libraries/C and C++
Provides: tunables-family-data = %{version}
Requires: tunables-data-2.6.5 = %{version}

%description -n tunables-data-SLES9-2.6.5
This package supplies the tunables database for SuSE Linux Enterprise Server
9's 2.6.5


%package -n tunables-data-SL9.3-2.6.11
Summary:  Distro-dependent tunables database
Group:    Development/Libraries/C and C++
Provides: tunables-family-data = %{version}
Requires: tunables-data-2.6.11 = %{version}

%description -n tunables-data-SL9.3-2.6.11
This package supplies the tunables database for SuSE Linux 9.3's 2.6.11


%package -n tunables-data-SLES10-2.6.16
Summary:  Distro-dependent tunables database
Group:    Development/Libraries/C and C++
Provides: tunables-family-data = %{version}
Requires: tunables-data-2.6.16 = %{version}

%description -n tunables-data-SLES10-2.6.16
This package supplies the tunables database for SuSE Linux Enterprise Server
10's 2.6.16


%package -n tunables-data-SL10.1-2.6.16
Summary:  Distro-dependent tunables database
Group:    Development/Libraries/C and C++
Provides: tunables-family-data = %{version}
Requires: tunables-data-2.6.16 = %{version}

%description -n tunables-data-SL10.1-2.6.16
This package supplies the tunables database for SuSE Linux 10.1's 2.6.16


%prep
%setup -q -n %{libname}-%{version}


%build
export CFLAGS="%{optflags}"
make -C lib %{?_smp_mflags}
make -C scripts %{?_smp_mflags}


%install
rm -rf $RPM_BUILD_ROOT

mkdir -p $RPM_BUILD_ROOT/%{_includedir}
make -C include install INSTDIR=$RPM_BUILD_ROOT

mkdir -p $RPM_BUILD_ROOT/%{_libdir}
make -C lib install INSTDIR=$RPM_BUILD_ROOT

install -m 0755 -d $RPM_BUILD_ROOT/%{_datadir}/%{libname}
install -m 0644 -T README $RPM_BUILD_ROOT/%{_datadir}/%{libname}/README-%{version}

mkdir -p $RPM_BUILD_ROOT/%{_bindir}
mkdir -p $RPM_BUILD_ROOT/%{_initrddir}
cd $RPM_BUILD_ROOT/%{_sysconfdir}
ln -s init.d rc.d
cd -
make -C scripts install INSTDIR=$RPM_BUILD_ROOT

#
# This is done to avoid delivering the symlinks in /etc/rc.d/rc*.d in the
# %files section: the symlinks are rebuilt during post install
#
rm -f $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d
rm  -rf $RPM_BUILD_ROOT/%{_initrddir}/rc[3-5].d

#
# Build the databases and install them
#
clean_str=""
devel_manifest=files-devel
echo "%defattr(-,root,root)" > $devel_manifest

nb_dbs=4
kreleases=("2.6.5" "2.6.11" "2.6.16" "2.6.16")
families=("SLES" "SL" "SLES" "SL")
freleases=(9 "9.3" "10" "10.1")

i=0
while [ ${i} -lt ${nb_dbs} ]
do
    KVERSION=${kreleases[${i}]}
    FAMILY=${families[${i}]}
    FRELEASE=${freleases[${i}]}

    $clean_str

    make -C db KVERSION=$KVERSION FAMILY=$FAMILY FRELEASE=$FRELEASE
    make -C db KVERSION=$KVERSION FAMILY=$FAMILY FRELEASE=$FRELEASE    \
        INSTDIR=$RPM_BUILD_ROOT install

    dmanifest=files-data-${FAMILY}${FRELEASE}-${KVERSION}
    echo "%defattr(-,root,root)" > $dmanifest
    echo "%{_datadir}/libtune/distrodbs/distro-${FAMILY}${FRELEASE}/tundb_distro" >> $dmanifest

    kmanifest=files-data-${KVERSION}

    if [ ! -f ${kmanifest} ]
    then
        echo "%defattr(-,root,root)" > $kmanifest
        echo "%{_datadir}/libtune/basedbs/base-${KVERSION}/tundb_kernel" >>   \
            $kmanifest

        echo "%{_datadir}/libtune/basedbs/base-${KVERSION}/libtuninitdb_base.h" >>    \
            $devel_manifest
    fi

    echo "%{_datadir}/libtune/distrodbs/distro-${FAMILY}${FRELEASE}/libtuninitdb_distro.h" >> $devel_manifest

    clean_str="make -C db KVERSION=$KVERSION FAMILY=$FAMILY    \
        FRELEASE=$FRELEASE clean"

    i=`expr $i + 1`
done

make -C templates install INSTDIR=$RPM_BUILD_ROOT

db/libtuncleandb $RPM_BUILD_ROOT/%{_datadir}/libtune/tundb_kernel    \
    $RPM_BUILD_ROOT/%{_datadir}/libtune/tundb_distro


%clean
rm -rf $RPM_BUILD_ROOT


%post -p /sbin/ldconfig

%post devel
if [ -x %{_libdir}/lsb/install_initd ]
then
    %{_libdir}/lsb/install_initd %{_initrddir}/chtunedb
else
    /sbin/chkconfig --add chtunedb
fi
/sbin/ldconfig

%post -n tunables-data-2.6.5
/usr/share/libtune/bin/libtune_upgrade.sh post basedbs/base-2.6.5 tundb_kernel

%post -n tunables-data-2.6.11
/usr/share/libtune/bin/libtune_upgrade.sh post basedbs/base-2.6.11 tundb_kernel

%post -n tunables-data-2.6.16
/usr/share/libtune/bin/libtune_upgrade.sh post basedbs/base-2.6.16 tundb_kernel

%post -n tunables-data-SLES9-2.6.5
/usr/share/libtune/bin/libtune_upgrade.sh post distrodbs/distro-SLES9   \
    tundb_distro

%post -n tunables-data-SL9.3-2.6.11
/usr/share/libtune/bin/libtune_upgrade.sh post distrodbs/distro-SL9.3  \
    tundb_distro

%post -n tunables-data-SLES10-2.6.16
/usr/share/libtune/bin/libtune_upgrade.sh post distrodbs/distro-SLES10 \
    tundb_distro

%post -n tunables-data-SL10.1-2.6.16
/usr/share/libtune/bin/libtune_upgrade.sh post distrodbs/distro-SL10.1 \
    tundb_distro


%preun devel
#
# There's no need to stop chtunedb before deleting it: it is not a daemon
#
if [ -x %{_libdir}/lsb/remove_initd ]
then
    %{_libdir}/lsb/remove_initd %{_initrddir}/chtunedb
else
    /sbin/chkconfig --del chtunedb
fi

%preun -n tunables-data-2.6.5
/usr/share/libtune/bin/libtune_upgrade.sh prekernel

%preun -n tunables-data-2.6.11
/usr/share/libtune/bin/libtune_upgrade.sh prekernel

%preun -n tunables-data-2.6.16
/usr/share/libtune/bin/libtune_upgrade.sh prekernel

%preun -n tunables-data-SLES9-2.6.5
/usr/share/libtune/bin/libtune_upgrade.sh predistro

%preun -n tunables-data-SL9.3-2.6.11
/usr/share/libtune/bin/libtune_upgrade.sh predistro

%preun -n tunables-data-SLES10-2.6.16
/usr/share/libtune/bin/libtune_upgrade.sh predistro

%preun -n tunables-data-SL10.1-2.6.16
/usr/share/libtune/bin/libtune_upgrade.sh predistro


%postun -p /sbin/ldconfig

%postun devel -p /sbin/ldconfig


%files
%defattr(-,root,root)
%{_libdir}/libtune.so.*
%doc %{_datadir}/%{libname}/README-%{version}

%files devel -f files-devel
%defattr(-,root,root)
%{_includedir}/libtune.h
%{_libdir}/libtune.la
%{_libdir}/libtune.a
%{_libdir}/libtune.so
%{_datadir}/libtune/bin/get_current_distro.sh
%{_initrddir}/chtunedb
%{_datadir}/libtune/templates
%{_datadir}/libtune/bin/add_distro.sh
%{_datadir}/libtune/bin/add_kernel.sh
%{_bindir}/add_tunable
%{_datadir}/libtune/bin/add_tunable.awk
%{_datadir}/libtune/bin/add_tunable.sh
%{_datadir}/libtune/bin/contents_attributes
%{_datadir}/libtune/bin/name_attributes
%{_datadir}/libtune/bin/new_tunable.awk
%{_datadir}/libtune/bin/new_tunable.sh
%{_bindir}/get_tunedb
%{_bindir}/remove_tunable
%{_datadir}/libtune/bin/remove_tunable.awk
%{_datadir}/libtune/bin/remove_tunable.sh
%{_datadir}/libtune/bin/rpm_constants.sh
%{_datadir}/libtune/bin/scripts_constants.sh
%{_datadir}/libtune/bin/scripts_lib.sh
%{_datadir}/libtune/bin/strategy_routines
%doc COPYING lib/LGPL ChangeLog
%doc %{_datadir}/libtune/doc/README
%doc templates/GPL

%files -n tunables-data-2.6.5 -f files-data-2.6.5
%defattr(-,root,root)
%{_datadir}/libtune/bin/libtune_upgrade.sh
%doc %{_datadir}/libtune/doc/README

%files -n tunables-data-2.6.11 -f files-data-2.6.11
%defattr(-,root,root)
%{_datadir}/libtune/bin/libtune_upgrade.sh
%doc %{_datadir}/libtune/doc/README

%files -n tunables-data-2.6.16 -f files-data-2.6.16
%defattr(-,root,root)
%{_datadir}/libtune/bin/libtune_upgrade.sh
%doc %{_datadir}/libtune/doc/README

%files -n tunables-data-SLES9-2.6.5 -f files-data-SLES9-2.6.5
%defattr(-,root,root)
%doc %{_datadir}/libtune/doc/README

%files -n tunables-data-SL9.3-2.6.11 -f files-data-SL9.3-2.6.11
%defattr(-,root,root)
%doc %{_datadir}/libtune/doc/README

%files -n tunables-data-SLES10-2.6.16 -f files-data-SLES10-2.6.16
%defattr(-,root,root)
%doc %{_datadir}/libtune/doc/README

%files -n tunables-data-SL10.1-2.6.16 -f files-data-SL10.1-2.6.16
%defattr(-,root,root)
%doc %{_datadir}/libtune/doc/README


%changelog
* Fri Nov 17 2006 Nadia Derbey <Nadia.Derbey@bull.net> 0.11-1
- the db directory has been revisited: kernel tunables DB's and distro tunables
  DB's are now completely independent: this enables to deliver a kernel
  tunables DB for any kernel supported together with a given distro release.
- Changes in the spec file and in the sources to enable building for SuSE
- Changes in the spec file and in the sources to enable a more LSB compliant
  init script
- Removed the /etc/rc.d/rc*.d/S*chtunedb from the delivery since the links are
  rebuilt by chkconfig

* Thu Nov  9 2006 Nadia Derbey <Nadia.Derbey@bull.net> 0.10-3
- Fixed lib/Makefile in order for the rpm to be buildable on a 64-bit release
- Fixed the licensing issues in the specfile as well as in various source
  files.

* Mon Oct 23 2006 Nadia Derbey <Nadia.Derbey@bull.net> 0.10-2
- Many fixes in the specfile
  (see https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=210007)

* Mon Sep 18 2006 Nadia Derbey <Nadia.Derbey@bull.net> 0.10-1
- The tunables DB is now a shared object (mapped file)
- The original package is now delivered in several packages

* Mon Jun 05 2006 Nadia Derbey <Nadia.Derbey@bull.net> 0.9-1
- Added support for some new tunables
- Enhanced add_support.sh script