File Printrun.spec of Package Printrun

#
# spec file for package printrun
#
# Copyright (c) 2017 SUSE LINUX 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:           Printrun
Version:        20170720~pre.1494969671.f54b6f9
Release:        0
Summary:        RepRap printer interface and tools
License:        GPL-3.0+
Group:          Productivity/Graphics/Convertors
Url:            https://github.com/kliment/Printrun
Source0:        Printrun-%{version}.tar.xz

# Desktop files
Source1:        pronsole.desktop
Source2:        pronterface.desktop
Source3:        plater.desktop

Patch0:         %{name}-pyglet12.patch

BuildRequires:  python-Cython
BuildRequires:  python-devel
BuildRequires:  python-pyserial
%if 0%{?suse_version}
BuildRequires:  fdupes
BuildRequires:  update-desktop-files
#BuildConflicts: post-build-checks
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%endif

%if 0%{?fedora_version}
BuildRequires:  desktop-file-utils
%endif

BuildRequires:  gettext
Requires:       plater = %{version}-%{release}
Requires:       pronsole = %{version}-%{release}
Requires:       pronterface = %{version}-%{release}

%description
Printrun is a set of G-code sending applications for RepRap.
It consists of printcore (dumb G-code sender), pronsole (featured command line
G-code sender), pronterface (featured G-code sender with graphical user
interface), and a small collection of helpful scripts. Together with skeinforge
they form a pretty powerful softwarecombo. This package installs whole Printrun.

###############################################

%package        common
Summary:        Common files for Printrun
Group:          Productivity/Graphics/Convertors
Requires:       python-numpy
Requires:       python-pyglet
Requires:       python-pyserial

%description    common
Printrun is a set of G-code sending applications for RepRap.
This package contains common files.

###############################################

%package     -n pronsole
Summary:        CLI interface for RepRap
Group:          Productivity/Graphics/Convertors
Requires:       %{name}-common = %{version}-%{release}

%description -n pronsole
Pronsole is a featured command line G-code sender.
It controls the ReRap printer and integrates skeinforge.
It is a part of Printrun.

###############################################

%package     -n pronterface
Summary:        GUI interface for RepRap
Group:          Productivity/Graphics/Convertors
Requires:       pronsole = %{version}-%{release}
Requires:       wxPython

%description -n pronterface
Pronterface is a featured G-code sender with graphical user interface.
It controls the ReRap printer and integrates skeinforge.
It is a part of Printrun.

###############################################

%package     -n plater
Summary:        RepRap STL plater
Group:          Productivity/Graphics/Convertors
Requires:       %{name}-common = %{version}-%{release}
Requires:       wxPython

%description -n plater
Plater is a GUI tool to prepare printing plate from STL files for ReRap.
It is a part of Printrun.

###############################################


%prep
%setup -q
#%patch0 -p1

# use launchers for skeinforge
sed -i 's|python skeinforge/skeinforge_application/skeinforge.py|skeinforge|' pronsole.py
sed -i 's|python skeinforge/skeinforge_application/skeinforge_utilities/skeinforge_craft.py|skeinforge-craft|' pronsole.py

%build
CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build

# rebuild locales
cd locale
for FILE in *
  do msgfmt $FILE/LC_MESSAGES/plater.po -o $FILE/LC_MESSAGES/plater.mo || echo plater not there
     msgfmt $FILE/LC_MESSAGES/pronterface.po -o $FILE/LC_MESSAGES/pronterface.mo || echo pronterface not there
done
cd ..

%install
DESTDIR=%{buildroot}
# python => 2.5 expects this to exist (it will exist if the package
# installs something there, but we don't) otherwise fails for SLE_11
mkdir -p %{buildroot}/%{python_sitelib}
install -dpm 0755 %buildroot/{%_bindir,%_datadir/pixmaps,%_datadir/applications,%_datadir/%progname,%_defaultdocdir/progname}

%{__python} setup.py install --skip-build --prefix %{buildroot}%{_prefix}

test -d "%{buildroot}%{python_sitelib}" && find "%{buildroot}%{python_sitelib}/" -name '*.pyc' -exec %__rm {} \;

# desktop files
# via home:dbruce > tuxmath_test > tuxmath.spec
# via openSUSE:12.2 > nagstamon > nagstamon.spec 
%if 0%{?suse_version}
mkdir -p "%buildroot/%_docdir/%name"
mkdir -p %{buildroot}%{_datadir}/applications
install -Dm644 %{SOURCE1} %{buildroot}/%{_datadir}/applications/pronsole.desktop
install -Dm644 %{SOURCE2} %{buildroot}/%{_datadir}/applications/pronterface.desktop
install -Dm644 %{SOURCE3} %{buildroot}/%{_datadir}/applications/plater.desktop

%suse_update_desktop_file -i %{buildroot}/%{_datadir}/applications/pronsole.desktop
%suse_update_desktop_file -i %{buildroot}/%{_datadir}/applications/pronterface.desktop
%suse_update_desktop_file -i %{buildroot}/%{_datadir}/applications/plater.desktop
#%%fdupes -s %%buildroot
%endif

%if 0%{?fedora_version}
desktop-file-install --dir=%{buildroot}%{_datadir}/applications %{SOURCE1}
desktop-file-install --dir=%{buildroot}%{_datadir}/applications %{SOURCE2}
desktop-file-install --dir=%{buildroot}%{_datadir}/applications %{SOURCE3}
%endif

# locales
mkdir -p %{buildroot}%{_datadir}/locale
cp -ar %{buildroot}%{_datadir}/pronterface/locale/* %{buildroot}%{_datadir}/locale
rm -rf %{buildroot}%{_datadir}/pronterface/locale
ln -s -f %{_datadir}/locale/ %{buildroot}%{_datadir}/pronterface/ # the app expects the locale folder in here

# exacutables
#cd %{buildroot}%{python_sitelib}/printrun
#chmod +x gcview.py graph.py stlview.py SkeinforgeQuickEditDialog.py calibrateextruder.py webinterface.py
#cd -

%{find_lang} pronterface
%{find_lang} plater

%files
%defattr(-,root,root,0755)
#%%{python_sitelib}/*
%doc README* COPYING

%files common
%defattr(-,root,root,0755)
%{_libdir}/python*/site-packages/*
%{_bindir}/printcore.*
%doc README* COPYING

%files -n pronsole
%defattr(-,root,root,0755)
%{_bindir}/pronsole.*
#%{_bindir}/gcoder.*
%{_datadir}/pixmaps/pronsole.png
%{_datadir}/applications/pronsole.desktop
%{_datadir}/appdata/pronsole.appdata.xml
%doc README* COPYING

%files -n pronterface -f pronterface.lang
%defattr(-,root,root,0755)
%{_bindir}/pronterface.*
%{_datadir}/pronterface
%{_datadir}/pixmaps/pronterface.png
%{_datadir}/appdata/pronterface.appdata.xml
%{_datadir}/applications/pronterface.desktop
%doc README* COPYING

%files -n plater -f plater.lang
%defattr(-,root,root,0755)
%{_bindir}/plater.*
%{_datadir}/pixmaps/plater.png
%{_datadir}/applications/plater.desktop
%{_datadir}/appdata/plater.appdata.xml
%doc README* COPYING

%changelog
openSUSE Build Service is sponsored by