Skip to content

Embed version from VERSION #4718

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

Merged
merged 2 commits into from
Apr 23, 2025
Merged

Conversation

kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented Apr 9, 2025

This is a carry/rework of #3163.

See individual commits for details.

Aside from embedding VERSION file into the binary, it simplifies the output of runc help.

Before:

$ runc help
 ...
USAGE:
   runc [global options] command [command options] [arguments...]

VERSION:
   1.3.0-rc.1+dev
commit: v1.3.0-rc.1-93-g932e8342
spec: 1.2.1
go: go1.24.2
libseccomp: 2.5.5

COMMANDS:
   checkpoint  checkpoint a running container
...

After:

$ runc help
 ...
USAGE:
   runc [global options] command [command options] [arguments...]
   
VERSION:
   1.3.0-rc.1+dev

COMMANDS:
   checkpoint  checkpoint a running container
...

The full version info is still shown by runc --version exactly as before:

$ runc --version
runc version 1.3.0-rc.1+dev
commit: v1.3.0-rc.1-93-g932e8342
spec: 1.2.1
go: go1.24.2
libseccomp: 2.5.5

The EXTRA_VERSION kludge, added by #4370, also works exactly as before:

$ make EXTRA_VERSION="+build-1"
go build -trimpath "-buildmode=pie"  -tags "seccomp urfave_cli_no_docs" -ldflags "-X main.gitCommit=v1.3.0-rc.1-95-gd84aaa38 -X main.extraVersion=+build-1 " -o runc .
[kir@kir-tp1 runc]$ ./runc --version
runc version 1.3.0-rc.1+dev+build-1
commit: v1.3.0-rc.1-95-gd84aaa38
spec: 1.2.1
go: go1.24.2
libseccomp: 2.5.5

Copy link
Contributor

@akhilerm akhilerm left a comment

Choose a reason for hiding this comment

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

LGTM. Since the output doesnt change. Works well for my use cases.

Copy link
Member

@rata rata left a comment

Choose a reason for hiding this comment

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

LGTM

@kolyshkin
Copy link
Contributor Author

@cyphar @thaJeztah PTAL

Copy link
Member

@thaJeztah thaJeztah 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!

Instead of setting cli.App.Version in main, let's set up
cli.VersionPrinter. This way, we only get various versions
when needed.

Note it does not change the output of runc --version.

It changes the output of runc --help though, and I think it's for the
better.

Before this patch:

> $ runc help
> ...
> USAGE:
>    runc [global options] command [command options] [arguments...]
>
> VERSION:
>    1.3.0-rc.1+dev
> commit: v1.3.0-rc.1-93-g932e8342
> spec: 1.2.1
> go: go1.24.2
> libseccomp: 2.5.5
>
> COMMANDS:
>    checkpoint  checkpoint a running container
> ...

After:

> $ runc help
> ...
> USAGE:
>    runc [global options] command [command options] [arguments...]
>
> VERSION:
>    1.3.0-rc.1+dev
>
> COMMANDS:
>    checkpoint  checkpoint a running container
> ...

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This ensures that if runc is built without the provided Makefile, the
version is still properly set.

No change in the output.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
Copy link
Contributor Author

Let's backport it to 1.3 as well, this may help distro vendors.

@kolyshkin kolyshkin merged commit 96bb2b0 into opencontainers:main Apr 23, 2025
33 checks passed
@kolyshkin
Copy link
Contributor Author

1.3 backport: #4744

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.

6 participants