summaryrefslogtreecommitdiff
path: root/PKGBUILD
blob: aea9bef4ec252895f3f842d8374d8f4ab55409d9 (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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# Maintainer: Ingar <ingar@telenet.be>
# based on the archlinux libcamera package by David Runge <dvzrv@archlinux.org>
#
# TODO
# - create a separate libpisp package

pkgbase=libcamera-rpi
pkgname=(
  libcamera-rpi
  libcamera-rpi-docs
  libcamera-rpi-ipa
  libcamera-rpi-tools
  gst-plugin-libcamera-rpi
)
pkgver=0.3.2+rpt20240927
pkgrel=1
pkgdesc="A complex camera support library for Linux, Android, and ChromeOS (RPi Foundation fork)"
arch=(aarch64)
url="https://github.com/raspberrypi/libcamera"
_url="https://github.com/raspberrypi/libcamera.git"
makedepends=(
  doxygen
  glib2
  graphviz
  gst-plugins-base
  gtest
  libdrm
  libjpeg-turbo
  libtiff
  libyaml
  meson
  python-jinja
  python-ply
  python-sphinx
  python-pyyaml
  qt6-base
  qt6-tools
  sdl2
  systemd
  texlive-core
  texlive-latex
)
source=(
  "https://github.com/raspberrypi/libcamera/releases/download/v${pkgver}/libcamera-${pkgver}.tar.xz"
  "libcamera-rpi-0.3.2-arch.patch"
)
sha256sums=(
  '4d6502a2371204f3a54955f4a25f806be88fcc469167f655afbe9b398f827392'
  '5c8f66b75a3d470101bb69c572de93e1d14e29c614dcb0391f3ea526781c260e'
)
_pick() {
  local p="$1" f d; shift
  for f; do
    d="$srcdir/$p/${f#$pkgdir/}"
    mkdir -p "$(dirname "$d")"
    mv "$f" "$d"
    rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
  done
}

prepare() {
  mv libcamera-0.3.2 $pkgbase
  cd $pkgbase

  patch -Np1 -i ../libcamera-rpi-0.3.2-arch.patch

  # add version, so that utils/gen-version.sh may rely on it
  printf "%s\n" "$pkgver" > .tarball-version
}

build() {
  local meson_options=(
    --buildtype=release
    --wrap-mode default
    -D pipelines=rpi/vc4,rpi/pisp
    -D ipas=rpi/vc4,rpi/pisp 
    -D v4l2=true
    -D tracing=disabled
    -D test=true
    -D pycamera=enabled
  )

  arch-meson $pkgbase build "${meson_options[@]}"
  meson compile -C build
}

check() {
  meson test -C build || echo "Tests require CLONE_NEWUSER/ CLONE_NEWNET."
}

package_libcamera-rpi() {
  license=(
    Apache-2.0
    CC0-1.0
    'GPL-2.0-only WITH Linux-syscall-note'
    GPL-2.0-or-later
    LGPL-2.1-or-later
    'GPL-2.0-or-later WITH Linux-syscall-note OR BSD-3-Clause'
    'GPL-2.0-or-later WITH Linux-syscall-note OR MIT'
  )
  depends=(
    gcc-libs
    glibc
    gnutls
    libcamera-rpi-ipa
    libelf
    libunwind
    libyaml
    sh
    systemd-libs libudev.so
  )
  optdepends=(
    'gst-plugin-libcamera-rpi: GStreamer plugin'
    'libcamera-rpi-docs: for documentation'
    'libcamera-rpi-tools: for applications'
  )
  provides=(libcamera.so libcamera-base.so)

  conflicts=(libcamera)

  meson install -C build --destdir "$pkgdir"
  install -vDm 644 $pkgbase/LICENSES/{BSD-3-Clause,Linux-syscall-note,MIT}.txt -t "$pkgdir/usr/share/licenses/$pkgname/"

  (
    cd "$pkgdir"
    _pick $pkgbase-docs usr/share/doc
    _pick $pkgbase-ipa usr/lib/libcamera/
    _pick $pkgbase-tools usr/bin/{cam,qcam,lc-compliance}
    _pick gst-plugin-$pkgbase usr/lib/gstreamer-*
  )
}

package_libcamera-rpi-docs() {
  pkgdesc+=" - documentation"
  license=(
    CC-BY-4.0
    CC-BY-SA-4.0
    CC0-1.0
  )
  conflicts=(libcamera-docs)

  mv -v $pkgname/* "$pkgdir"
  mv -v "$pkgdir/usr/share/doc/libcamera-0.3.2/" "$pkgdir/usr/share/doc/$pkgbase/"
  rm -frv "$pkgdir/usr/share/doc/$pkgbase/html/.buildinfo"
}

package_libcamera-rpi-ipa() {
  pkgdesc+=" - signed IPA"
  license=(
    BSD-2-Clause
    CC-BY-SA-4.0
    CC0-1.0
    GPL-2.0-or-later
    LGPL-2.1-or-later
  )
  depends=(
    gcc-libs
    glibc
    libcamera-rpi libcamera.so libcamera-base.so
  )
  conflicts=(libcamera-ipa)
  # stripping requires re-signing of IPA libs, so we do it manually
  options=(!strip)

  strip $pkgname/usr/lib/libcamera/*{.so,proxy}
  for _lib in $pkgname/usr/lib/libcamera/*.so; do
    $pkgbase/src/ipa/ipa-sign.sh "$(find build -type f -iname "*ipa-priv-key.pem")" "$_lib" "$_lib.sign"
  done
  mv -v $pkgname/* "$pkgdir"
  install -vDm 644 $pkgbase/LICENSES/BSD-2-Clause.txt -t "$pkgdir/usr/share/licenses/$pkgname/"
}

package_libcamera-rpi-tools() {
  pkgdesc+=" - tools"
  license=(
    BSD-2-Clause
    CC0-1.0
    GPL-2.0-or-later
    LGPL-2.1-or-later
  )
  depends=(
    gcc-libs
    glibc
    gtest
    libcamera-rpi libcamera.so libcamera-base.so
    libdrm
    libevent libevent-2.1.so libevent_pthreads-2.1.so
    libjpeg-turbo libjpeg.so
    libtiff libtiff.so
    libyaml
    qt5-base
    sdl2
  )
  conflicts=("libcamera-tools")

  mv -v $pkgname/* "$pkgdir"
  install -vDm 644 $pkgbase/LICENSES/BSD-2-Clause.txt -t "$pkgdir/usr/share/licenses/$pkgname/"
}

package_gst-plugin-libcamera-rpi() {
  pkgdesc="Multimedia graph framework - libcamera plugin"
  license=(
    CC0-1.0
    LGPL-2.1-or-later
  )
  depends=(
    gcc-libs
    glibc
    glib2 libg{lib,object}-2.0.so
    gstreamer
    gst-plugins-base-libs
    libcamera-rpi libcamera.so libcamera-base.so
  )
  conflicts=(gst-plugin-libcamera)

  mv -v $pkgname/* "$pkgdir"
}