Skip to content

apk/installed: parse Z: (file checksum) token in ParseInstalled#2230

Closed
Dev-X25874 wants to merge 1 commit into
chainguard-dev:mainfrom
Dev-X25874:fix/parse-installed-file-checksum
Closed

apk/installed: parse Z: (file checksum) token in ParseInstalled#2230
Dev-X25874 wants to merge 1 commit into
chainguard-dev:mainfrom
Dev-X25874:fix/parse-installed-file-checksum

Conversation

@Dev-X25874

Copy link
Copy Markdown

AddInstalledPackage writes a Z:<checksum> line for every regular
file that carries a checksum, and real installed databases are full of
them. ParseInstalled had no case "Z": handler, so those lines were
silently dropped on read-back — every reconstructed tar.Header came
back with a nil PAXRecords map and no checksum.

Add the missing case, mirroring the write path: allocate PAXRecords
on demand and store the value under paxRecordsChecksumKey, the same
key used by installRegularFile and AddInstalledPackage.

Signed-off-by: Dev-X25874 <283057883+Dev-X25874@users.noreply.github.com>
@Dev-X25874

Copy link
Copy Markdown
Author

Hey @a-crate — would you mind taking a look at this when you get a chance? This adds the missing Z: case in ParseInstalled to handle file checksums that were being silently dropped on read-back. Happy to answer any questions or make changes based on your feedback!

@a-crate

a-crate commented Jun 10, 2026

Copy link
Copy Markdown
Member

Sorry for delay. Looking.

@a-crate a-crate left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Z: is an APK V2 field: https://wiki.alpinelinux.org/wiki/Apk_spec

apko doesn't have support for APK V2 yet, and while it would be good to add it I don't think adding piecemeal support for individual APK V2 fields is the right way go about this. Even if we parse APK V2 fields in the installed DB we're not going to write new correct entries in V2 format.

Do you have a specific usecase that's broken without this change?

Comment thread pkg/apk/apk/installed.go

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unify the indentation here please, keep all cases statements at the same indentation and don't modify indentation from 341:344. gofmt should do this for you, I think. The diff and control flow is a bit confusing otherwise.

@Dev-X25874 Dev-X25874 closed this Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants