Overview

Request 6173 (accepted)

Initial packaging

Submit package home:gcomes.pmbs:dsnote / speechnote to package Extra / speechnote

speechnote.spec Added
x
 
1
@@ -0,0 +1,379 @@
2
+#
3
+# spec file for package speechnote
4
+#
5
+# Copyright (c) 2025 SUSE LINUX GmbH, Nuernberg, Germany.
6
+#
7
+# All modifications and additions to the file contributed by third parties
8
+# remain the property of their copyright owners, unless otherwise agreed
9
+# upon. The license for this file, and modifications and additions to the
10
+# file, is the same license as for the pristine package itself (unless the
11
+# license for the pristine package is not an Open Source License, in which
12
+# case the license is the MIT License). An "Open Source License" is a
13
+# license that conforms to the Open Source Definition (Version 1.9)
14
+# published by the Open Source Initiative.
15
+
16
+# Please submit bugfixes or comments via http://bugs.opensuse.org/
17
+#
18
+
19
+%define  aname  dsnote
20
+%define __provides_exclude ^(libRHVoice.*\\.so.*|libaprilasr\\.so.*|libbergamot_api.*\\.so.*|libclblast\\.so.*|libespeak-ng\\.so.*|libkenlm\\.so.*|libonnxruntime\\.so.*|libstt\\.so.*|libtensorflowlite\\.so.*|libtflitedelegates\\.so.*|libvosk\\.so.*|libwhisper-.*\\.so.*|mimehandler\\(.*|perl\\(.*)$
21
+%define __requires_exclude ^(libRHVoice.*\\.so.*|libaprilasr\\.so.*|libbergamot_api.*\\.so.*|libclblast\\.so.*|libespeak-ng\\.so.*|libkenlm\\.so.*|libonnxruntime\\.so.*|libstt\\.so.*|libtensorflowlite\\.so.*|libtflitedelegates\\.so.*|libvosk\\.so.*|libwhisper-.*\\.so.*|libamdhip64\\.so.*|libhipblas\\.so.*|librocblas\\.so.*)$
22
+
23
+%if 0%{?suse_version} <= 1600
24
+%define pythons python311
25
+%else
26
+%define pythons python3
27
+%endif
28
+%if 0%{?suse_version} < 1600
29
+%define isLeap15 %nil
30
+%else
31
+%undefine isLeap15
32
+%endif
33
+%if 0%{?suse_version} == 1600
34
+%define isLeap16 %nil
35
+%else
36
+%undefine isLeap16
37
+%endif
38
+
39
+%bcond_with mkl
40
+%bcond_with download
41
+
42
+Name:           speechnote
43
+Version:        4.7.0
44
+Release:        0
45
+Summary:        App for note taking, reading and translating
46
+URL:            https://github.com/mkiol/dsnote
47
+License:        MPL-2.0
48
+Group:          Productivity/Office/Other
49
+Source:         %aname-%version.tar.gz
50
+Source1:        sources.tar.zst
51
+Source2:        libxkbcommon-1.6.0.tar.xz
52
+Source3:        CTranslate2-v4.3.1.tar.zst
53
+Source4:        rhvoice-71a1a8.tar.zst
54
+Source5:        bergamot-ada8c3.tar.zst
55
+Source6:        pythonmodules.tar.zst
56
+Source7:        %name.rpmlintrc
57
+Source8:        README.SUSE
58
+BuildRequires:  cmake
59
+BuildRequires:  gcc-c++
60
+BuildRequires:  cmake(Qt5LinguistTools)
61
+BuildRequires:  cmake(Qt5Multimedia)
62
+BuildRequires:  cmake(Qt5Xml)
63
+BuildRequires:  cmake(Qt5Sql)
64
+BuildRequires:  cmake(Qt5QuickControls2)
65
+BuildRequires:  cmake(Qt5X11Extras)
66
+BuildRequires:  extra-cmake-modules
67
+%if %{defined isLeap15} || %{defined isLeap16}
68
+BuildRequires:  meson
69
+BuildRequires:  bison
70
+BuildRequires:  pkgconfig(libxml-2.0)
71
+%else
72
+BuildRequires:  pkgconfig(xkbcommon-x11) >= 1.6
73
+%endif
74
+BuildRequires:  cmake(KF5DBusAddons)
75
+BuildRequires:  git-core
76
+BuildRequires:  %{python_module devel}
77
+BuildRequires:  AppStream
78
+BuildRequires:  libXtst-devel
79
+BuildRequires:  libXinerama-devel
80
+
81
+BuildRequires:  libopenblas_pthreads-devel
82
+BuildRequires:  libarchive-devel
83
+BuildRequires:  fmt-devel
84
+BuildRequires:  xz-devel
85
+BuildRequires:  %{python_module pybind11-devel}
86
+BuildRequires:  librubberband-devel
87
+BuildRequires:  libtag-devel
88
+BuildRequires:  libnumbertext-devel
89
+BuildRequires:  libtool
90
+BuildRequires:  ocl-icd-devel
91
+%if %{defined isLeap15}
92
+BuildRequires:  libboost_headers1_75_0-devel
93
+%else
94
+%if %{defined isLeap16}
95
+BuildRequires:  libboost_headers1_84_0-devel
96
+%else
97
+BuildRequires:  libboost_headers-devel
98
+%endif
99
+%endif
100
+BuildRequires:  chrpath
101
+BuildRequires:  dos2unix
102
+BuildRequires:  fdupes
103
+BuildRequires:  site-config
104
+BuildRequires:  yq
105
+BuildRequires:  wget
106
+BuildRequires:  %{python_module pip}
107
+BuildRequires:  %{python_module Cython0}
108
+BuildRequires:  %{python_module wheel}
109
+BuildRequires:  %{python_module six}
110
+BuildRequires:  %{python_module Markdown}
111
+BuildRequires:  %{python_module setuptools}
112
+BuildRequires:  zstd
113
+BuildRequires:  onednn-devel
114
+%if %{with mkl}
115
+BuildRequires:  intel-oneapi-mkl-devel
116
+%endif
117
+
118
+Recommends:     %{name}-python-modules = %{version}
119
+
120
+%description
121
+Speech Note let you take, read and translate notes in multiple languages.
122
+It uses Speech to Text, Text to Speech and Machine Translation to do so.
123
+Text and voice processing take place entirely offline, locally on your
124
+computer, without using a network connection.
125
+
126
+%package python-modules
127
+Summary:        Extra python modules
128
+Requires:       %{name} = %{version}
129
+Requires:       libdnnl3
130
+AutoReqProv:    no
131
+
132
+%description python-modules
133
+Python modules for %name
134
+
135
+
136
+
137
+%prep
138
+%setup -q -n %{aname}-%{version}
139
+%if %{without download}
140
+#do not download libsst
141
+sed -i '/DOWNLOAD/d' cmake/libstt.cmake
142
+%endif
143
+
144
+mkdir build build/aux external external/pythonsrc
145
+
146
+%if %{without download}
147
+tar fx %SOURCE1 -C build
148
+
149
+tar fx %SOURCE4 -C external
150
+sed -i '/GIT_REPOSITORY/d;/GIT_TAG/d;/GIT_SHALLOW/d' cmake/rhvoice.cmake
151
+
152
+tar fx %SOURCE5 -C external
153
+mv external/bergamot external/bergamotfallback
154
+tar fx %SOURCE5 -C external
155
+sed -i '/GIT_REPOSITORY/d;/GIT_TAG/d;/GIT_SHALLOW/d' cmake/bergamot.cmake
156
+%endif
157
+#endif without download
158
+
159
+srcdownload () {
160
+    local n i URL DEST SHA256
161
+    n=$(yq '.modules | explode(.) | select(.name == "'$2'" )' $3 | yq '.sources' | grep -c -e ^-)
162
+    if ((n)); then
163
+        for ((i=0;i<n;i++)) ; do
164
+            case $(yq '.modules | explode(.) | select(.name == "'$2'" )' $3 | yq '.sources'$i'.type') in
165
+                git)
166
+                    git -C $1 clone --recursive $(yq '.modules | explode(.) | select(.name == "'$2'" )' $3 | yq '.sources'$i'.url')
167
+                    pushd $1/* >/dev/null
168
+                    git checkout $(yq '.modules | explode(.) | select(.name == "'$2'" )' $3 | yq '.sources'$i'.commit')
169
+                    popd >/dev/null
170
+                    ;;
171
+                file|archive)
172
+                    URL=$(yq '.modules | explode(.) | select(.name == "'$2'" )' $3 | yq '.sources'$i'.url')
173
+                    DEST=$(yq '.modules | explode(.) | select(.name == "'$2'" )' $3 | yq '.sources'$i'.dest-filename')
174
+                     $DEST = null  && DEST=${URL##*/}
175
+                    SHA256=$(yq '.modules | explode(.) | select(.name == "'$2'" )' $3 | yq '.sources'$i'.sha256')
176
+                     ! -f $1/$DEST  && wget -q -O $1/$DEST $URL
177
+                     $(sha256sum $1/$DEST | cut -f1 -d" ") = $SHA256 
178
+                    ;;&
179
+                archive)
180
+                    tar fx $1/$DEST -C $1 && mv $1/$DEST $1/..
181
+                    ;;
182
+                patch|file) : ;;
183
+                *) false ;;
184
+            esac
185
+        done
186
+    fi
187
+}
188
+
189
+%if %{with download}
190
+srcdownload build/aux ctranslate2 $PWD/flatpak/net.mkiol.SpeechNote.yaml
191
+%else
192
+tar fx %SOURCE3 -C build/aux
193
+%endif
194
+
195
+
196
+%if %{with download}
197
+for m in $(yq '.modules.name | explode(.)' flatpak/python3-modules-x86-64.yaml) ; do
198
+    srcdownload external/pythonsrc $m $PWD/flatpak/python3-modules-x86-64.yaml
199
+done
200
+%else
201
+tar fx %SOURCE6 -C external/pythonsrc
202
+%endif
203
+
204
+cp %SOURCE8 .
205
+
206
+#rpath /usr/share/dsnote/lib
207
+sed -i '/-rpath/s@/lib@/share/%{aname}&@' CMakeLists.txt
208
+
209
+#fix build error
210
+sed -i 's@X11::Xtst@Xtst@;s@X11::Xinerama@Xinerama@' CMakeLists.txt
211
+
212
+
213
+%build
214
+export PKG_CONFIG_PATH=%{python_sitelib}/pybind11/share/pkgconfig
215
+
216
+%if %{defined isLeap15} || %{defined isLeap16}
217
+mkdir xkb
218
+tar fx %SOURCE2 -C xkb
219
+cd xkb/libxkbcommon-1.6.0
220
+mkdir build
221
+%meson -Denable-docs=false -Ddefault_library=static -Denable-x11=true -Denable-tools=false -Denable-bash-completion=false --buildtype=release
222
+%meson_build
223
+DESTDIR=$PWD/build meson install -C x86_64-suse-linux --no-rebuild
224
+PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$PWD/build%{_libdir}/pkgconfig
225
+sed -i '/^prefix=/s@=.*@=${pcfiledir}/../../@' build%{_libdir}/pkgconfig/xkbcommon.pc
226
+sed -i '/^prefix=/s@=.*@=${pcfiledir}/../../@' build%{_libdir}/pkgconfig/xkbcommon-x11.pc
227
+cd ../..
228
+%endif
229
+
230
+%cmake \
231
+  -DCMAKE_BUILD_TYPE=Release \
232
+  -DWITH_DESKTOP=ON \
233
+  \
234
+  -DBUILD_WHISPERCPP_CLBLAST=ON \
235
+  -DBUILD_WHISPERCPP_VULKAN=ON \
236
+%if %{defined isLeap15} || %{defined isLeap16}
237
+  -DCMAKE_EXE_LINKER_FLAGS_RELEASE=-L$PWD/../xkb/libxkbcommon-1.6.0/build/%{_libdir} \
238
+%endif
239
+  -DBUILD_OPENBLAS=OFF \
240
+  -DBUILD_LIBARCHIVE=OFF \
241
+  -DBUILD_XZ=OFF \
242
+  -DBUILD_FMT=OFF \
243
+  -DBUILD_RUBBERBAND=OFF \
244
+  -DBUILD_LIBNUMBERTEXT=OFF \
245
+  -DBUILD_PYBIND11=OFF \
246
+  -DBUILD_FFMPEG=ON \
247
+  -DBUILD_TAGLIB=OFF \
248
+  -DBUILD_ESPEAK=ON \
249
+  -DCMAKE_VERBOSE_MAKEFILE=OFF \
250
+  -Wno-dev
251
+
252
+%cmake_build
253
+
254
+
255
+cd aux/CTranslate2*
256
+%cmake \
257
+  -DCMAKE_BUILD_TYPE=Release \
258
+  -DBUILD_CLI=OFF \
259
+  -DCUDA_DYNAMIC_LOADING=ON \
260
+  -DOPENMP_RUNTIME=COMP \
261
+%if %{with mkl}
262
+  -DWITH_MKL=ON \
263
+%else
264
+  -DWITH_MKL=OFF \
265
+%endif
266
+  -DWITH_DNNL=ON \
267
+  -DWITH_RUY=ON \
268
+  -DCMAKE_CXX_FLAGS=-msse4.1 \
269
+  -DCMAKE_INSTALL_PREFIX=%{_datadir}/%{aname}/python/extensions/cpu \
270
+  %{nil}
271
+
272
+%cmake_build
273
+DESTDIR=$PWD/../tmpinst make install
274
+cd ../python
275
+sed -i '/^ldflags/s@=.*@= "-Wl,-rpath,%_datadir/%{aname}/python/extensions/cpu/%{_lib}"@' setup.py 
276
+CTRANSLATE2_ROOT=$PWD/../tmpinst/%{_datadir}/%{aname}/python/extensions/cpu python%{python_version} setup.py bdist_wheel
277
+cd ../../..
278
+
279
+
280
+
281
+%install
282
+%cmake_install
283
+
284
+FLATPAK_DEST=%buildroot%{_datadir}/%{aname}/python
285
+export PYTHONPATH=$FLATPAK_DEST/extensions/cpu/%{_lib}/python%{python_version}/site-packages:$FLATPAK_DEST/lib/python%{python_version}/site-packages:$FLATPAK_DEST/%{_lib}/python%{python_version}/site-packages
286
+
287
+YAMLSRC=$PWD/flatpak/python3-modules-x86-64.yaml
288
+ -f $YAMLSRC 
289
+MODSRCDIR=$PWD/external/pythonsrc
290
+
291
+modules=$(yq '.modules.name' $YAMLSRC)
292
+
293
+for m in $modules ; do
294
+    DSBUILDFLAGS=
295
+    BUILDMOD=$PWD/python-modules
296
+    mkdir $BUILDMOD
297
+    pushd $MODSRCDIR >/dev/null
298
+    modsrc=$(yq '.modules | explode(.) | select(.name == "'$m'" )' $YAMLSRC | yq '.sources.url' | sed 's@.*/@@;s@%2B@+@g')
299
+    for a in $modsrc ; do
300
+         -f $a  && ln $a $BUILDMOD
301
+    done
302
+    popd >/dev/null
303
+    pushd $BUILDMOD >/dev/null
304
+    #build
305
+%if ! ( %{defined isLeap15} || %{defined isLeap16} )
306
+     $m = python3-mycroft_mimic3_tts  && DSBUILDFLAGS="CFLAGS=-Wno-error=incompatible-pointer-types"
307
+%endif
308
+    eval $(yq '.modules | explode(.) | select(.name == "'$m'" )' $YAMLSRC | yq '.build-commands' | sed "s@python @python%{python_version} @;s@^pip3 @$DSBUILDFLAGS pip3 @;s@\$@;@")
309
+    #cleanup
310
+    eval $(yq '.modules | explode(.) | select(.name == "'$m'" )' $YAMLSRC | yq '.cleanup' | sed 's@^@rm -rf $FLATPAK_DEST@;s@/lib/@/lib*/@g;s@$@;@')
311
+    popd >/dev/null
312
+    rm -r $BUILDMOD
313
+done
314
+
315
+YAMLSRC=$(dirname $YAMLSRC)/net.mkiol.SpeechNote.yaml
316
+cd build/aux/CTranslate2*
317
+%cmake_install
318
+( export PYTHONPATH=${FLATPAK_DEST}/extensions/cpu/%{_lib}/python%{python_version}/site-packages:$FLATPAK_DEST/lib/python%{python_version}/site-packages:$FLATPAK_DEST/%{_lib}/python%{python_version}/site-packages
319
+  rm -rf ${FLATPAK_DEST}/%{_lib}/python%{python_version}/site-packages/ctranslate2*
320
+  m=ctranslate2
321
+  #install
322
+  eval $(yq '.modules | explode(.) | select(.name == "'$m'" )' $YAMLSRC | yq '.post-install' | grep -A4 ^pip3 | sed 's@/lib/@/lib*/@g;s@$@;@')
323
+  #cleanup
324
+  eval $(yq '.modules | explode(.) | select(.name == "'$m'" )' $YAMLSRC | yq '.cleanup' | sed 's@^@rm -rf $FLATPAK_DEST@;s@/lib/@/lib*/@g;s@$@;@')
325
+)
326
+cd ../../..
327
+
328
+
329
+rm -r $FLATPAK_DEST/lib{,64}/python%{python_version}/site-packages/__pycache__
330
+rm -r $FLATPAK_DEST/lib/python%{python_version}/site-packages/pypinyin/__pycache__
331
+rm -r $FLATPAK_DEST/%{_lib}/python%{python_version}/site-packages/pandas/tests
332
+rm -r $FLATPAK_DEST/extensions/cpu/%{_lib}/python%{python_version}/site-packages/torch/{test,include}
333
+rm $FLATPAK_DEST/%{_lib}/python%{python_version}/site-packages/numpy/*/lib/lib*.a
334
+
335
+find $FLATPAK_DEST -name "*.so" -exec strip --strip-unneeded {} \;
336
+find $FLATPAK_DEST -name "*.so.*" -exec strip --strip-unneeded {} \;
337
+find $FLATPAK_DEST/extensions/cpu/%{_lib}/python%{python_version}/site-packages/torch -type f -perm -a+x -a ! -name "*.so.*" -exec strip --strip-unneeded {} \;
338
+chmod a-x $FLATPAK_DEST/lib/python%{python_version}/site-packages/tensorboard/webfiles.zip
339
+rm $FLATPAK_DEST/%{_lib}/python%{python_version}/site-packages/.gitignore
340
+rm -r $FLATPAK_DEST/share
341
+rm $FLATPAK_DEST/bin/widsindex
342
+rmdir $FLATPAK_DEST/bin
343
+
344
+%fdupes %buildroot%_datadir/%{aname}/python
345
+mv %buildroot%{_bindir}/%{aname} %buildroot%{_bindir}/%{aname}.exe
346
+#main program script
347
+SHPRE=%_datadir/%{aname}/python/extensions
348
+SHPOST=%{_lib}/python%{python_version}/site-packages
349
+SHSP=
350
+echo -e "#!/bin/bash\n" >%buildroot%{_bindir}/%{aname}
351
+echo -e "${SHSP}export LD_LIBRARY_PATH=\${LD_LIBRARY_PATH:+\$LD_LIBRARY_PATH:}$SHPRE/cpu/%{_lib}\n${SHSP}export PYTHONPATH=\${PYTHONPATH:+\$PYTHONPATH:}$SHPRE/cpu/$SHPOST" >>%buildroot%{_bindir}/%{aname}
352
+echo -e 'export PYTHONPATH=$PYTHONPATH:%_datadir/%{aname}/python/lib/python%{python_version}/site-packages:%_datadir/%{aname}/python/'$SHPOST'\nexec %{aname}.exe "$@"' >>%buildroot%{_bindir}/%{aname}
353
+chmod a+x %buildroot%{_bindir}/%{aname}
354
+
355
+ln -s %aname %buildroot%{_bindir}/%{name}
356
+chrpath -r %_datadir/%{aname}/lib %buildroot%_datadir/%aname/bin/espeak-ng
357
+chrpath -r %_datadir/%{aname}/lib %buildroot%_datadir/%aname/lib/libstt.so
358
+dos2unix %buildroot%_datadir/%aname/share/uroman/bin/*
359
+chmod u+x %buildroot%_datadir/%aname/share/uroman/bin/*.pl
360
+
361
+export NO_BRP_CHECK_RPATH=true
362
+
363
+%files
364
+%doc README.md README.SUSE
365
+%license LICENSE
366
+%{_bindir}/%{name}
367
+%{_bindir}/%{aname}
368
+%{_bindir}/%{aname}.exe
369
+%{_datadir}/applications/%{aname}.desktop
370
+%{_datadir}/dbus-1/services/%{aname}.service
371
+%{_datadir}/icons/hicolor/*
372
+%{_datadir}/metainfo/%{aname}.metainfo.xml
373
+%{_datadir}/%{aname}
374
+%exclude %{_datadir}/%{aname}/python
375
+
376
+%files python-modules
377
+%{_datadir}/%{aname}/python
378
+
379
+
380
+%changelog
381
CTranslate2-v4.3.1.tar.zst Added
README.SUSE Added
28
 
1
@@ -0,0 +1,26 @@
2
+Speech Note is split in two packages:
3
+speechnote and speechnote-python-modules.
4
+Installing speechnote alone gives you a
5
+functional program, although some features are
6
+missing: 
7
+see Settings -> Advanced in the program's menu.
8
+More capabilities are available when you
9
+install speechnote-python-modules.
10
+
11
+
12
+If you find a problem running the program, there could
13
+be two possible causes:
14
+
15
+1) the problem is related to the packaging for openSUSE.
16
+Run the flatpak version of speechnote and see if it shows
17
+the same problem.
18
+If it doesn't, then something went wrong while
19
+building speechnote. Please report the issue to
20
+the following mailing list:
21
+  packman@links2linux.de
22
+
23
+2) If the flatpak version and the rpm version both show
24
+the same issue, then the bug is not related to the rpm 
25
+packaging. In such case report the issue upstream:
26
+  https://github.com/mkiol/dsnote/issues
27
+
28
bergamot-ada8c3.tar.zst Added
dsnote-4.7.0.tar.gz Added
libxkbcommon-1.6.0.tar.xz Added
pythonmodules.tar.zst Added
rhvoice-71a1a8.tar.zst Added
sources.tar.zst Added
speechnote.rpmlintrc Added
29
 
1
@@ -0,0 +1,27 @@
2
+setBadness('arch-dependent-file-in-usr-share',0)
3
+setBadness('library-without-ldconfig-postin',0)
4
+setBadness('library-without-ldconfig-postun',0)
5
+setBadness('devel-file-in-non-devel-package',0)
6
+setBadness('env-script-interpreter',0)
7
+#tumbleweed
8
+setBadness('binary-or-shlib-defines-rpath',0)
9
+setBadness('missing-hash-section',0)
10
+setBadness('shared-library-not-executable',0)
11
+setBadness('executable-stack',0)
12
+addFilter('arch-dependent-file-in-usr-share')
13
+addFilter('devel-file-in-non-devel-package')
14
+addFilter('library-without-ldconfig-postin')
15
+addFilter('library-without-ldconfig-postun')
16
+addFilter('shared-lib-calls-exit')
17
+addFilter('zero-length')
18
+addFilter('python-bytecode-inconsistent-mtime')
19
+addFilter('env-script-interpreter')
20
+addFilter('hidden-file-or-dir')
21
+addFilter('non-executable-script')
22
+addFilter('script-without-shebang')
23
+addFilter('position-independent-executable-suggested')
24
+addFilter('shared-lib-without-dependency-information')
25
+#tumbleweed
26
+addFilter('python-missing-require')
27
+addFilter('binary-or-shlib-defines-rpath')
28
+addFilter('missing-hash-section')
29
Refresh
Refresh
Request History
Giacomo Comes's avatar

gcomes.pmbs created request about 1 month ago

Initial packaging


Olaf Hering's avatar

olh accepted request 23 days ago