File librecad.spec of Package librecad

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

Name:           librecad
Version:        2.1.3
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

#Git-Clone:     git://
# Version is actually 8, not 3 (it is 3 in the filename due to how MediaWiki
# works -- see
Source10:       ttf2lff.1
Source20:       %name-rpmlintrc
Patch0:         ensured-all-objects-are-shown-when-a-layer-is-toggle.patch
Patch2:         librecad-no-date.diff
Patch3:         librecad-use-system-libdxfrw.patch
Patch4:         librecad-install.diff
Patch5:         librecad-plugindir.diff
Patch6:         librecad-use-system-shapelib.patch
%if 0%{?suse_version} > 1325
BuildRequires:  libboost_headers-devel
BuildRequires:  boost-devel
BuildRequires:  fdupes
BuildRequires:  freetype2-devel
BuildRequires:  gcc-c++ >= 4.7
BuildRequires:  libdxfrw-devel >= 0.6.1
%if 0%{?suse_version} >= 1321
BuildRequires:  libshp-devel
%if 0%{?suse_version} >= 1321
BuildRequires:  pkgconfig(Qt5Core)
BuildRequires:  pkgconfig(Qt5Gui)
BuildRequires:  pkgconfig(Qt5Help)
BuildRequires:  pkgconfig(Qt5PrintSupport)
BuildRequires:  pkgconfig(Qt5Svg)
BuildRequires:  pkgconfig(Qt5Widgets)
BuildRequires:  libqt4-devel
BuildRequires:  muparser-devel
BuildRequires:  unzip
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

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.

%setup -qn LibreCAD-%version -a 2 -a 3 -a 4
%patch -P 0 -P 2 -P 3 -P 4 -P 5 -p1
%if 0%{?suse_version} >= 1321
%patch -P 6 -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/
%if 0%{?suse_version} >= 1321
sed -i 's@LRELEASE="lrelease"@LRELEASE="lrelease-qt5"@' scripts/

# Make sure bundled libraries are not used
rm -rf libraries/libdxfrw
%if 0%{?suse_version} >= 1321
rm -rf plugins/importshp/shapelib

# Fix "wrong-file-end-of-line-encoding" rpmlint warning
sed -i 's/\r$//' LICENSE-MIT.txt LICENSE_KST32B_v2.txt license-lc_opengost-fonts.txt

echo 'DISABLE_POSTSCRIPT = true' > librecad/src/custom.pri
%if 0%{?suse_version} >= 1321
qmake-qt5 \
qmake \
%endif 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" \
	"%_datadir/fonts/truetype/wqy-microhei.ttc" \

# No make install :(
export BUILDDIR="$b/%_datadir/%name"
sh scripts/

install -Dpm0755 "unix/%name" "$b/%_bindir/%name"
install -Dpm0644 "unix/appdata/%name.appdata.xml" "$b/%_datadir/appdata/%name.appdata.xml"
install -Dpm0755 "unix/ttf2lff" "$b/%_bindir/ttf2lff"
install -Dpm0644 "desktop/%name.1" "$b/%_mandir/man1/%name.1"
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 "%_sourcedir/ttf2lff.1" "$b/%_mandir/man1/"

mkdir -p "$b/%_datadir/%name/library/architecture" \
	"$b/%_datadir/%name/library/electronics" \
cp -a Architect8-LCAD "$b/%_datadir/%name/library/architecture/"
cp -a Electronic8-LCAD "$b/%_datadir/%name/library/electronics/"
cp -a Electrical1-LCAD "$b/%_datadir/%name/library/electrical/"

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

%fdupes -s %buildroot/%_prefix



%doc LICENSE* gpl-2.0* license-lc_opengost-fonts.txt
%if 0%{?suse_version} < 1320
%dir %_datadir/appdata/
%dir %_datadir/%name

%files parts
%dir %_datadir/%name

openSUSE Build Service is sponsored by