From 9596ea50f5a35f399a24a18caa8997855832302a Mon Sep 17 00:00:00 2001 From: Gavin Inglis Date: Tue, 18 Jun 2024 03:49:04 +0000 Subject: [PATCH] revert application-inventory: use RPM's Version and Release, set Epoch revert most of #263, which set the Epoch for packages built with Twoliter, set package inventory Version as the actual package version, and built a customer release field to give to the package. This PR retains the change to setting Release in the actual package RPM but reverts the change to include that in the application inventory for the package. Signed-off-by: Gavin Inglis --- tools/buildsys/src/args.rs | 8 +------- tools/buildsys/src/builder.rs | 3 --- twoliter/embedded/Makefile.toml | 3 --- twoliter/embedded/build.Dockerfile | 12 +----------- twoliter/embedded/rpm2img | 5 ++--- 5 files changed, 4 insertions(+), 27 deletions(-) diff --git a/tools/buildsys/src/args.rs b/tools/buildsys/src/args.rs index 43cd93cde..6fbcb51e7 100644 --- a/tools/buildsys/src/args.rs +++ b/tools/buildsys/src/args.rs @@ -15,7 +15,7 @@ use url::Url; /// variable changes. The build type is represented with bit flags so that we can easily list /// multiple build types for a single variable. See `[BuildType]` and `[rerun_for_envs]` below to /// see how this list is used. -const REBUILD_VARS: [(&str, u8); 17] = [ +const REBUILD_VARS: [(&str, u8); 16] = [ ("BUILDSYS_ARCH", PACKAGE | KIT | VARIANT), ("BUILDSYS_CACERTS_BUNDLE_OVERRIDE", VARIANT), ("BUILDSYS_KITS_DIR", KIT), @@ -30,7 +30,6 @@ const REBUILD_VARS: [(&str, u8); 17] = [ ("BUILDSYS_TIMESTAMP", VARIANT), ("BUILDSYS_VARIANT", VARIANT), ("BUILDSYS_VERSION_BUILD", KIT | VARIANT), - ("BUILDSYS_VERSION_BUILD_EPOCH", PACKAGE), ("BUILDSYS_VERSION_IMAGE", KIT | VARIANT), ("TLPRIVATE_SDK_IMAGE", PACKAGE | KIT | VARIANT), ]; @@ -113,11 +112,6 @@ pub(crate) struct BuildPackageArgs { #[arg(long, env = "BUILDSYS_VERSION_BUILD_TIMESTAMP")] pub(crate) version_build_timestamp: String, - /// version_build_epoch sets the "Epoch" for a package when generating its application-inventory - /// entry. The value defaults to "1". - #[arg(long, env = "BUILDSYS_VERSION_BUILD_EPOCH")] - pub(crate) version_build_epoch: String, - #[arg(long, env = "BUILDSYS_SOURCES_DIR")] pub(crate) sources_dir: PathBuf, diff --git a/tools/buildsys/src/builder.rs b/tools/buildsys/src/builder.rs index af76a3302..4d6a029f4 100644 --- a/tools/buildsys/src/builder.rs +++ b/tools/buildsys/src/builder.rs @@ -132,7 +132,6 @@ struct PackageBuildArgs { kit_dependencies: Vec, external_kit_dependencies: Vec, version_build: String, - version_build_epoch: String, version_build_timestamp: String, } @@ -175,7 +174,6 @@ impl crate::builder::PackageBuildArgs { args.build_arg("PACKAGE", &self.package); args.build_arg("PACKAGE_DEPENDENCIES", self.package_dependencies.join(" ")); args.build_arg("BUILD_ID", &self.version_build); - args.build_arg("BUILD_EPOCH", &self.version_build_epoch); args.build_arg("BUILD_ID_TIMESTAMP", &self.version_build_timestamp); args } @@ -356,7 +354,6 @@ impl DockerBuild { .context(error::GraphSnafu)? .list(), version_build: args.version_build, - version_build_epoch: args.version_build_epoch, version_build_timestamp: args.version_build_timestamp, }), secrets_args: Vec::new(), diff --git a/twoliter/embedded/Makefile.toml b/twoliter/embedded/Makefile.toml index aec81d7f0..e5ee74cf5 100644 --- a/twoliter/embedded/Makefile.toml +++ b/twoliter/embedded/Makefile.toml @@ -28,9 +28,6 @@ BUILDSYS_VERSION_BUILD = { script = ["git describe --always --dirty --exclude '* # The unix timestamp in ms of the latest commit of the project. # This is an input for setting the Release value of a package. BUILDSYS_VERSION_BUILD_TIMESTAMP = { script = ["git show -s --format=%ct HEAD || echo 0000000000"] } -# The epoch field sets the RPM epoch for all built packages. This versioning information -# is ultimately reflected in the application inventory generated by rpm2img. -BUILDSYS_VERSION_BUILD_EPOCH = "1" # For now, release config path can't be overridden with -e, because it's used # later in this section. You have to edit the path here in Makefile.toml to # use a different Release.toml. diff --git a/twoliter/embedded/build.Dockerfile b/twoliter/embedded/build.Dockerfile index 1d75262d7..3402db33c 100644 --- a/twoliter/embedded/build.Dockerfile +++ b/twoliter/embedded/build.Dockerfile @@ -43,28 +43,18 @@ ARG ARCH ARG NOCACHE ARG BUILD_ID ARG BUILD_ID_TIMESTAMP -ARG BUILD_EPOCH ENV BUILD_ID=${BUILD_ID} ENV BUILD_ID_TIMESTAMP=${BUILD_ID_TIMESTAMP} -ENV BUILD_EPOCH=${BUILD_EPOCH} WORKDIR /home/builder USER builder ENV PACKAGE=${PACKAGE} ARCH=${ARCH} COPY ./packages/${PACKAGE}/ . -# Copy over the target-specific macros, and put sources in the right place. Set Epoch values for the package -# and all of its subpackages. Additionally, for packages declaring explicit package versions requirements via -# "{Requires,Conflicts,Obsoletes}: = ...", ensure the epoch for the specified package is set. -# "[Requires|Conflicts|Obsoletes]:.*[=>,>,<,<=,=]\) \(\%{version}\-\%{release}$\)" matches any line in a form like: -# "Requires: %{name}-modules = %{version}-%{release}". The full `sed` expression below captures this match into -# two groups and insert the Epoch value such that the result is "Requires: %{name}-modules = EPOCH:%{version}-%{release}" +# Copy over the target-specific macros, and put sources in the right place. RUN \ cp "/usr/lib/rpm/platform/${ARCH}-bottlerocket/macros" .rpmmacros \ - && echo "Epoch: ${BUILD_EPOCH}" >> rpmbuild/SPECS/${PACKAGE}.spec \ && cat ${PACKAGE}.spec >> rpmbuild/SPECS/${PACKAGE}.spec \ - && sed -i "/^%package\s.*$/a Epoch: ${BUILD_EPOCH}" rpmbuild/SPECS/${PACKAGE}.spec \ - && sed -i "s;\([Requires|Conflicts|Obsoletes]:.*[=>,>,<,<=,=]\) \(\%{version}\-\%{release}$\);\1 ${BUILD_EPOCH}:\2;" rpmbuild/SPECS/${PACKAGE}.spec \ && find . -maxdepth 1 -not -path '*/\.*' -type f -exec mv {} rpmbuild/SOURCES/ \; \ && echo ${NOCACHE} diff --git a/twoliter/embedded/rpm2img b/twoliter/embedded/rpm2img index fdbdda48f..dc3a56aa8 100755 --- a/twoliter/embedded/rpm2img +++ b/twoliter/embedded/rpm2img @@ -164,9 +164,8 @@ rpm -iv --ignorearch --root "${ROOT_MOUNT}" "${PACKAGE_DIR}"/*.rpm # newer release of a package were to have a lower "Release". INVENTORY_QUERY="\{\"Name\":\"%{NAME}\"\ ,\"Publisher\":\"Bottlerocket\"\ -,\"Version\":\"%{Version}\"\ -,\"Release\":\"%{Release}\"\ -,\"Epoch\":\"%{Epoch}\"\ +,\"Version\":\"${VERSION_ID}\"\ +,\"Release\":\"${BUILD_ID}\"\ ,\"InstalledTime\":\"${INSTALL_TIME}\"\ ,\"ApplicationType\":\"%{GROUP}\"\ ,\"Architecture\":\"%{ARCH}\"\