Unverified Commit 426a7afc authored by Tristan Daniël Maat's avatar Tristan Daniël Maat
Browse files

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
326517a5.
parent 06b47bf4
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -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; {