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

release: Set os-release fields at build time #538

Closed
wants to merge 1 commit into from
Closed

Conversation

sam-aws
Copy link
Contributor

@sam-aws sam-aws commented Nov 19, 2019

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.

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]>
@sam-aws
Copy link
Contributor Author

sam-aws commented Nov 22, 2019

Updated to also name build symlinks based on ..VERSION_TAG.

@sam-aws
Copy link
Contributor Author

sam-aws commented Nov 22, 2019

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 = [
'''
Copy link
Contributor

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"] }
Copy link
Contributor

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.

@sam-aws
Copy link
Contributor Author

sam-aws commented Dec 30, 2019

Closing this in favour of a slightly different solution to help #616

@sam-aws sam-aws closed this Dec 30, 2019
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.

2 participants