spec: Support printing commit id in version output

This may be useful for bug reporting.

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
This commit is contained in:
Vitaly Chikunov 2025-05-09 00:21:47 +03:00
parent b2f17b3cba
commit 9167cfc475
3 changed files with 10 additions and 3 deletions

View file

@ -26,6 +26,7 @@ Requires: %name-cuda = %EVR
%endif
Source: %name-%version.tar
Patch: %name-%version.patch
Source1: kompute-0.tar
BuildRequires(pre): rpm-macros-cmake
@ -121,11 +122,13 @@ Requires: %name-cpu = %EVR
%prep
%setup
%autopatch -p1
tar xf %SOURCE1 -C ggml/src/ggml-kompute
commit=$(awk '$2=="b%version"{print$1}' .gear/tags/list)
cat <<-EOF >> cmake/build-info.cmake
set(BUILD_NUMBER %version)
set(GGML_BUILD_NUMBER %version)
set(BUILD_COMMIT "%release")
set(BUILD_COMMIT "${commit::8} [%release]")
EOF
sed -i '/POSITION_INDEPENDENT_CODE/s/PROPERTIES/& SOVERSION 0.0.%version/' ggml/src/CMakeLists.txt src/CMakeLists.txt
sed -i 's/POSITION_INDEPENDENT_CODE/SOVERSION 0.0.%version &/' ggml/cmake/ggml-config.cmake.in
@ -178,7 +181,7 @@ printf '%%s\n' llama-server llama-simple llama-run |
%dnl export LD_LIBRARY_PATH=%buildroot%_libdir:%buildroot%_libexecdir/llama PATH+=:%buildroot%_bindir
export LD_LIBRARY_PATH=$PWD/%_cmake__builddir/bin PATH+=:$PWD/%_cmake__builddir/bin
llama-cli --version
llama-cli --version |& grep -Fx 'version: %version (%release)'
llama-cli --version |& grep -Ex 'version: %version \(\S+ \[%release\]\)'
# test-eval-callback wants network.
%ctest -j1 -E test-eval-callback
llama-cli -m %_datadir/tinyllamas/stories260K.gguf -p "Hello" -s 42 -n 500

View file

@ -1,3 +1,6 @@
tar: .
# The diff is only to detect commit hash of release tag `gear-update-tag -ac`
# for version output.
tar: b@version@:.
diff: b@version@:. . name=@name@-@version@.patch
spec: .gear/llama.cpp.spec
tar: submodule/kompute-0:. name=kompute-0 base=kompute

View file

@ -1 +1,2 @@
4565194ed7c32d1d2efa32ceab4d3c6cae006306 submodule/kompute-0
15e03282bb432631193464100c2237a3b6bcfe4c b5318