File mtr.spec of Package mtr

#
# spec file for package mtr
#
# Copyright (c) 2012 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/
#


Name:           mtr
BuildRequires:  automake
BuildRequires:  gtk2-devel
BuildRequires:  ncurses-devel
BuildRequires:  update-desktop-files
BuildRequires:  xorg-x11-devel
Summary:        Ping and Traceroute Network Diagnostic Tool
License:        GPL-2.0
Group:          Productivity/Networking/Diagnostic
Version:        0.82
Release:        0
Url:            http://www.BitWizard.nl/mtr
Source:         %{name}-%{version}.tar.bz2
Source1:        xmtr.desktop
Patch1:         mtr-0.75-manmtr.patch
Patch2:         mtr-0.75-manxmtr.patch
Patch3:         mtr-0.75-nonvoid.patch
Patch4:         mtr-0.75-sec_snprintf.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Icon:           mtr.gif
PreReq:         permissions

%description
Mtr is a network diagnostic tool that combines Ping and Traceroute into
one program. This package contains the mtr version with an ncurses
interface, in other words, the text mode version is usable in a shell
(telnet or SSH session, for example).

Find the graphical version in the mtr-gtk package.

%package gtk
Summary:        Ping and Traceroute Network Diagnostic Tool
Group:          Productivity/Networking/Diagnostic

%description gtk
Mtr is a network diagnostic tool which combines Ping and Traceroute
into one program. This package contains mtr with a GTK interface.
You'll find the text mode version in the mtr package.

%define _xorg7libs %_lib
%define _xorg7libs32 lib
%define _xorg7bin bin
%define _xorg7mandir %_mandir
%define _xorg7pixmaps include
%define _xorg7libshare share
%define _xorg7xkb /usr/share/X11/xkb
%define _xorg7termcap /usr/lib/X11/etc
%define _xorg7include /usr/include/xorg
%define _xorg7fonts /usr/share/fonts
%define _xorg7prefix /usr

%prep
%setup -q 
cp mtr.8 xmtr.8
%patch1
%patch2
%patch3
%patch4

%build
aclocal -I /usr/share/aclocal
autoconf
automake --foreign -a
#
# GTK version
CFLAGS="$RPM_OPT_FLAGS" ./configure \
	--enable-gtk2 \
	--prefix=%{_xorg7prefix}
make && mv mtr xmtr  
make distclean
#
# console version
export CFLAGS="$RPM_OPT_FLAGS -fpie -fPIE" 
export LDFLAGS="-pie -Wl,-z,relro,-z,now"
./configure \
	--prefix=/usr \
	--mandir=%{_mandir} \
	--without-gtk
make %{?jobs:-j%jobs}

%install
mkdir -p $RPM_BUILD_ROOT/usr/sbin
mkdir -p $RPM_BUILD_ROOT/usr/%{_xorg7bin}
mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man8
make DESTDIR=$RPM_BUILD_ROOT install
install -m 4755 xmtr $RPM_BUILD_ROOT/usr/%{_xorg7bin}
install -m 644 xmtr.8 $RPM_BUILD_ROOT/%{_mandir}/man8
install -d -m 755 $RPM_BUILD_ROOT/usr/%{_xorg7pixmaps}/X11/pixmaps/
install -m 644 img/mtr_icon.xpm $RPM_BUILD_ROOT/usr/%{_xorg7pixmaps}/X11/pixmaps/xmtr_icon.xpm
install -d -m 755 $RPM_BUILD_ROOT/usr/share/pixmaps/
install -m 644 img/mtr_icon.xpm $RPM_BUILD_ROOT/usr/share/pixmaps/xmtr_icon.xpm
%suse_update_desktop_file -i xmtr Network Monitor

%clean
rm -rf  %{buildroot}

%files
%defattr(-,root,root)
%doc AUTHORS COPYING FORMATS NEWS README SECURITY TODO
%doc %{_mandir}/man8/mtr.8*
%verify(not mode) %attr(755,root,dialout) /usr/sbin/mtr

%files gtk
%defattr(-,root,root)
%doc AUTHORS COPYING FORMATS NEWS README SECURITY TODO
%doc %{_mandir}/man8/xmtr.8*
%attr(755,root,root) /usr/%{_xorg7bin}/xmtr
/usr/%{_xorg7pixmaps}/X11/pixmaps
/usr/share/applications/*
/usr/share/pixmaps/*

%post
%if 0%{?suse_version} <= 1130
%run_permissions
%else
%set_permissions /usr/sbin/mtr
%endif
%verifyscript
%verify_permissions -e /usr/sbin/mtr

%changelog
openSUSE Build Service is sponsored by