File kicad.spec of Package kicad

#
# spec file for package kicad
#
# Copyright (c) 2016 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:           kicad
Version:        4.0.2
Release:        0
Summary:        EDA software suite for the creation of schematics and PCB
License:        GPL-2.0+ and GPL-3.0+
Group:          Productivity/Scientific/Electronics
Url:            http://kicad-pcb.org
Source:         https://launchpad.net/kicad/4.0/%{version}/+download/kicad-%{version}.tar.xz
# License file was removed due to GPL-3.0+ code
# https://github.com/KiCad/kicad-source-mirror/commit/681090b8ef3a362af75e8ca4417e18622747b63b
Source2:        COPYRIGHT.txt
# PATCH-FEATURE-OPENSUSE kicad-user-library.patch -- add user library path
Patch1:         kicad-user-library.patch
# PATCH-FEATURE-OPENSUSE kicad-library-repos-install.patch
Patch2:         kicad-library-repos-install.patch
# kicad looks in /usr/share/doc/kicad for help files and doesn't find them.
# this patch adds packges/ befor kicad.
Patch3:         kicad-suse-help-path.patch
# PATCH-FIX-UPSTREAM kicad-swig-3.0.10.patch -- Fix broken swig import script when using swig >= 3.0.10
Patch4:         kicad-swig-3.0.10.patch
%if 0%{?suse_version} > 1320
BuildRequires:  boost-devel >= 1.56
%else
BuildRequires:  boost_1_58_0-devel
%endif
BuildRequires:  cmake
BuildRequires:  doxygen
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  pkg-config
BuildRequires:  python-devel
BuildRequires:  update-desktop-files
# Use direct version to avoid problems with wx 3.2
BuildRequires:  wxWidgets-3_0-devel >= 3
# Fix bug in old python-wxWidgets-3_0-devel
BuildRequires:  python-wxWidgets-3_0 >= 3
BuildRequires:  python-wxWidgets-3_0-devel >= 3
BuildRequires:  swig
BuildRequires:  pkgconfig(bzip2)
BuildRequires:  pkgconfig(cairo)
BuildRequires:  pkgconfig(glew)
BuildRequires:  pkgconfig(openssl)
BuildRequires:  pkgconfig(zlib)
# Fix directory owner
BuildRequires:  hicolor-icon-theme
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires:       python-wxWidgets-3_0 >= 3
Recommends:     %{name}-doc
Recommends:     %{name}-library = %{version}
Recommends:     %{name}-library-install = %{version}
Obsoletes:      kicad = 20140120

%description
Kicad is an open source (GPL) software for the creation of electronic schematic
diagrams and printed circuit with up to 32 copper layers and additional techinical layers.

KiCad includes a project manager and four main independent software tools:
- Eeschema: schematic editor.
- Pcbnew: printed circuit board editor.
- Gerbview: GERBER file viewer (photoplotter documents).
- Cvpcb: footprint selector for components association.

%package        library-install
Summary:        Script for KiCad libraries downloading
Group:          Productivity/Scientific/Electronics
Requires:       %{name} = %{version}
Requires:       curl
Requires:       git-core
Requires:       sed

%description    library-install
Kicad is an open source (GPL) software for the creation of electronic schematic
diagrams and printed circuit with up to 32 copper layers and additional techinical layers.

This package contains script for KiCad libraries downloading.

%prep
%setup -q -n kicad-%{version}
%patch1 -p1
%patch2 -p1
%patch3
%patch4 -p1

cp %{SOURCE2} .

# Fix plugin directory
sed -i 's|KICAD_PLUGINS lib/kicad/plugins|KICAD_PLUGINS %{_lib}/kicad/plugins|' CMakeLists.txt
# Fix documentation directory
sed -i 's|KICAD_DOCS share/doc/kicad|KICAD_DOCS share/doc/packages/kicad|' CMakeLists.txt

%build
%cmake \
    -DKICAD_REPO_NAME=stable \
    -DKICAD_BUILD_VERSION=%{version} \
    -DKICAD_SKIP_BOOST=ON \
    -DBUILD_GITHUB_PLUGIN=ON \
    -DKICAD_SCRIPTING=ON \
    -DKICAD_SCRIPTING_MODULES=ON \
    -DKICAD_SCRIPTING_WXPYTHON=ON

make %{?_smp_mflags}

%install
%cmake_install

%suse_update_desktop_file -r bitmap2component "Education;Engineering"
%suse_update_desktop_file -r cvpcb "Education;Engineering"
%suse_update_desktop_file -r eeschema "Education;Engineering"
%suse_update_desktop_file -r gerbview "Education;Engineering"
%suse_update_desktop_file -r kicad "Education;Engineering"
%suse_update_desktop_file -r pcbcalculator "Education;Engineering"
%suse_update_desktop_file -r pcbnew "Education;Engineering"

install -D scripts/library-repos-install.sh %{buildroot}%{_bindir}/kicad-library-install.sh

%fdupes -s %{buildroot}%{_datadir}/kicad
%fdupes -s %{buildroot}%{_datadir}/icons/hicolor

%post
%desktop_database_post
%icon_theme_cache_post
%mime_database_post

%postun
%desktop_database_postun
%icon_theme_cache_postun
%mime_database_postun

%files
%defattr(-,root,root)
%doc CHANGELOG.txt COPYRIGHT.txt
%{_bindir}/*
%exclude %{_bindir}/kicad-library-install.sh
%{_libdir}/kicad/
%{_datadir}/kicad/
%{_datadir}/doc/packages/kicad/
%{python_sitelib}/*
%{_datadir}/applications/*.desktop
%{_datadir}/mime/packages/kicad.xml
%{_datadir}/mimelnk/application/x-kicad-*.desktop
%dir %{_datadir}/mimelnk/
%dir %{_datadir}/mimelnk/application/
%{_datadir}/icons/hicolor/*/mimetypes/application-x-*
%{_datadir}/icons/hicolor/*/apps/*.*

%files library-install
%defattr(-,root,root)
%{_bindir}/kicad-library-install.sh

%changelog
openSUSE Build Service is sponsored by