stewbeet.plugins.compute_sha1
The compute_sha1 plugin generates SHA1 hashes for all generated zip archives.
It scans the output directory for zip files, computes their SHA1 checksums for integrity
verification, and creates a JSON file containing all hash values
for distribution verification, security auditing, and change detection purposes.
Feature Showcase
Example content of sha1_hashes.json
Position: Should run after all archive generation plugins
Optional: Multiple zip files in output directory (processes all found)
Related: Complements archive and merge_smithed_weld plugins
Source Code: stewbeet/plugins/compute_sha1/__init__.py
What it does
- Computes SHA1 hashes for all generated zip archives
- Creates a hash manifest for integrity verification
- Enables change detection between builds
- Provides security checksums for distribution verification
- Scans output directory automatically for zip files
- Generates machine-readable JSON hash file
Configuration
Basic Example Configuration
# No direct configuration required - uses project settings
# Requires output to be configured in beet.yml:
output: "build"
pipeline:
- ...
- stewbeet.plugins.compute_sha1Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
output | string | Required | Directory containing zip files to hash |
| Hash Algorithm | constant | SHA1 | Uses SHA1 algorithm for checksum generation |
| Output File | constant | sha1_hashes.json | Filename for the generated hash manifest |
| File Filter | automatic | *.zip | Only processes files with .zip extension |
Features
Automatic Archive Discovery
Scans output directory for zip files to process:
- π Automatically discovers all zip files in the output directory
- π Uses file extension filtering to identify archive files
- π Processes all found archives without manual configuration
- β Handles empty directories gracefully with no errors
SHA1 Hash Computation
Generates secure SHA1 checksums for each archive:
- π Uses Python's built-in hashlib for reliable hash generation
- π Reads files in binary mode for accurate checksum calculation
- π― Generates standard hexadecimal hash representation
- β‘ Processes files efficiently with stream reading
Hash Manifest Creation
Creates a JSON file with all computed hashes:
- π Stores filename-to-hash mappings in JSON format
- π¨ Uses json_dump for properly formatted output
- πΎ Creates sha1_hashes.json file in the output directory
- π Provides machine-readable format for automated verification
Integrity Verification System
Enables integrity checking and change detection:
- β Provides checksums for verifying archive integrity
- π Enables detection of file corruption or tampering
- π Supports automated verification workflows
- π Creates audit trail for security compliance
Output Directory Integration
Integrates with beet's output directory system:
- π Uses configured output directory from project settings
- β Validates output directory existence before processing
- π― Works with any output directory configuration
- π§ Integrates with beet's standard directory management
Efficient Processing Pipeline
Optimized for performance with minimal resource usage:
- β±οΈ Uses measure_time decorator for performance monitoring
- πΎ Reads files once for hash calculation
- π Processes all files in a single pass
- π§Ή Clean and simple implementation with minimal overhead
Next steps
- All plugins: the rest of the pipeline, in the order it runs.
- Configuring the build: enabling, ordering and configuring plugins.