Skip to content

Commit

Permalink
image: add rpm database as build output
Browse files Browse the repository at this point in the history
  • Loading branch information
malt3 committed Oct 11, 2023
1 parent e231a24 commit 2923258
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build-os-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,11 @@ jobs:
TARGET: //image/system:${{ matrix.csp }}_${{ matrix.attestation_variant }}_${{ needs.build-settings.outputs.stream }}
run: |
echo "::group::Build"
bazel build --host_platform=@rules_nixpkgs_core//platforms:host //image/base:rpmdb
bazel build --host_platform=@rules_nixpkgs_core//platforms:host "${TARGET}"
{
echo "image-dir=$(bazel cquery --host_platform=@rules_nixpkgs_core//platforms:host --output=files "$TARGET")"
echo "rpmdb=$(realpath $(bazel cquery --host_platform=@rules_nixpkgs_core//platforms:host --output=files //image/base:rpmdb))"
} | tee -a "$GITHUB_OUTPUT"
echo "::endgroup::"
Expand All @@ -192,6 +194,7 @@ jobs:
${{ steps.build.outputs.image-dir }}/constellation.efi
${{ steps.build.outputs.image-dir }}/constellation.initrd
${{ steps.build.outputs.image-dir }}/constellation.vmlinuz
${{ steps.build.outputs.rpmdb }}
upload-os-image:
name: "Upload OS image to CSP"
Expand Down
23 changes: 23 additions & 0 deletions image/base/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file")
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("//bazel/mkosi:mkosi_image.bzl", "mkosi_image")

copy_to_directory(
Expand Down Expand Up @@ -41,6 +42,10 @@ mkosi_image(
outs = [
"image",
"image.tar",
"image-rpmdb.sqlite-wal",
"image-rpmdb.sqlite-shm",
"image-rpmdb.sqlite",
"image-.rpm.lock",
],
extra_trees = [
"//image:sysroot_tar",
Expand All @@ -58,3 +63,21 @@ mkosi_image(
],
visibility = ["//visibility:public"],
)

pkg_tar(
name = "rpmdb",
remap_paths = {
"/image-rpmdb.sqlite": "/var/lib/rpm/rpmdb.sqlite",
"/image-rpmdb.sqlite-shm": "/var/lib/rpm/rpmdb.sqlite-shm",
"/image-rpmdb.sqlite-wal": "/var/lib/rpm/image-rpmdb.sqlite-wal",
"/image-.rpm.lock": "/var/lib/rpm/.rpm.lock",
},
srcs = [
"image-rpmdb.sqlite",
"image-rpmdb.sqlite-shm",
"image-rpmdb.sqlite-wal",
"image-.rpm.lock",
],
tags = ["manual"],
visibility = ["//visibility:public"],
)
4 changes: 0 additions & 4 deletions image/base/mkosi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ PackageManagerTrees=reposdir:/etc/yum.repos.d
RemoveFiles=/var/log
RemoveFiles=/var/cache
RemoveFiles=/etc/pki/ca-trust/extracted/java/cacerts
/usr/lib/sysimage/libdnf5/transaction_history.sqlite*
/var/cache/ldconfig/aux-cache
# https://github.com/authselect/authselect/pull/348
# RemoveFiles=/etc/authselect/*
RemoveFiles=/etc/issue
RemoveFiles=/etc/issue.net
CleanPackageMetadata=true
Seed=b04a9a33-4559-4af4-8b38-9249cf933229
7 changes: 7 additions & 0 deletions image/base/mkosi.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ mkdir -p "${BUILDROOT}"/etc/{cni,kubernetes}
# move issue files away from /etc
# to allow /run/issue and /run/issue.d to take precedence
mv "${BUILDROOT}/etc/issue.d" "${BUILDROOT}/usr/lib/issue.d" || true

# generate reproducible package manifest
mkdir -p "${BUILDROOT}/usr/share/constellation"
rpm -qa --qf '%{name};%{version};%{license}\n' --dbpath "${BUILDROOT}/var/lib/rpm/" | LC_ALL=C sort | tee "${BUILDROOT}/usr/share/constellation/packagemanifest.txt"

# copy rpmdb to outputs
cp "${BUILDROOT}"/var/lib/rpm/{rpmdb.sqlite-wal,rpmdb.sqlite-shm,rpmdb.sqlite,.rpm.lock} "${OUTPUTDIR}/"
2 changes: 0 additions & 2 deletions image/initrd/mkosi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,5 @@ RemoveFiles=/var/cache
RemoveFiles=/etc/pki/ca-trust/extracted/java/cacerts
/usr/lib/sysimage/libdnf5/transaction_history.sqlite*
/var/cache/ldconfig/aux-cache
# https://github.com/authselect/authselect/pull/348
# RemoveFiles=/etc/authselect/*
CleanPackageMetadata=true
Seed=b04a9a33-4559-4af4-8b38-9249cf933229
2 changes: 0 additions & 2 deletions image/system/mkosi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@ RemoveFiles=/var/cache
RemoveFiles=/etc/pki/ca-trust/extracted/java/cacerts
/usr/lib/sysimage/libdnf5/transaction_history.sqlite*
/var/cache/ldconfig/aux-cache
# https://github.com/authselect/authselect/pull/348
# RemoveFiles=/etc/authselect/*
CleanPackageMetadata=true

0 comments on commit 2923258

Please sign in to comment.