PKGBUILD 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. # Maintainer (arch): Alexander F. Rødseth <xyproto@archlinux.org>
  2. # Contributor: loqs <bugs-archlinux@entropy-collector.net>
  3. # Contributor: Gabriel Souza Franco <gabrielfrancosouza@gmail.com>
  4. # Contributor: Florian Pritz
  5. # Contributor: Jonas Heinrich <onny@project-insanity.org>
  6. # Contributor: Jordi De Groof <jordi.degroof@gmail.com>
  7. # Contributor: mickele
  8. # Contributor: manwithgrenade
  9. # Contributor: bricem13
  10. # Contributor: gborzi
  11. # Contributor: Adrian Insaurralde
  12. # Maintainer: Parabola Hackers <dev@lists.parabola.nu>
  13. # Contributor: bill-auger <bill-auger@programmer.net>
  14. # parabola changes and rationale:
  15. # libre:
  16. # - build without webengine (BR #1167)
  17. # - build without pip (BR #1035)
  18. # - disable downloader (BR #1035)
  19. # - add default session XML (BR #3522)
  20. # technical:
  21. # - build from versioned source-ball rather than VCS sources
  22. # - pin to strongly-coupled dependency versions
  23. pkgname=freecad
  24. pkgver=0.21.2
  25. pkgrel=16
  26. pkgrel+=.parabola2
  27. pkgdesc='Feature based parametric 3D CAD modeler'
  28. arch=(x86_64)
  29. arch+=(armv7h) # 'med-openmpi' is unavailable for i686
  30. url='https://freecadweb.org/'
  31. license=(LGPL)
  32. depends=(boost-libs coin fmt glew jsoncpp libspnav med-openmpi netcdf
  33. opencascade openmpi pugixml pyside6 python-gitpython
  34. python-markdown python-matplotlib python-pip python-pivy python-ply
  35. python-yaml qt6-svg qt6-tools qt6-webengine
  36. xerces-c verdict)
  37. depends=( ${depends[*]/python-pip/} ) # build without pip
  38. depends=( ${depends[*]/qt6-webengine/} ) # build without webengine
  39. makedepends=(boost cgns cmake eigen git libharu liblas ninja openvdb openvr
  40. ospray pdal postgresql-libs python-mpi4py
  41. shiboken6 swig utf8cpp nlohmann-json)
  42. makedepends=( ${makedepends[*]/git/} ) # build from source-ball
  43. [[ "${CARCH}" == x86_64 ]] || makedepends=( ${makedepends[*]/ospray/} ) # unavailable for i686 and armv7h
  44. optdepends=('graphviz: dependency graph support'
  45. 'openscad: OpenSCAD support')
  46. source=(${pkgname}-${pkgver}.tar.gz::https://github.com/${pkgname}/${pkgname}/archive/refs/tags/${pkgver}.tar.gz # build from source-ball
  47. freecad-vtk9.3.patch
  48. pyside6.patch
  49. 62c3836c.patch
  50. https://github.com/FreeCAD/FreeCAD/commit/6043c904.patch)
  51. source+=(branding.xml)
  52. b2sums=('84a4f8008192cd1a2ee1737b537b2668a8c028aa8c8645e6e412ab9ef79bf3bdd2cb73d96fcfd2dbcff613cdcc59cbab95821406acdc9cd7d4eb4636c081be78'
  53. 'f0b5a4648eb4befabb2339bae4e42044e436aa50ad1c2a25b243c965272a217b2c1c69c34d0d20bd01c573008de10f733b74857ffecac502b8558a7095e305e5'
  54. '63bfac252cc813f4e2454b4bbd8b0c55e2882566bd39bf1d0b812bafc305cad6b65293bad4f3c043b58df93a2c685e82e5853059335fe8e90531dcbc23e324e9'
  55. 'eb474708c3611293cfe3dfc287418b606f7735f6eb306f44f7394cd7e65256daddcee35984211982f25064e7ec81cc038d4eeb8d34af7399058ecfb6e8e99e9f'
  56. 'de4b98c4b488045f9810dce124c271d6f4f629922e026f2d4f1efd6c9060b92309db41f8e0f6ebe5e7a27399911ac908cc8935c2501214326dbb1c4b739d46cc')
  57. b2sums+=('eb678f8bed6e11544bc7fb31205acbeaa0904c63d1828a0574900dcaeae453c7dacf5beaceeac5e2f951b8d46dfc5ae11ccd1b4a876f8809f81d76c71fc22e6a')
  58. _version_constraint() # (dep_pkgname [precision])
  59. {
  60. Log() { [[ "${FUNCNAME[2]}" == package ]] && echo "$@" >&2 || : ; }
  61. local dep_pkgname=$1
  62. declare -i req_precision=$2
  63. local full_version=$(pacman -S --print-format='%v' ${dep_pkgname} 2> /dev/null | tail -n 1)
  64. local n_dots=$(tmp=${full_version%-*} ; tmp=${tmp//[^\.]} ; echo "${#tmp}" ;)
  65. local def_precision=$(( n_dots + 1 ))
  66. local is_prec_valid=$(( req_precision > 0 && req_precision <= def_precision ))
  67. local precision=$((( is_prec_valid )) && echo ${req_precision} || echo ${def_precision})
  68. local epoch_rx='[0-9]+:'
  69. local pkgver_rx='[0-9A-Za-z_]+'
  70. pkgver_rx=$(sed 's|\]|\+]|' <<<${pkgver_rx}) # according to the wiki, '+' is not allowed,
  71. # but some pkgver have it (eg: 5.15.10+kde+r130)
  72. local subver_rx='\.'${pkgver_rx}
  73. local pkgrel_rx='[0-9]+'
  74. local garbage_rx='[^0-9].*'
  75. local capture_rx=${pkgver_rx}
  76. for (( n_dots=1 ; n_dots < precision ; ++n_dots )) ; do capture_rx+=${subver_rx} ; done ;
  77. local epoch version pkgrel has_dot_char version_min version_max constraint_string
  78. declare -i subver subver_inc pkgrel_inc
  79. if [[ "${full_version}" =~ ^(${epoch_rx})*(${capture_rx})(${subver_rx})*-(${pkgrel_rx}).*$ ]]
  80. then epoch=${BASH_REMATCH[1]} # optional epoch
  81. version=${BASH_REMATCH[2]} # pkgver cut to the requested precision
  82. #unused=${BASH_REMATCH[3]} # discarded pkgver segments
  83. pkgrel=${BASH_REMATCH[4]} # pkgrel with non-numerics right-trimmed
  84. has_dot_char=$([[ "${version}" =~ \. ]] ; echo $(( ! $? )) ; )
  85. subver=$(sed "s|${garbage_rx}||" <<<${version##*.}) # right-trim from any non-numeric
  86. version=$( (( has_dot_char )) && echo ${version%.*}.${subver} || echo ${subver} )
  87. version=${epoch}${version}
  88. subver_inc=$(( subver + 1 ))
  89. pkgrel_inc=$(( pkgrel + 1 ))
  90. version_min=$( (( ! is_prec_valid )) && echo ${full_version%-*}-${pkgrel} || \
  91. echo ${version} )
  92. version_max=$( ( (( ! is_prec_valid )) && echo ${full_version%-*}-${pkgrel_inc} ) || \
  93. ( [[ "${version}" =~ \. ]] && echo ${version%.*}.${subver_inc} ) || \
  94. echo ${subver_inc} )
  95. constraint_string="${dep_pkgname}>=${version_min} ${dep_pkgname}<${version_max}"
  96. Log "Applied version constraint: '${constraint_string}'"
  97. else Log "ERROR: in _version_constraint() parsing: dep_pkgname='${dep_pkgname}' full_version='${full_version}'"
  98. exit 1
  99. fi
  100. unset -f Log
  101. echo -n "${constraint_string}"
  102. }
  103. prepare() {
  104. ln -fs FreeCAD-${pkgver} ${pkgname} # link source-ball root dir as VCS root dirname
  105. patch -d freecad -Np1 -i "$srcdir"/freecad-vtk9.3.patch
  106. patch -d freecad -Np1 -i ../62c3836c.patch # Fix Qt6 issues in addons manager
  107. patch -d freecad -Np1 -i ../pyside6.patch
  108. patch -d freecad -Np1 -i ../6043c904.patch # Fix build with Python 3.12
  109. sed -e 's|Shiboken::Module::getTypes(requiredModule)|reinterpret_cast<PyTypeObject **>(Shiboken::Module::getTypes(requiredModule))|' \
  110. -i freecad/src/Gui/PythonWrapper.cpp # Fix build with PySide 6.7
  111. }
  112. build() {
  113. local parabola_opts=( -D BUILD_ADDONMGR=OFF \
  114. -D BUILD_WEB=OFF )
  115. cmake \
  116. ${parabola_opts[*]} \
  117. -B build \
  118. -D BUILD_ENABLE_CXX_STD=C++17 \
  119. -D BUILD_FLAT_MESH=ON \
  120. -D FREECAD_QT_VERSION=6 \
  121. -D CMAKE_BUILD_TYPE=Release \
  122. -D CMAKE_C_FLAGS="$CFLAGS -ffat-lto-objects -fPIC -w" \
  123. -D CMAKE_CXX_FLAGS="$CXXFLAGS -ffat-lto-objects -fPIC -w" \
  124. -D CMAKE_INSTALL_BINDIR=/usr/lib/freecad/bin \
  125. -D CMAKE_INSTALL_DATADIR=/usr/share/freecad \
  126. -D CMAKE_INSTALL_DATAROOTDIR=/usr/share \
  127. -D CMAKE_INSTALL_DOCDIR=/usr/share/freecad/doc \
  128. -D CMAKE_INSTALL_LIBDIR=/usr/lib/freecad/lib \
  129. -D CMAKE_INSTALL_PREFIX=/usr/lib/freecad \
  130. -D FREECAD_USE_EXTERNAL_PIVY=ON \
  131. -D FREECAD_USE_OCC_VARIANT='Official Version' \
  132. -D FREECAD_USE_QT_FILEDIALOG=ON \
  133. -D PYTHON_EXECUTABLE=/usr/bin/python \
  134. -D INSTALL_TO_SITEPACKAGES=ON \
  135. -G Ninja \
  136. -S $pkgname \
  137. -W no-dev
  138. ninja -C build
  139. }
  140. package() {
  141. # pin to strongly-coupled dependency versions
  142. depends=( ${depends[*]/boost-libs/} $(_version_constraint boost-libs 3) )
  143. depends+=( $(_version_constraint opencascade 3) \
  144. $(_version_constraint python 2) )
  145. DESTDIR="$pkgdir" ninja -C build install
  146. # tools
  147. install -Dm755 $pkgname/src/Tools/{$pkgname-thumbnailer,fcinfo} -t "$pkgdir/usr/bin/"
  148. # symlinks
  149. install -d "$pkgdir/usr/bin"
  150. ln -sf /usr/lib/freecad/bin/FreeCAD "$pkgdir/usr/bin/freecad"
  151. ln -sf /usr/lib/freecad/bin/FreeCAD "$pkgdir/usr/bin/FreeCAD"
  152. ln -sf /usr/lib/freecad/bin/FreeCADCmd "$pkgdir/usr/bin/freecadcmd"
  153. ln -sf /usr/lib/freecad/bin/FreeCADCmd "$pkgdir/usr/bin/FreeCADCmd"
  154. # default session descriptor
  155. install -Dm644 branding.xml -t "$pkgdir/usr/lib/$pkgname/bin/"
  156. }