View Issue Details

IDProjectCategoryView StatusLast Update
0004132FreeCADPatchpublic2019-09-25 18:21
Reportersopwith Assigned Topfirszt  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformLinuxOSFedoraOS Version30
Summary0004132: Patch fedora.spec to get FreeCAD packages building again
DescriptionBuilds are failing/disabled on https://copr.fedorainfracloud.org/coprs/g/freecad/nightly/

The attached patch for FreeCAD/package/fedora/freecad.spec gets it building again for me - I used FC30 and FreeCAD master branch as of commit #18236.
Tags#lowhangingfruit, linux, packaging
FreeCAD Information

Activities

sopwith

2019-09-16 20:13

reporter  

freecad.spec.patch (5,381 bytes)   
diff -up ./freecad.spec.base ./freecad.spec
--- ./freecad.spec.base	2019-09-16 15:40:59.908156457 -0400
+++ ./freecad.spec	2019-09-16 15:41:46.564758799 -0400
@@ -44,17 +44,32 @@ BuildRequires:  med-devel
 BuildRequires:  mesa-libGLU-devel
 BuildRequires:  netgen-mesher-devel
 BuildRequires:  netgen-mesher-devel-private
+BuildRequires:  libusb-devel
+%if 0%{?fedora} > 28
+BuildRequires:  python3-pivy
+BuildRequires:  boost-python3
+BuildRequires:  boost-python3-devel
+BuildRequires:  mesa-libEGL-devel
+BuildRequires:  python3-matplotlib
+BuildRequires:  python3
+BuildRequires:  python3-devel
+BuildRequires:  python3-pyside
+BuildRequires:  pyside2-tools
+BuildRequires:  python3-pyside2-devel
+BuildRequires:  python3-shiboken2-devel
+%else
+BuildRequires:  boost-python2
+BuildRequires:  boost-python2-devel
+BuildRequires:  python2-pivy
+BuildRequires:  python2-matplotlib
+BuildRequires:  python2
+BuildRequires:  python2-devel
+BuildRequires:  python2-pyside
 BuildRequires:  pyside-tools
-BuildRequires:  python
-BuildRequires:  python-matplotlib
-%if 0%{?fedora} < 30
-BuildRequires:  python-pivy
-%endif
-BuildRequires:  python-pyside
 BuildRequires:  python-pyside-devel
-BuildRequires:  python2-devel
-BuildRequires:  qt-devel
-BuildRequires:  qt-webkit-devel
+%endif
+BuildRequires:  qt5-devel
+BuildRequires:  qt5-qtwebkit-devel
 BuildRequires:  shiboken
 BuildRequires:  shiboken-devel
 BuildRequires:  smesh
@@ -65,14 +80,7 @@ BuildRequires:  vtk-devel
 BuildRequires:  xerces-c
 BuildRequires:  xerces-c-devel
 BuildRequires:  zlib-devel
-%if 0%{?fedora} > 28
-BuildRequires:  boost-python2
-BuildRequires:  boost-python2-devel
-BuildRequires:  boost-python3
-BuildRequires:  boost-python3-devel
-BuildRequires:  mesa-libEGL-devel
-BuildRequires:  python3-matplotlib
-%endif
+BuildRequires:  pcl-devel
 
 # For appdata
 %if 0%{?fedora}
@@ -88,12 +96,23 @@ Obsoletes:      %{name}-doc < 0.13-5
 # Needed for plugin support and is not a soname dependency.
 %if ! 0%{?rhel} <= 6 && "%{_arch}" != "ppc64"
 # python-pivy does not build on EPEL 6 ppc64.
-Requires:       python-pivy
+%if 0%{?fedora} > 28
+Requires:       python3-pivy
+%else
+Requires:       python2-pivy
+%endif
 %endif
 Requires:       hicolor-icon-theme
+%if 0%{?fedora} > 28
+Requires:       python3-matplotlib
+Requires:       python3-collada
+Requires:       python3-pyside2
+Recommends:	python3-pysolar
+%else
 Requires:       python-matplotlib
 Requires:       python-collada
 Requires:       python-pyside
+%endif
 
 # plugins and private shared libs in %%{_libdir}/freecad/lib are private;
 # prevent private capabilities being advertised in Provides/Requires
@@ -154,9 +173,18 @@ rm -rf build && mkdir build && cd build
        -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir} \
        -DRESOURCEDIR=%{_datadir}/%{name} \
        -DFREECAD_USE_EXTERNAL_PIVY=TRUE \
+       -DFREECAD_USE_PCL=TRUE \
+       -DBUILD_QT5=ON \
+       -DPYSIDE_INCLUDE_DIR=/usr/include/PySide2 \
+%if 0%{?fedora} > 28
+       -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 \
+%else
+       -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python2 \
+%endif
        -DMEDFILE_INCLUDE_DIRS=%{MEDFILE_INCLUDE_DIRS} \
        ../
 
+make fc_version
 sed -i 's,FCRevision      \"Unknown\",FCRevision      \"%{release} (Git)\",' src/Build/Version.h
 sed -i 's,FCRepositoryURL \"Unknown\",FCRepositoryURL \"git://github.com/FreeCAD/FreeCAD.git master\",' src/Build/Version.h
 
