SPECS/systemtap/systemtap.spec
b0c195c6
 %define        with_boost     1
 %define        with_crash     1
 %define        with_docs      0
 %define        with_grapher   0
 %define        with_pie       1
 %define        with_rpm       0
 %define        with_sqlite    1
 
 Name:          systemtap
31204a78
 Version:       3.1
7f9d2e12
 Release:       4%{?dist}
b0c195c6
 Summary:       Programmable system-wide instrumentation system
 Group:         Development/System
 Vendor:	       VMware, Inc.
 Distribution:  Photon
 URL:           http://sourceware.org/systemtap/
 Source0:       http://sourceware.org/systemtap/ftp/releases/systemtap-%{version}.tar.gz
31204a78
 %define sha1 systemtap=2927ee7e780b45e47d770798f80dfd5be62e095d
b0c195c6
 License:       GPLv2+
 
 BuildRequires: elfutils-devel
 BuildRequires: glibc-devel
 BuildRequires: elfutils-libelf-devel
 BuildRequires: libgcc
7fbd3a1e
 BuildRequires: nspr-devel
b0c195c6
 BuildRequires: nss-devel
fb300e7c
 BuildRequires: sqlite-devel
b0c195c6
 BuildRequires: libstdc++-devel
 BuildRequires: libtirpc-devel
 BuildRequires: libxml2-devel
 BuildRequires: perl
31204a78
 BuildRequires: python-setuptools
b0c195c6
 BuildRequires: nss
 %if %with_boost 
 BuildRequires: boost-devel
 %endif
 %if %with_crash
 BuildRequires: crash-devel
 BuildRequires: zlib-devel
 Requires:      crash
 %endif
 BuildRequires: pkg-config
 %if %with_rpm
 BuildRequires: rpm-devel
 %endif
 Requires:      gcc
7c85d55b
 Requires:      linux-devel
b0c195c6
 Requires:      make
52d2668a
 Requires:      elfutils
b0c195c6
 Requires:      %{name}-runtime = %{?epoch:%epoch:}%{version}-%{release}
7f9d2e12
 Requires(pre):  /usr/sbin/useradd /usr/sbin/groupadd
 Requires(postun):/usr/sbin/userdel /usr/sbin/groupdel
d3cc2624
 
b0c195c6
 BuildRoot:     %{_tmppath}/%{name}-%{version}-root
 
 %description
 SystemTap is an instrumentation system for systems running Linux.
 Developers can write instrumentation scripts to collect data on
 the operation of the system.  The base systemtap package contains/requires
 the components needed to locally develop and execute systemtap scripts.
 
 
 %package initscript
 Group:         System/Tools
 Summary:       Systemtap Initscript
 Requires:      %{name}-runtime = %{?epoch:%epoch:}%{version}-%{release}
 Requires:      initscripts
 
 %description initscript
 Initscript for Systemtap scripts.
 
31204a78
 %package python
 Group:         System/Tools
 Summary:       Python interface for systemtap
 
 %description python
 This packages has the python interface to systemtap
 
b0c195c6
 %package runtime
 Group:         System/Tools
 Summary:       Instrumentation System Runtime
7c85d55b
 Requires:      linux-devel
b0c195c6
 
 %description runtime
 SystemTap runtime is the runtime component of an instrumentation system for systems running Linux.
 
 %package sdt-devel
 Group:         System/Tools
 Summary:       Static probe support tools
16e76bee
 Requires:      %{name} = %{?epoch:%epoch:}%{version}-%{release}
b0c195c6
 
 %description sdt-devel
 Support tools to allow applications to use static probes.
 
 %package server
 Group:         System/Tools
 Summary:       Instrumentation System Server
 Requires:      %{name} = %{?epoch:%epoch:}%{version}-%{release}
 Requires:      %{name}-runtime = %{?epoch:%epoch:}%{version}-%{release}
7f9d2e12
 Requires:      (coreutils or toybox)
b0c195c6
 Requires:      nss
 Requires:      unzip
 Requires:      gzip
 
 %description server
 SystemTap server is the server component of an instrumentation system for systems running Linux.
 
 
 %prep
 %setup -q
d3cc2624
 sed -i "s#"kernel"#"linux"#g" stap-prep
 sed -i "s#"devel"#"dev"#g" stap-prep
