Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] misformatted version string when installing from the release tarballs #297

Closed
ferki opened this issue May 3, 2024 · 4 comments · Fixed by #298
Closed

[BUG] misformatted version string when installing from the release tarballs #297

ferki opened this issue May 3, 2024 · 4 comments · Fixed by #298

Comments

@ferki
Copy link
Contributor

ferki commented May 3, 2024

Clight version the issue has been seen with:

4.11 (but apparently present since 4.8)

Used distribution:

Gentoo

Describe the bug
When unpacking the release tarballs to build Clight, the extracted content is not a git repository, therefore cmake complains about "fatal: not a git repository" when trying to determing the git commit hash.

It results in an empty GIT_HASH variable, causing the version string to miss the trailing git commit id, and look like 4.11-

Expected behavior
I'd like Clight to have a clean build process without errors/warnings, and to report properly formatted version strings regardless of how one obtains the source code (from git or from release tarballs).

To Reproduce

  1. Download and extract the release tarball.
  2. Run cmake . in the extracted source directory.
  3. Observe a line starting with fatal: not a git repository in the output.
  4. Build Clight fully, and run clight -v to get the version string.
  5. Observe the missing trailing git commit hash after the - character.

Given the build-time issue, I decided not to attach a verbose Clight log from runtime for now. It contains the same version string though, so let me know if that's relevant after all.

Additional notes:

  1. I currently use a quick patch around it in my Gentoo overlay. If that is an acceptable solution for this repo, I would be more than happy to sent it in a PR here.
  2. The same issue is apparently also present in Clightd, and I have a similar patch for it too. I can open a similar issue and/or PR in the Clightd repository accordingly, I just wished to get a first feedback early, before making more noise about this :) Let me know how you prefer to proceed!
@FedeDP
Copy link
Owner

FedeDP commented May 7, 2024

Hi! Thanks for reporting this! I agree, this is a bad behavior that should be fixed.

I currently use a quick patch around it in my Gentoo overlay. If that is an acceptable solution for this repo, I would be more than happy to sent it in a PR here.

It seems a suited solution! We could also capture the result variable and check if it is not 0, like:

execute_process(COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
         OUTPUT_VARIABLE GIT_HASH
         OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE ret)
if(ret EQUAL "0")
    set(VERSION "${PROJECT_VERSION}-${GIT_HASH}")
else()
   set(VERSION "${PROJECT_VERSION}")
endif()

(Also, it would be great if you could open same PR on clightd too, thanks!)

@ferki
Copy link
Contributor Author

ferki commented May 11, 2024

It seems a suited solution! We could also capture the result variable and check if it is not 0

Using the git command itself makes it a build-time dependency, which I'd also like to avoid when using source tarballs to install instead of the git tree.

I'm afraid using the exit code would lead to a different error during build if the source tarballs are used and git is not installed on the system.

That's why I ended up with an approach which uses something else than git to check if the directory looks like a git repo (such as test -d .git as first approximation).

(Also, it would be great if you could open same PR on clightd too, thanks!)

Great, thanks, will do both PRs shortly!

@ferki
Copy link
Contributor Author

ferki commented May 12, 2024

I'm glad it was acceptable in both places, thank again for merging!

@FedeDP
Copy link
Owner

FedeDP commented May 12, 2024

You're welcome, thanks for proposing the patches indeed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants