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

Fix dpkg queries #156

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/defaults.ini
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ hooks_add =
70-flatpak-appstream-catalog
70-flatpak-manifest
70-ostree-manifest
70-packages-manifest
80-ldconfig-aux-cache.chroot

# Gzip compression by default (valid choices: gz or xz)
Expand Down
10 changes: 7 additions & 3 deletions helpers/packages-manifest → hooks/image/70-packages-manifest
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ apt_pkg.init()

# Use the dpkg status file from the ostree deployment
dpkg_status = os.path.join(os.environ['OSTREE_DEPLOYMENT'],
'var/lib/dpkg/status')
'usr/share/dpkg/database/status')
apt_pkg.config.set('Dir::State::status', dpkg_status)

# Open an apt Cache and output data for each installed package
Expand All @@ -35,5 +35,9 @@ for pkg in sorted(cache):
'size': pkg.installed.installed_size,
}

# Print out the json
print(json.dumps(data, sort_keys=True))
# Now write out the json to a fragment
manifestdir = os.environ['EIB_MANIFESTDIR']
manifest_path = os.path.join(manifestdir, 'packages.json')
print('Writing packages manifest info to', manifest_path)
with open(manifest_path, 'w') as manifest:
json.dump(data, manifest, sort_keys=True)
11 changes: 3 additions & 8 deletions stages/eib_image
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,12 @@ if [[ "${EIB_IMAGE_SDBOOT}" = "true" ]]; then
unset sdboot_esp_img_loop
fi

# Output package list using the dpkg database from the deployment's /var
dpkgdir="${OSTREE_DEPLOYMENT}"/var/lib/dpkg
# Output package list using the dpkg database from the deployment's
# immutable copy in /usr/share/dpkg/database.
dpkgdir="${OSTREE_DEPLOYMENT}"/usr/share/dpkg/database
packageinfo="${EIB_TMPDIR}"/packages.txt
dpkg-query -W --admindir="${dpkgdir}" > "${packageinfo}"

# Add package info to manifest using helper. This needs to be run here
# rather than in an image hook because the dpkg database will be masked
# by the OS /var mount.
pkg_manifest="${EIB_MANIFESTDIR}"/packages.json
"${EIB_HELPERSDIR}"/packages-manifest > "${pkg_manifest}"

run_hooks content "${OSTREE_DEPLOYMENT}"

create_image() {
Expand Down
Loading