b0c195c6
 
 %build
 %configure \
 %if %with_crash
 	--enable-crash \
 %else
 	--disable-crash \
 %endif
 	--disable-docs \
 %if %with_sqlite
 	--enable-sqlite \
 %else
 	--disable-sqlite \
 %endif
 %if %with_rpm
 	--with-rpm \
 %else
 	--without-rpm \
 %endif
 %if %with_pie
 	--enable-pie \
 %else
 	--disable-pie \
 %endif
 	--disable-grapher \
         --disable-virt \
 	--disable-silent-rules
 
 make
 
 %install
 [ "%{buildroot}" != / ] && rm -rf ""
 %makeinstall
 
31204a78
 mv %{buildroot}%{_datadir}/systemtap/examples examples
b0c195c6
 
 find examples -type f -name '*.stp' -print0 | xargs -0 sed -i -r -e '1s@^#!.+stap@#!%{_bindir}/stap@'
 
 chmod 755 %{buildroot}%{_bindir}/staprun
 
 install -c -m 755 stap-prep %{buildroot}%{_bindir}/stap-prep
 
 
 mkdir -p %{buildroot}%{_sysconfdir}//rc.d/init.d/
 install -m 755 initscript/systemtap %{buildroot}%{_sysconfdir}/rc.d/init.d/
 mkdir -p %{buildroot}%{_sysconfdir}/systemtap
 mkdir -p %{buildroot}%{_sysconfdir}/systemtap/conf.d
 mkdir -p %{buildroot}%{_sysconfdir}/systemtap/script.d
 install -m 644 initscript/config.systemtap %{buildroot}%{_sysconfdir}/systemtap/config
 mkdir -p %{buildroot}%{_localstatedir}/cache/systemtap
 mkdir -p %{buildroot}%{_localstatedir}/run/systemtap
 
 %if %with_docs
 mkdir docs.installed
