File net-snmp-5.4.2.1.spec of Package net-snmp-5.4.2.1-isst

#
# 5.4+ enables Perl by default
#

%define _prefix /opt/comcast/snmp
Prefix: /opt/comcast/snmp

%define netsnmp_embedded_perl 1
%define netsnmp_perl_modules 1
%define netsnmp_cflags ""

# ugly RHEL detector
# SuSE build service defines rhel_version, RHEL itself defines nothing
%if 0%{?rhel_version}
%define rhel %{?rhel_version}
%else
%define is_rhel %(grep "Red Hat Enterprise Linux" /etc/redhat-release &>/dev/null && echo 1 || echo 0)
%if %{is_rhel}
%define rhel %(sed </etc/redhat-release -e 's/.*release \\(.\\).*/\\1/'  )
%endif
%endif

# because perl(Tk) is optional, automatic dependencies will never succeed:
%define _use_internal_dependency_generator 0
%define __find_requires %{_builddir}/net-snmp/dist/find-requires
%define __find_provides /usr/lib/rpm/find-provides

#
# Check for -without embedded_perl
#
%{?_without_embedded_perl:%define netsnmp_embedded_perl 0}
#
# check for -without perl_modules
#
%{?_without_perl_modules:%define netsnmp_perl_modules 0}
#
# if embedded_perl or perl_modules specified, include some Perl stuff
#
%if 0%{?netsnmp_embedded_perl} || 0%{?netsnmp_perl_modules}
%define netsnmp_include_perl 1
%endif
Summary: Tools and servers for the SNMP protocol
Name: net-snmp
Version: 5.4.2.1
# update release for vendor release. (eg 1.fc6, 1.rh72, 1.ydl3, 1.ydl23)
Release: 1.1
URL: http://www.net-snmp.org/
License: BSDish
Group: System Environment/Daemons
Vendor: Net-SNMP project
Source0: net-snmp-5.4.2.1.tar.gz
Source1: snmpd.conf
Source2: snmptrapd.conf
Source3: snmp.conf
Source4: snmpd-isst
Source5: snmptrapd-isst

#Source: net-snmp.tar.gz
Prereq: openssl
Obsoletes: cmu-snmp ucd-snmp ucd-snmp-utils
BuildRoot: /tmp/%{name}-root
Packager: The Net-SNMP Coders <http://sourceforge.net/projects/net-snmp/>
Requires: openssl, popt, rpm, zlib, bzip2-libs, elfutils-libelf, glibc
BuildRequires: perl, elfutils-libelf-devel, openssl-devel, bzip2-devel, rpm-devel, libselinux-devel
%if %{netsnmp_embedded_perl}
BuildRequires: perl(ExtUtils::Embed)
Requires: perl
%endif

%if 0%{?fedora}%{?rhel}
# Fedora & RHEL specific requires/provides
Provides: net-snmp-libs, net-snmp-utils
Obsoletes: net-snmp-libs, net-snmp-utils
Epoch: 2

%if 0%{?fedora} >= 9
Provides: net-snmp-gui
Obsoletes: net-snmp-gui
# newer fedoras need following macro to compile with new rpm
%define netsnmp_cflags "-D_RPM_4_4_COMPAT"
%else
BuildRequires: beecrypt-devel
%endif

%endif # RHEL or Fedora

%description

Net-SNMP provides tools and libraries relating to the Simple Network
Management Protocol including: An extensible agent, An SNMP library,
tools to request or set information from SNMP agents, tools to
generate and handle SNMP traps, etc.  Using SNMP you can check the
status of a network of computers, routers, switches, servers, ... to
evaluate the state of your network.

%if %{netsnmp_embedded_perl}
This package includes embedded Perl support within the agent.
%endif

%package devel
Group: Development/Libraries
Summary: The includes and static libraries from the Net-SNMP package.
AutoReqProv: no
Requires: net-snmp = %{epoch}:%{version}
Obsoletes: cmu-snmp-devel ucd-snmp-devel

%description devel
The net-snmp-devel package contains headers and libraries which are
useful for building SNMP applications, agents, and sub-agents.

%if %{netsnmp_include_perl}
%package perlmods
Group: System Environment/Libraries
Summary: The Perl modules provided with Net-SNMP
AutoReqProv: no
Requires: net-snmp = %{epoch}:%{version}, perl

%if 0%{?fedora}%{?rhel}
Provides: net-snmp-perl
Obsoletes: net-snmp-perl
%endif

%description perlmods
Net-SNMP provides a number of Perl modules useful when using the SNMP
protocol.  Both client and agent support modules are provided.
%endif

%prep
%if %{netsnmp_embedded_perl} == 1 && %{netsnmp_perl_modules} == 0
echo "'-with embedded_perl' requires '-with perl_modules'"
exit 1
%endif
%setup -n net-snmp

%build

MIBS="host agentx smux \
         disman/event-mib disman/schedule ucd-snmp/diskio  \
         tcp-mib udp-mib agent_mibs mibII/mta_sendmail \
         ip-mib/ipv4InterfaceTable ip-mib/ipv6InterfaceTable \
         ip-mib/ipAddressPrefixTable/ipAddressPrefixTable"



%configure --with-defaults --with-sys-contact="_NETO-ISSTools_@cable.comcast.com" \
	--with-mib-modules="$MIBS" \
	--with-sysconfdir="/etc/net-snmp"               \
	--enable-shared \
        --with-default-snmp-version="2"                 \
        --enable-ucd-snmp-compatibility                 \
        --with-openssl                                  \
        --enable-static                                 \
        --enable-checking                               \
        --with-pic                                      \
        --enable-mfd-rewrites                           \
        --enable-local-smux                             \
        --enable-as-needed                              \
	%{?netsnmp_perl_modules: --with-perl-modules="INSTALLDIRS=vendor"} \
	%{!?netsnmp_perl_modules: --without-perl-modules} \
	%{?netsnmp_embedded_perl: --enable-embedded-perl} \
	%{!?netsnmp_embedded_perl: --disable-embedded-perl} \
	--with-cflags="$RPM_OPT_FLAGS %{netsnmp_cflags}"

make

%install
# ----------------------------------------------------------------------
# 'install' sets the current directory to _topdir/BUILD/{name}-{version}
# ----------------------------------------------------------------------
rm -rf $RPM_BUILD_ROOT

make DESTDIR=%{buildroot} install


# Remove 'snmpinform' from the temporary directory because it is a
# symbolic link, which cannot be handled by the rpm installation process.
%__rm -f $RPM_BUILD_ROOT%{_prefix}/bin/snmpinform
# install the init script
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d

install -d $RPM_BUILD_ROOT%{_prefix}/etc
install -m 644 %SOURCE1 $RPM_BUILD_ROOT%{_prefix}/etc/snmpd.conf
install -m 644 %SOURCE2 $RPM_BUILD_ROOT%{_prefix}/etc/snmptrapd.conf


install -d $RPM_BUILD_ROOT%{_prefix}/share/snmp
install -m 644 %SOURCE3 $RPM_BUILD_ROOT%{_prefix}/share/snmp/snmp.conf

install -d $RPM_BUILD_ROOT%{_initrddir}
install -m 755 %SOURCE4 $RPM_BUILD_ROOT%{_initrddir}/snmpd-isst
install -m 755 %SOURCE5 $RPM_BUILD_ROOT%{_initrddir}/snmptrapd-isst


%if %{netsnmp_include_perl}
# unneeded Perl stuff
find $RPM_BUILD_ROOT/%{_libdir}/perl5/ -name Bundle -type d | xargs rm -rf
find $RPM_BUILD_ROOT/%{_libdir}/perl5/ -name perllocal.pod | xargs rm -f

# store a copy of installed Perl stuff.  It's too complex to predict
(xxdir=`pwd` && cd $RPM_BUILD_ROOT && find usr/lib*/perl5 -type f | sed 's/^/\//' > $xxdir/net-snmp-perl-files)
%endif

%post

set > /tmp/rpm.vars
# ----------------------------------------------------------------------
# The 'post' script is executed just after the package is installed.
# ----------------------------------------------------------------------
# Create the symbolic link 'snmpinform' after all other files have
# been installed.
%__rm -f $RPM_INSTALL_PREFIX/bin/snmpinform
%__ln_s $RPM_INSTALL_PREFIX/bin/snmptrap $RPM_INSTALL_PREFIX/bin/snmpinform

# run ldconfig
PATH="$PATH:/sbin" ldconfig -n $RPM_INSTALL_PREFIX/lib

%preun
# ----------------------------------------------------------------------
# The 'preun' script is executed just before the package is erased.
# ----------------------------------------------------------------------
# Remove the symbolic link 'snmpinform' before anything else, in case
# it is in a directory that rpm wants to remove (at present, it isn't).
%__rm -f $RPM_INSTALL_PREFIX/bin/snmpinform

%postun
# ----------------------------------------------------------------------
# The 'postun' script is executed just after the package is erased.
# ----------------------------------------------------------------------
PATH="$PATH:/sbin" ldconfig -n $RPM_INSTALL_PREFIX/lib

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)

# Install the following documentation in _defaultdocdir/{name}-{version}/
%doc AGENT.txt ChangeLog CodingStyle COPYING
%doc EXAMPLE.conf.def FAQ INSTALL NEWS PORTING TODO
%doc README README.agentx README.hpux11 README.krb5
%doc README.snmpv3 README.solaris README.thread README.win32
%doc README.aix README.osX README.tru64 README.irix README.agent-mibs
%doc README.Panasonic_AM3X.txt
	 
#%config(noreplace) /etc/net-snmp/snmpd.conf
	 
#%{_datadir}/snmp/snmpconf-data
%{_datadir}/snmp

%{_bindir}
%{_sbindir}
%{_mandir}/man1/*
# don't include Perl man pages, which start with caps
%{_mandir}/man3/[^A-Z]*
%{_mandir}/man5/*
%{_mandir}/man8/*
%{_libdir}/*.so*
#/etc/rc.d/init.d/snmpd
%config(noreplace,missingok) /opt/comcast/snmp/etc/snmpd.conf 
%config(noreplace,missingok) /opt/comcast/snmp/etc/snmptrapd.conf 
%config(noreplace,missingok) /opt/comcast/snmp/share/snmp/snmp.conf 
%config(noreplace) %{_initrddir}/snmpd-isst
%config(noreplace) %{_initrddir}/snmptrapd-isst 

%files devel
%defattr(-,root,root)

%{_includedir}
%{_libdir}/*.a
%{_libdir}/*.la

%if %{netsnmp_include_perl}
%files -f net-snmp-perl-files perlmods
%defattr(-,root,root)
/usr/share/man/man3/*::*
/usr/share/man/man3/SNMP*
%endif

%verifyscript
echo "No additional verification is done for net-snmp"
openSUSE Build Service is sponsored by