crowdsec: Set tag version as expected by upstream

Without setting the correct version here, the package is completely
broken as the local API checks that any clients report the correct
user agent, which includes this string.

The sanity check missed this since `grep` just checks if a string
exists in the line, and the version happened to be a superstring of
what is expected. I've made this a bit more robust and switched to
using `preCheck` rather than replacing the whole `checkPhase` while
I'm here.

This has been broken since switching to `refs/tags` in
326517a529.
This commit is contained in:
Tristan Daniël Maat
2025-01-29 01:32:59 +08:00
parent 06b47bf4d0
commit 426a7afc9a
+8 -3
View File
@@ -30,7 +30,7 @@ buildGoModule rec {
"-w"
"-X github.com/crowdsecurity/go-cs-lib/version.Version=v${version}"
"-X github.com/crowdsecurity/go-cs-lib/version.BuildDate=1970-01-01_00:00:00"
"-X github.com/crowdsecurity/go-cs-lib/version.Tag=${src.rev}"
"-X github.com/crowdsecurity/go-cs-lib/version.Tag=v${version}"
"-X github.com/crowdsecurity/crowdsec/pkg/cwversion.Codename=alphaga"
"-X github.com/crowdsecurity/crowdsec/pkg/csconfig.defaultConfigDir=/etc/crowdsec"
"-X github.com/crowdsecurity/crowdsec/pkg/csconfig.defaultDataDir=/var/lib/crowdsec/data"
@@ -53,8 +53,13 @@ buildGoModule rec {
'';
# It's important that the version is correctly set as it also determines feature capabilities
checkPhase = ''
$GOPATH/bin/cscli version 2>&1 | grep -q "version: v${version}"
preCheck = ''
version=$($GOPATH/bin/cscli version 2>&1 | sed -nE 's/^version: (.*)/\1/p')
if [ "$version" != "v${version}" ]; then
echo "Invalid version string: '$version'"
exit 1
fi
'';
meta = with lib; {