@@ -179,8 +207,11 @@ mv %{buildroot}%{_libdir}/%{name}/share/
 mkdir %{buildroot}%{_datadir}/applications/
 mv %{buildroot}%{_libdir}/%{name}/share/applications/* %{buildroot}%{_datadir}/applications/
 
-mkdir -p %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/
-mv %{buildroot}%{_libdir}/%{name}/share/icons/hicolor/scalable/apps/* %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/
+mkdir -p %{buildroot}%{_datadir}/icons/hicolor/scalable/
+mv %{buildroot}%{_libdir}/%{name}/share/icons/hicolor/scalable/* %{buildroot}%{_datadir}/icons/hicolor/scalable/
+
+mkdir -p %{buildroot}%{_datadir}/pixmaps/
+mv %{buildroot}%{_libdir}/%{name}/share/pixmaps/* %{buildroot}%{_datadir}/pixmaps/
 
 mkdir -p %{buildroot}%{_datadir}/mime/packages/
 mv %{buildroot}%{_libdir}/%{name}/share/mime/packages/* %{buildroot}%{_datadir}/mime/packages/
@@ -188,8 +219,8 @@ mv %{buildroot}%{_libdir}/%{name}/share/
 pushd %{buildroot}%{_libdir}/%{name}/share/
 rmdir metainfo/
 rmdir applications/
-rmdir -p mime/packages/
-rmdir -p icons/hicolor/scalable/apps/
+rm -rf mime
+rm -rf icons
 popd
 
 # Bug maintainers to keep %%{plugins} macro up to date.
@@ -206,7 +237,7 @@ if [ -n "$new_plugins" ]; then
 fi
 # Make sure there are no entries in the plugins macro that don't match plugins
 for p in %{plugins}; do
-    if [ -z "`ls %{buildroot}%{_libdir}/%{name}/lib/$p*.so`" ]; then
+    if [ -z "`ls %{buildroot}%{_libdir}/%{name}/%{_lib}/$p*.so`" ]; then
         set +x
         echo -e "\n\n\n**** ERROR:\n" \
              "\nExtra entry in %%{plugins} macro with no matching plugin:" \
@@ -246,11 +277,12 @@ fi
 %{_bindir}/*
 %dir %{_libdir}/%{name}
 %{_libdir}/%{name}/bin/
-%{_libdir}/%{name}/lib/
+%{_libdir}/%{name}/%{_lib}/
 %{_libdir}/%{name}/Mod/
 %{_libdir}/%{name}/Ext/
 %{_datadir}/applications/*
-%{_datadir}/icons/hicolor/scalable/apps/*
+%{_datadir}/icons/hicolor/scalable/*
+%{_datadir}/pixmaps/*
 %{_datadir}/appdata/*
 %{_datadir}/mime/packages/*
 
freecad.spec.patch (5,381 bytes)   

Kunda1

2019-09-16 23:10

administrator   ~0013611

@hobbes1069 are you involved with the copr nightly ?

hobbes1069

2019-09-16 23:41

reporter   ~0013612

No, I'm not. I only manage the official builds for Fedora... I tried to look at the patch but it won't load.

Currently I'm working on two things:
1. Pyside1 -> PySide2 (which includes qt4 -> qt5)
2. Coin3 -> Coin4 (new package for Fedora)

Kunda1

2019-09-17 20:17

administrator   ~0013617

I tried to look at the patch but it won't load.

hobbes1069

@hobbes1069 do you see the '+' sign ? (See screenshot)
mantisbt-patch-inline.png (14,612 bytes)   
mantisbt-patch-inline.png (14,612 bytes)   

sopwith

2019-09-18 00:49

reporter   ~0013621

After a little more digging, @sliptonic seems to be the maintainer of the COPR build.

If someone reviews this patch and commits it into the FreeCAD git repository, I think COPR should probably just pick it up automatically, since COPR appears to be pulling everything from the master branch for its builds, .spec file included.

hobbes1069

2019-09-18 01:59

reporter   ~0013622

Yes, the + button helped but I still don't know why it was having trouble downloading the patch.

On the surface it looks fine but I don't know why the location of the icons was changed.

/usr/share/icons/hicolor/<size>x<size>/apps is the correct location. For SVG files the size "scalable" is correct.

On a side note Fedora 28 is EOL so the conditionals could go away unless Fedora 28 is intentionally still being supported for freecad.

Kunda1

2019-09-18 12:27

administrator   ~0013626

CC @pfirszt

sopwith

2019-09-18 12:33

reporter   ~0013627

Hi @hobbes1069

The location of the apps icons was not changed. The commands still put those in the same place, but the commands changed to also include the file format icon which is in another subdirectory of "scalable".

Elliot

sliptonic

2019-09-18 12:48

manager   ~0013628

I don't have anything to do with this build. I never have and wouldn't know where to begin.

pfirszt

2019-09-18 13:31

developer   ~0013629

@sopwith: thanks for the patch! I run the COPR nightly.

My pull request is in the pipeline [1], but it's just a very dirty copy of what hobbes1069 prepared for the official repo. If your patch works I'm happy to cancel my pull request and go with your version (make a PR and let me know to cancel mine).

[1] https://github.com/FreeCAD/FreeCAD/pull/2534

P.S. If you're interested helping to maintain copr nightly send me a PM please.

sopwith

2019-09-18 15:18

reporter   ~0013631

Hi @pfirszt,

I think both patches have some good pieces. Yours allows using OpenCASCADE instead of OCE, for example. Mine builds with qt5 instead of qt4. Probably what we need to do is come up with a new patch that incorporates the best of both. I'll see what I can do.

Sorry, I'm kind of a hit-and-run contributor so I don't do git PR's or maintain stuff long-term.

hobbes1069

2019-09-18 19:25

reporter   ~0013632

Ok, I wasn't aware the icon location changed so that's fine.

I'm trying to build with the new stack in fedora Rawhide (f32) (PySide2 / Coin4) but running into the following issue:

BUILDSTDERR: /builddir/build/BUILD/FreeCAD-0.18.3/src/Base/swigpyrun.inl: In function 'void Swig_python::cleanupSWIG_T(const char*)':
BUILDSTDERR: /builddir/build/BUILD/FreeCAD-0.18.3/src/Base/swigpyrun.inl:75:31: error: invalid use of incomplete type 'PyInterpreterState' {aka 'struct _is'}
BUILDSTDERR:    75 |     PyObject *modules = interp->modules;
BUILDSTDERR:       |                               ^~

I posted about it here to the forums but haven't gotten any replies:

https://forum.freecadweb.org/viewtopic.php?f=4&t=38982

When I try Fedora 30 (in case SWIG 4.0.x is the problem) I get a different error:

BUILDSTDERR: In file included from /builddir/build/BUILD/FreeCAD-0.18.3/src/Gui/Application.cpp:73:
BUILDSTDERR: /builddir/build/BUILD/FreeCAD-0.18.3/src/Gui/WidgetFactory.h:28:10: fatal error: QUiLoader: No such file or directory
BUILDSTDERR:    28 | #include <QUiLoader>
BUILDSTDERR:       |          ^~~~~~~~~~~

sopwith

2019-09-18 20:42

reporter   ~0013633

Last edited: 2019-09-18 21:44

@pfirszt - FreeCAD doesn't build with the pycxx included in Fedora 30, only the bundled one, so it will be necessary to always use the bundled one for now.

FreeCAD also won't build against the SMESH 6.7.5-6 included in Fedora 30. The bundled version is 7.7.1, and the upstream version of Salome is currently 9.3.0, so it would be nice if Fedora would update to upstream and then FreeCAD could accomodate building against that.

@hobbes1069 - As far as your build on Fedora 30, QUiLoader should be in /usr/include/qt5/QUiTools and is part of the qt5-qttools-static package. qt5-qttools-static is Required by qt5-devel, and I assume your package has 'BuildRequires: qt5-devel', so I don't know what's going on.

sopwith

2019-09-18 22:08

reporter   ~0013634

I looked over @pfirszt's changeset and tried to incorporate the best parts into the attached version. It eliminates the python2 support as suggested by @hobbes1069 and fixes some bugs in my earlier submission.

Since different people are using different versions of the .spec file, I'm also attaching the .spec file that I actually built from just now. You can diff it against your working version to see the changes.
freecad.spec (11,463 bytes)   
# This package depends on automagic byte compilation
# https://fedoraproject.org/wiki/Changes/No_more_automagic_Python_bytecompilation_phase_2
%global _python_bytecompile_extra 1

# Setup python target for shiboken so the right cmake file is imported.
%global py_suffix %(%{__python3} -c "import sysconfig; print(sysconfig.get_config_var('SOABI'))")

# Maintainers:  keep this list of plugins up to date
# List plugins in %%{_libdir}/%{name}/lib, less '.so' and 'Gui.so', here
%global plugins Drawing Fem FreeCAD Image Import Inspection Mesh MeshPart Part Points QtUnit Raytracing ReverseEngineering Robot Sketcher Start Web PartDesignGui _PartDesign Path PathGui Spreadsheet SpreadsheetGui area DraftUtils DraftUtils libDriver libDriverDAT libDriverSTL libDriverUNV libMEFISTO2 libSMDS libSMESH libSMESHDS libStdMeshers Measure TechDraw TechDrawGui libarea-native Surface SurfaceGui PathSimulator

# Some configuration options for other environments
# rpmbuild --with=occ:  Compile using OpenCASCADE instead of OCE
%global occ %{?_with_occ: 1} %{?!_with_occ: 0}
# rpmbuild --with=bundled_zipios:  use bundled version of zipios++
%global bundled_zipios %{?_with_bundled_zipios: 1} %{?!_with_bundled_zipios: 0}
# rpmbuild --without=bundled_pycxx:  don't use bundled version of pycxx
%global bundled_pycxx %{?_without_bundled_pycxx: 0} %{?!_without_bundled_pycxx: 1}
# rpmbuild --without=bundled_smesh:  don't use bundled version of Salome's Mesh
%global bundled_smesh %{?_without_bundled_smesh: 0} %{?!_without_bundled_smesh: 1}

# See FreeCAD-master/src/3rdParty/salomesmesh/CMakeLists.txt to find this out.
%global bundled_smesh_version 7.7.1.0

# Some plugins go in the Mod folder instead of lib. Deal with those here:
%global mod_plugins Mod/PartDesign
%define name freecad
%define github_name FreeCAD
%define branch master

Name:           %{name}
Epoch:          1
Version:    	0.19_pre
Release:        {{{ git_commits_no }}}
Summary:        A general purpose 3D CAD modeler
Group:          Applications/Engineering

License:        GPLv2+
URL:            http://sourceforge.net/apps/mediawiki/free-cad/
Source0:        https://github.com/%{github_name}/FreeCAD/archive/%{branch}.tar.gz
Patch0:		FreeCAD-external-smesh.patch

# Utilities
BuildRequires:  cmake gcc-c++ gettext dos2unix
BuildRequires:  doxygen swig graphviz
BuildRequires:  gcc-gfortran
BuildRequires:  desktop-file-utils
BuildRequires:  git

# Development Libraries

BuildRequires:  Coin3-devel
BuildRequires:  Inventor-devel
%if %{occ}
BuildRequires:  OpenCASCADE-devel
%else
BuildRequires:  OCE-devel
BuildRequires:  OCE-draw
%endif

BuildRequires:  boost-devel
BuildRequires:  boost-python3-devel
BuildRequires:  eigen3-devel
BuildRequires:  freeimage-devel
BuildRequires:  libicu-devel
BuildRequires:  libspnav-devel
BuildRequires:  med-devel
BuildRequires:  mesa-libEGL-devel
BuildRequires:  mesa-libGLU-devel
BuildRequires:  netgen-mesher-devel
BuildRequires:  netgen-mesher-devel-private
BuildRequires:  libXmu-devel
# For appdata
%if 0%{?fedora}
BuildRequires:  libappstream-glib
%endif
BuildRequires:  libkdtree++-devel
BuildRequires:  libusb-devel
BuildRequires:  python3-pivy
BuildRequires:  mesa-libEGL-devel
BuildRequires:  pcl-devel
BuildRequires:  pyside2-tools
BuildRequires:  python3
BuildRequires:  python3-devel
BuildRequires:  python3-matplotlib
%if ! %{bundled_pycxx}
BuildRequires:  python3-pycxx-devel
%endif
BuildRequires:  python3-pyside2-devel
BuildRequires:  python3-shiboken2-devel
BuildRequires:  qt5-devel
BuildRequires:  qt5-qtwebkit-devel
%if ! %{bundled_smesh}
BuildRequires:  smesh-devel
%endif
BuildRequires:  tbb-devel
BuildRequires:  vtk-devel
BuildRequires:  xerces-c
BuildRequires:  xerces-c-devel
%if ! %{bundled_zipios}
BuildRequires:  zipios++-devel
%endif
BuildRequires:  zlib-devel

# Packages separated because they are noarch, but not optional so require them
# here.
Requires:       %{name}-data = %{epoch}:%{version}-%{release}
# Obsolete old doc package since it's required for functionality.
Obsoletes:      %{name}-doc < 0.13-5

Requires:       hicolor-icon-theme
Requires:       python3-collada
Requires:       python3-matplotlib
Requires:       python3-pivy
Requires:       python3-pyside2
Requires:	qt-assistant
%if %{bundled_smesh} 
Provides:       bundled(smesh) = %{bundled_smesh_version}
%endif
%if %{bundled_pycxx} 
Provides:       bundled(python-pycxx)
%endif
Recommends:	python3-pysolar

# plugins and private shared libs in %%{_libdir}/freecad/lib are private;
# prevent private capabilities being advertised in Provides/Requires
%define plugin_regexp /^\\\(libFreeCAD.*%(for i in %{plugins}; do echo -n "\\\|$i\\\|$iGui"; done)\\\)\\\(\\\|Gui\\\)\\.so/d
%{?filter_setup:
%filter_provides_in %{_libdir}/%{name}/lib
%filter_from_requires %{plugin_regexp}
%filter_from_provides %{plugin_regexp}
%filter_provides_in %{_libdir}/%{name}/Mod
%filter_requires_in %{_libdir}/%{name}/Mod
%filter_setup
}

%description
FreeCAD is a general purpose Open Source 3D CAD/MCAD/CAx/CAE/PLM modeler, aimed
directly at mechanical engineering and product design but also fits a wider
range of uses in engineering, such as architecture or other engineering
specialties. It is a feature-based parametric modeler with a modular software
architecture which makes it easy to provide additional functionality without
modifying the core system.


%package data
Summary:        Data files for FreeCAD
BuildArch:      noarch
Requires:       %{name} = %{epoch}:%{version}-%{release}

%description data
Data files for FreeCAD


%prep
%autosetup -p1 -n FreeCAD-%{branch}

# Remove bundled pycxx if we're not using it
%if ! %{bundled_pycxx}
rm -rf src/CXX
%endif

%if ! %{bundled_zipios}
rm -rf src/zipios++
#sed -i "s/zipios-config.h/zipios-config.hpp/g" \
#    src/Base/Reader.cpp src/Base/Writer.h
%endif

# Fix encodings
dos2unix -k src/Mod/Test/unittestgui.py \
            ChangeLog.txt \
            data/License.txt

# Removed bundled libraries

%build
rm -rf build && mkdir build && cd build

# Deal with cmake projects that tend to link excessively.
CXXFLAGS='-Wno-error=cast-function-type'; export CXXFLAGS
LDFLAGS='-Wl,--as-needed -Wl,--no-undefined'; export LDFLAGS

%if 0%{?fedora} > 27
%define MEDFILE_INCLUDE_DIRS %{_includedir}/med/
%else
%define MEDFILE_INCLUDE_DIRS %{_includedir}/
%endif

%cmake \
       -DCMAKE_INSTALL_PREFIX=%{_libdir}/%{name} \
       -DCMAKE_INSTALL_DATADIR=%{_datadir}/%{name} \
       -DCMAKE_INSTALL_DOCDIR=%{_docdir}/%{name} \
       -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir} \
       -DRESOURCEDIR=%{_datadir}/%{name} \
       -DFREECAD_USE_EXTERNAL_PIVY=TRUE \
       -DFREECAD_USE_PCL=TRUE \
       -DBUILD_QT5=ON \
       -DSHIBOKEN_INCLUDE_DIR=%{_includedir}/shiboken2 \
       -DSHIBOKEN_LIBRARY=-lshiboken2.%{py_suffix} \
       -DPYTHON_SUFFIX=.%{py_suffix} \
       -DPYSIDE_INCLUDE_DIR=/usr/include/PySide2 \
       -DPYSIDE_LIBRARY=-lpyside2.%{py_suffix} \
       -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 \
       -DMEDFILE_INCLUDE_DIRS=%{MEDFILE_INCLUDE_DIRS} \
       -DOpenGL_GL_PREFERENCE=GLVND \
       -DCOIN3D_INCLUDE_DIR=%{_includedir}/Coin3 \
       -DCOIN3D_DOC_PATH=%{_datadir}/Coin3/Coin \
       -DFREECAD_USE_EXTERNAL_PIVY=TRUE \
%if %{occ}
       -DUSE_OCC=TRUE \
%endif
%if ! %{bundled_smesh}
       -DFREECAD_USE_EXTERNAL_SMESH=TRUE \
       -DSMESH_FOUND=TRUE \
       -DSMESH_INCLUDE_DIR=%{_includedir}/smesh \
       -DSMESH_DIR=`pwd`/../cMake \
%endif
%if ! %{bundled_zipios}
       -DFREECAD_USE_EXTERNAL_ZIPIOS=TRUE \
%endif
%if ! %{bundled_pycxx}
       -DPYCXX_INCLUDE_DIR=$(pkg-config --variable=includedir PyCXX) \
       -DPYCXX_SOURCE_DIR=$(pkg-config --variable=srcdir PyCXX) \
%endif
       ../

make fc_version
sed -i 's,FCRevision      \"Unknown\",FCRevision      \"%{release} (Git)\",' src/Build/Version.h
sed -i 's,FCRepositoryURL \"Unknown\",FCRepositoryURL \"git://github.com/FreeCAD/FreeCAD.git master\",' src/Build/Version.h

make %{?_smp_mflags}

%install
cd build
%make_install

# Symlink binaries to /usr/bin
mkdir -p %{buildroot}%{_bindir}
ln -s ../%{_lib}/%{name}/bin/FreeCAD %{buildroot}%{_bindir}/FreeCAD
ln -s ../%{_lib}/%{name}/bin/FreeCADCmd %{buildroot}%{_bindir}/FreeCADCmd

mkdir %{buildroot}%{_metainfodir}/
mv %{buildroot}%{_libdir}/%{name}/share/metainfo/* %{buildroot}%{_metainfodir}/

mkdir %{buildroot}%{_datadir}/applications/
mv %{buildroot}%{_libdir}/%{name}/share/applications/* %{buildroot}%{_datadir}/applications/

mkdir -p %{buildroot}%{_datadir}/icons/hicolor/scalable/
mv %{buildroot}%{_libdir}/%{name}/share/icons/hicolor/scalable/* %{buildroot}%{_datadir}/icons/hicolor/scalable/

mkdir -p %{buildroot}%{_datadir}/pixmaps/
mv %{buildroot}%{_libdir}/%{name}/share/pixmaps/* %{buildroot}%{_datadir}/pixmaps/

mkdir -p %{buildroot}%{_datadir}/mime/packages/
mv %{buildroot}%{_libdir}/%{name}/share/mime/packages/* %{buildroot}%{_datadir}/mime/packages/

pushd %{buildroot}%{_libdir}/%{name}/share/
rmdir metainfo/
rmdir applications/
rm -rf mime
rm -rf icons
popd

# Remove obsolete Start_Page.html
rm -f %{buildroot}%{_docdir}/%{name}/Start_Page.html
# Belongs in %%license not %%doc
rm -f %{buildroot}%{_docdir}/freecad/ThirdPartyLibraries.html

# Bug maintainers to keep %%{plugins} macro up to date.
#
# Make sure there are no plugins that need to be added to plugins macro
new_plugins=`ls %{buildroot}%{_libdir}/%{name}/%{_lib} | sed -e  '%{plugin_regexp}'`
if [ -n "$new_plugins" ]; then
    echo -e "\n\n\n**** ERROR:\n" \
        "\nPlugins not caught by regexp:  " $new_plugins \
        "\n\nPlugins in %{_libdir}/%{name}/lib do not exist in" \
         "\nspecfile %%{plugins} macro.  Please add these to" \
         "\n%%{plugins} macro at top of specfile and rebuild.\n****\n" 1>&2
    exit 1
fi
# Make sure there are no entries in the plugins macro that don't match plugins
for p in %{plugins}; do
    if [ -z "`ls %{buildroot}%{_libdir}/%{name}/%{_lib}/$p*.so`" ]; then
        set +x
        echo -e "\n\n\n**** ERROR:\n" \
             "\nExtra entry in %%{plugins} macro with no matching plugin:" \
             "'$p'.\n\nPlease remove from %%{plugins} macro at top of" \
             "\nspecfile and rebuild.\n****\n" 1>&2
        exit 1
    fi
done

%check
desktop-file-validate \
    %{buildroot}%{_datadir}/applications/org.freecadweb.FreeCAD.desktop
%{?fedora:appstream-util validate-relax --nonet \
    %{buildroot}/%{_metainfodir}/*.appdata.xml}


%post
/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
/usr/bin/update-desktop-database &> /dev/null || :
/usr/bin/update-mime-database %{_datadir}/mime &> /dev/null || :

%postun
if [ $1 -eq 0 ] ; then
    /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null
    /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
fi
/usr/bin/update-desktop-database &> /dev/null || :
/usr/bin/update-mime-database %{_datadir}/mime &> /dev/null || :

%posttrans
/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor/scalable/apps &>/dev/null || :


%files
%license data/License.txt
%doc ChangeLog.txt
%exclude %{_docdir}/%{name}/%{name}.*
%exclude %{_docdir}/%{name}/ThirdPartyLibraries.html
%{_bindir}/*
%{_metainfodir}/*
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/bin/
%{_libdir}/%{name}/%{_lib}/
%{_libdir}/%{name}/Mod/
%{_libdir}/%{name}/Ext/
%{_datadir}/applications/*
%{_datadir}/icons/hicolor/scalable/*
%{_datadir}/pixmaps/*
%{_datadir}/mime/packages/*

%files data
%{_datadir}/%{name}/
%{_docdir}/%{name}/%{name}.q*
freecad.spec (11,463 bytes)   
freecad.spec-2.patch (12,400 bytes)   
diff -up ./freecad.spec.base ./freecad.spec
--- ./freecad.spec.base	2019-09-16 15:40:59.908156457 -0400
+++ ./freecad.spec	2019-09-18 17:54:52.576122826 -0400
@@ -1,8 +1,27 @@
+# This package depends on automagic byte compilation
+# https://fedoraproject.org/wiki/Changes/No_more_automagic_Python_bytecompilation_phase_2
+%global _python_bytecompile_extra 1
+
+# Setup python target for shiboken so the right cmake file is imported.
+%global py_suffix %(%{__python3} -c "import sysconfig; print(sysconfig.get_config_var('SOABI'))")
 
 # Maintainers:  keep this list of plugins up to date
 # List plugins in %%{_libdir}/%{name}/lib, less '.so' and 'Gui.so', here
 %global plugins Drawing Fem FreeCAD Image Import Inspection Mesh MeshPart Part Points QtUnit Raytracing ReverseEngineering Robot Sketcher Start Web PartDesignGui _PartDesign Path PathGui Spreadsheet SpreadsheetGui area DraftUtils DraftUtils libDriver libDriverDAT libDriverSTL libDriverUNV libMEFISTO2 libSMDS libSMESH libSMESHDS libStdMeshers Measure TechDraw TechDrawGui libarea-native Surface SurfaceGui PathSimulator
 
+# Some configuration options for other environments
+# rpmbuild --with=occ:  Compile using OpenCASCADE instead of OCE
+%global occ %{?_with_occ: 1} %{?!_with_occ: 0}
+# rpmbuild --with=bundled_zipios:  use bundled version of zipios++
+%global bundled_zipios %{?_with_bundled_zipios: 1} %{?!_with_bundled_zipios: 0}
+# rpmbuild --without=bundled_pycxx:  don't use bundled version of pycxx
+%global bundled_pycxx %{?_without_bundled_pycxx: 0} %{?!_without_bundled_pycxx: 1}
+# rpmbuild --without=bundled_smesh:  don't use bundled version of Salome's Mesh
+%global bundled_smesh %{?_without_bundled_smesh: 0} %{?!_without_bundled_smesh: 1}
+
+# See FreeCAD-master/src/3rdParty/salomesmesh/CMakeLists.txt to find this out.
+%global bundled_smesh_version 7.7.1.0
+
 # Some plugins go in the Mod folder instead of lib. Deal with those here:
 %global mod_plugins Mod/PartDesign
 %define name freecad
@@ -19,65 +38,69 @@ Group:          Applications/Engineering
 License:        GPLv2+
 URL:            http://sourceforge.net/apps/mediawiki/free-cad/
 Source0:        https://github.com/%{github_name}/FreeCAD/archive/%{branch}.tar.gz
+Patch0:		FreeCAD-external-smesh.patch
+
+# Utilities
+BuildRequires:  cmake gcc-c++ gettext dos2unix
+BuildRequires:  doxygen swig graphviz
+BuildRequires:  gcc-gfortran
+BuildRequires:  desktop-file-utils
+BuildRequires:  git
+
+# Development Libraries
 
-BuildRequires:  Coin3
 BuildRequires:  Coin3-devel
 BuildRequires:  Inventor-devel
+%if %{occ}
+BuildRequires:  OpenCASCADE-devel
+%else
 BuildRequires:  OCE-devel
 BuildRequires:  OCE-draw
+%endif
+
 BuildRequires:  boost-devel
-BuildRequires:  cmake
-BuildRequires:  desktop-file-utils
-BuildRequires:  dos2unix
-BuildRequires:  doxygen
-BuildRequires:  eigen3
+BuildRequires:  boost-python3-devel
 BuildRequires:  eigen3-devel
 BuildRequires:  freeimage-devel
-BuildRequires:  gettext
-BuildRequires:  git
-BuildRequires:  graphviz
 BuildRequires:  libicu-devel
-BuildRequires:  libspnav
 BuildRequires:  libspnav-devel
-BuildRequires:  med
 BuildRequires:  med-devel
+BuildRequires:  mesa-libEGL-devel
 BuildRequires:  mesa-libGLU-devel
 BuildRequires:  netgen-mesher-devel
 BuildRequires:  netgen-mesher-devel-private
-BuildRequires:  pyside-tools
-BuildRequires:  python
-BuildRequires:  python-matplotlib
-%if 0%{?fedora} < 30
-BuildRequires:  python-pivy
-%endif
-BuildRequires:  python-pyside
-BuildRequires:  python-pyside-devel
-BuildRequires:  python2-devel
-BuildRequires:  qt-devel
-BuildRequires:  qt-webkit-devel
-BuildRequires:  shiboken
-BuildRequires:  shiboken-devel
-BuildRequires:  smesh
+BuildRequires:  libXmu-devel
+# For appdata
+%if 0%{?fedora}
+BuildRequires:  libappstream-glib
+%endif
+BuildRequires:  libkdtree++-devel
+BuildRequires:  libusb-devel
+BuildRequires:  python3-pivy
+BuildRequires:  mesa-libEGL-devel
+BuildRequires:  pcl-devel
+BuildRequires:  pyside2-tools
+BuildRequires:  python3
+BuildRequires:  python3-devel
+BuildRequires:  python3-matplotlib
+%if ! %{bundled_pycxx}
+BuildRequires:  python3-pycxx-devel
+%endif
+BuildRequires:  python3-pyside2-devel
+BuildRequires:  python3-shiboken2-devel
+BuildRequires:  qt5-devel
+BuildRequires:  qt5-qtwebkit-devel
+%if ! %{bundled_smesh}
 BuildRequires:  smesh-devel
-BuildRequires:  swig
+%endif
 BuildRequires:  tbb-devel
 BuildRequires:  vtk-devel
 BuildRequires:  xerces-c
 BuildRequires:  xerces-c-devel
-BuildRequires:  zlib-devel
-%if 0%{?fedora} > 28
-BuildRequires:  boost-python2
-BuildRequires:  boost-python2-devel
-BuildRequires:  boost-python3
-BuildRequires:  boost-python3-devel
-BuildRequires:  mesa-libEGL-devel
-BuildRequires:  python3-matplotlib
-%endif
-
-# For appdata
-%if 0%{?fedora}
-BuildRequires:  libappstream-glib
+%if ! %{bundled_zipios}
+BuildRequires:  zipios++-devel
 %endif
+BuildRequires:  zlib-devel
 
 # Packages separated because they are noarch, but not optional so require them
 # here.
@@ -85,15 +108,19 @@ Requires:       %{name}-data = %{epoch}:
 # Obsolete old doc package since it's required for functionality.
 Obsoletes:      %{name}-doc < 0.13-5
 
-# Needed for plugin support and is not a soname dependency.
-%if ! 0%{?rhel} <= 6 && "%{_arch}" != "ppc64"
-# python-pivy does not build on EPEL 6 ppc64.
-Requires:       python-pivy
-%endif
 Requires:       hicolor-icon-theme
-Requires:       python-matplotlib
-Requires:       python-collada
-Requires:       python-pyside
+Requires:       python3-collada
+Requires:       python3-matplotlib
+Requires:       python3-pivy
+Requires:       python3-pyside2
+Requires:	qt-assistant
+%if %{bundled_smesh} 
+Provides:       bundled(smesh) = %{bundled_smesh_version}
+%endif
+%if %{bundled_pycxx} 
+Provides:       bundled(python-pycxx)
+%endif
+Recommends:	python3-pysolar
 
 # plugins and private shared libs in %%{_libdir}/freecad/lib are private;
 # prevent private capabilities being advertised in Provides/Requires
@@ -107,7 +134,6 @@ Requires:       python-pyside
 %filter_setup
 }
 
-
 %description
 FreeCAD is a general purpose Open Source 3D CAD/MCAD/CAx/CAE/PLM modeler, aimed
 directly at mechanical engineering and product design but also fits a wider
@@ -127,7 +153,18 @@ Data files for FreeCAD
 
 
 %prep
-%autosetup -n FreeCAD-%{branch}
+%autosetup -p1 -n FreeCAD-%{branch}
+
+# Remove bundled pycxx if we're not using it
+%if ! %{bundled_pycxx}
+rm -rf src/CXX
+%endif
+
+%if ! %{bundled_zipios}
+rm -rf src/zipios++
+#sed -i "s/zipios-config.h/zipios-config.hpp/g" \
+#    src/Base/Reader.cpp src/Base/Writer.h
+%endif
 
 # Fix encodings
 dos2unix -k src/Mod/Test/unittestgui.py \
@@ -140,7 +177,8 @@ dos2unix -k src/Mod/Test/unittestgui.py
 rm -rf build && mkdir build && cd build
 
 # Deal with cmake projects that tend to link excessively.
-#LDFLAGS='-Wl,--as-needed'; export LDFLAGS
+CXXFLAGS='-Wno-error=cast-function-type'; export CXXFLAGS
+LDFLAGS='-Wl,--as-needed -Wl,--no-undefined'; export LDFLAGS
 
 %if 0%{?fedora} > 27
 %define MEDFILE_INCLUDE_DIRS %{_includedir}/med/
@@ -148,15 +186,45 @@ rm -rf build && mkdir build && cd build
 %define MEDFILE_INCLUDE_DIRS %{_includedir}/
 %endif
 
-%cmake -DCMAKE_INSTALL_PREFIX=%{_libdir}/%{name} \
+%cmake \
+       -DCMAKE_INSTALL_PREFIX=%{_libdir}/%{name} \
        -DCMAKE_INSTALL_DATADIR=%{_datadir}/%{name} \
        -DCMAKE_INSTALL_DOCDIR=%{_docdir}/%{name} \
        -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir} \
        -DRESOURCEDIR=%{_datadir}/%{name} \
        -DFREECAD_USE_EXTERNAL_PIVY=TRUE \
+       -DFREECAD_USE_PCL=TRUE \
+       -DBUILD_QT5=ON \
+       -DSHIBOKEN_INCLUDE_DIR=%{_includedir}/shiboken2 \
+       -DSHIBOKEN_LIBRARY=-lshiboken2.%{py_suffix} \
+       -DPYTHON_SUFFIX=.%{py_suffix} \
+       -DPYSIDE_INCLUDE_DIR=/usr/include/PySide2 \
+       -DPYSIDE_LIBRARY=-lpyside2.%{py_suffix} \
+       -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 \
        -DMEDFILE_INCLUDE_DIRS=%{MEDFILE_INCLUDE_DIRS} \
+       -DOpenGL_GL_PREFERENCE=GLVND \
+       -DCOIN3D_INCLUDE_DIR=%{_includedir}/Coin3 \
+       -DCOIN3D_DOC_PATH=%{_datadir}/Coin3/Coin \
+       -DFREECAD_USE_EXTERNAL_PIVY=TRUE \
+%if %{occ}
+       -DUSE_OCC=TRUE \
+%endif
+%if ! %{bundled_smesh}
+       -DFREECAD_USE_EXTERNAL_SMESH=TRUE \
+       -DSMESH_FOUND=TRUE \
+       -DSMESH_INCLUDE_DIR=%{_includedir}/smesh \
+       -DSMESH_DIR=`pwd`/../cMake \
+%endif
+%if ! %{bundled_zipios}
+       -DFREECAD_USE_EXTERNAL_ZIPIOS=TRUE \
+%endif
+%if ! %{bundled_pycxx}
+       -DPYCXX_INCLUDE_DIR=$(pkg-config --variable=includedir PyCXX) \
+       -DPYCXX_SOURCE_DIR=$(pkg-config --variable=srcdir PyCXX) \
+%endif
        ../
 
+make fc_version
 sed -i 's,FCRevision      \"Unknown\",FCRevision      \"%{release} (Git)\",' src/Build/Version.h
 sed -i 's,FCRepositoryURL \"Unknown\",FCRepositoryURL \"git://github.com/FreeCAD/FreeCAD.git master\",' src/Build/Version.h
 
@@ -168,19 +236,20 @@ cd build
 
 # Symlink binaries to /usr/bin
 mkdir -p %{buildroot}%{_bindir}
-pushd %{buildroot}%{_bindir}
-ln -s ../%{_lib}/%{name}/bin/FreeCAD .
-ln -s ../%{_lib}/%{name}/bin/FreeCADCmd .
-popd
+ln -s ../%{_lib}/%{name}/bin/FreeCAD %{buildroot}%{_bindir}/FreeCAD
+ln -s ../%{_lib}/%{name}/bin/FreeCADCmd %{buildroot}%{_bindir}/FreeCADCmd
 
-mkdir %{buildroot}%{_datadir}/appdata/
-mv %{buildroot}%{_libdir}/%{name}/share/metainfo/* %{buildroot}%{_datadir}/appdata/
+mkdir %{buildroot}%{_metainfodir}/
+mv %{buildroot}%{_libdir}/%{name}/share/metainfo/* %{buildroot}%{_metainfodir}/
 
 mkdir %{buildroot}%{_datadir}/applications/
 mv %{buildroot}%{_libdir}/%{name}/share/applications/* %{buildroot}%{_datadir}/applications/
 
-mkdir -p %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/
-mv %{buildroot}%{_libdir}/%{name}/share/icons/hicolor/scalable/apps/* %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/
+mkdir -p %{buildroot}%{_datadir}/icons/hicolor/scalable/
+mv %{buildroot}%{_libdir}/%{name}/share/icons/hicolor/scalable/* %{buildroot}%{_datadir}/icons/hicolor/scalable/
+
+mkdir -p %{buildroot}%{_datadir}/pixmaps/
+mv %{buildroot}%{_libdir}/%{name}/share/pixmaps/* %{buildroot}%{_datadir}/pixmaps/
 
 mkdir -p %{buildroot}%{_datadir}/mime/packages/
 mv %{buildroot}%{_libdir}/%{name}/share/mime/packages/* %{buildroot}%{_datadir}/mime/packages/
@@ -188,14 +257,19 @@ mv %{buildroot}%{_libdir}/%{name}/share/
 pushd %{buildroot}%{_libdir}/%{name}/share/
 rmdir metainfo/
 rmdir applications/
-rmdir -p mime/packages/
-rmdir -p icons/hicolor/scalable/apps/
+rm -rf mime
+rm -rf icons
 popd
 
+# Remove obsolete Start_Page.html
+rm -f %{buildroot}%{_docdir}/%{name}/Start_Page.html
+# Belongs in %%license not %%doc
+rm -f %{buildroot}%{_docdir}/freecad/ThirdPartyLibraries.html
+
 # Bug maintainers to keep %%{plugins} macro up to date.
 #
 # Make sure there are no plugins that need to be added to plugins macro
-new_plugins=`ls %{buildroot}%{_libdir}/%{name}/lib | sed -e  '%{plugin_regexp}'`
+new_plugins=`ls %{buildroot}%{_libdir}/%{name}/%{_lib} | sed -e  '%{plugin_regexp}'`
 if [ -n "$new_plugins" ]; then
     echo -e "\n\n\n**** ERROR:\n" \
         "\nPlugins not caught by regexp:  " $new_plugins \
@@ -206,7 +280,7 @@ if [ -n "$new_plugins" ]; then
 fi
 # Make sure there are no entries in the plugins macro that don't match plugins
 for p in %{plugins}; do
-    if [ -z "`ls %{buildroot}%{_libdir}/%{name}/lib/$p*.so`" ]; then
+    if [ -z "`ls %{buildroot}%{_libdir}/%{name}/%{_lib}/$p*.so`" ]; then
         set +x
         echo -e "\n\n\n**** ERROR:\n" \
              "\nExtra entry in %%{plugins} macro with no matching plugin:" \
@@ -217,8 +291,10 @@ for p in %{plugins}; do
 done
 
 %check
+desktop-file-validate \
+    %{buildroot}%{_datadir}/applications/org.freecadweb.FreeCAD.desktop
 %{?fedora:appstream-util validate-relax --nonet \
-    %{buildroot}/%{_datadir}/appdata/*.appdata.xml}
+    %{buildroot}/%{_metainfodir}/*.appdata.xml}
 
 
 %post
@@ -244,14 +320,15 @@ fi
 %exclude %{_docdir}/%{name}/%{name}.*
 %exclude %{_docdir}/%{name}/ThirdPartyLibraries.html
 %{_bindir}/*
+%{_metainfodir}/*
 %dir %{_libdir}/%{name}
 %{_libdir}/%{name}/bin/
-%{_libdir}/%{name}/lib/
+%{_libdir}/%{name}/%{_lib}/
 %{_libdir}/%{name}/Mod/
 %{_libdir}/%{name}/Ext/
 %{_datadir}/applications/*
-%{_datadir}/icons/hicolor/scalable/apps/*
-%{_datadir}/appdata/*
+%{_datadir}/icons/hicolor/scalable/*
+%{_datadir}/pixmaps/*
 %{_datadir}/mime/packages/*
 
 %files data
freecad.spec-2.patch (12,400 bytes)   

hobbes1069

2019-09-18 22:17

reporter   ~0013635

Ok, I don't use qt5-devel because it pulls in everything and is not recommended. It's really just there for ease of transition from the qt4-devel package. I'll add the static package and see if that fixes it.

sopwith

2019-09-19 01:39

reporter   ~0013638

One more fix - should have a Requires: qt5-assistant instead of qt-assistant.
freecad-2.spec (11,464 bytes)   
# This package depends on automagic byte compilation
# https://fedoraproject.org/wiki/Changes/No_more_automagic_Python_bytecompilation_phase_2
%global _python_bytecompile_extra 1

# Setup python target for shiboken so the right cmake file is imported.
%global py_suffix %(%{__python3} -c "import sysconfig; print(sysconfig.get_config_var('SOABI'))")

# Maintainers:  keep this list of plugins up to date
# List plugins in %%{_libdir}/%{name}/lib, less '.so' and 'Gui.so', here
%global plugins Drawing Fem FreeCAD Image Import Inspection Mesh MeshPart Part Points QtUnit Raytracing ReverseEngineering Robot Sketcher Start Web PartDesignGui _PartDesign Path PathGui Spreadsheet SpreadsheetGui area DraftUtils DraftUtils libDriver libDriverDAT libDriverSTL libDriverUNV libMEFISTO2 libSMDS libSMESH libSMESHDS libStdMeshers Measure TechDraw TechDrawGui libarea-native Surface SurfaceGui PathSimulator

# Some configuration options for other environments
# rpmbuild --with=occ:  Compile using OpenCASCADE instead of OCE
%global occ %{?_with_occ: 1} %{?!_with_occ: 0}
# rpmbuild --with=bundled_zipios:  use bundled version of zipios++
%global bundled_zipios %{?_with_bundled_zipios: 1} %{?!_with_bundled_zipios: 0}
# rpmbuild --without=bundled_pycxx:  don't use bundled version of pycxx
%global bundled_pycxx %{?_without_bundled_pycxx: 0} %{?!_without_bundled_pycxx: 1}
# rpmbuild --without=bundled_smesh:  don't use bundled version of Salome's Mesh
%global bundled_smesh %{?_without_bundled_smesh: 0} %{?!_without_bundled_smesh: 1}

# See FreeCAD-master/src/3rdParty/salomesmesh/CMakeLists.txt to find this out.
%global bundled_smesh_version 7.7.1.0

# Some plugins go in the Mod folder instead of lib. Deal with those here:
%global mod_plugins Mod/PartDesign
%define name freecad
%define github_name FreeCAD
%define branch master

Name:           %{name}
Epoch:          1
Version:    	0.19_pre
Release:        {{{ git_commits_no }}}
Summary:        A general purpose 3D CAD modeler
Group:          Applications/Engineering

License:        GPLv2+
URL:            http://sourceforge.net/apps/mediawiki/free-cad/
Source0:        https://github.com/%{github_name}/FreeCAD/archive/%{branch}.tar.gz
Patch0:		FreeCAD-external-smesh.patch

# Utilities
BuildRequires:  cmake gcc-c++ gettext dos2unix
BuildRequires:  doxygen swig graphviz
BuildRequires:  gcc-gfortran
BuildRequires:  desktop-file-utils
BuildRequires:  git

# Development Libraries

BuildRequires:  Coin3-devel
BuildRequires:  Inventor-devel
%if %{occ}
BuildRequires:  OpenCASCADE-devel
%else
BuildRequires:  OCE-devel
BuildRequires:  OCE-draw
%endif

BuildRequires:  boost-devel
BuildRequires:  boost-python3-devel
BuildRequires:  eigen3-devel
BuildRequires:  freeimage-devel
BuildRequires:  libicu-devel
BuildRequires:  libspnav-devel
BuildRequires:  med-devel
BuildRequires:  mesa-libEGL-devel
BuildRequires:  mesa-libGLU-devel
BuildRequires:  netgen-mesher-devel
BuildRequires:  netgen-mesher-devel-private
BuildRequires:  libXmu-devel
# For appdata
%if 0%{?fedora}
BuildRequires:  libappstream-glib
%endif
BuildRequires:  libkdtree++-devel
BuildRequires:  libusb-devel
BuildRequires:  python3-pivy
BuildRequires:  mesa-libEGL-devel
BuildRequires:  pcl-devel
BuildRequires:  pyside2-tools
BuildRequires:  python3
BuildRequires:  python3-devel
BuildRequires:  python3-matplotlib
%if ! %{bundled_pycxx}
BuildRequires:  python3-pycxx-devel
%endif
BuildRequires:  python3-pyside2-devel
BuildRequires:  python3-shiboken2-devel
BuildRequires:  qt5-devel
BuildRequires:  qt5-qtwebkit-devel
%if ! %{bundled_smesh}
BuildRequires:  smesh-devel
%endif
BuildRequires:  tbb-devel
BuildRequires:  vtk-devel
BuildRequires:  xerces-c
BuildRequires:  xerces-c-devel
%if ! %{bundled_zipios}
BuildRequires:  zipios++-devel
%endif
BuildRequires:  zlib-devel

# Packages separated because they are noarch, but not optional so require them
# here.
Requires:       %{name}-data = %{epoch}:%{version}-%{release}
# Obsolete old doc package since it's required for functionality.
Obsoletes:      %{name}-doc < 0.13-5

Requires:       hicolor-icon-theme
Requires:       python3-collada
Requires:       python3-matplotlib
Requires:       python3-pivy
Requires:       python3-pyside2
Requires:	qt5-assistant
%if %{bundled_smesh} 
Provides:       bundled(smesh) = %{bundled_smesh_version}
%endif
%if %{bundled_pycxx} 
Provides:       bundled(python-pycxx)
%endif
Recommends:	python3-pysolar

# plugins and private shared libs in %%{_libdir}/freecad/lib are private;
# prevent private capabilities being advertised in Provides/Requires
%define plugin_regexp /^\\\(libFreeCAD.*%(for i in %{plugins}; do echo -n "\\\|$i\\\|$iGui"; done)\\\)\\\(\\\|Gui\\\)\\.so/d
%{?filter_setup:
%filter_provides_in %{_libdir}/%{name}/lib
%filter_from_requires %{plugin_regexp}
%filter_from_provides %{plugin_regexp}
%filter_provides_in %{_libdir}/%{name}/Mod
%filter_requires_in %{_libdir}/%{name}/Mod
%filter_setup
}

%description
FreeCAD is a general purpose Open Source 3D CAD/MCAD/CAx/CAE/PLM modeler, aimed
directly at mechanical engineering and product design but also fits a wider
range of uses in engineering, such as architecture or other engineering
specialties. It is a feature-based parametric modeler with a modular software
architecture which makes it easy to provide additional functionality without
modifying the core system.


%package data
Summary:        Data files for FreeCAD
BuildArch:      noarch
Requires:       %{name} = %{epoch}:%{version}-%{release}

%description data
Data files for FreeCAD


%prep
%autosetup -p1 -n FreeCAD-%{branch}

# Remove bundled pycxx if we're not using it
%if ! %{bundled_pycxx}
rm -rf src/CXX
%endif

%if ! %{bundled_zipios}
rm -rf src/zipios++
#sed -i "s/zipios-config.h/zipios-config.hpp/g" \
#    src/Base/Reader.cpp src/Base/Writer.h
%endif

# Fix encodings
dos2unix -k src/Mod/Test/unittestgui.py \
            ChangeLog.txt \
            data/License.txt

# Removed bundled libraries

%build
rm -rf build && mkdir build && cd build

# Deal with cmake projects that tend to link excessively.
CXXFLAGS='-Wno-error=cast-function-type'; export CXXFLAGS
LDFLAGS='-Wl,--as-needed -Wl,--no-undefined'; export LDFLAGS

%if 0%{?fedora} > 27
%define MEDFILE_INCLUDE_DIRS %{_includedir}/med/
%else
%define MEDFILE_INCLUDE_DIRS %{_includedir}/
%endif

%cmake \
       -DCMAKE_INSTALL_PREFIX=%{_libdir}/%{name} \
       -DCMAKE_INSTALL_DATADIR=%{_datadir}/%{name} \
       -DCMAKE_INSTALL_DOCDIR=%{_docdir}/%{name} \
       -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir} \
       -DRESOURCEDIR=%{_datadir}/%{name} \
       -DFREECAD_USE_EXTERNAL_PIVY=TRUE \
       -DFREECAD_USE_PCL=TRUE \
       -DBUILD_QT5=ON \
       -DSHIBOKEN_INCLUDE_DIR=%{_includedir}/shiboken2 \
       -DSHIBOKEN_LIBRARY=-lshiboken2.%{py_suffix} \
       -DPYTHON_SUFFIX=.%{py_suffix} \
       -DPYSIDE_INCLUDE_DIR=/usr/include/PySide2 \
       -DPYSIDE_LIBRARY=-lpyside2.%{py_suffix} \
       -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 \
       -DMEDFILE_INCLUDE_DIRS=%{MEDFILE_INCLUDE_DIRS} \
       -DOpenGL_GL_PREFERENCE=GLVND \
       -DCOIN3D_INCLUDE_DIR=%{_includedir}/Coin3 \
       -DCOIN3D_DOC_PATH=%{_datadir}/Coin3/Coin \
       -DFREECAD_USE_EXTERNAL_PIVY=TRUE \
%if %{occ}
       -DUSE_OCC=TRUE \
%endif
%if ! %{bundled_smesh}
       -DFREECAD_USE_EXTERNAL_SMESH=TRUE \
       -DSMESH_FOUND=TRUE \
       -DSMESH_INCLUDE_DIR=%{_includedir}/smesh \
       -DSMESH_DIR=`pwd`/../cMake \
%endif
%if ! %{bundled_zipios}
       -DFREECAD_USE_EXTERNAL_ZIPIOS=TRUE \
%endif
%if ! %{bundled_pycxx}
       -DPYCXX_INCLUDE_DIR=$(pkg-config --variable=includedir PyCXX) \
       -DPYCXX_SOURCE_DIR=$(pkg-config --variable=srcdir PyCXX) \
%endif
       ../

make fc_version
sed -i 's,FCRevision      \"Unknown\",FCRevision      \"%{release} (Git)\",' src/Build/Version.h
sed -i 's,FCRepositoryURL \"Unknown\",FCRepositoryURL \"git://github.com/FreeCAD/FreeCAD.git master\",' src/Build/Version.h

make %{?_smp_mflags}

%install
cd build
%make_install

# Symlink binaries to /usr/bin
mkdir -p %{buildroot}%{_bindir}
ln -s ../%{_lib}/%{name}/bin/FreeCAD %{buildroot}%{_bindir}/FreeCAD
ln -s ../%{_lib}/%{name}/bin/FreeCADCmd %{buildroot}%{_bindir}/FreeCADCmd

mkdir %{buildroot}%{_metainfodir}/
mv %{buildroot}%{_libdir}/%{name}/share/metainfo/* %{buildroot}%{_metainfodir}/

mkdir %{buildroot}%{_datadir}/applications/
mv %{buildroot}%{_libdir}/%{name}/share/applications/* %{buildroot}%{_datadir}/applications/

mkdir -p %{buildroot}%{_datadir}/icons/hicolor/scalable/
mv %{buildroot}%{_libdir}/%{name}/share/icons/hicolor/scalable/* %{buildroot}%{_datadir}/icons/hicolor/scalable/

mkdir -p %{buildroot}%{_datadir}/pixmaps/
mv %{buildroot}%{_libdir}/%{name}/share/pixmaps/* %{buildroot}%{_datadir}/pixmaps/

mkdir -p %{buildroot}%{_datadir}/mime/packages/
mv %{buildroot}%{_libdir}/%{name}/share/mime/packages/* %{buildroot}%{_datadir}/mime/packages/

pushd %{buildroot}%{_libdir}/%{name}/share/
rmdir metainfo/
rmdir applications/
rm -rf mime
rm -rf icons
popd

# Remove obsolete Start_Page.html
rm -f %{buildroot}%{_docdir}/%{name}/Start_Page.html
# Belongs in %%license not %%doc
rm -f %{buildroot}%{_docdir}/freecad/ThirdPartyLibraries.html

# Bug maintainers to keep %%{plugins} macro up to date.
#
# Make sure there are no plugins that need to be added to plugins macro
new_plugins=`ls %{buildroot}%{_libdir}/%{name}/%{_lib} | sed -e  '%{plugin_regexp}'`
if [ -n "$new_plugins" ]; then
    echo -e "\n\n\n**** ERROR:\n" \
        "\nPlugins not caught by regexp:  " $new_plugins \
        "\n\nPlugins in %{_libdir}/%{name}/lib do not exist in" \
         "\nspecfile %%{plugins} macro.  Please add these to" \
         "\n%%{plugins} macro at top of specfile and rebuild.\n****\n" 1>&2
    exit 1
fi
# Make sure there are no entries in the plugins macro that don't match plugins
for p in %{plugins}; do
    if [ -z "`ls %{buildroot}%{_libdir}/%{name}/%{_lib}/$p*.so`" ]; then
        set +x
        echo -e "\n\n\n**** ERROR:\n" \
             "\nExtra entry in %%{plugins} macro with no matching plugin:" \
             "'$p'.\n\nPlease remove from %%{plugins} macro at top of" \
             "\nspecfile and rebuild.\n****\n" 1>&2
        exit 1
    fi
done

%check
desktop-file-validate \
    %{buildroot}%{_datadir}/applications/org.freecadweb.FreeCAD.desktop
%{?fedora:appstream-util validate-relax --nonet \
    %{buildroot}/%{_metainfodir}/*.appdata.xml}


%post
/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
/usr/bin/update-desktop-database &> /dev/null || :
/usr/bin/update-mime-database %{_datadir}/mime &> /dev/null || :

%postun
if [ $1 -eq 0 ] ; then
    /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null
    /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
fi
/usr/bin/update-desktop-database &> /dev/null || :
/usr/bin/update-mime-database %{_datadir}/mime &> /dev/null || :

%posttrans
/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor/scalable/apps &>/dev/null || :


%files
%license data/License.txt
%doc ChangeLog.txt
%exclude %{_docdir}/%{name}/%{name}.*
%exclude %{_docdir}/%{name}/ThirdPartyLibraries.html
%{_bindir}/*
%{_metainfodir}/*
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/bin/
%{_libdir}/%{name}/%{_lib}/
%{_libdir}/%{name}/Mod/
%{_libdir}/%{name}/Ext/
%{_datadir}/applications/*
%{_datadir}/icons/hicolor/scalable/*
%{_datadir}/pixmaps/*
%{_datadir}/mime/packages/*

%files data
%{_datadir}/%{name}/
%{_docdir}/%{name}/%{name}.q*
freecad-2.spec (11,464 bytes)   
freecad.spec-3.patch (12,401 bytes)   
diff -up ./freecad.spec.base ./freecad.spec
--- ./freecad.spec.base	2019-09-16 15:40:59.908156457 -0400
+++ ./freecad.spec	2019-09-18 21:38:00.973653219 -0400
@@ -1,8 +1,27 @@
+# This package depends on automagic byte compilation
+# https://fedoraproject.org/wiki/Changes/No_more_automagic_Python_bytecompilation_phase_2
+%global _python_bytecompile_extra 1
+
+# Setup python target for shiboken so the right cmake file is imported.
+%global py_suffix %(%{__python3} -c "import sysconfig; print(sysconfig.get_config_var('SOABI'))")
 
 # Maintainers:  keep this list of plugins up to date
 # List plugins in %%{_libdir}/%{name}/lib, less '.so' and 'Gui.so', here
 %global plugins Drawing Fem FreeCAD Image Import Inspection Mesh MeshPart Part Points QtUnit Raytracing ReverseEngineering Robot Sketcher Start Web PartDesignGui _PartDesign Path PathGui Spreadsheet SpreadsheetGui area DraftUtils DraftUtils libDriver libDriverDAT libDriverSTL libDriverUNV libMEFISTO2 libSMDS libSMESH libSMESHDS libStdMeshers Measure TechDraw TechDrawGui libarea-native Surface SurfaceGui PathSimulator
 
+# Some configuration options for other environments
+# rpmbuild --with=occ:  Compile using OpenCASCADE instead of OCE
+%global occ %{?_with_occ: 1} %{?!_with_occ: 0}
+# rpmbuild --with=bundled_zipios:  use bundled version of zipios++
+%global bundled_zipios %{?_with_bundled_zipios: 1} %{?!_with_bundled_zipios: 0}
+# rpmbuild --without=bundled_pycxx:  don't use bundled version of pycxx
+%global bundled_pycxx %{?_without_bundled_pycxx: 0} %{?!_without_bundled_pycxx: 1}
+# rpmbuild --without=bundled_smesh:  don't use bundled version of Salome's Mesh
+%global bundled_smesh %{?_without_bundled_smesh: 0} %{?!_without_bundled_smesh: 1}
+
+# See FreeCAD-master/src/3rdParty/salomesmesh/CMakeLists.txt to find this out.
+%global bundled_smesh_version 7.7.1.0
+
 # Some plugins go in the Mod folder instead of lib. Deal with those here:
 %global mod_plugins Mod/PartDesign
 %define name freecad
@@ -19,65 +38,69 @@ Group:          Applications/Engineering
 License:        GPLv2+
 URL:            http://sourceforge.net/apps/mediawiki/free-cad/
 Source0:        https://github.com/%{github_name}/FreeCAD/archive/%{branch}.tar.gz
+Patch0:		FreeCAD-external-smesh.patch
+
+# Utilities
+BuildRequires:  cmake gcc-c++ gettext dos2unix
+BuildRequires:  doxygen swig graphviz
+BuildRequires:  gcc-gfortran
+BuildRequires:  desktop-file-utils
+BuildRequires:  git
+
+# Development Libraries
 
-BuildRequires:  Coin3
 BuildRequires:  Coin3-devel
 BuildRequires:  Inventor-devel
+%if %{occ}
+BuildRequires:  OpenCASCADE-devel
+%else
 BuildRequires:  OCE-devel
 BuildRequires:  OCE-draw
+%endif
+
 BuildRequires:  boost-devel
-BuildRequires:  cmake
-BuildRequires:  desktop-file-utils
-BuildRequires:  dos2unix
-BuildRequires:  doxygen
-BuildRequires:  eigen3
+BuildRequires:  boost-python3-devel
 BuildRequires:  eigen3-devel
 BuildRequires:  freeimage-devel
-BuildRequires:  gettext
-BuildRequires:  git
-BuildRequires:  graphviz
 BuildRequires:  libicu-devel
-BuildRequires:  libspnav
 BuildRequires:  libspnav-devel
-BuildRequires:  med
 BuildRequires:  med-devel
+BuildRequires:  mesa-libEGL-devel
 BuildRequires:  mesa-libGLU-devel
 BuildRequires:  netgen-mesher-devel
 BuildRequires:  netgen-mesher-devel-private
-BuildRequires:  pyside-tools
-BuildRequires:  python
-BuildRequires:  python-matplotlib
-%if 0%{?fedora} < 30
-BuildRequires:  python-pivy
-%endif
-BuildRequires:  python-pyside
-BuildRequires:  python-pyside-devel
-BuildRequires:  python2-devel
-BuildRequires:  qt-devel
-BuildRequires:  qt-webkit-devel
-BuildRequires:  shiboken
-BuildRequires:  shiboken-devel
-BuildRequires:  smesh
+BuildRequires:  libXmu-devel
+# For appdata
+%if 0%{?fedora}
+BuildRequires:  libappstream-glib
+%endif
+BuildRequires:  libkdtree++-devel
+BuildRequires:  libusb-devel
+BuildRequires:  python3-pivy
+BuildRequires:  mesa-libEGL-devel
+BuildRequires:  pcl-devel
+BuildRequires:  pyside2-tools
+BuildRequires:  python3
+BuildRequires:  python3-devel
+BuildRequires:  python3-matplotlib
+%if ! %{bundled_pycxx}
+BuildRequires:  python3-pycxx-devel
+%endif
+BuildRequires:  python3-pyside2-devel
+BuildRequires:  python3-shiboken2-devel
+BuildRequires:  qt5-devel
+BuildRequires:  qt5-qtwebkit-devel
+%if ! %{bundled_smesh}
 BuildRequires:  smesh-devel
-BuildRequires:  swig
+%endif
 BuildRequires:  tbb-devel
 BuildRequires:  vtk-devel
 BuildRequires:  xerces-c
 BuildRequires:  xerces-c-devel
-BuildRequires:  zlib-devel
-%if 0%{?fedora} > 28
-BuildRequires:  boost-python2
-BuildRequires:  boost-python2-devel
-BuildRequires:  boost-python3
-BuildRequires:  boost-python3-devel
-BuildRequires:  mesa-libEGL-devel
-BuildRequires:  python3-matplotlib
-%endif
-
-# For appdata
-%if 0%{?fedora}
-BuildRequires:  libappstream-glib
+%if ! %{bundled_zipios}
+BuildRequires:  zipios++-devel
 %endif
+BuildRequires:  zlib-devel
 
 # Packages separated because they are noarch, but not optional so require them
 # here.
@@ -85,15 +108,19 @@ Requires:       %{name}-data = %{epoch}:
 # Obsolete old doc package since it's required for functionality.
 Obsoletes:      %{name}-doc < 0.13-5
 
-# Needed for plugin support and is not a soname dependency.
-%if ! 0%{?rhel} <= 6 && "%{_arch}" != "ppc64"
-# python-pivy does not build on EPEL 6 ppc64.
-Requires:       python-pivy
-%endif
 Requires:       hicolor-icon-theme
-Requires:       python-matplotlib
-Requires:       python-collada
-Requires:       python-pyside
+Requires:       python3-collada
+Requires:       python3-matplotlib
+Requires:       python3-pivy
+Requires:       python3-pyside2
+Requires:	qt5-assistant
+%if %{bundled_smesh} 
+Provides:       bundled(smesh) = %{bundled_smesh_version}
+%endif
+%if %{bundled_pycxx} 
+Provides:       bundled(python-pycxx)
+%endif
+Recommends:	python3-pysolar
 
 # plugins and private shared libs in %%{_libdir}/freecad/lib are private;
 # prevent private capabilities being advertised in Provides/Requires
@@ -107,7 +134,6 @@ Requires:       python-pyside
 %filter_setup
 }
 
-
 %description
 FreeCAD is a general purpose Open Source 3D CAD/MCAD/CAx/CAE/PLM modeler, aimed
 directly at mechanical engineering and product design but also fits a wider
@@ -127,7 +153,18 @@ Data files for FreeCAD
 
 
 %prep
-%autosetup -n FreeCAD-%{branch}
+%autosetup -p1 -n FreeCAD-%{branch}
+
+# Remove bundled pycxx if we're not using it
+%if ! %{bundled_pycxx}
+rm -rf src/CXX
+%endif
+
+%if ! %{bundled_zipios}
+rm -rf src/zipios++
+#sed -i "s/zipios-config.h/zipios-config.hpp/g" \
+#    src/Base/Reader.cpp src/Base/Writer.h
+%endif
 
 # Fix encodings
 dos2unix -k src/Mod/Test/unittestgui.py \
@@ -140,7 +177,8 @@ dos2unix -k src/Mod/Test/unittestgui.py
 rm -rf build && mkdir build && cd build
 
 # Deal with cmake projects that tend to link excessively.
-#LDFLAGS='-Wl,--as-needed'; export LDFLAGS
+CXXFLAGS='-Wno-error=cast-function-type'; export CXXFLAGS
+LDFLAGS='-Wl,--as-needed -Wl,--no-undefined'; export LDFLAGS
 
 %if 0%{?fedora} > 27
 %define MEDFILE_INCLUDE_DIRS %{_includedir}/med/
@@ -148,15 +186,45 @@ rm -rf build && mkdir build && cd build
 %define MEDFILE_INCLUDE_DIRS %{_includedir}/
 %endif
 
-%cmake -DCMAKE_INSTALL_PREFIX=%{_libdir}/%{name} \
+%cmake \
+       -DCMAKE_INSTALL_PREFIX=%{_libdir}/%{name} \
        -DCMAKE_INSTALL_DATADIR=%{_datadir}/%{name} \
        -DCMAKE_INSTALL_DOCDIR=%{_docdir}/%{name} \
        -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir} \
        -DRESOURCEDIR=%{_datadir}/%{name} \
        -DFREECAD_USE_EXTERNAL_PIVY=TRUE \
+       -DFREECAD_USE_PCL=TRUE \
+       -DBUILD_QT5=ON \
+       -DSHIBOKEN_INCLUDE_DIR=%{_includedir}/shiboken2 \
+       -DSHIBOKEN_LIBRARY=-lshiboken2.%{py_suffix} \
+       -DPYTHON_SUFFIX=.%{py_suffix} \
+       -DPYSIDE_INCLUDE_DIR=/usr/include/PySide2 \
+       -DPYSIDE_LIBRARY=-lpyside2.%{py_suffix} \
+       -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 \
        -DMEDFILE_INCLUDE_DIRS=%{MEDFILE_INCLUDE_DIRS} \
+       -DOpenGL_GL_PREFERENCE=GLVND \
+       -DCOIN3D_INCLUDE_DIR=%{_includedir}/Coin3 \
+       -DCOIN3D_DOC_PATH=%{_datadir}/Coin3/Coin \
+       -DFREECAD_USE_EXTERNAL_PIVY=TRUE \
+%if %{occ}
+       -DUSE_OCC=TRUE \
+%endif
+%if ! %{bundled_smesh}
+       -DFREECAD_USE_EXTERNAL_SMESH=TRUE \
+       -DSMESH_FOUND=TRUE \
+       -DSMESH_INCLUDE_DIR=%{_includedir}/smesh \
+       -DSMESH_DIR=`pwd`/../cMake \
+%endif
+%if ! %{bundled_zipios}
+       -DFREECAD_USE_EXTERNAL_ZIPIOS=TRUE \
+%endif
+%if ! %{bundled_pycxx}
+       -DPYCXX_INCLUDE_DIR=$(pkg-config --variable=includedir PyCXX) \
+       -DPYCXX_SOURCE_DIR=$(pkg-config --variable=srcdir PyCXX) \
+%endif
        ../
 
+make fc_version
 sed -i 's,FCRevision      \"Unknown\",FCRevision      \"%{release} (Git)\",' src/Build/Version.h
 sed -i 's,FCRepositoryURL \"Unknown\",FCRepositoryURL \"git://github.com/FreeCAD/FreeCAD.git master\",' src/Build/Version.h
 
@@ -168,19 +236,20 @@ cd build
 
 # Symlink binaries to /usr/bin
 mkdir -p %{buildroot}%{_bindir}
-pushd %{buildroot}%{_bindir}
-ln -s ../%{_lib}/%{name}/bin/FreeCAD .
-ln -s ../%{_lib}/%{name}/bin/FreeCADCmd .
-popd
+ln -s ../%{_lib}/%{name}/bin/FreeCAD %{buildroot}%{_bindir}/FreeCAD
+ln -s ../%{_lib}/%{name}/bin/FreeCADCmd %{buildroot}%{_bindir}/FreeCADCmd
 
-mkdir %{buildroot}%{_datadir}/appdata/
-mv %{buildroot}%{_libdir}/%{name}/share/metainfo/* %{buildroot}%{_datadir}/appdata/
+mkdir %{buildroot}%{_metainfodir}/
+mv %{buildroot}%{_libdir}/%{name}/share/metainfo/* %{buildroot}%{_metainfodir}/
 
 mkdir %{buildroot}%{_datadir}/applications/
 mv %{buildroot}%{_libdir}/%{name}/share/applications/* %{buildroot}%{_datadir}/applications/
 
-mkdir -p %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/
-mv %{buildroot}%{_libdir}/%{name}/share/icons/hicolor/scalable/apps/* %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/
+mkdir -p %{buildroot}%{_datadir}/icons/hicolor/scalable/
+mv %{buildroot}%{_libdir}/%{name}/share/icons/hicolor/scalable/* %{buildroot}%{_datadir}/icons/hicolor/scalable/
+
+mkdir -p %{buildroot}%{_datadir}/pixmaps/
+mv %{buildroot}%{_libdir}/%{name}/share/pixmaps/* %{buildroot}%{_datadir}/pixmaps/
 
 mkdir -p %{buildroot}%{_datadir}/mime/packages/
 mv %{buildroot}%{_libdir}/%{name}/share/mime/packages/* %{buildroot}%{_datadir}/mime/packages/
@@ -188,14 +257,19 @@ mv %{buildroot}%{_libdir}/%{name}/share/
 pushd %{buildroot}%{_libdir}/%{name}/share/
 rmdir metainfo/
 rmdir applications/
-rmdir -p mime/packages/
-rmdir -p icons/hicolor/scalable/apps/
+rm -rf mime
+rm -rf icons
 popd
 
+# Remove obsolete Start_Page.html
+rm -f %{buildroot}%{_docdir}/%{name}/Start_Page.html
+# Belongs in %%license not %%doc
+rm -f %{buildroot}%{_docdir}/freecad/ThirdPartyLibraries.html
+
 # Bug maintainers to keep %%{plugins} macro up to date.
 #
 # Make sure there are no plugins that need to be added to plugins macro
-new_plugins=`ls %{buildroot}%{_libdir}/%{name}/lib | sed -e  '%{plugin_regexp}'`
+new_plugins=`ls %{buildroot}%{_libdir}/%{name}/%{_lib} | sed -e  '%{plugin_regexp}'`
 if [ -n "$new_plugins" ]; then
     echo -e "\n\n\n**** ERROR:\n" \
         "\nPlugins not caught by regexp:  " $new_plugins \
@@ -206,7 +280,7 @@ if [ -n "$new_plugins" ]; then
 fi
 # Make sure there are no entries in the plugins macro that don't match plugins
 for p in %{plugins}; do
-    if [ -z "`ls %{buildroot}%{_libdir}/%{name}/lib/$p*.so`" ]; then
+    if [ -z "`ls %{buildroot}%{_libdir}/%{name}/%{_lib}/$p*.so`" ]; then
         set +x
         echo -e "\n\n\n**** ERROR:\n" \
              "\nExtra entry in %%{plugins} macro with no matching plugin:" \
@@ -217,8 +291,10 @@ for p in %{plugins}; do
 done
 
 %check
+desktop-file-validate \
+    %{buildroot}%{_datadir}/applications/org.freecadweb.FreeCAD.desktop
 %{?fedora:appstream-util validate-relax --nonet \
-    %{buildroot}/%{_datadir}/appdata/*.appdata.xml}
+    %{buildroot}/%{_metainfodir}/*.appdata.xml}
 
 
 %post
@@ -244,14 +320,15 @@ fi
 %exclude %{_docdir}/%{name}/%{name}.*
 %exclude %{_docdir}/%{name}/ThirdPartyLibraries.html
 %{_bindir}/*
+%{_metainfodir}/*
 %dir %{_libdir}/%{name}
 %{_libdir}/%{name}/bin/
-%{_libdir}/%{name}/lib/
+%{_libdir}/%{name}/%{_lib}/
 %{_libdir}/%{name}/Mod/
 %{_libdir}/%{name}/Ext/
 %{_datadir}/applications/*
-%{_datadir}/icons/hicolor/scalable/apps/*
-%{_datadir}/appdata/*
+%{_datadir}/icons/hicolor/scalable/*
+%{_datadir}/pixmaps/*
 %{_datadir}/mime/packages/*
 
 %files data
freecad.spec-3.patch (12,401 bytes)   

pfirszt

2019-09-19 07:28

developer   ~0013642

What should be licence in the spec (GPL vs LGPL)? See the vocx-fc comment to my PR [1]

[1] https://github.com/FreeCAD/FreeCAD/pull/2534

pfirszt

2019-09-19 08:26

developer   ~0013643

@sopwith: what's in FreeCAD-external-smesh.patch ? I tried your spec as-is with COPR, but it failed on missing patch.

sopwith

2019-09-19 11:54

reporter   ~0013644

@pfirszt - vocx-fc is correct about the license being LGPLv2+.

Sorry about the missing patch (attached). It was necessary to get FreeCAD to even pay attention to an external smesh when configuring.
FreeCAD-external-smesh.patch (650 bytes)   
diff -up FreeCAD-master/CMakeLists.txt.sopwith FreeCAD-master/CMakeLists.txt
--- FreeCAD-master/CMakeLists.txt.sopwith	2019-09-18 15:51:53.411979083 -0400
+++ FreeCAD-master/CMakeLists.txt	2019-09-18 15:52:06.835864739 -0400
@@ -781,7 +781,7 @@ if(NOT FREECAD_LIBPACK_USE OR FREECAD_LI
             set(SMESH_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/3rdParty/salomesmesh/inc)
 
         else(NOT FREECAD_USE_EXTERNAL_SMESH)
-            find_package(SMESH CONFIG)
+            find_package(SMESH REQUIRED)
             set (SMESH_INCLUDE_DIR ${SMESH_INCLUDE_PATH})
             set(EXTERNAL_SMESH_LIBS ${SMESH_LIBRARIES})
             if(NOT SMESH_FOUND)

pfirszt

2019-09-19 12:47

developer   ~0013645

Last edited: 2019-09-19 12:48

Thanks! Test build went OK after commenting out the patch, but there is a problem with version. We have "make fc_version" (I'm not yet familiar with it) and the 2 sed commands, but the final info is:
$ /usr/bin/FreeCAD
FreeCAD 0.19, Libs: 0.19RUnknown
© Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2019
and
OS: Fedora 30 (Workstation Edition) (GNOME/gnome)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.Unknown
Build type: Unknown
Python version: 3.7.4
Qt version: 5.12.4
Coin version: 3.1.3
OCC version: 6.9.1.oce-0.18
Locale: Polish/Poland (pl_PL)

P.S. Tentative link to the test build: https://copr.fedorainfracloud.org/coprs/g/freecad/przemof-test-from-github/build/1035874/

hobbes1069

2019-09-19 14:55

reporter   ~0013647

Ok, let me know if I should open a separate bug or if you guys are OK with handling this here...

I've made some progress but now I'm getting a bunch of linker errors:

BUILDSTDERR: /builddir/build/BUILD/FreeCAD-0.18.3/src/Gui/View3DInventorViewer.cpp:1642: undefined reference to `glDisable'
BUILDSTDERR: /usr/bin/ld: /builddir/build/BUILD/FreeCAD-0.18.3/src/Gui/View3DInventorViewer.cpp:1643: undefined reference to `glViewport'
BUILDSTDERR: /usr/bin/ld: /builddir/build/BUILD/FreeCAD-0.18.3/src/Gui/View3DInventorViewer.cpp:1644: undefined reference to `glMatrixMode'
BUILDSTDERR: /usr/bin/ld: /builddir/build/BUILD/FreeCAD-0.18.3/src/Gui/View3DInventorViewer.cpp:1645: undefined reference to `glLoadIdentity'
BUILDSTDERR: /usr/bin/ld: /builddir/build/BUILD/FreeCAD-0.18.3/src/Gui/View3DInventorViewer.cpp:1646: undefined reference to `glMatrixMode'
BUILDSTDERR: /usr/bin/ld: /builddir/build/BUILD/FreeCAD-0.18.3/src/Gui/View3DInventorViewer.cpp:1647: undefined reference to `glLoadIdentity'
BUILDSTDERR: /usr/bin/ld: /builddir/build/BUILD/FreeCAD-0.18.3/src/Gui/View3DInventorViewer.cpp:1648: undefined reference to `glDisable'
BUILDSTDERR: /usr/bin/ld: /builddir/build/BUILD/FreeCAD-0.18.3/src/Gui/View3DInventorViewer.cpp:1650: undefined reference to `glClear'
BUILDSTDERR: /usr/bin/ld: /builddir/build/BUILD/FreeCAD-0.18.3/src/Gui/View3DInventorViewer.cpp:1651: undefined reference to `glEnable'
BUILDSTDERR: /usr/bin/ld: /builddir/build/BUILD/FreeCAD-0.18.3/src/Gui/View3DInventorViewer.cpp:1652: undefined reference to `glBindTexture'
BUILDSTDERR: /usr/bin/ld: /builddir/build/BUILD/FreeCAD-0.18.3/src/Gui/View3DInventorViewer.cpp:1653: undefined reference to `glColor3f'
BUILDSTDERR: /usr/bin/ld: /builddir/build/BUILD/FreeCAD-0.18.3/src/Gui/View3DInventorViewer.cpp:1655: undefined reference to `glBegin'
BUILDSTDERR: /usr/bin/ld: /builddir/build/BUILD/FreeCAD-0.18.3/src/Gui/View3DInventorViewer.cpp:1656: undefined reference to `glTexCoord2f'

And the only problem I can find during the CMake configuration is it's computing the shiboken2 include dir wrong...


-- Shiboken2Config: Using default python: .cpython-37m-x86_64-linux-gnu
-- SHIBOKEN_PYTHON_INCLUDE_DIRS computed to value: '/usr/include/python3.7m'
-- SHIBOKEN_PYTHON_LIBRARIES computed to value: ''
-- libshiboken built for Release

Ideas?

sopwith

2019-09-19 15:17

reporter   ~0013648

@pfirszt - I added 'make fc_version' there because the Version.h used by the sed commands didn't exist otherwise. The sed commands are supposed to fix it up. If Version.h is not coming out right at the end of the build, either the sed commands are not doing their job or Version.h is being overwritten during the main 'make' run.

@hobbes1069 - SHIBOKEN_PYTHON_INCLUDE_DIRS is correct - it's supposed to be the path to the Python headers not the Shiboken2 headers. The cmake line in the .spec file passes in SHIBOKEN_INCLUDE_DIR correctly.

As far as the missing symbols, they are all part of libGL.so. I think the .spec file might need to add 'BuildRequires: libglvnd-devel'.

sopwith

2019-09-19 16:22

reporter   ~0013651

@pfirszt Here is an updated .spec file to fix the Version.h stuff, along with a necessary patch to the source tree. Basically there was a bug in src/Tools/SubWCRev.py when build directory != source directory.

I also fixed a couple of other things in the .spec file - utilized the %make_build macro, added BuildRequires: libglvnd-devel, and updating the package URL: away from sourceforge.
FreeCAD-SubWCRev.patch (3,163 bytes)   
diff -up FreeCAD-master/src/Tools/SubWCRev.py.sopwith FreeCAD-master/src/Tools/SubWCRev.py
--- FreeCAD-master/src/Tools/SubWCRev.py.sopwith	2019-09-19 12:10:08.041461628 -0400
+++ FreeCAD-master/src/Tools/SubWCRev.py	2019-09-19 12:12:41.058155371 -0400
@@ -56,7 +56,7 @@ class VersionControl:
         self.date = ""
         self.url = ""
 
-    def extractInfo(self, srcdir):
+    def extractInfo(self, srcdir, bindir):
         return False
 
     def printInfo(self):
@@ -72,9 +72,9 @@ class VersionControl:
         return content
 
 class UnknownControl(VersionControl):
-    def extractInfo(self, srcdir):
+    def extractInfo(self, srcdir, bindir):
         # Do not overwrite existing file with almost useless information
-        if os.path.exists(srcdir+"/src/Build/Version.h.out"):
+        if os.path.exists(bindir+"/src/Build/Version.h.out"):
             return False
         self.rev = "Unknown"
         self.date = "Unknown"
@@ -85,9 +85,9 @@ class UnknownControl(VersionControl):
         print("Unknown version control")
 
 class DebianChangelog(VersionControl):
-    def extractInfo(self, srcdir):
+    def extractInfo(self, srcdir, bindir):
         # Do not overwrite existing file with almost useless information
-        if os.path.exists(srcdir+"/src/Build/Version.h.out"):
+        if os.path.exists(bindir+"/src/Build/Version.h.out"):
             return False
         try:
             f = open(srcdir+"/debian/changelog")
@@ -108,7 +108,7 @@ class DebianChangelog(VersionControl):
         print("debian/changelog")
 
 class BazaarControl(VersionControl):
-    def extractInfo(self, srcdir):
+    def extractInfo(self, srcdir, bindir):
         info=os.popen("bzr log -l 1 %s" % (srcdir)).read()
         if len(info) == 0:
             return False
@@ -232,7 +232,7 @@ class GitControl(VersionControl):
             if hasnames >=2: # merging master into dev is not enough
                 self.branch=','.join(names)
 
-    def extractInfo(self, srcdir):
+    def extractInfo(self, srcdir, bindir):
         self.hash=os.popen("git log -1 --pretty=format:%H").read().strip()
         if self.hash == "":
             return False # not a git repo
@@ -294,14 +294,14 @@ class GitControl(VersionControl):
         return content
 
 class MercurialControl(VersionControl):
-    def extractInfo(self, srcdir):
+    def extractInfo(self, srcdir, bindir):
         return False
 
     def printInfo(self):
         print("mercurial")
 
 class Subversion(VersionControl):
-    def extractInfo(self, srcdir):
+    def extractInfo(self, srcdir, bindir):
         parser=xml.sax.make_parser()
         handler=SvnHandler()
         parser.setContentHandler(handler)
@@ -376,7 +376,7 @@ def main():
 
     vcs=[GitControl(), BazaarControl(), Subversion(), MercurialControl(), DebianChangelog(), UnknownControl()]
     for i in vcs:
-        if i.extractInfo(srcdir):
+        if i.extractInfo(srcdir, bindir):
             # Open the template file and the version file
             inp = open("%s/src/Build/Version.h.in" % (bindir))
             lines = inp.readlines()
FreeCAD-SubWCRev.patch (3,163 bytes)   
freecad-3.spec (11,651 bytes)   
# This package depends on automagic byte compilation
# https://fedoraproject.org/wiki/Changes/No_more_automagic_Python_bytecompilation_phase_2
%global _python_bytecompile_extra 1

# Setup python target for shiboken so the right cmake file is imported.
%global py_suffix %(%{__python3} -c "import sysconfig; print(sysconfig.get_config_var('SOABI'))")

# Maintainers:  keep this list of plugins up to date
# List plugins in %%{_libdir}/%{name}/lib, less '.so' and 'Gui.so', here
%global plugins Drawing Fem FreeCAD Image Import Inspection Mesh MeshPart Part Points QtUnit Raytracing ReverseEngineering Robot Sketcher Start Web PartDesignGui _PartDesign Path PathGui Spreadsheet SpreadsheetGui area DraftUtils DraftUtils libDriver libDriverDAT libDriverSTL libDriverUNV libMEFISTO2 libSMDS libSMESH libSMESHDS libStdMeshers Measure TechDraw TechDrawGui libarea-native Surface SurfaceGui PathSimulator

# Some configuration options for other environments
# rpmbuild --with=occ:  Compile using OpenCASCADE instead of OCE
%global occ %{?_with_occ: 1} %{?!_with_occ: 0}
# rpmbuild --with=bundled_zipios:  use bundled version of zipios++
%global bundled_zipios %{?_with_bundled_zipios: 1} %{?!_with_bundled_zipios: 0}
# rpmbuild --without=bundled_pycxx:  don't use bundled version of pycxx
%global bundled_pycxx %{?_without_bundled_pycxx: 0} %{?!_without_bundled_pycxx: 1}
# rpmbuild --without=bundled_smesh:  don't use bundled version of Salome's Mesh
%global bundled_smesh %{?_without_bundled_smesh: 0} %{?!_without_bundled_smesh: 1}

# See FreeCAD-master/src/3rdParty/salomesmesh/CMakeLists.txt to find this out.
%global bundled_smesh_version 7.7.1.0

# Some plugins go in the Mod folder instead of lib. Deal with those here:
%global mod_plugins Mod/PartDesign
%define name freecad
%define github_name FreeCAD
%define branch master

Name:           %{name}
Epoch:          1
Version:    	0.19_pre
Release:        {{{ git_commit_nos }}}
Summary:        A general purpose 3D CAD modeler
Group:          Applications/Engineering

License:        GPLv2+
URL:            http://www.freecadweb.org/
Source0:        https://github.com/%{github_name}/FreeCAD/archive/%{branch}.tar.gz
Patch0:		FreeCAD-external-smesh.patch
Patch1:		FreeCAD-SubWCRev.patch

# Utilities
BuildRequires:  cmake gcc-c++ gettext dos2unix
BuildRequires:  doxygen swig graphviz
BuildRequires:  gcc-gfortran
BuildRequires:  desktop-file-utils
BuildRequires:  git

# Development Libraries

BuildRequires:  Coin3-devel
BuildRequires:  Inventor-devel
%if %{occ}
BuildRequires:  OpenCASCADE-devel
%else
BuildRequires:  OCE-devel
BuildRequires:  OCE-draw
%endif

BuildRequires:  boost-devel
BuildRequires:  boost-python3-devel
BuildRequires:  eigen3-devel
BuildRequires:  freeimage-devel
BuildRequires:  libXmu-devel
# For appdata
%if 0%{?fedora}
BuildRequires:  libappstream-glib
%endif
BuildRequires:  libglvnd-devel
BuildRequires:  libicu-devel
BuildRequires:  libkdtree++-devel
BuildRequires:  libspnav-devel
BuildRequires:  libusb-devel
BuildRequires:  med-devel
BuildRequires:  mesa-libEGL-devel
BuildRequires:  mesa-libGLU-devel
BuildRequires:  netgen-mesher-devel
BuildRequires:  netgen-mesher-devel-private
BuildRequires:  python3-pivy
BuildRequires:  mesa-libEGL-devel
BuildRequires:  pcl-devel
BuildRequires:  pyside2-tools
BuildRequires:  python3
BuildRequires:  python3-devel
BuildRequires:  python3-matplotlib
%if ! %{bundled_pycxx}
BuildRequires:  python3-pycxx-devel
%endif
BuildRequires:  python3-pyside2-devel
BuildRequires:  python3-shiboken2-devel
BuildRequires:  qt5-devel
BuildRequires:  qt5-qtwebkit-devel
%if ! %{bundled_smesh}
BuildRequires:  smesh-devel
%endif
BuildRequires:  tbb-devel
BuildRequires:  vtk-devel
BuildRequires:  xerces-c
BuildRequires:  xerces-c-devel
%if ! %{bundled_zipios}
BuildRequires:  zipios++-devel
%endif
BuildRequires:  zlib-devel

# Packages separated because they are noarch, but not optional so require them
# here.
Requires:       %{name}-data = %{epoch}:%{version}-%{release}
# Obsolete old doc package since it's required for functionality.
Obsoletes:      %{name}-doc < 0.13-5

Requires:       hicolor-icon-theme
Requires:       python3-collada
Requires:       python3-matplotlib
Requires:       python3-pivy
Requires:       python3-pyside2
Requires:	qt5-assistant
%if %{bundled_smesh} 
Provides:       bundled(smesh) = %{bundled_smesh_version}
%endif
%if %{bundled_pycxx} 
Provides:       bundled(python-pycxx)
%endif
Recommends:	python3-pysolar

# plugins and private shared libs in %%{_libdir}/freecad/lib are private;
# prevent private capabilities being advertised in Provides/Requires
%define plugin_regexp /^\\\(libFreeCAD.*%(for i in %{plugins}; do echo -n "\\\|$i\\\|$iGui"; done)\\\)\\\(\\\|Gui\\\)\\.so/d
%{?filter_setup:
%filter_provides_in %{_libdir}/%{name}/lib
%filter_from_requires %{plugin_regexp}
%filter_from_provides %{plugin_regexp}
%filter_provides_in %{_libdir}/%{name}/Mod
%filter_requires_in %{_libdir}/%{name}/Mod
%filter_setup
}

%description
FreeCAD is a general purpose Open Source 3D CAD/MCAD/CAx/CAE/PLM modeler, aimed
directly at mechanical engineering and product design but also fits a wider
range of uses in engineering, such as architecture or other engineering
specialties. It is a feature-based parametric modeler with a modular software
architecture which makes it easy to provide additional functionality without
modifying the core system.


%package data
Summary:        Data files for FreeCAD
BuildArch:      noarch
Requires:       %{name} = %{epoch}:%{version}-%{release}

%description data
Data files for FreeCAD


%prep
%autosetup -p1 -n FreeCAD-%{branch}

# Remove bundled pycxx if we're not using it
%if ! %{bundled_pycxx}
rm -rf src/CXX
%endif

%if ! %{bundled_zipios}
rm -rf src/zipios++
#sed -i "s/zipios-config.h/zipios-config.hpp/g" \
#    src/Base/Reader.cpp src/Base/Writer.h
%endif

# Fix encodings
dos2unix -k src/Mod/Test/unittestgui.py \
            ChangeLog.txt \
            data/License.txt

# Removed bundled libraries

%build
rm -rf build && mkdir build && cd build

# Deal with cmake projects that tend to link excessively.
CXXFLAGS='-Wno-error=cast-function-type'; export CXXFLAGS
LDFLAGS='-Wl,--as-needed -Wl,--no-undefined'; export LDFLAGS

%if 0%{?fedora} > 27
%define MEDFILE_INCLUDE_DIRS %{_includedir}/med/
%else
%define MEDFILE_INCLUDE_DIRS %{_includedir}/
%endif

%cmake \
       -DCMAKE_INSTALL_PREFIX=%{_libdir}/%{name} \
       -DCMAKE_INSTALL_DATADIR=%{_datadir}/%{name} \
       -DCMAKE_INSTALL_DOCDIR=%{_docdir}/%{name} \
       -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir} \
       -DRESOURCEDIR=%{_datadir}/%{name} \
       -DFREECAD_USE_EXTERNAL_PIVY=TRUE \
       -DFREECAD_USE_PCL=TRUE \
       -DBUILD_QT5=ON \
       -DSHIBOKEN_INCLUDE_DIR=%{_includedir}/shiboken2 \
       -DSHIBOKEN_LIBRARY=-lshiboken2.%{py_suffix} \
       -DPYTHON_SUFFIX=.%{py_suffix} \
       -DPYSIDE_INCLUDE_DIR=/usr/include/PySide2 \
       -DPYSIDE_LIBRARY=-lpyside2.%{py_suffix} \
       -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 \
       -DMEDFILE_INCLUDE_DIRS=%{MEDFILE_INCLUDE_DIRS} \
       -DOpenGL_GL_PREFERENCE=GLVND \
       -DCOIN3D_INCLUDE_DIR=%{_includedir}/Coin3 \
       -DCOIN3D_DOC_PATH=%{_datadir}/Coin3/Coin \
       -DFREECAD_USE_EXTERNAL_PIVY=TRUE \
%if %{occ}
       -DUSE_OCC=TRUE \
%endif
%if ! %{bundled_smesh}
       -DFREECAD_USE_EXTERNAL_SMESH=TRUE \
       -DSMESH_FOUND=TRUE \
       -DSMESH_INCLUDE_DIR=%{_includedir}/smesh \
       -DSMESH_DIR=`pwd`/../cMake \
%endif
%if ! %{bundled_zipios}
       -DFREECAD_USE_EXTERNAL_ZIPIOS=TRUE \
%endif
%if ! %{bundled_pycxx}
       -DPYCXX_INCLUDE_DIR=$(pkg-config --variable=includedir PyCXX) \
       -DPYCXX_SOURCE_DIR=$(pkg-config --variable=srcdir PyCXX) \
%endif
       -DPACKAGE_WCREF="%{release} (Git)" \
       -DPACKAGE_WCURL="git://github.com/%{github_name}/FreeCAD.git master" \
       ../

make fc_version
for I in src/Build/Version.h src/Build/Version.h.out; do
	sed -i 's,FCRevision      \"Unknown\",FCRevision      \"%{release} (Git)\",' $I
	sed -i 's,FCRepositoryURL \"Unknown\",FCRepositoryURL \"git://github.com/FreeCAD/FreeCAD.git master\",' $I
done

%{make_build}

%install
cd build
%make_install

# Symlink binaries to /usr/bin
mkdir -p %{buildroot}%{_bindir}
ln -s ../%{_lib}/%{name}/bin/FreeCAD %{buildroot}%{_bindir}/FreeCAD
ln -s ../%{_lib}/%{name}/bin/FreeCADCmd %{buildroot}%{_bindir}/FreeCADCmd

mkdir %{buildroot}%{_metainfodir}/
mv %{buildroot}%{_libdir}/%{name}/share/metainfo/* %{buildroot}%{_metainfodir}/

mkdir %{buildroot}%{_datadir}/applications/
mv %{buildroot}%{_libdir}/%{name}/share/applications/* %{buildroot}%{_datadir}/applications/

mkdir -p %{buildroot}%{_datadir}/icons/hicolor/scalable/
mv %{buildroot}%{_libdir}/%{name}/share/icons/hicolor/scalable/* %{buildroot}%{_datadir}/icons/hicolor/scalable/

mkdir -p %{buildroot}%{_datadir}/pixmaps/
mv %{buildroot}%{_libdir}/%{name}/share/pixmaps/* %{buildroot}%{_datadir}/pixmaps/

mkdir -p %{buildroot}%{_datadir}/mime/packages/
mv %{buildroot}%{_libdir}/%{name}/share/mime/packages/* %{buildroot}%{_datadir}/mime/packages/

pushd %{buildroot}%{_libdir}/%{name}/share/
rmdir metainfo/
rmdir applications/
rm -rf mime
rm -rf icons
popd

# Remove obsolete Start_Page.html
rm -f %{buildroot}%{_docdir}/%{name}/Start_Page.html
# Belongs in %%license not %%doc
rm -f %{buildroot}%{_docdir}/freecad/ThirdPartyLibraries.html

# Bug maintainers to keep %%{plugins} macro up to date.
#
# Make sure there are no plugins that need to be added to plugins macro
new_plugins=`ls %{buildroot}%{_libdir}/%{name}/%{_lib} | sed -e  '%{plugin_regexp}'`
if [ -n "$new_plugins" ]; then
    echo -e "\n\n\n**** ERROR:\n" \
        "\nPlugins not caught by regexp:  " $new_plugins \
        "\n\nPlugins in %{_libdir}/%{name}/lib do not exist in" \
         "\nspecfile %%{plugins} macro.  Please add these to" \
         "\n%%{plugins} macro at top of specfile and rebuild.\n****\n" 1>&2
    exit 1
fi
# Make sure there are no entries in the plugins macro that don't match plugins
for p in %{plugins}; do
    if [ -z "`ls %{buildroot}%{_libdir}/%{name}/%{_lib}/$p*.so`" ]; then
        set +x
        echo -e "\n\n\n**** ERROR:\n" \
             "\nExtra entry in %%{plugins} macro with no matching plugin:" \
             "'$p'.\n\nPlease remove from %%{plugins} macro at top of" \
             "\nspecfile and rebuild.\n****\n" 1>&2
        exit 1
    fi
done

%check
desktop-file-validate \
    %{buildroot}%{_datadir}/applications/org.freecadweb.FreeCAD.desktop
%{?fedora:appstream-util validate-relax --nonet \
    %{buildroot}/%{_metainfodir}/*.appdata.xml}


%post
/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
/usr/bin/update-desktop-database &> /dev/null || :
/usr/bin/update-mime-database %{_datadir}/mime &> /dev/null || :

%postun
if [ $1 -eq 0 ] ; then
    /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null
    /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
fi
/usr/bin/update-desktop-database &> /dev/null || :
/usr/bin/update-mime-database %{_datadir}/mime &> /dev/null || :

%posttrans
/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor/scalable/apps &>/dev/null || :


%files
%license data/License.txt
%doc ChangeLog.txt
%exclude %{_docdir}/%{name}/%{name}.*
%exclude %{_docdir}/%{name}/ThirdPartyLibraries.html
%{_bindir}/*
%{_metainfodir}/*
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/bin/
%{_libdir}/%{name}/%{_lib}/
%{_libdir}/%{name}/Mod/
%{_libdir}/%{name}/Ext/
%{_datadir}/applications/*
%{_datadir}/icons/hicolor/scalable/*
%{_datadir}/pixmaps/*
%{_datadir}/mime/packages/*

%files data
%{_datadir}/%{name}/
%{_docdir}/%{name}/%{name}.q*
freecad-3.spec (11,651 bytes)   
freecad.spec-4.patch (13,148 bytes)   
diff -up ./freecad.spec.base ./freecad.spec
--- ./freecad.spec.base	2019-09-16 15:40:59.908156457 -0400
+++ ./freecad.spec	2019-09-19 12:19:18.126765718 -0400
@@ -1,8 +1,27 @@
+# This package depends on automagic byte compilation
+# https://fedoraproject.org/wiki/Changes/No_more_automagic_Python_bytecompilation_phase_2
+%global _python_bytecompile_extra 1
+
+# Setup python target for shiboken so the right cmake file is imported.
+%global py_suffix %(%{__python3} -c "import sysconfig; print(sysconfig.get_config_var('SOABI'))")
 
 # Maintainers:  keep this list of plugins up to date
 # List plugins in %%{_libdir}/%{name}/lib, less '.so' and 'Gui.so', here
 %global plugins Drawing Fem FreeCAD Image Import Inspection Mesh MeshPart Part Points QtUnit Raytracing ReverseEngineering Robot Sketcher Start Web PartDesignGui _PartDesign Path PathGui Spreadsheet SpreadsheetGui area DraftUtils DraftUtils libDriver libDriverDAT libDriverSTL libDriverUNV libMEFISTO2 libSMDS libSMESH libSMESHDS libStdMeshers Measure TechDraw TechDrawGui libarea-native Surface SurfaceGui PathSimulator
 
+# Some configuration options for other environments
+# rpmbuild --with=occ:  Compile using OpenCASCADE instead of OCE
+%global occ %{?_with_occ: 1} %{?!_with_occ: 0}
+# rpmbuild --with=bundled_zipios:  use bundled version of zipios++
+%global bundled_zipios %{?_with_bundled_zipios: 1} %{?!_with_bundled_zipios: 0}
+# rpmbuild --without=bundled_pycxx:  don't use bundled version of pycxx
+%global bundled_pycxx %{?_without_bundled_pycxx: 0} %{?!_without_bundled_pycxx: 1}
+# rpmbuild --without=bundled_smesh:  don't use bundled version of Salome's Mesh
+%global bundled_smesh %{?_without_bundled_smesh: 0} %{?!_without_bundled_smesh: 1}
+
+# See FreeCAD-master/src/3rdParty/salomesmesh/CMakeLists.txt to find this out.
+%global bundled_smesh_version 7.7.1.0
+
 # Some plugins go in the Mod folder instead of lib. Deal with those here:
 %global mod_plugins Mod/PartDesign
 %define name freecad
@@ -12,72 +31,78 @@
 Name:           %{name}
 Epoch:          1
 Version:    	0.19_pre
-Release:        {{{ git_commits_no }}}
+Release:        {{{ git_commit_nos }}}
 Summary:        A general purpose 3D CAD modeler
 Group:          Applications/Engineering
 
 License:        GPLv2+
-URL:            http://sourceforge.net/apps/mediawiki/free-cad/
+URL:            http://www.freecadweb.org/
 Source0:        https://github.com/%{github_name}/FreeCAD/archive/%{branch}.tar.gz
+Patch0:		FreeCAD-external-smesh.patch
+Patch1:		FreeCAD-SubWCRev.patch
+
+# Utilities
+BuildRequires:  cmake gcc-c++ gettext dos2unix
+BuildRequires:  doxygen swig graphviz
+BuildRequires:  gcc-gfortran
+BuildRequires:  desktop-file-utils
+BuildRequires:  git
+
+# Development Libraries
 
-BuildRequires:  Coin3
 BuildRequires:  Coin3-devel
 BuildRequires:  Inventor-devel
+%if %{occ}
+BuildRequires:  OpenCASCADE-devel
+%else
 BuildRequires:  OCE-devel
 BuildRequires:  OCE-draw
+%endif
+
 BuildRequires:  boost-devel
-BuildRequires:  cmake
-BuildRequires:  desktop-file-utils
-BuildRequires:  dos2unix
-BuildRequires:  doxygen
-BuildRequires:  eigen3
+BuildRequires:  boost-python3-devel
 BuildRequires:  eigen3-devel
 BuildRequires:  freeimage-devel
-BuildRequires:  gettext
-BuildRequires:  git
-BuildRequires:  graphviz
+BuildRequires:  libXmu-devel
+# For appdata
+%if 0%{?fedora}
+BuildRequires:  libappstream-glib
+%endif
+BuildRequires:  libglvnd-devel
 BuildRequires:  libicu-devel
-BuildRequires:  libspnav
+BuildRequires:  libkdtree++-devel
 BuildRequires:  libspnav-devel
-BuildRequires:  med
+BuildRequires:  libusb-devel
 BuildRequires:  med-devel
+BuildRequires:  mesa-libEGL-devel
 BuildRequires:  mesa-libGLU-devel
 BuildRequires:  netgen-mesher-devel
 BuildRequires:  netgen-mesher-devel-private
-BuildRequires:  pyside-tools
-BuildRequires:  python
-BuildRequires:  python-matplotlib
-%if 0%{?fedora} < 30
-BuildRequires:  python-pivy
-%endif
-BuildRequires:  python-pyside
-BuildRequires:  python-pyside-devel
-BuildRequires:  python2-devel
-BuildRequires:  qt-devel
-BuildRequires:  qt-webkit-devel
-BuildRequires:  shiboken
-BuildRequires:  shiboken-devel
-BuildRequires:  smesh
+BuildRequires:  python3-pivy
+BuildRequires:  mesa-libEGL-devel
+BuildRequires:  pcl-devel
+BuildRequires:  pyside2-tools
+BuildRequires:  python3
+BuildRequires:  python3-devel
+BuildRequires:  python3-matplotlib
+%if ! %{bundled_pycxx}
+BuildRequires:  python3-pycxx-devel
+%endif
+BuildRequires:  python3-pyside2-devel
+BuildRequires:  python3-shiboken2-devel
+BuildRequires:  qt5-devel
+BuildRequires:  qt5-qtwebkit-devel
+%if ! %{bundled_smesh}
 BuildRequires:  smesh-devel
-BuildRequires:  swig
+%endif
 BuildRequires:  tbb-devel
 BuildRequires:  vtk-devel
 BuildRequires:  xerces-c
 BuildRequires:  xerces-c-devel
-BuildRequires:  zlib-devel
-%if 0%{?fedora} > 28
-BuildRequires:  boost-python2
-BuildRequires:  boost-python2-devel
-BuildRequires:  boost-python3
-BuildRequires:  boost-python3-devel
-BuildRequires:  mesa-libEGL-devel
-BuildRequires:  python3-matplotlib
-%endif
-
-# For appdata
-%if 0%{?fedora}
-BuildRequires:  libappstream-glib
+%if ! %{bundled_zipios}
+BuildRequires:  zipios++-devel
 %endif
+BuildRequires:  zlib-devel
 
 # Packages separated because they are noarch, but not optional so require them
 # here.
@@ -85,15 +110,19 @@ Requires:       %{name}-data = %{epoch}:
 # Obsolete old doc package since it's required for functionality.
 Obsoletes:      %{name}-doc < 0.13-5
 
-# Needed for plugin support and is not a soname dependency.
-%if ! 0%{?rhel} <= 6 && "%{_arch}" != "ppc64"
-# python-pivy does not build on EPEL 6 ppc64.
-Requires:       python-pivy
-%endif
 Requires:       hicolor-icon-theme
-Requires:       python-matplotlib
-Requires:       python-collada
-Requires:       python-pyside
+Requires:       python3-collada
+Requires:       python3-matplotlib
+Requires:       python3-pivy
+Requires:       python3-pyside2
+Requires:	qt5-assistant
+%if %{bundled_smesh} 
+Provides:       bundled(smesh) = %{bundled_smesh_version}
+%endif
+%if %{bundled_pycxx} 
+Provides:       bundled(python-pycxx)
+%endif
+Recommends:	python3-pysolar
 
 # plugins and private shared libs in %%{_libdir}/freecad/lib are private;
 # prevent private capabilities being advertised in Provides/Requires
@@ -107,7 +136,6 @@ Requires:       python-pyside
 %filter_setup
 }
 
-
 %description
 FreeCAD is a general purpose Open Source 3D CAD/MCAD/CAx/CAE/PLM modeler, aimed
 directly at mechanical engineering and product design but also fits a wider
@@ -127,7 +155,18 @@ Data files for FreeCAD
 
 
 %prep
-%autosetup -n FreeCAD-%{branch}
+%autosetup -p1 -n FreeCAD-%{branch}
+
+# Remove bundled pycxx if we're not using it
+%if ! %{bundled_pycxx}
+rm -rf src/CXX
+%endif
+
+%if ! %{bundled_zipios}
+rm -rf src/zipios++
+#sed -i "s/zipios-config.h/zipios-config.hpp/g" \
+#    src/Base/Reader.cpp src/Base/Writer.h
+%endif
 
 # Fix encodings
 dos2unix -k src/Mod/Test/unittestgui.py \
@@ -140,7 +179,8 @@ dos2unix -k src/Mod/Test/unittestgui.py
 rm -rf build && mkdir build && cd build
 
 # Deal with cmake projects that tend to link excessively.
-#LDFLAGS='-Wl,--as-needed'; export LDFLAGS
+CXXFLAGS='-Wno-error=cast-function-type'; export CXXFLAGS
+LDFLAGS='-Wl,--as-needed -Wl,--no-undefined'; export LDFLAGS
 
 %if 0%{?fedora} > 27
 %define MEDFILE_INCLUDE_DIRS %{_includedir}/med/
@@ -148,19 +188,53 @@ rm -rf build && mkdir build && cd build
 %define MEDFILE_INCLUDE_DIRS %{_includedir}/
 %endif
 
-%cmake -DCMAKE_INSTALL_PREFIX=%{_libdir}/%{name} \
+%cmake \
+       -DCMAKE_INSTALL_PREFIX=%{_libdir}/%{name} \
        -DCMAKE_INSTALL_DATADIR=%{_datadir}/%{name} \
        -DCMAKE_INSTALL_DOCDIR=%{_docdir}/%{name} \
        -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir} \
        -DRESOURCEDIR=%{_datadir}/%{name} \
        -DFREECAD_USE_EXTERNAL_PIVY=TRUE \
+       -DFREECAD_USE_PCL=TRUE \
+       -DBUILD_QT5=ON \
+       -DSHIBOKEN_INCLUDE_DIR=%{_includedir}/shiboken2 \
+       -DSHIBOKEN_LIBRARY=-lshiboken2.%{py_suffix} \
+       -DPYTHON_SUFFIX=.%{py_suffix} \
+       -DPYSIDE_INCLUDE_DIR=/usr/include/PySide2 \
+       -DPYSIDE_LIBRARY=-lpyside2.%{py_suffix} \
+       -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 \
        -DMEDFILE_INCLUDE_DIRS=%{MEDFILE_INCLUDE_DIRS} \
+       -DOpenGL_GL_PREFERENCE=GLVND \
+       -DCOIN3D_INCLUDE_DIR=%{_includedir}/Coin3 \
+       -DCOIN3D_DOC_PATH=%{_datadir}/Coin3/Coin \
+       -DFREECAD_USE_EXTERNAL_PIVY=TRUE \
+%if %{occ}
+       -DUSE_OCC=TRUE \
+%endif
+%if ! %{bundled_smesh}
+       -DFREECAD_USE_EXTERNAL_SMESH=TRUE \
+       -DSMESH_FOUND=TRUE \
+       -DSMESH_INCLUDE_DIR=%{_includedir}/smesh \
+       -DSMESH_DIR=`pwd`/../cMake \
+%endif
+%if ! %{bundled_zipios}
+       -DFREECAD_USE_EXTERNAL_ZIPIOS=TRUE \
+%endif
+%if ! %{bundled_pycxx}
+       -DPYCXX_INCLUDE_DIR=$(pkg-config --variable=includedir PyCXX) \
+       -DPYCXX_SOURCE_DIR=$(pkg-config --variable=srcdir PyCXX) \
+%endif
+       -DPACKAGE_WCREF="%{release} (Git)" \
+       -DPACKAGE_WCURL="git://github.com/%{github_name}/FreeCAD.git master" \
        ../
 
-sed -i 's,FCRevision      \"Unknown\",FCRevision      \"%{release} (Git)\",' src/Build/Version.h
-sed -i 's,FCRepositoryURL \"Unknown\",FCRepositoryURL \"git://github.com/FreeCAD/FreeCAD.git master\",' src/Build/Version.h
+make fc_version
+for I in src/Build/Version.h src/Build/Version.h.out; do
+	sed -i 's,FCRevision      \"Unknown\",FCRevision      \"%{release} (Git)\",' $I
+	sed -i 's,FCRepositoryURL \"Unknown\",FCRepositoryURL \"git://github.com/FreeCAD/FreeCAD.git master\",' $I
+done
 
-make %{?_smp_mflags}
+%{make_build}
 
 %install
 cd build
@@ -168,19 +242,20 @@ cd build
 
 # Symlink binaries to /usr/bin
 mkdir -p %{buildroot}%{_bindir}
-pushd %{buildroot}%{_bindir}
-ln -s ../%{_lib}/%{name}/bin/FreeCAD .
-ln -s ../%{_lib}/%{name}/bin/FreeCADCmd .
-popd
+ln -s ../%{_lib}/%{name}/bin/FreeCAD %{buildroot}%{_bindir}/FreeCAD
+ln -s ../%{_lib}/%{name}/bin/FreeCADCmd %{buildroot}%{_bindir}/FreeCADCmd
 
-mkdir %{buildroot}%{_datadir}/appdata/
-mv %{buildroot}%{_libdir}/%{name}/share/metainfo/* %{buildroot}%{_datadir}/appdata/
+mkdir %{buildroot}%{_metainfodir}/
+mv %{buildroot}%{_libdir}/%{name}/share/metainfo/* %{buildroot}%{_metainfodir}/
 
 mkdir %{buildroot}%{_datadir}/applications/
 mv %{buildroot}%{_libdir}/%{name}/share/applications/* %{buildroot}%{_datadir}/applications/
 
-mkdir -p %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/
-mv %{buildroot}%{_libdir}/%{name}/share/icons/hicolor/scalable/apps/* %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/
+mkdir -p %{buildroot}%{_datadir}/icons/hicolor/scalable/
+mv %{buildroot}%{_libdir}/%{name}/share/icons/hicolor/scalable/* %{buildroot}%{_datadir}/icons/hicolor/scalable/
+
+mkdir -p %{buildroot}%{_datadir}/pixmaps/
+mv %{buildroot}%{_libdir}/%{name}/share/pixmaps/* %{buildroot}%{_datadir}/pixmaps/
 
 mkdir -p %{buildroot}%{_datadir}/mime/packages/
 mv %{buildroot}%{_libdir}/%{name}/share/mime/packages/* %{buildroot}%{_datadir}/mime/packages/
@@ -188,14 +263,19 @@ mv %{buildroot}%{_libdir}/%{name}/share/
 pushd %{buildroot}%{_libdir}/%{name}/share/
 rmdir metainfo/
 rmdir applications/
-rmdir -p mime/packages/
-rmdir -p icons/hicolor/scalable/apps/
+rm -rf mime
+rm -rf icons
 popd
 
+# Remove obsolete Start_Page.html
+rm -f %{buildroot}%{_docdir}/%{name}/Start_Page.html
+# Belongs in %%license not %%doc
+rm -f %{buildroot}%{_docdir}/freecad/ThirdPartyLibraries.html
+
 # Bug maintainers to keep %%{plugins} macro up to date.
 #
 # Make sure there are no plugins that need to be added to plugins macro
-new_plugins=`ls %{buildroot}%{_libdir}/%{name}/lib | sed -e  '%{plugin_regexp}'`
+new_plugins=`ls %{buildroot}%{_libdir}/%{name}/%{_lib} | sed -e  '%{plugin_regexp}'`
 if [ -n "$new_plugins" ]; then
     echo -e "\n\n\n**** ERROR:\n" \
         "\nPlugins not caught by regexp:  " $new_plugins \
@@ -206,7 +286,7 @@ if [ -n "$new_plugins" ]; then
 fi
 # Make sure there are no entries in the plugins macro that don't match plugins
 for p in %{plugins}; do
-    if [ -z "`ls %{buildroot}%{_libdir}/%{name}/lib/$p*.so`" ]; then
+    if [ -z "`ls %{buildroot}%{_libdir}/%{name}/%{_lib}/$p*.so`" ]; then
         set +x
         echo -e "\n\n\n**** ERROR:\n" \
              "\nExtra entry in %%{plugins} macro with no matching plugin:" \
@@ -217,8 +297,10 @@ for p in %{plugins}; do
 done
 
 %check
+desktop-file-validate \
+    %{buildroot}%{_datadir}/applications/org.freecadweb.FreeCAD.desktop
 %{?fedora:appstream-util validate-relax --nonet \
-    %{buildroot}/%{_datadir}/appdata/*.appdata.xml}
+    %{buildroot}/%{_metainfodir}/*.appdata.xml}
 
 
 %post
@@ -244,14 +326,15 @@ fi
 %exclude %{_docdir}/%{name}/%{name}.*
 %exclude %{_docdir}/%{name}/ThirdPartyLibraries.html
 %{_bindir}/*
+%{_metainfodir}/*
 %dir %{_libdir}/%{name}
 %{_libdir}/%{name}/bin/
-%{_libdir}/%{name}/lib/
+%{_libdir}/%{name}/%{_lib}/
 %{_libdir}/%{name}/Mod/
 %{_libdir}/%{name}/Ext/
 %{_datadir}/applications/*
-%{_datadir}/icons/hicolor/scalable/apps/*
-%{_datadir}/appdata/*
+%{_datadir}/icons/hicolor/scalable/*
+%{_datadir}/pixmaps/*
 %{_datadir}/mime/packages/*
 
 %files data
freecad.spec-4.patch (13,148 bytes)   

pfirszt

2019-09-20 07:39

developer   ~0013652

Last edited: 2019-09-20 07:46

OK, thanks again! That SubWCRev.py bug should end up in the main repo (1). I see you changed git_commit_no to git_commit_nos, but we still have git_commit_no in rpkg.macros - is it just a typo or there is something behind it?

(1) I can make PR and submit it, but if you want a credit for it you'd do it yourself :-)
Edit: PR ready, please check if you're OK with that
https://github.com/FreeCAD/FreeCAD/pull/2538

hobbes1069

2019-09-20 10:14

reporter   ~0013653

@sopwith
What's the purpose of adding:
+BuildRequires: mesa-libEGL-devel
I can't find any evidence it's needed.

I added libglvnd-devel to mine but it turns out it's already being pulled in with mesa-libGLU-devel which didn't solve my linker problem.

Looking at the log I don't see that "-lGLU" or "-lGL" is on the linker line...

sopwith

2019-09-20 10:52

reporter   ~0013654

@hobbes1069 - the libEGL buildrequires might be unnecessary after all. If libGL is not on the linker line then it's probably a problem with cmake files. I can't reproduce the problem here so I don't have any suggestions.

@pfirszt - I think the git_commit_nos change was just my mistake. Should stay as git_commits_no. I don't have any more changes to submit, so please work with hobbes1069 to make whatever changes are necessary for his libGL problem, then go ahead and submit a PR.

hobbes1069

2019-09-20 11:08

reporter   ~0013655

Found part of the problem:

https://forum.freecadweb.org/viewtopic.php?f=4&t=39484

FreeCADGui is expecting to link via "OPENGL_gl_LIBRARY" but CMake (perhaps due to newer version?) is returning "OPENGL_opengl_LIBRARY" and CMakeLists in src/Gui is blindly assuming the former.

pfirszt

2019-09-20 11:50

developer   ~0013658

@sopwith, OK, thanks again!
Fedora 29 fails with:
No matching package to install: 'pyside2-tools'
No matching package to install: 'python3-pyside2-devel'
No matching package to install: 'python3-shiboken2-devel'

I'll add conditionals if the rest builds fine.

pfirszt

2019-09-20 15:48

developer   ~0013662

Building works, tests work, but I can't get the rev version:
Unknown version control
/builddir/build/BUILD/FreeCAD-copr_fix_v22/build/src/Build/Version.h.out written
Generating Version.h
cd /builddir/build/BUILD/FreeCAD-copr_fix_v22/src/Build && /usr/bin/cmake -E copy_if_different /builddir/build/BUILD/FreeCAD-copr_fix_v22/build/src/Build/Version.h.out /builddir/build/BUILD/FreeCAD-copr_fix_v22/build/src/Build/Version.h
make[3]: Leaving directory '/builddir/build/BUILD/FreeCAD-copr_fix_v22/build'
Built target fc_version
make[2]: Leaving directory '/builddir/build/BUILD/FreeCAD-copr_fix_v22/build'
/usr/bin/cmake -E cmake_progress_start /builddir/build/BUILD/FreeCAD-copr_fix_v22/build/CMakeFiles 0
make[1]: Leaving directory '/builddir/build/BUILD/FreeCAD-copr_fix_v22/build'
+ for I in src/Build/Version.h src/Build/Version.h.out
+ sed -i 's,FCRevision      \"Unknown\",FCRevision      \"18263 (Git)\",' src/Build/Version.h
+ sed -i 's,FCRepositoryURL \"Unknown\",FCRepositoryURL \"git://github.com/FreeCAD/FreeCAD.git master\",' src/Build/Version.h
+ for I in src/Build/Version.h src/Build/Version.h.out
+ sed -i 's,FCRevision      \"Unknown\",FCRevision      \"18263 (Git)\",' src/Build/Version.h.out
+ sed -i 's,FCRepositoryURL \"Unknown\",FCRepositoryURL \"git://github.com/FreeCAD/FreeCAD.git master\",' src/Build/Version.h.out
+ /usr/bin/make -O -j2

sopwith

2019-09-20 17:10

reporter   ~0013665

@pfirszt Is the Version.h that it ends up with not correct? Those commands all look right to me. SubWCRev is not going to be able to come up with the revision and URL on its own because it is building from a tarball tree, so we use sed to manually edit in the revision and URL based on what we know from the .spec file.

pfirszt

2019-09-21 09:07

developer   ~0013669

It looks OK to ma as well, but the version doesn't show up in FreeCAD. I'm trying to find why,

hobbes1069

2019-09-21 12:33

reporter   ~0013672

I think for Fedora Rawhide I'm running into a Python 3.8 error. I've googled as much as I can but it looks like it has to do with some changes in thread management? I found some related errors and fixes, but not this specific one so it's beyond me.


BUILDSTDERR: In file included from /builddir/build/BUILD/FreeCAD-0.18.3/src/Base/swigpyrun.cpp:41:
BUILDSTDERR: /builddir/build/BUILD/FreeCAD-0.18.3/src/Base/swigpyrun.inl: In function 'void Swig_python::cleanupSWIG_T(const char*)':
BUILDSTDERR: /builddir/build/BUILD/FreeCAD-0.18.3/src/Base/swigpyrun.inl:75:31: error: invalid use of incomplete type 'PyInterpreterState' {aka 'struct _is'}
BUILDSTDERR:    75 |     PyObject *modules = interp->modules;
BUILDSTDERR:       |                               ^~
BUILDSTDERR: In file included from /usr/include/python3.8/genobject.h:11,
BUILDSTDERR:                  from /usr/include/python3.8/Python.h:121,
BUILDSTDERR:                  from /builddir/build/BUILD/FreeCAD-0.18.3/src/Base/PyExport.h:42,
BUILDSTDERR:                  from /builddir/build/BUILD/FreeCAD-0.18.3/src/Base/swigpyrun.cpp:25:
BUILDSTDERR: /usr/include/python3.8/pystate.h:20:8: note: forward declaration of 'PyInterpreterState' {aka 'struct _is'}
BUILDSTDERR:    20 | struct _is;
BUILDSTDERR:       |        ^~~

pfirszt

2019-09-21 18:08

developer   ~0013673

Ad Version problem. Added cat shows sed works as expected, so the problem is somewhere else.
+ for I in src/Build/Version.h src/Build/Version.h.out
+ sed -i 's,FCRevision      \"Unknown\",FCRevision      \"18272 (Git)\",' src/Build/Version.h
+ sed -i 's,FCRepositoryURL \"Unknown\",FCRepositoryURL \"git://github.com/FreeCAD/FreeCAD.git master\",' src/Build/Version.h
+ cat src/Build/Version.h

// Version Number
#define FCVersionMajor "0"
#define FCVersionMinor "19"
#define FCVersionName  "Vulcan"
// test: $Format:Hash (%H), Date: %ci$
#define FCRevision      "18272 (Git)"      //Highest committed revision number
#define FCRevisionDate  "Unknown"     //Date of highest committed revision
#define FCRepositoryURL "git://github.com/FreeCAD/FreeCAD.git master"      //Repository URL of the working copy


+ for I in src/Build/Version.h src/Build/Version.h.out
+ sed -i 's,FCRevision      \"Unknown\",FCRevision      \"18272 (Git)\",' src/Build/Version.h.out
+ sed -i 's,FCRepositoryURL \"Unknown\",FCRepositoryURL \"git://github.com/FreeCAD/FreeCAD.git master\",' src/Build/Version.h.out
+ cat src/Build/Version.h.out

// Version Number
#define FCVersionMajor "0"
#define FCVersionMinor "19"
#define FCVersionName  "Vulcan"
// test: $Format:Hash (%H), Date: %ci$
#define FCRevision      "18272 (Git)"      //Highest committed revision number
#define FCRevisionDate  "Unknown"     //Date of highest committed revision
#define FCRepositoryURL "git://github.com/FreeCAD/FreeCAD.git master"      //Repository URL of the working copy

pfirszt

2019-09-23 11:39

developer   ~0013675

Test builds went OK, so I made a PR:
https://github.com/FreeCAD/FreeCAD/pull/2551

hobbes1069

2019-09-24 12:42

reporter   ~0013683

Just and FYI I finally got a build for F31 with the following diff from the Fedora spec:


diff --git a/freecad.spec b/freecad.spec
index 3a42597..f655d50 100644
--- a/freecad.spec
+++ b/freecad.spec
@@ -46,7 +46,9 @@ BuildRequires:  tbb-devel
 # Development Libraries
 BuildRequires:  freeimage-devel
 BuildRequires:  libXmu-devel
+BuildRequires:  mesa-libGL-devel
 BuildRequires:  mesa-libGLU-devel
+BuildRequires:  libglvnd-devel
 %if %{occ}
 BuildRequires:  OpenCASCADE-devel
 %else
@@ -57,12 +59,14 @@ BuildRequires:  python3-devel
 BuildRequires:  python3-matplotlib
 BuildRequires:  boost-devel boost-python3-devel
 BuildRequires:  eigen3-devel
-BuildRequires:  qt-devel qt-webkit-devel
+BuildRequires:  qt5-qtbase-devel qt5-qtsvg-devel
+BuildRequires:  qt5-qttools-static
+BuildRequires:  qt5-qtwebkit-devel
 BuildRequires:  SoQt-devel
 BuildRequires:  xerces-c xerces-c-devel
 BuildRequires:  libspnav-devel
-BuildRequires:  shiboken-python3-devel
-BuildRequires:  python-pyside-devel pyside-tools
+BuildRequires:  python3-shiboken2-devel
+BuildRequires:  python3-pyside2-devel pyside2-tools
 %if ! %{bundled_smesh}
 BuildRequires:  smesh-devel
 %endif
@@ -135,6 +139,10 @@ dos2unix -k src/Mod/Test/unittestgui.py \
 # Removed bundled libraries
 #rm -rf src/3rdParty

+# At some point CMake changed from returning OPENGL_gl_LIBRARY to
+# OPENGL_opengl_LIBRARY
+sed -i "s|OPENGL_gl_LIBRARY|OPENGL_opengl_LIBRARY|g" src/Gui/CMakeLists.txt
+

 %build
 mkdir build && pushd build
@@ -153,6 +161,11 @@ LDFLAGS='%{build_ldflags} -Wl,--as-needed -Wl,--no-undefined'; export LDFLAGS
 %if 0%{?fedora} < 30
        -DPYTHON_SUFFIX=.%{py_suffix} \
 %endif
+       -DPYSIDE_INCLUDE_DIR=/usr/include/PySide2 \
+       -DPYSIDE_LIBRARY=%{_libdir}/libpyside2.%{py_suffix}.so \
+       -DSHIBOKEN_INCLUDE_DIR=%{_includedir}/shiboken2 \
+       -DSHIBOKEN_LIBRARY=%{_libdir}/libshiboken2.%{py_suffix}.so \
+       -DBUILD_QT5=ON \
        -DOpenGL_GL_PREFERENCE=GLVND \
        -DCOIN3D_INCLUDE_DIR=%{_includedir}/Coin3 \
        -DCOIN3D_DOC_PATH=%{_datadir}/Coin3/Coin \

The ones I don't understand are the SHIBOKEN/PYSIDE_LIBRARY ones... Shouldn't these be found automatically?

Both PYSIDE_LIBRARY and SHIBOKEN_LIBRARY are referenced in src/Gui/CMakeLists.txt but are never setup on Linux...


$ grep -r SHIBOKEN_LIBRARY
src/Gui/CMakeLists.txt:        ${SHIBOKEN_LIBRARY}
cMake/UseLibPack10x.cmake:#  SHIBOKEN_LIBRARY            - Files to link against to use SHIBOKEN
cMake/UseLibPack10x.cmake:SET(SHIBOKEN_LIBRARY     optimized ${FREECAD_LIBPACK_DIR}/lib/shiboken-python2.7.lib debug ${FREECAD_LIBPACK_DIR}/lib/shiboken-python2.7_d.lib)
cMake/UseLibPack9x.cmake:#  SHIBOKEN_LIBRARY            - Files to link against to use SHIBOKEN
cMake/UseLibPack9x.cmake:SET(SHIBOKEN_LIBRARY     optimized ${FREECAD_LIBPACK_DIR}/lib/shiboken-python2.7.lib debug ${FREECAD_LIBPACK_DIR}/lib/shiboken-python2.7_d.lib)
cMake/UseLibPack8x.cmake:    #  SHIBOKEN_LIBRARY            - Files to link against to use SHIBOKEN
cMake/UseLibPack8x.cmake:    SET(SHIBOKEN_LIBRARY     optimized ${FREECAD_LIBPACK_DIR}/lib/shiboken-python2.6.lib debug ${FREECAD_LIBPACK_DIR}/lib/shiboken-python2.6_d.lib)
[build@hobbes FreeCAD-0.18.3]$ grep -r PYSIDE_LIBRARY
src/Gui/CMakeLists.txt:        ${PYSIDE_LIBRARY}
cMake/UseLibPack10x.cmake:#  PYSIDE_LIBRARY       - Files to link against to use PySide
cMake/UseLibPack10x.cmake:SET(PYSIDE_LIBRARY     optimized ${FREECAD_LIBPACK_DIR}/lib/pyside-python2.7.lib debug ${FREECAD_LIBPACK_DIR}/lib/pyside-python2.7_d.lib)
cMake/UseLibPack9x.cmake:#  PYSIDE_LIBRARY       - Files to link against to use PySide
cMake/UseLibPack9x.cmake:SET(PYSIDE_LIBRARY     optimized ${FREECAD_LIBPACK_DIR}/lib/pyside-python2.7.lib debug ${FREECAD_LIBPACK_DIR}/lib/pyside-python2.7_d.lib)
cMake/UseLibPack8x.cmake:    #  PYSIDE_LIBRARY       - Files to link against to use PySide
cMake/UseLibPack8x.cmake:    SET(PYSIDE_LIBRARY     optimized ${FREECAD_LIBPACK_DIR}/lib/pyside-python2.6.lib debug ${FREECAD_LIBPACK_DIR}/lib/pyside-python2.6_d.lib)

I maintain PySide2 for Fedora and CMake import targets are created.

On a side note I still can't build for f32/Rawhide due to Python 3.8 but I guess I need to open a separate ticket for that.

pfirszt

2019-09-24 16:28

developer   ~0013684

Thanks! I'll make a PR as soon as the current one is in the main tree.

Related Changesets

FreeCAD: master 1966238d

2019-09-20 07:49:00

Przemo Firszt


Committer: wmayer Details Diff
Update fedora spec as per sopwith

Signed-off-by: Przemo Firszt <przemo@firszt.eu>
Affected Issues
0004132
mod - package/fedora/freecad.spec Diff File
mod - package/fedora/rpkg.macros Diff File

FreeCAD: master 64e7cd2d

2019-09-22 07:52:55

Przemo Firszt


Committer: wmayer Details Diff
Exclude some packages from fedora 29 builds

Those packages don't exist in fedora 29:
pyside2-tools, python3-pyside2-devel, python3-shiboken2-devel

Signed-off-by: Przemo Firszt <przemo@firszt.eu>
Affected Issues
0004132
mod - package/fedora/freecad.spec Diff File

Issue History

Date Modified Username Field Change
2019-09-16 20:13 sopwith New Issue
2019-09-16 20:13 sopwith Tag Attached: #lowhangingfruit
2019-09-16 20:13 sopwith Tag Attached: linux
2019-09-16 20:13 sopwith Tag Attached: packaging
2019-09-16 20:13 sopwith File Added: freecad.spec.patch
2019-09-16 23:10 Kunda1 Note Added: 0013611
2019-09-16 23:41 hobbes1069 Note Added: 0013612
2019-09-17 20:17 Kunda1 File Added: mantisbt-patch-inline.png
2019-09-17 20:17 Kunda1 Note Added: 0013617
2019-09-18 00:49 sopwith Note Added: 0013621
2019-09-18 01:59 hobbes1069 Note Added: 0013622
2019-09-18 12:27 Kunda1 Note Added: 0013626
2019-09-18 12:33 sopwith Note Added: 0013627
2019-09-18 12:48 sliptonic Note Added: 0013628
2019-09-18 13:31 pfirszt Note Added: 0013629
2019-09-18 15:18 sopwith Note Added: 0013631
2019-09-18 19:25 hobbes1069 Note Added: 0013632
2019-09-18 20:42 sopwith Note Added: 0013633
2019-09-18 21:44 sopwith Note Edited: 0013633
2019-09-18 22:08 sopwith File Added: freecad.spec
2019-09-18 22:08 sopwith File Added: freecad.spec-2.patch
2019-09-18 22:08 sopwith Note Added: 0013634
2019-09-18 22:17 hobbes1069 Note Added: 0013635
2019-09-19 01:39 sopwith File Added: freecad-2.spec
2019-09-19 01:39 sopwith File Added: freecad.spec-3.patch
2019-09-19 01:39 sopwith Note Added: 0013638
2019-09-19 02:23 Kunda1 Status new => confirmed
2019-09-19 07:28 pfirszt Note Added: 0013642
2019-09-19 08:26 pfirszt Note Added: 0013643
2019-09-19 11:54 sopwith File Added: FreeCAD-external-smesh.patch
2019-09-19 11:54 sopwith Note Added: 0013644
2019-09-19 12:47 pfirszt Note Added: 0013645
2019-09-19 12:48 pfirszt Note Edited: 0013645
2019-09-19 14:55 hobbes1069 Note Added: 0013647
2019-09-19 15:17 sopwith Note Added: 0013648
2019-09-19 16:22 sopwith File Added: FreeCAD-SubWCRev.patch
2019-09-19 16:22 sopwith File Added: freecad-3.spec
2019-09-19 16:22 sopwith File Added: freecad.spec-4.patch
2019-09-19 16:22 sopwith Note Added: 0013651
2019-09-20 07:39 pfirszt Note Added: 0013652
2019-09-20 07:46 pfirszt Note Edited: 0013652
2019-09-20 10:14 hobbes1069 Note Added: 0013653
2019-09-20 10:52 sopwith Note Added: 0013654
2019-09-20 11:08 hobbes1069 Note Added: 0013655
2019-09-20 11:50 pfirszt Note Added: 0013658
2019-09-20 15:48 pfirszt Note Added: 0013662
2019-09-20 17:10 sopwith Note Added: 0013665
2019-09-21 09:07 pfirszt Note Added: 0013669
2019-09-21 12:33 hobbes1069 Note Added: 0013672
2019-09-21 18:08 pfirszt Note Added: 0013673
2019-09-23 11:39 pfirszt Note Added: 0013675
2019-09-24 12:42 Kunda1 Assigned To => pfirszt
2019-09-24 12:42 Kunda1 Status confirmed => assigned
2019-09-24 12:42 hobbes1069 Note Added: 0013683
2019-09-24 16:28 pfirszt Note Added: 0013684
2019-09-25 18:18 wmayer Changeset attached => FreeCAD master 64e7cd2d
2019-09-25 18:18 wmayer Changeset attached => FreeCAD master 1966238d
2019-09-25 18:21 wmayer Status assigned => closed
2019-09-25 18:21 wmayer Resolution open => fixed
2019-09-25 18:21 wmayer Fixed in Version => 0.19