File librecad.spec of Package librecad

#
# spec file for package librecad
#
# 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/
#


Name:           librecad
Version:        2.0.4
Release:        0
Summary:        Computer-aided design (CAD) software package for 2D design and drafting
License:        GPL-2.0 and (Apache-2.0 or SUSE-GPL-3.0+-with-font-exception)
Group:          Productivity/Graphics/CAD
Url:            http://librecad.org/

#Git-Clone:     git://github.com/LibreCAD/LibreCAD
#Git-Web:       http://github.com/LibreCAD/LibreCAD/tags
#DL-URL:        https://github.com/LibreCAD/LibreCAD/archive/2.0.3.tar.gz
Source0:        LibreCAD-%version.tar.gz
Source1:        ttf2lff.1
Source2:        %name-rpmlintrc
Patch1:         librecad-no-date.diff
Patch2:         librecad-use-system-libdxfrw.patch
Patch3:         librecad-install.diff
Patch4:         librecad-plugindir.diff
BuildRequires:  boost-devel
BuildRequires:  fdupes
BuildRequires:  gcc-c++ >= 4.7
BuildRequires:  libdxfrw-devel
BuildRequires:  libqt4-devel
BuildRequires:  muparser-devel
BuildRequires:  update-desktop-files
BuildRequires:  wqy-microhei-fonts
Requires(post): desktop-file-utils
Requires(post): shared-mime-info
Requires(postun): desktop-file-utils
Requires(postun): shared-mime-info
Recommends:     %name-parts
# old qcad had a newer version, so we provide all versions here.
Provides:       qcad
Obsoletes:      qcad <= 2.0.5
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
LibreCAD is a Qt4 Computer-aided design (CAD) software package for 2D design
and drafting.

%package parts
Summary:        Parts collection for LibreCAD
Group:          Productivity/Graphics/CAD
Requires:       %name
BuildArch:      noarch

%description parts
Collection of parts for LibreCAD, a Qt4 application to design 2D
CAD drawings.

%prep
%setup -qn LibreCAD-%version
%patch -P 1 -P 2 -P 3 -P 4 -p1

dxfrw_includedir=$(pkg-config --cflags-only-I libdxfrw0 | sed 's|-I||g')

# Fix paths
sed -i 's|##LIBDIR##|%_libdir|g' librecad/src/lib/engine/rs_system.cpp
sed -i 's|$${DXFRW_INCLUDEDIR}|'"$dxfrw_includedir"'|g' librecad/src/src.pro

# Make sure bundled libraries are not used
rm -rf libraries/libdxfrw

%build
qmake librecad.pro CONFIG+="release" QMAKE_CFLAGS+="%optflags" QMAKE_CXXFLAGS+="%optflags"
make %{?_smp_mflags}
rm -f unix/resources/fonts/wqy-unicode.lff
mkdir -p unix/resources/fonts
./unix/ttf2lff -L "Apache-2.0 or SUSE-GPL-3.0+-with-font-exception" /usr/share/fonts/truetype/wqy-microhei.ttc unix/resources/fonts/wqy-unicode.lff

%install
b="%buildroot";
# No make install :(
export BUILDDIR="%buildroot/%_datadir/%name";
sh scripts/postprocess-unix.sh;

install -Dpm0755 "unix/%name" "$b/%_bindir/%name";
install -Dpm0755 "unix/ttf2lff" "$b/%_bindir/ttf2lff"
install -Dpm0644 "desktop/%name.1" "$b/%_mandir/man1/%name.1";
p="$b/%_libdir/%name/plugins";
mkdir -p "$p";
install -Dpm0755 unix/resources/plugins/* "$p/";
install -Dpm0644 "desktop/%name.desktop" "$b/%_datadir/applications/%name.desktop";
install -Dpm0644 "librecad/res/main/%name.png" "$b/%_datadir/pixmaps/%name.png";
install -Dpm0644 "desktop/%name.sharedmimeinfo" "$b/%_datadir/mime/packages/%name.xml"
install -Dpm0644 %SOURCE1 "$b/%_mandir/man1/ttf2lff.1"

%if 0%{?suse_version}
%suse_update_desktop_file -G "CAD Program" -r %name Graphics 2DGraphics VectorGraphics
%endif
# Fix rpmlint warning "invalid-desktopfile"
perl -pi -e "s|image/vnd.dxf|image/vnd.dxf;|" %buildroot%_datadir/applications/librecad.desktop

%fdupes -s %buildroot/%_prefix

%post
%mime_database_post
%desktop_database_post

%postun
%mime_database_postun
%desktop_database_postun

%files
%defattr(-,root,root)
%doc LICENSE* README.md gpl-2.0*
%_bindir/librecad
%_bindir/ttf2lff
%_libdir/%name
%_mandir/man1/librecad.1*
%_mandir/man1/ttf2lff.1*
%_datadir/applications/librecad.desktop
%_datadir/mime/packages/%name.xml
%_datadir/pixmaps/librecad.png
%dir %_datadir/%name
%_datadir/%name/fonts
%_datadir/%name/patterns
%_datadir/%name/qm

%files parts
%defattr(-,root,root)
%dir %_datadir/%name
%_datadir/%name/library

%changelog
openSUSE Build Service is sponsored by