Skip to content

Commit

Permalink
Merge pull request #156 from endlessm/T35244-dpkg-db-query
Browse files Browse the repository at this point in the history
Fix dpkg queries
  • Loading branch information
wjt authored Mar 5, 2024
2 parents 02e82cc + 05b858b commit fb5eabf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
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

0 comments on commit fb5eabf

Please sign in to comment.