File gns3.spec of Package gns3

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

%if %{defined fedora}

# get python version
%global py_ver %(if [ -f "%{__python}" ]; then %{__python} -c "import sys; sys.stdout.write(sys.version[:3])"; else echo 0; fi;)

%endif

Name:           gns3
Summary:        A graphical network simulator
License:        GPL-2.0
Group:          Productivity/Networking/Other
Version:        0.8.7
Release:        0
Url:            http://www.gns3.net/
Source0:        GNS3-%{version}-src.tar.gz
Source1:        %{name}.png
Source2:        http://kent.dl.sourceforge.net/sourceforge/gns-3/GNS3-0.5-tutorial.pdf
Source3:        %{name}.xml
Source4:        %{name}.desktop
Source5:        application-x-%{name}.png
BuildRequires:  desktop-file-utils
BuildRequires:  dos2unix
BuildRequires:  hicolor-icon-theme
BuildRequires:  libosip2-devel
BuildRequires:  libqt4-devel
BuildRequires:  python-devel
BuildRequires:  python-qt4
BuildRequires:  python-sip
%if %{undefined fedora}
BuildRequires:  update-desktop-files
BuildRequires:	fdupes
Recommends:     wireshark
Recommends:     qemu
Recommends:     vde2
Recommends:     xdotool
Recommends:     vpcs
%{py_requires}
%endif
Requires:       python-qt4
Requires:       python-sip
Requires:       dynamips
%if !0%{?sles_version}
BuildArch:      noarch
%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
GNS3 is a excellent complementary tool to real labs for administrators
of Cisco networks or people wanting to pass their CCNA,
CCNP, CCIP or CCIE certifications.

It can also be used to experiment features of Cisco IOS or to check configurations
that need to be deployed later on real routers.

Important notice: users must provide their own Cisco IOS to use GNS3.

%prep
%setup -q -n gns3-legacy-GNS3-%{version}

%build
%__cp %SOURCE2 .
%{__python} setup.py build

%install
%{__python} setup.py install --root=%{buildroot} --prefix=%{_prefix}
%__mkdir_p %buildroot/%_datadir/%{name}
%__mkdir_p %buildroot/%_datadir/%{name}/examples
%__rm qemuwrapper/*.bat
%__cp -R qemuwrapper %buildroot/%_datadir/%{name}/
%__mkdir_p %buildroot/%_datadir/icons/hicolor/48x48/mimetypes/
%__mkdir_p %buildroot/%_datadir/mime/packages/
%__mkdir_p %buildroot/%_datadir/applications/
%__mkdir_p %buildroot/%_datadir/pixmaps
%__mkdir_p %buildroot/%_mandir/man1/
%__mkdir_p %buildroot/%_libexecdir/%name
%__mv qemuwrapper/qemuwrapper.py %buildroot/%_libexecdir/%{name}/qemuwrapper.py
%__mv vboxwrapper/vboxcontroller_4_1.py %buildroot/%_libexecdir/%{name}/vboxcontroller_4_1.py
%__mv vboxwrapper/vboxwrapper.py %buildroot/%_libexecdir/%{name}/vboxwrapper.py
%__mv %buildroot/usr/local/share/examples/gns3/baseconfig.txt %buildroot/%_datadir/%{name}/examples/
%__mv %buildroot/usr/local/share/examples/gns3/baseconfig_sw.txt %buildroot/%_datadir/%{name}/examples/
%__cp %SOURCE1 %buildroot/%_datadir/pixmaps
%__cp %SOURCE3 %buildroot/%_datadir/mime/packages/%{name}.xml
%__cp %SOURCE4 %buildroot/%_datadir/applications/
%__cp %SOURCE5 %buildroot/%_datadir/icons/hicolor/48x48/mimetypes/application-x-%{name}.png
%__cp docs/man/gns3.1 %buildroot/%_mandir/man1/
%if %{undefined fedora}
%suse_update_desktop_file %{name}
%fdupes %{buildroot}/%{python_sitelib}
%endif
%__rm -rf %buildroot/usr/local/share/*
chmod -x CHANGELOG README TODO AUTHORS
chmod -x %buildroot/%{_mandir}/man1/*
chmod -x %buildroot/%_datadir/%{name}/examples/*
dos2unix README

#make rpmlint happy
chmod +x %{buildroot}/%{_datadir}/%{name}/qemuwrapper/qemuwrapper.py
chmod +x %{buildroot}/%{_libexecdir}/%{name}/vboxcontroller_4_1.py
chmod +x %{buildroot}/%{_datadir}/%{name}/vboxcontroller_4_1.py
chmod +x %{buildroot}/%{python_sitelib}/GNS3/Dynagen/portTracker_lib.py
chmod +x %{buildroot}/%{_datadir}/%{name}/qemuwrapper/make-qemuwrapper-exe.py
chmod +x %{buildroot}/%{python_sitelib}/GNS3/Export/ExportPDF.py
chmod +x %{buildroot}/%{python_sitelib}/GNS3/Dynagen/dynamips_lib.py
chmod +x %{buildroot}/%{python_sitelib}/GNS3/Dynagen/console.py
chmod +x %{buildroot}/%{python_sitelib}/GNS3/Dynagen/dynagen.py
chmod +x %{buildroot}/%{_libexecdir}/%{name}/vboxwrapper.py
chmod +x %{buildroot}/%{_datadir}/%{name}/vboxwrapper.py
chmod +x %{buildroot}/%{python_sitelib}/GNS3/Dynagen/qemu_lib.py
chmod +x %{buildroot}/%{python_sitelib}/GNS3/Dynagen/dynagen_vbox_lib.py
chmod +x %{buildroot}/%{_datadir}/%{name}/tcp_pipe_proxy.py
chmod +x %{buildroot}/%{_libexecdir}/%{name}/qemuwrapper.py
chmod +x %{buildroot}/%{_datadir}/%{name}/qemuwrapper.py
chmod +x %{buildroot}/%{python_sitelib}/GNS3/Dynagen/confConsole.py

%post
/usr/bin/update-mime-database %{_datadir}/mime &> /dev/null || :
/usr/bin/update-desktop-database                                

%postun
/usr/bin/update-mime-database %{_datadir}/mime &> /dev/null || :
/usr/bin/update-desktop-database 

%files
%defattr(-, root, root, 0755)
%doc CHANGELOG README TODO AUTHORS GNS3-0.5-tutorial.pdf
%{_bindir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/pixmaps/%{name}.png
%{_datadir}/%{name}
%{_datadir}/icons/hicolor/48x48/mimetypes/application-x-%{name}.png
%{_datadir}/mime/packages/%{name}.xml
%{_mandir}/man1/*
%dir %_libexecdir/%{name}
%_libexecdir/%{name}/*
%dir %{python_sitelib}/GNS3
%{python_sitelib}/GNS3/*
%{python_sitelib}/GNS3-%{version}-py%{py_ver}.egg-info

%changelog
openSUSE Build Service is sponsored by