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

Various bpak improvements #30

Merged
merged 12 commits into from
Feb 24, 2023
Merged

Conversation

thebolt
Copy link

@thebolt thebolt commented Feb 24, 2023

No description provided.

…_id) combination

There is no non-contrived use-case where two parts should have the same
id, or two metadata hve same id and same part_ref_id. The code in core
bpak_ APIs technically support it, however bpak_pkg for example does not
have any sensible way of dealing with multiple parts with same id.
…adata

These functions will remove the data from the parts and metadata header
tables and remove any holes within the arrays. Also compacts the meta
storage array after removing metadata.
Multiple places in the cli takes either a reference by name hashed into a
bpak id, or a id specified as a hex number prefixed by 0x. Unify the parsing
of these into a separate helper function
To make a clearer API with named types, introduce a bpak_id_t to represent
numerical object (metadata / part) IDs.

No functional change
The functionality to take a part and extract it binary to a file is useful
to other library users, including the python wrapper. Move it from
CLI to lib.
Add bpak_pkg_delete_part and bpak_pkg_delete_all_parts to remove one and
all parts respectively. The functions can optionally remove all metadata
associated with the parts being removed.

Also add the equivalent functionality to bpak CLI tool, and a test using
the CLI to verify bit-identical result between files with removed parts
and files built without ever having the part added.
Probably no real impact, but required for strict conformance.
The offset parameter could theoretically be used for iterating over
parts, however bpak_foreach_part provides a better interface. No code
within the lib or CLI passed anythign other than NULL.
A number of problems have been identified with the bpak_add_meta and
bpak_get_meta APIs. These include:
 - Not matching the _part APIs in terms of parameter types

 - Like _part APIs the _meta version had the uneccesary offset parameters,
   but it did refer to the offset of the metadata _data_ pointer (or offset)
   not the header.

 - Using part_ref_id == 0 was in some places an explicitly looked at value
   and in other places acted as a wildcard, which meant that bpak_get_meta
   with part_id_ref == 0 could return a meta-data pointer associated with
   an explicit partition, without any way for the calling code to
   query or find out that this is the case.


The fix for all of these problem is to reduce and simplify the bpak_get_meta
API to have a single method that always takes explicit part_ref_id and
one that can match any, and then they return a bpak_meta_header instead
of the meta-data pointer directly; same with bpak_add_meta.

The data pointer can, in a somewhat type-safe way, be retrieved using
bpak_get_meta_ptr.
@jonasblixt jonasblixt merged commit 3875ed0 into jonasblixt:master Feb 24, 2023
@thebolt thebolt deleted the bpak-improvement1 branch February 27, 2023 07:55
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