-
Notifications
You must be signed in to change notification settings - Fork 519
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
release: Set os-release fields at build time #538
Conversation
Add two new variables to Makefile.toml; BUILDSYS_VERSION_ID_TAG and BUILDSYS_VERSION_ID_FULL. These are passed through buildsys to rpm2img and are used to set VERSION_ID and BUILD_ID respectively in /etc/os-release. VERSION_ID and BUILD_ID are now set along with VARIANT_ID instead of in release.spec. The format of VERSION_ID is unchanged, unless no tag information is available in which case the current date is used. The leading 'v' from the git tag is removed to maintain compatibility with the Semver crate used by Updog. VERSION_ID can also be set manually from the THAR_CUSTOM_VERSION environment variable to support build and pre-release testing, for example. BUILD_ID is used to include the full version information, including how many commits have occurred since the most recent tag, and whether the build tree was dirty. This also fixes up an ordering dependency Updog had on the contents of /etc/os-release. Signed-off-by: Samuel Mendoza-Jonas <[email protected]>
Updated to also name build symlinks based on ..VERSION_TAG. |
As an aside the setting of BUILDSYS_VERSION_TAG might instead be based on the RELEASE.toml file introduced in #556 but I reckon BUILD_ID should still be based relative to the git version as it is in this PR. |
@@ -7,7 +7,21 @@ BUILDSYS_ROOT_DIR = "${CARGO_MAKE_WORKING_DIRECTORY}" | |||
BUILDSYS_OUTPUT_DIR = "${BUILDSYS_ROOT_DIR}/build" | |||
BUILDSYS_SOURCES_DIR = "${BUILDSYS_ROOT_DIR}/workspaces" | |||
BUILDSYS_TIMESTAMP = { script = ["date +%s"] } | |||
BUILDSYS_VERSION = { script = ["git describe --tag --dirty || date +%Y%m%d"] } | |||
BUILDSYS_VERSION_TAG = { script = [ | |||
''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we move BUILDSYS_VERSION_TAG
to the dev
profile, it can be overridden directly on the command line, e.g. cargo make -e BUILDSYS_VERSION_TAG=foo
. I'd prefer that over a second variable.
fi | ||
''' | ||
] } | ||
BUILDSYS_VERSION_FULL = { script = ["git describe --tag --dirty || date +%Y%m%d"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to name the variables in a way that reflects how they are ultimately used. E.g. BUILDSYS_VERSION_ID
or BUILDSYS_BUILD_ID
.
Closing this in favour of a slightly different solution to help #616 |
Issue #, if available:
N/A, related to https://github.com/amazonlinux/PRIVATE-thar/projects/13
Description of changes:
Add two new variables to Makefile.toml; BUILDSYS_VERSION_ID_TAG and
BUILDSYS_VERSION_ID_FULL. These are passed through buildsys to rpm2img
and are used to set VERSION_ID and BUILD_ID respectively in
/etc/os-release. VERSION_ID and BUILD_ID are now set along with
VARIANT_ID instead of in release.spec.
The format of VERSION_ID is unchanged, unless no tag information is
available in which case the current date is used. The leading 'v' from
the git tag is removed to maintain compatibility with the Semver crate
used by Updog.
VERSION_ID can also be set manually from the THAR_CUSTOM_VERSION
environment variable to support build and pre-release testing, for
example.
BUILD_ID is used to include the full version information, including how
many commits have occurred since the most recent tag, and whether the
build tree was dirty.
This also fixes up an ordering dependency Updog had on the contents of
/etc/os-release.
Signed-off-by: Samuel Mendoza-Jonas [email protected]
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Tested by building and launching an instance and checking the version fields are correct and Updog is happy; also tested in a repo without tags available which results in a fallback to date.