sources: add optional "source-checksum" property
Metadata
Current evaluation
Merged after CLA verification and conflict resolution. Adds an optional source-checksum property to verify source file integrity using multiple hash algorithms, accompanied by unit and integration tests.
Suggested action: —
No scores available.
Issue body
# Features
- Solution for [LP: #1585913](https://bugs.launchpad.net/snapcraft/+bug/1585913) bug based on work done by @tsimonq2 in PR #619 but with support only for checksums specified in the snapcraft.yml file.
- The code adds the optional property **"source-checksum"** to check the integrity of the source files (tar, zip, deb or rpm).
- The format of the property is **\<algorithm\>/\<digest\>**. For example:
- sha256/de2fb61252548af3c87c4aab17e82601691d19e37fd3d29ea6288e56
- Currently, the supported algorithms are: **md5**, **sha1**, **sha224**, **sha256**, **sha384**, **sha512**, **sha3_256**, **sha3_384** & **sha3_512**
- The sha3 support comes from [pysha3](https://pypi.python.org/pypi/pysha3) in systems where python version < 3.6.
- ~~The size of **sha2** digests is automatically detected, supporting the following bit sizes:~~
- ~~224~~
- ~~256~~
- ~~384~~
- ~~512~~
# Failsafes
- It has the following failsafes to ensure the code always works as intended:
- Special exception for a checksum that doesn't match
- Raises an exception for a checksum that is invalid, or incompatible with the checksums supported
# Testing coverage
- I have the following testing in place:
- Integration tests:
- Testing of each supported algorithm in raw form with a created file (tar) that has a static checksum in the snapcraft.yaml file.
- A single test in simple-zip.
- Tests deb-with-checksum and rpm-with-checksum created.
- Unit tests:
- Testing for sources that don't allow digest.
- Testing for sources that allow digest and where the digest:
- is correct
- is wrong
- uses an invalid algorithm
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Merged after CLA verification and conflict resolution. Adds an optional source-checksum property to verify source file integrity using multiple hash algorithms, accompanied by unit and integration tests. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged after test refactoring, CLA verification, and conflict resolution. Adds an optional source-checksum property to verify source file integrity using md5, sha1, sha256, and sha3 algorithms. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged. Implemented an optional source-checksum property to verify source file integrity using specified hash algorithms. Addressed CLA verification and merge conflicts during review, then approved and merged by maintainers. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #26 sources: add support for source checksum | craft-parts | merged | Merged: adds file checksum computation to validate the source-checksum part property. Approved by two reviewers and passed CI checks. |