#
# spec file for package systemtap (Version 1.3)
#
# Copyright (c) 2010 SUSE LINUX Products 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 http://bugs.opensuse.org/
#

# norootforbuild


Name:           systemtap
BuildRequires:  gcc-c++ glib2-devel libcap-devel libebl-devel pkg-config sqlite-devel
BuildRequires:  mozilla-nspr-devel mozilla-nss-devel mozilla-nss-tools
%define use_snapshot	0
License:        GPLv2+
Version:        1.3
Release:        1
Summary:        Instrumentation System
Group:          Development/Tools/Debuggers
Url:            http://sourceware.org/systemtap/
# Requires: kernel-source gcc make
# Suggest: kernel-smp-debuginfo
%if %use_snapshot
%define package_version  20090214
%else
%define package_version  %{version}
%endif
Source:         ftp://sources.redhat.com/pub/systemtap/snapshots/systemtap-%{package_version}.tar.bz2
# need -docdir patch even though docs are packaged by systemtap-docs.spec
# so that they are installed into directories matching below rm -rf's
Patch1:         systemtap-docdir-fix.diff
Patch2:         systemtap-hppa.diff
Patch3:         systemtap-support-2.6.36.diff
Patch4:         systemtap_improve_gettimeofday_stability.patch
Patch5:         systemtap_fix_mod_vs_del_timer_race.patch

Requires:       libebl1
Requires:       %{name}-runtime = %{version}-%{release}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
SystemTap is an instrumentation system for systems running Linux 2.6.
Developers can write instrumentation to collect data on the operation
of the system.

%package runtime
License:        GPLv2+
Group:          Development/Tools/Debuggers
Summary:        Runtime environment for systemtap

%description runtime
SystemTap is an instrumentation system for systems running Linux 2.6.
This package contains the runtime environment for systemtap programs.

%package client
License:        GPLv2+
Group:          Development/Tools/Debuggers
Summary:        Systemtap client
Requires:       %{name}-runtime = %{version}-%{release}
# dependancies for systemtap shell scripts
Requires:       coreutils avahi avahi-utils mozilla-nss-tools zip unzip

%description client
SystemTap is an instrumentation system for systems running Linux 2.6.
This package contains the client component for systemtap.

%package server
License:        GPLv2+
Group:          Development/Tools/Debuggers
Summary:        Systemtap server
Requires:       %{name} = %{version}-%{release}
# dependancies for systemtap shell scripts
Requires:       coreutils avahi avahi-utils mozilla-nss-tools zip unzip

%description server
SystemTap is an instrumentation system for systems running Linux 2.6.
This package contains the server component of systemtap.

%package sdt-devel
License:        GPLv2+
Group:          Development/Tools/Debuggers
Summary:        Static probe support tools
Requires:       %{name} = %{version}-%{release}
Requires:       python-base

%description sdt-devel
SystemTap is an instrumentation system for systems running Linux 2.6.
This package contains the support tools for static probes.

%prep
%if %use_snapshot
%setup -n src -q
%else
%setup -n %{name}-%{package_version} -q
%endif
%patch1 -p1
%patch2
%patch3 -p1
%patch4 -p1
%patch5 -p1

%build
autoreconf -fi
%configure
make %{?jobs:-j %jobs}

%install
%makeinstall
# XXX
rm -f $RPM_BUILD_ROOT/usr/lib/systemtap/stap-server-request
# README, AUTHORS, NEWS, man3 and all examples packaged by systemtap-docs
# COPYING needs to stay in main for GPL
rm -rf $RPM_BUILD_ROOT%{_docdir}/systemtap/
rm -rf $RPM_BUILD_ROOT%{_mandir}/man3
mkdir -p $RPM_BUILD_ROOT%{_docdir}/systemtap/
cp COPYING $RPM_BUILD_ROOT%{_docdir}/systemtap/
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/cache/systemtap
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/run/systemtap
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/log
touch $RPM_BUILD_ROOT%{_localstatedir}/log/stap-server.log

%clean
rm -rf ${RPM_BUILD_ROOT}

%files
%defattr(-,root,root)
%{_bindir}/stap
%{_mandir}/man[17]/*

%dir %{_datadir}/%{name}
%{_datadir}/%{name}/runtime
%{_datadir}/%{name}/tapset
#packaged by systemtap-initscript in upstream
%dir %{_localstatedir}/cache/systemtap
%dir %{_localstatedir}/run/systemtap

%files runtime
%defattr(-,root,root)
%doc %{_docdir}/systemtap
%{_bindir}/staprun
%{_bindir}/stap-report
%{_bindir}/stap-authorize-signing-cert
%dir %{_libexecdir}/%{name}
%{_libexecdir}/%{name}/stapio
%{_libexecdir}/%{name}/stap-env
%{_libexecdir}/%{name}/stap-authorize-cert
%{_mandir}/man8/staprun.8*
%{_mandir}/man8/stap-authorize-signing-cert.8*

%files client
%defattr(-,root,root)
%defattr(-,root,root)
%{_bindir}/stap-client
%{_bindir}/stap-authorize-server-cert
%{_libexecdir}/%{name}/stap-find-servers
%{_libexecdir}/%{name}/stap-client-connect
%{_mandir}/man8/stap-client.8*
%{_mandir}/man8/stap-authorize-server-cert.8*

%files server
%defattr(-,root,root)
%{_bindir}/stap-authorize-server-cert
%{_bindir}/stap-server
%{_libexecdir}/%{name}/stap-serverd
%{_libexecdir}/%{name}/stap-start-server
%{_libexecdir}/%{name}/stap-find-servers
%{_libexecdir}/%{name}/stap-find-or-start-server
%{_libexecdir}/%{name}/stap-stop-server
%{_libexecdir}/%{name}/stap-gen-cert
%{_libexecdir}/%{name}/stap-server-connect
%{_libexecdir}/%{name}/stap-sign-module
%{_mandir}/man8/stap-server.8*
%{_mandir}/man8/stap-authorize-server-cert.8*
%ghost %{_localstatedir}/log/stap-server.log

%files sdt-devel
%defattr(-,root,root)
%{_bindir}/dtrace
%{_includedir}/sys/*.h

%changelog