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

Add package validation command #64

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

landerweit-phytec
Copy link
Collaborator

@landerweit-phytec landerweit-phytec commented Aug 2, 2023

Add a new command for package validation validate.
The goal of package validation is to make sure a package can be written to a device without writing to the device. Additionally, remove most validation steps from the install command to reduce the time i takes to write to the device.
Open tasks:

  • Check if URI points into archive
  • Size calculation for uncompressed archives
  • Option to use validate without passing a device (maybe use a loop device and pass eMMC size as argument)
  • Ensure the partitions fit the device
  • Test validate command
  • Add commit messages

@landerweit-phytec landerweit-phytec added the enhancement New feature or request label Aug 2, 2023
@landerweit-phytec landerweit-phytec added this to the v1.0.0 milestone Aug 2, 2023
@landerweit-phytec landerweit-phytec self-assigned this Aug 2, 2023
@landerweit-phytec landerweit-phytec force-pushed the wip-validate-command branch 4 times, most recently from 812ecaa to 92ddeb8 Compare August 14, 2023 15:03
@landerweit-phytec landerweit-phytec force-pushed the wip-validate-command branch 10 times, most recently from 418f8e1 to 2458213 Compare August 17, 2023 09:47
@landerweit-phytec landerweit-phytec marked this pull request as ready for review August 17, 2023 11:02
@landerweit-phytec landerweit-phytec force-pushed the wip-validate-command branch 5 times, most recently from 319aac1 to ad3f15f Compare September 8, 2023 09:13
Copy link
Collaborator

@mschwan-phytec mschwan-phytec left a comment

Choose a reason for hiding this comment

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

A first glimpse on your PR...

src/pu-utils.c Outdated Show resolved Hide resolved
tests/emmc.c Show resolved Hide resolved
src/pu-input.c Outdated Show resolved Hide resolved
src/pu-input.c Outdated Show resolved Hide resolved
src/pu-input.c Outdated Show resolved Hide resolved
src/pu-input.c Outdated Show resolved Hide resolved
src/pu-input.h Outdated Show resolved Hide resolved
src/pu-emmc.c Outdated Show resolved Hide resolved
@mschwan-phytec
Copy link
Collaborator

You may want to consider squashing some commit fixing earlier stuff of your PR, e.g.:

Check file size and raw overlap only in validate

There is code in src/pu-emmc.c:pu_emmc_new that gets added earlier and then removed. Maybe you can squash/rearrange your commits, so changes are correct in the first place.

doc/usage.rst Outdated Show resolved Hide resolved
doc/usage.rst Outdated
Comment on lines 54 to 56
-s, --skip-checksums Skip checksum verification for all input files
-w, --write-file Install the package to a file as an additional validation step
-k, --keep-file-as=FILENAME Keep the file. Implies --write-file
Copy link
Collaborator

Choose a reason for hiding this comment

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

From a user perspective I think it is not clear, what you mean exactly with "file" in the options --write-file and --keep-file-as as the term collides with the input files.

src/pu-main.c Outdated
{ "skip-checksums", 's', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE,
&arg_validate_skip_checksums, "Skip checksum verification for all input files", NULL },
{ "size", 0, G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING,
&arg_validate_file_size, "Size of loop device. Default is 1G", "SIZE" },
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again, a user may not be familiar with loop devices, so this description is not easy to understand without looking at the inner workings of partup.

src/pu-main.c Show resolved Hide resolved
Copy link
Collaborator

@mschwan-phytec mschwan-phytec left a comment

Choose a reason for hiding this comment

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

Please rebase your changes, just in case.

src/pu-utils.c Outdated Show resolved Hide resolved
doc/usage.rst Outdated Show resolved Hide resolved
@mschwan-phytec
Copy link
Collaborator

I tried running partup with the validate command and somehow my RAM got clogged up. I guess there is a memory leak or similar in your code? I checked for leftover mounted loop device but that does not seem to be the issue on first sight. When running partup I get the following generic error message:

10:07:13.989678 CRITICAL partup: Error writing to file: No space left on device

However, running anything that requires RAM then throws a similar error message, e.g. GCC:

../src/pu-loopdev.c:88:1: fatal error: error writing to /tmp/ccScBcPv.s: No space left on device

The commands I ran before are something like this:

sudo partup-git validate -d rauc-image.partup --size 2G -s

Maybe partup must return with an error code before this issue appears. Should happen if there are no checksums in the layout config and we do not provide the -s option.

@mschwan-phytec mschwan-phytec removed this from the v2.0.0 milestone Jan 30, 2024
Add a new function pu_spwan_command_line_sync_result() which returns the
output of stdout.
Also, add a corresponding unit test.

Signed-off-by: Leonard Anderweit <[email protected]>
Only append the source filename in case the destination is a directory.

Signed-off-by: Leonard Anderweit <[email protected]>
Add functions to create and remove loop devices.

Signed-off-by: Leonard Anderweit <[email protected]>
Signed-off-by: Leonard Anderweit <[email protected]>
Separate input files from flash specific information as they only
contain general information like filename, checksums and size on target.

Signed-off-by: Leonard Anderweit <[email protected]>
Signed-off-by: Leonard Anderweit <[email protected]>
Add a list for all input files regardless of their destination. Use
it to get the absolute path and size of all input files at once after
config parsing instead of during writing.

Signed-off-by: Leonard Anderweit <[email protected]>
Add a new function for config validation. For now only verifies
checksums.

Signed-off-by: Leonard Anderweit <[email protected]>
Checksum verification is done with the validate command. So remove it
from the install command to save time when writing to a device.
Update the docs accordingly.

Signed-off-by: Leonard Anderweit <[email protected]>
These steps are not necessary for package installation so execute them
only when validating a package.
Also, update the tests accordingly.

Signed-off-by: Leonard Anderweit <[email protected]>
Add an additional validation step to check if the input files of each
partition fit into the corresponding partition.

Signed-off-by: Leonard Anderweit <[email protected]>
Check if the fixed size partitions fit into the device. This does not
check expanding partitions.

Signed-off-by: Leonard Anderweit <[email protected]>
Add a new function pu_parse_size() which accepts a size string and
returns the size in bytes. Accepts strings with the same format as
ped_parse_unit, but only with absolute units.
Also, add a corresponding unit test.

Signed-off-by: Leonard Anderweit <[email protected]>
The new command 'validate' validates a package either against a provided
device or a new loop device.

Signed-off-by: Leonard Anderweit <[email protected]>
Writing the package to the loop device is an additional validation step.
This is similar to installing the package to a real device.

Signed-off-by: Leonard Anderweit <[email protected]>
The generated image can be written with dd.

Signed-off-by: Leonard Anderweit <[email protected]>
Signed-off-by: Leonard Anderweit <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants