Skip to content

Commit

Permalink
rpm2img: use package version, release, and epoch
Browse files Browse the repository at this point in the history
When building application inventory, use a package's actual version
and use the <timestamp>.<commit>.br1 for all packages, not just
first party packages. Additionally, expose a package's Epoch -
set to 0 if "(none)".

Signed-off-by: Gavin Inglis <[email protected]>
  • Loading branch information
ginglis13 committed Oct 2, 2024
1 parent 3a625a4 commit d1f98f6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions twoliter/embedded/rpm2img
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ INVENTORY_QUERY="\{\"Name\":\"%{NAME}\"\
,\"Publisher\":\"Bottlerocket\"\
,\"Version\":\"%{Version}\"\
,\"Release\":\"%{Release}\"\
,\"Epoch\":\"%{Epoch}\"\
,\"InstalledTime\":\"${INSTALL_TIME}\"\
,\"ApplicationType\":\"%{GROUP}\"\
,\"Architecture\":\"%{ARCH}\"\
Expand Down Expand Up @@ -237,14 +238,13 @@ if [[ -n "${CORE_KIT_VERSION}" && -n "${CORE_KIT_VENDOR}" ]]; then
# the version with the core kit's version, and replace the name with the unprefixed name.
INVENTORY_DATA="$(jq \
--argfile replace core-kit-replacements.json \
--arg CORE_KIT_VERSION "${CORE_KIT_VERSION}" \
--arg CORE_KIT_GIT_SHA "${CORE_KIT_GIT_SHA}" \
'(.Content[] | select(.Name | $replace[.] != null) | .Version) = $CORE_KIT_VERSION |
(.Content[] | select(.Name | $replace[.] != null) | .Release) = $CORE_KIT_GIT_SHA |
.Content[].Name |= (if $replace[.] then $replace[.] else . end)' \
'.Content[].Name |= (if $replace[.] then $replace[.] else . end)' \
<<<"${INVENTORY_DATA}")"
fi

# Queries on an RPM with no Epoch set result in "(none)". This is effectively "0" for package comparisons.
INVENTORY_DATA="${INVENTORY_DATA//\(none\)/0}"

# Verify we successfully inventoried some RPMs.
INVENTORY_COUNT="$(jq '.Content | length' <<<"${INVENTORY_DATA}")"
RPM_COUNT="$(find "${PACKAGE_DIR}" -maxdepth 1 -type f -name '*.rpm' | wc -l)"
Expand Down

0 comments on commit d1f98f6

Please sign in to comment.