summaryrefslogtreecommitdiff
path: root/libre/blender/PKGBUILD
blob: 76274cfc0cfe5309b3cbcda49c075f23e63ae853 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# Maintainer (arch): Sven-Hendrik Haase <svenstaro@gmail.com>
# Contributor: John Sowiak <john@archlinux.org>
# Contributor: tobias <tobias@archlinux.org>
# Contributor: Andreas Grapentin <andreas@grapentin.org>
# Contributor: Márcio Silva <coadde@hyperbola.info>
# Contributor: bill-auger <bill-auger@programmer.net>


# parabola changes and rationale:
# - removed support for non-free CUDA and optix
# - set OS type string to GNU/Linux-libre
# - pin to tightly-coupled dependency versions


pkgname=blender
pkgver=3.2.0
pkgrel=4
pkgrel+=.parabola1
epoch=17
_pythonver_x86_64=3.10
_pythonver_i686=3.10
_pythonver_armv7h=3.10
eval "_python_ver=\$_pythonver_${CARCH}"
pkgdesc="A fully integrated 3D graphics creation suite"
arch=('x86_64')
arch+=('i686' 'armv7h')
license=('GPL')
url="https://www.blender.org"
depends=('libpng' 'libtiff' 'openexr' 'python' 'desktop-file-utils' 'python-requests' 'potrace'
         'shared-mime-info' 'hicolor-icon-theme' 'xdg-utils' 'glew' 'openjpeg2' 'python-numpy'
         'freetype2' 'openal' 'ffmpeg' 'fftw' 'boost-libs' 'opencollada' 'alembic' 'openxr'
         'openimageio' 'libsndfile' 'jack' 'opencolorio' 'openshadinglanguage' 'openimagedenoise'
         'jemalloc' 'libspnav' 'ptex' 'opensubdiv' 'openvdb' 'log4cplus' 'sdl2' 'embree' 'libharu'
         'draco')
[[ "${CARCH}" != 'x86_64' ]] && depends=( ${depends[*]/openimagedenoise/} )
[[ "${CARCH}" != 'x86_64' ]] && depends=( ${depends[*]/libharu/} )
[[ "${CARCH}" == 'armv7h' ]] && depends=( ${depends[*]/embree/} )
makedepends=('cmake' 'boost' 'mesa' 'git' 'llvm' 'cuda' 'ninja')
makedepends=( ${makedepends[*]/cuda/} ) # non-free
options=(!strip)
source=("git+https://git.blender.org/blender.git#tag=v$pkgver"
        "git+https://git.blender.org/blender-addons.git"
        "git+https://git.blender.org/blender-addons-contrib.git"
        "git+https://git.blender.org/blender-translations.git"
        "git+https://git.blender.org/blender-dev-tools.git"
        https://developer.download.nvidia.com/redist/optix/v7.3/OptiX-7.3.0-Include.zip
        force-draco1.patch
        force-draco2.patch)
source=( ${source[*]/*optix*/dummy-source} ) # non-free
sha512sums=('SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP' # dummy-source
            'e239da4f3906f1b54265435181cf770bae3d269c8d915df9a73861e6ee71ec70bf2339426e7c81a91e5a567273b3b3742d7a99feefd3398d821b26e1ff3a56d0'
            '527ab66e5eace777de0043c1ca5787a488f6471450ce67fd6d08137ad0ef56177bc0c17696f30a5fca23fa55d8ca9c3f30cb7b17550dba2dbd8e89ca0b361990')


_version_constraint() # (dep_pkgname [precision])
{
  local dep_pkgname=$1
  local full_version=$(pacman -S --print-format='%v' ${dep_pkgname} | tail -n 1)
  local n_dots=$(tmp=${full_version%-*} ; tmp=${tmp//[^\.]} ; echo "${#tmp}" ;)
  local def_precision=$(( n_dots + 1 ))
  local precision=$( [[ "$2" =~ ^[1-${def_precision}]$ ]] && echo $2 || echo ${def_precision} )
  local pkgver_rx='[^-\.\ ]+'
  local subver_rx='\.'${pkgver_rx}
  local pkgrel_rx='[^-\ ]+'
  local capture_rx=${pkgver_rx}
  for (( n_dots=1 ; n_dots < precision ; n_dots++ )) ; do capture_rx+=${subver_rx} ; done ;

  if   [[ "${full_version}" =~ ^(${capture_rx})(${subver_rx})*-${pkgrel_rx}$ ]]
  then local version=${BASH_REMATCH[1]}
       local subver_inc=$(( ${version##*.} + 1 ))
       local version_inc=$( [[ "${version}" =~ \. ]] && echo ${version%.*}.${subver_inc} || \
                                                        echo ${subver_inc}                  )
       local constraint_string="${dep_pkgname}>=${version} ${dep_pkgname}<${version_inc}"

       echo "applied version constraint: ${constraint_string}" >&2
       echo -n "${constraint_string}"
  else echo "ERROR: _version_constraint() error parsing: dep_pkgname='${dep_pkgname}' full_version='${full_version}'" >&2
       exit 1
  fi
}

prepare() {
  cd "$pkgname"

  git submodule init
  git config submodule."release/scripts/addons".url "${srcdir}/blender-addons"
  git config submodule."release/scripts/addons_contrib".url "${srcdir}/blender-addons-contrib"
  git config submodule."release/datafiles/locale".url "${srcdir}/blender-translations"
  git config submodule."source/tools".url "${srcdir}/blender-dev-tools"
  git submodule update
  git submodule foreach git checkout v${pkgver}

  patch -p1 -i "$srcdir"/force-draco1.patch
  patch -p1 -d release/scripts/addons -i "$srcdir"/force-draco2.patch


  ## parabola patching ##

  # set OS type string
  sed -i 's|BUILD_PLATFORM;|"GNU/Linux-libre";|' 'source/creator/buildinfo.c'

  # FIXME: error: implicit declaration of function ‘atomic_add_and_fetch_uint64’;
  #               did you mean ‘atomic_add_and_fetch_uint32’? [-Werror=implicit-function-declaration]
  if   [[ "${CARCH}" == 'armv7h' ]] || [[ "${CARCH}" == 'i686' ]]
  then local sed_cmd='s| atomic_add_and_fetch_uint64(| atomic_add_and_fetch_uint32(|'
       sed -i "${sed_cmd}" source/blender/blenlib/intern/session_uuid.c
  fi
}

build() {
  cd "$pkgname"

  local PYTHON_VER=${_python_ver}

  # libre options
  local _parabola_opts=( -DWITH_CYCLES_CUDA_BINARIES=OFF \
                         -DWITH_CYCLES_DEVICE_CUDA=OFF   \
                         -DWITH_CYCLES_DEVICE_OPTIX=OFF  )
  # arch-specific options
  case "${CARCH}" in
  'i686'  ) _parabola_opts+=( -DWITH_RAYOPTIMIZATION=OFF \
                              -DWITH_CYCLES_EMBREE=ON    ) ;;
  'x86_64') _parabola_opts+=( -DWITH_CYCLES_EMBREE=ON    ) ;;
  esac

  cmake \
    -Bbuild \
    -GNinja \
    -Cbuild_files/cmake/config/blender_release.cmake \
    ${_parabola_opts[@]} \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=Release \
    -DWITH_INSTALL_PORTABLE=OFF \
    -DWITH_PYTHON_INSTALL=OFF \
    -DPYTHON_VERSION=$PYTHON_VER \
    -DPYTHON_LIBPATH=/usr/lib \
    -DPYTHON_LIBRARY=python$PYTHON_VER \
    -DPYTHON_INCLUDE_DIRS=/usr/include/python$PYTHON_VER \
    -DCMAKE_CXX_FLAGS="-I /usr/include/python$PYTHON_VER"
  ninja -C build
}

package() {
  cd "$pkgname"

  # pin to tightly-coupled dependency versions
  # NOTE: indirect sodeps may still be unsatisfyable:
  #       libboost_filesystem.so <- openimageio,
  #       libboost_thread.so     <- openshadinglanguage,
  #       libboost_iostreams.so  <- openvdb
  depends+=( libboost_locale.so
             $(_version_constraint opencolorio         2)   # eg: libOpenColorIO.so.2.1
             $(_version_constraint openexr             2)   # eg: libHalf.so.12
             $(_version_constraint openimageio         2)   # eg: libOpenImageIO.so.2.0
             $(_version_constraint openshadinglanguage 2)   # eg: liboslcomp.so.1.10
             $(_version_constraint opensubdiv          3)   # eg: libosdGPU.so.3.3.3
             $(_version_constraint openvdb             2)   # eg: libopenvdb.so.6.2
             $(_version_constraint python              2) ) # eg: libpython3.6.so.1.0

  DESTDIR="${pkgdir}" ninja -C build install
  install -Dm755 release/bin/blender-softwaregl "${pkgdir}/usr/bin/blender-softwaregl"
  python -m compileall "${pkgdir}/usr/share/blender"
  python -O -m compileall "${pkgdir}/usr/share/blender"

  install -Dm644 release/freedesktop/org.blender.Blender.appdata.xml "${pkgdir}/usr/share/metainfo/org.blender.Blender.appdata.xml"

  # Manually install additional scripts (See FS#69351)
  cp -r release/scripts/addons_contrib/* "${pkgdir}"/usr/share/blender/3*/scripts/addons_contrib/

  # Manually install draco bindings (See FS#73415)
  mkdir -p "${pkgdir}"/usr/lib/python3.10/
  mv "${pkgdir}"/usr/share/blender/3*/python/lib/* "${pkgdir}"/usr/lib/
  rm -r "${pkgdir}"/usr/share/blender/3*/python
}