31204a78
 mv %{buildroot}%{_datadir}/systemtap/*.pdf docs.installed/
 mv %{buildroot}%{_datadir}/systemtap/tapsets docs.installed/
b0c195c6
 %if %with_publican
31204a78
 mv %{buildroot}%{_datadir}/systemtap/SystemTap_Beginners_Guide docs.installed/
b0c195c6
 %endif
 %endif
 
 install -m 755 initscript/stap-server %{buildroot}%{_sysconfdir}/rc.d/init.d/
 mkdir -p %{buildroot}%{_sysconfdir}/stap-server
 mkdir -p %{buildroot}%{_sysconfdir}/stap-server/conf.d
 mkdir -p %{buildroot}%{_sysconfdir}/sysconfig
 install -m 644 initscript/config.stap-server %{buildroot}%{_sysconfdir}/sysconfig/stap-server
 mkdir -p %{buildroot}%{_localstatedir}/log/stap-server
 touch %{buildroot}%{_localstatedir}/log/stap-server/log
 mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d
 install -m 644 initscript/logrotate.stap-server %{buildroot}%{_sysconfdir}/logrotate.d/stap-server
 
 %find_lang %{name}
 
85c433d7
 %check
 make %{?_smp_mflags} check
 
b0c195c6
 %clean
 [ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
 
 %pre
 getent group stap-server >/dev/null || groupadd -g 155 -r stap-server || groupadd -r stap-server
 
 %pre runtime
 getent group stapdev >/dev/null || groupadd -r stapdev
 getent group stapusr >/dev/null || groupadd -r stapusr
 exit 0
 
 %pre server
 getent passwd stap-server >/dev/null || \
 /usr/sbin/useradd -c "Systemtap Compile Server" -u 155 -g stap-server -d %{_localstatedir}/lib/stap-server -m -r -s /sbin/nologin stap-server || \
 /usr/sbin/useradd -c "Systemtap Compile Server" -g stap-server -d %{_localstatedir}/lib/stap-server -m -r -s /sbin/nologin stap-server
 test -e ~stap-server && chmod 755 ~stap-server
 exit 0
 
 %post server
04e27de8
 if [ $1 -eq 1 ] ; then
   test -e %{_localstatedir}/log/stap-server/log || {
   touch %{_localstatedir}/log/stap-server/log
   chmod 664 %{_localstatedir}/log/stap-server/log
   chown stap-server:stap-server %{_localstatedir}/log/stap-server/log
   }
 
   if test ! -e ~stap-server/.systemtap/ssl/server/stap.cert; then
b0c195c6
 	runuser -s /bin/sh - stap-server -c %{_libexecdir}/%{name}/stap-gen-cert >/dev/null
 
 	%{_bindir}/stap-authorize-server-cert ~stap-server/.systemtap/ssl/server/stap.cert
 	%{_bindir}/stap-authorize-signing-cert ~stap-server/.systemtap/ssl/server/stap.cert
04e27de8
   fi
   /sbin/chkconfig --add stap-server
   exit 0
b0c195c6
 fi
 
 %preun server
 if [ $1 = 0 ] ; then
 	/sbin/service stap-server stop >/dev/null 2>&1
 	/sbin/chkconfig --del stap-server
 fi
 exit 0
 
 %postun server
 if [ "$1" -ge "1" ] ; then
 	/sbin/service stap-server condrestart >/dev/null 2>&1 || :
 fi
 exit 0
 
 %post initscript
04e27de8
 if [ $1 -eq 1 ] ; then
 	/sbin/chkconfig --add systemtap
 	exit 0
 fi
b0c195c6
 
 %preun initscript
 if [ $1 = 0 ] ; then
 	/sbin/service systemtap stop >/dev/null 2>&1
 	/sbin/chkconfig --del systemtap
 fi
 exit 0
 
 %postun initscript
 if [ "$1" -ge "1" ] ; then
 	/sbin/service systemtap condrestart >/dev/null 2>&1 || :
 fi
 exit 0
 
 %post
04e27de8
 if [ $1 -eq 1 ] ; then
 	(make -C %{_datadir}/systemtap/runtime/linux/uprobes clean) >/dev/null 3>&1 || true
 	(/sbin/rmmod uprobes) >/dev/null 2>&1 || true
 fi
b0c195c6
 
 %preun
04e27de8
 if [ $1 -eq 0 ] ; then
 	(make -C %{_datadir}/systemtap/runtime/linux/uprobes clean) >/dev/null 3>&1 || true
 	(/sbin/rmmod uprobes) >/dev/null 2>&1 || true
 fi
b0c195c6
 
 %files -f %{name}.lang
 %defattr(-,root,root)
 %{_bindir}/stap
 %{_bindir}/stap-merge
 %{_bindir}/stap-prep
 %{_bindir}/stap-report
 %{_bindir}/stapsh
 %dir %{_datadir}/systemtap
 %dir %{_datadir}/systemtap/runtime
 %{_datadir}/systemtap/runtime/*.h
 %{_datadir}/systemtap/runtime/*.c
 %{_datadir}/systemtap/runtime/transport
 %{_datadir}/systemtap/runtime/unwind
 %dir %{_datadir}/systemtap/runtime/linux
 %{_datadir}/systemtap/runtime/linux/*.c
 %{_datadir}/systemtap/runtime/linux/*.h
 %dir %attr(0775,root,stap-server) %{_datadir}/systemtap/runtime/linux/uprobes
 %{_datadir}/systemtap/runtime/linux/uprobes/*
 %dir %{_datadir}/systemtap/runtime/linux/uprobes2
 %{_datadir}/systemtap/runtime/linux/uprobes2/*
 %{_datadir}/systemtap/tapset
74b63bd5
 %{_mandir}/man1
b0c195c6
 %{_mandir}/man3/stap*.3stap*
 %{_mandir}/man7/warning::symbols.7stap*
 %{_mandir}/man7/stappaths.7*
 %{_mandir}/man8/stapsh.8*
 %{_mandir}/man8/systemtap.8*
 %doc AUTHORS COPYING
68082a46
 %{_bindir}/dtrace
b0c195c6
 
 %files initscript
 %defattr(-,root,root)
 %{_sysconfdir}/rc.d/init.d/systemtap
 %dir %{_sysconfdir}/systemtap
 %dir %{_sysconfdir}/systemtap/conf.d
 %dir %{_sysconfdir}/systemtap/script.d
 %config(noreplace) %{_sysconfdir}/systemtap/config
 %dir %{_localstatedir}/cache/systemtap
 %dir %{_localstatedir}/run/systemtap
 
31204a78
 %files python
 %defattr(-,root,root)
 /usr/lib/python2.7/site-packages/*
 /usr/libexec/systemtap/python/stap-resolve-module-function.py
 
b0c195c6
 %files runtime
 %defattr(-,root,root)
 %attr(4111,root,root) %{_bindir}/staprun
 %{_libexecdir}/systemtap/stapio
 %{_libexecdir}/systemtap/stap-env
 %{_libexecdir}/systemtap/stap-authorize-cert
 %if %with_crash
 %{_libdir}/systemtap/staplog.so*
 %endif
 %{_mandir}/man8/staprun.8*
 
 %files sdt-devel
 %defattr(-,root,root)
 %{_includedir}/sys/sdt.h
 %{_includedir}/sys/sdt-config.h
 %doc NEWS examples
 
 %files server
 %defattr(-,root,root)
 %{_bindir}/stap-server
 %{_libexecdir}/systemtap/stap-serverd
 %{_libexecdir}/systemtap/stap-start-server
 %{_libexecdir}/systemtap/stap-stop-server
 %{_libexecdir}/systemtap/stap-gen-cert
 %{_libexecdir}/systemtap/stap-sign-module
 %{_sysconfdir}/rc.d/init.d/stap-server
 %config(noreplace) %{_sysconfdir}/logrotate.d/stap-server
 %dir %{_sysconfdir}/stap-server
 %dir %{_sysconfdir}/stap-server/conf.d
 %config(noreplace) %{_sysconfdir}/sysconfig/stap-server
 %dir %attr(0755,stap-server,stap-server) %{_localstatedir}/log/stap-server
 %ghost %config %attr(0644,stap-server,stap-server) %{_localstatedir}/log/stap-server/log
 %{_mandir}/man7/error::*.7stap*
 %{_mandir}/man7/warning::debuginfo.7stap*
 %{_mandir}/man8/stap-server.8*
 
 %changelog
7f9d2e12
 *   Mon Sep 18 2017 Alexey Makhalov <amakhalov@vmware.com> 3.1-4
 -   Remove shadow from requires and use explicit tools for post actions
 *   Mon Sep 18 2017 Alexey Makhalov <amakhalov@vmware.com> 3.1-3
 -   Requires coreutils or toybox
16e76bee
 *   Thu Aug 10 2017 Alexey Makhalov <amakhalov@vmware.com> 3.1-2
 -   systemtap-sdt-devel requires systemtap
31204a78
 *   Tue Apr 11 2017 Vinay Kulkarni <kulkarniv@vmware.com> 3.1-1
 -   Update to version 3.1
52d2668a
 *   Mon Nov 21 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 3.0-4
 -   add shadow to requires
 *   Wed Nov 16 2016 Alexey Makhalov <amakhalov@vmware.com> 3.0-3
fb300e7c
 -   Use sqlite-{devel,libs}
31204a78
 *   Tue Oct 04 2016 ChangLee <changlee@vmware.com> 3.0-2
fb300e7c
 -   Modified %check
 *   Fri Jul 22 2016 Divya Thaluru <dthaluru@vmware.com> 3.0-1 
 -   Updated version to 3.0
 -   Removing patch to enable kernel (fix is present in upstream)
 *   Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 2.9-5
 -   GA - Bump release of all rpms
 *   Mon May 23 2016 Harish Udaiya KUmar <hudaiyakumar@vmware.com> 2.9-4
 -   Added the patch to enable kernel building with Kernel 4.4
 *   Fri May 20 2016 Harish Udaiya Kumar <hudaiyakumar@vmware.com> 2.9-3 
 -   Fixed the stap-prep script to be compatible with Photon
 *   Wed May 4 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 2.9-2
 -   Fix for upgrade issues
 *   Wed Dec 16 2015 Harish Udaiya Kumar <hudaiyakumar@vmware.com> 2.9-1 
 -   Updated version to 2.9
 *   Fri Dec 11 2015 Xiaolin Li <xiaolinl@vmware.com> 2.7-2
 -   Move dtrace to the main package.
 *   Wed Nov 18 2015 Anish Swaminathan <anishs@vmware.com> 2.7-1
 -   Initial build. First version