Skip to content

Commit

Permalink
Merge pull request #301 from ginglis13/revert-app-inventory
Browse files Browse the repository at this point in the history
revert application-inventory: use RPM's Version and Release, set Epoch
  • Loading branch information
ginglis13 authored Jun 18, 2024
2 parents 75d6649 + 9596ea5 commit 1a52800
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 27 deletions.
8 changes: 1 addition & 7 deletions tools/buildsys/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
];
Expand Down Expand Up @@ -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,

Expand Down
3 changes: 0 additions & 3 deletions tools/buildsys/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ struct PackageBuildArgs {
kit_dependencies: Vec<String>,
external_kit_dependencies: Vec<String>,
version_build: String,
version_build_epoch: String,
version_build_timestamp: String,
}

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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(),
Expand Down
3 changes: 0 additions & 3 deletions twoliter/embedded/Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 1 addition & 11 deletions twoliter/embedded/build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
5 changes: 2 additions & 3 deletions twoliter/embedded/rpm2img
Original file line number Diff line number Diff line change
Expand Up @@ -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}\"\
Expand Down

0 comments on commit 1a52800

Please sign in to comment.