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

include commit hash in status output #35

Merged
merged 5 commits into from Oct 30, 2018
Merged

include commit hash in status output #35

merged 5 commits into from Oct 30, 2018

Conversation

ansemjo
Copy link
Contributor

@ansemjo ansemjo commented Oct 29, 2018

This is an alternative to #34 and fixes #22.

  • all commit hash definition logic is done in a subshell in the makefile
  • both the makefile shell and preprocessor directives in main.c fallback to unknown if the git command fails or VERSION is somehow undefined during compilation
  • the subshell uses git describe output when building from a checked-out repository or an inserted commit hash when building from a git-archive (i.e. a downloaded tarball)
  • lines 71-74 should be reusable for other projects and languages

Signed-off-by: Anton Semjonov <anton@semjonov.de>
Signed-off-by: Anton Semjonov <anton@semjonov.de>
this avoids confusing distclean etc. by not interfering with
automake's VERSION or PACKAGE_VERSION

Signed-off-by: Anton Semjonov <anton@semjonov.de>
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks, but can we move the version info to slirp4netns --version with runc-style machine-parseable format? (I can open PR for --version) https://github.com/opencontainers/runc/blob/f3ce8221ea760f51b5403a9892a69ace43845c2c/main.go#L55-L63

Makefile.am Outdated
# replaced during git-archive creation
COMMIT := $(shell V=$Format:%h$ ; \
expr match "$$V" ormat: >/dev/null \
&& ([ -d .git ] && git describe --always --abbrev || echo unknown) \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should be using $abs_srcdir not the build dir. Could you add a cd $abs_srcdir before any other command?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean $abs_top_srcdir?

Suggested change
&& ([ -d .git ] && git describe --always --abbrev || echo unknown) \
&& (cd "$$abs_top_srcdir" && [ -d .git ] && git describe --always --abbrev || echo unknown) \

@giuseppe
Copy link
Collaborator

PACKAGE_VERSION is defined by the configure script. It is then written into the config.h file

@ansemjo
Copy link
Contributor Author

ansemjo commented Oct 30, 2018

@AkihiroSuda something like this?

slirp4netns version $PACKAGE_VERSION
commit: $COMMIT_HASH

@AkihiroSuda
Copy link
Member

Yes, also it would be great if we can have -dirty suffix for dirty build https://github.com/opencontainers/runc/blob/f3ce8221ea760f51b5403a9892a69ace43845c2c/Makefile#L17

Signed-off-by: Anton Semjonov <anton@semjonov.de>
@ansemjo
Copy link
Contributor Author

ansemjo commented Oct 30, 2018

current output:

$ ./slirp4netns -v
./slirp4netns version 0.1
commit: bf62e3b-dirty

Makefile.am Outdated Show resolved Hide resolved
Signed-off-by: Anton Semjonov <anton@semjonov.de>
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

LGTM (if CI green)

@giuseppe giuseppe merged commit 777bdcc into rootless-containers:master Oct 30, 2018
@giuseppe
Copy link
Collaborator

LGTM as well, merged. Thanks for your contribution!

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 this pull request may close these issues.

include git commit hash in slirp4netns --version
3 participants