File ocsinventory-agent.spec of Package ocsinventory-agent

# Can, optionaly, be define at build time (see README.RPM)
# - ocstag    : administrative tag
# - ocsserver : OCS Inventory NG communication serveur

Name:      ocsinventory-agent
Summary:   Open Computer and Software Inventory Next Generation client

Version:   2.0
Release:   2%{?dist}%{?ocstag:.%{ocstag}}

Source0:   http://launchpad.net/ocsinventory-unix-agent/stable-2.0/2.0/+download/Ocsinventory-Agent-2.0.tar.bz2

Source1:   %{name}.logrotate
Source2:   %{name}.cron

Source11:   %{name}.README
Source12:   %{name}.README.fr

Group:     Productivity/Networking/Other
License:   GPLv2+
URL:       http://www.ocsinventory-ng.org/

# BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

%if "%{_vendor}" == "suse"
BuildRequires: perl(ExtUtils::MakeMaker)
Requires:  nmap
Requires:  perl-Crypt-SSLeay
Requires:  perl-Net-SSLeay
Requires:  perl-Proc-Daemon
Requires:  nmap
Requires:  perl(Net::IP)

%else
BuildRequires: perl-ExtUtils-MakeMaker
Requires:  nmap
Requires:  monitor-edid
Requires:  perl(Net::SSLeay) perl(Crypt::SSLeay) perl(Net::IP)
Requires:  perl(Proc::Daemon)
%endif

BuildRequires: perl(XML::Simple) perl(LWP) perl(Net::IP)
BuildRequires: perl(Digest::MD5) perl(File::Temp)
BuildRequires: gcc

Requires:  net-tools, pciutils, dmidecode, ipmitool
Requires:  %{_sysconfdir}/logrotate.d, %{_sysconfdir}/cron.hourly
Requires:  perl(HTTP::Request)
Requires:  smartmontools
Obsoletes: ocsinventory-client <= 1.02
Provides:  ocsinventory-client  = 2.0

%if "%{_vendor}" == "suse"
%define perl_vendorlib  %(eval "`%{__perl} -V:installvendorlib`"; echo $installvendorlib)
%else
%define perl_vendorlib  /usr/share/perl5/vendor_perl
%endif
%if 0%{?fedora} == 14
%define perl_vendorlib  /usr/share/perl5
%endif


%description
Open Computer and Software Inventory Next Generation is an application
designed to help a network or system administrator keep track of computer
configuration and software installed on the network. 

It also allows deploying softwares, commands or files on Windows and 
Linux client computers.

%{name} provides the client for Linux (Unified Unix Agent).


%description -l fr
Open Computer and Software Inventory Next Generation est une application
destinée à aider l'administrateur système ou réseau à garder un oeil sur
la configuration des machines du réseau et sur les logiciels qui y sont
installés. 

Elle autorise aussi la télédiffusion (ou déploiement) de logiciels, 
de commandes ou de fichiers sur les clients Windows ou Linux.

%{name} fournit le client pour Linux (Agent Unix Unifié)


%prep
%setup -q -n Ocsinventory-Agent-%{version}

chmod -x lib/Ocsinventory/Agent/Backend/OS/MacOS/Hostname.pm

cat <<EOF >%{name}.conf
# 
# OCS Inventory "Unix Unified Agent" Configuration File
# used by hourly cron job
#

# Add tools directory if needed (tw_cli, hpacucli, ipssend, ...)
PATH=/sbin:/bin:/usr/sbin:/usr/bin

%if 0%{?ocsserver:1}
# Mode, change to "none" to disable
OCSMODE[0]=cron

%else
# Mode, change to "cron" to activate
OCSMODE[0]=none

%endif

# can be used to override the %{name}.cfg setup.
# OCSSERVER[0]=your.ocsserver.name
# 
# corresponds with --local=%{_localstatedir}/lib/%{name}
# OCSSERVER[0]=local

# Wait before inventory 
OCSPAUSE[0]=100

# Administrative TAG (optional, must be filed before first inventory)
OCSTAG[0]=%{?ocstag}
EOF

cat <<EOF >%{name}.cfg
# 
# OCS Inventory "Unix Unified Agent" Configuration File
#
# options used by cron job overides this (see /etc/sysconfig/%{name})
#

%if 0%{?ocsserver:1}
server = http://%{ocsserver}/ocsinventory
%else
# Server URL, unconmment if needed
# server = your.ocsserver.name
local = %{_localstatedir}/lib/%{name}
%endif

# Administrative TAG (optional, must be filed before first inventory)
# tag = your_tag

# How to log, can be File,Stderr,Syslog
logger = Stderr
logfile = %{_localstatedir}/log/%{name}/%{name}.log
EOF

cp %{SOURCE11} README.RPM
cp %{SOURCE12} README.RPM.fr


%build
%{__perl} Makefile.PL INSTALLDIRS=vendor
cd resources/ipdiscover; gcc -o ipdiscover ipdiscover.c
cd ../..
make %{?_smp_mflags}


%install
rm -rf %{buildroot}

make pure_install PERL_INSTALL_ROOT=%{buildroot}
find %{buildroot} -type f -name .packlist -exec rm -f {} ';'
find %{buildroot} -type d -depth -exec rmdir {} 2>/dev/null ';'

chmod -R u+rwX,go+rX,go-w %{buildroot}/*

# Move exe to root directory
mv %{buildroot}%{_bindir} %{buildroot}%{_sbindir}

%{__mkdir_p} %{buildroot}%{_localstatedir}/{log,lib}/%{name}

%{__install} -m 750 resources/ipdiscover/ipdiscover %{buildroot}%{_sbindir}

%if "%{_vendor}" == "suse"
%{__mkdir_p} %{buildroot}%{_sysconfdir}/{logrotate.d,cron.hourly,ocsinventory}
%{__mkdir_p} %{buildroot}/var/adm/fillup-templates
%{__install} -m 644 %{name}.conf %{buildroot}/var/adm/fillup-templates/sysconfig-%{name}
%else
%{__mkdir_p} %{buildroot}%{_sysconfdir}/{logrotate.d,sysconfig,cron.hourly,ocsinventory}
%{__install} -m 644 %{name}.conf %{buildroot}%{_sysconfdir}/sysconfig/%{name}
%endif
%{__install} -pm 644 %{SOURCE1}   %{buildroot}%{_sysconfdir}/logrotate.d/%{name}

sed -e 's;/etc/;%{_sysconfdir}/;' \
    -e 's;/var/;%{_localstatedir}/;' \
    -e 's;/usr/sbin/;%{_sbindir}/;' \
    %{SOURCE2} > %{buildroot}%{_sysconfdir}/cron.hourly/%{name}
chmod +x %{buildroot}%{_sysconfdir}/cron.hourly/%{name}

%{__install} -m 644 %{name}.cfg %{buildroot}%{_sysconfdir}/ocsinventory/%{name}.cfg
%{__install} -m 644 etc/ocsinventory-agent/modules.conf %{buildroot}%{_sysconfdir}/ocsinventory/modules.conf

# Remove some unusefull files (which brings unresolvable deps)
rm -rf %{buildroot}%{perl_vendorlib}/Ocsinventory/Agent/Backend/OS/Win32*

%{__mkdir_p} %{buildroot}%{_defaultdocdir}/%{name}-%{version}/examples
%{__install} -m 644 AUTHORS Changes LICENSE README README.RPM.fr THANKS README.RPM %{buildroot}%{_defaultdocdir}/%{name}-%{version}/

# Only need for manual installation
mv %{buildroot}%{perl_vendorlib}/Ocsinventory/postinst.pl %{buildroot}%{_defaultdocdir}/%{name}-%{version}/examples



%clean
rm -rf %{buildroot}


%files
%defattr(-, root, root, -)
%{_defaultdocdir}/%{name}-%{version}
# %doc AUTHORS Changes LICENSE README THANKS README.RPM
# %lang(fr) %doc README.RPM.fr
%{perl_vendorlib}/Ocsinventory
%{_sbindir}/%{name}
%{_sbindir}/ipdiscover
%dir %{_localstatedir}/log/%{name}
%dir %{_localstatedir}/lib/%{name}
%dir %{_sysconfdir}/ocsinventory
%if "%{_vendor}" == "suse"
%config(noreplace) /var/adm/fillup-templates/sysconfig-%{name}
%else
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%endif
%config(noreplace) %{_sysconfdir}/ocsinventory/%{name}.cfg
%config(noreplace) %{_sysconfdir}/ocsinventory/modules.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%{_sysconfdir}/cron.hourly/%{name}
%{_mandir}/man1/%{name}*
%{_mandir}/man3/Ocs*



%changelog
* Thu Jun 28 2011 Sebastian Hetze <she@lunetix.de> - 2.0-2
- update to new upstream version 2.0

* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.1.2.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Wed Oct 13 2010 Remi Collet <Fedora@famillecollet.com> 1.1.2.1-1
- security update for CVE-2009-0667
  http://bugs.debian.org/590879
  http://www.debian.org/security/2009/dsa-1828
openSUSE Build Service is sponsored by