swugenerator
A host tool to generate SWU update package for SWUpdate.
SYNOPSIS
- usage: SWUGenerator [-h] [-K ENCRYPTION_KEY_FILE] [-k SIGN] [-s SW_DESCRIPTION]
[-a ARTIFACTORY] [-o SWU_FILE] [-c CONFIG] command
Generator SWU Packages for SWUpdate
- positional arguments:
- command:
- {create,sign,extract,mender} command to be executed
create creates a SWU file sign signs an existing SWU file provided by -i extract extracts the files of an existing SWU file provided by -i mender wraps an existing SWU file provided by -i into a Mender Artifact
- optional arguments:
- -h, --help
show this help message and exit
- -K ENCRYPTION_KEY_FILE, --encryption-key-file ENCRYPTION_KEY_FILE
AES Key to encrypt artifacts
- -n, --no-compress
Do not compress files
- -e, --no-encrypt
Do not encrypt files, for artifacts that are already encrypted. encrypted and ivt are kept as set in sw-description
- -x, --no-ivt
Do not generate IV when encrypting
- --keep-names
Store encrypted artifacts under their name, without the suffix .enc in the SWU and in sw-description
- -y, --no-hash
Do not store sha256 hash in sw-description
- -k SIGN, --sign SIGN
RSA key or certificate to sign the SWU
- -s SW_DESCRIPTION, --sw-description SW_DESCRIPTION
sw-description template for the create command
- -t, --encrypt-swdesc
Encrypt sw-description
- -a ARTIFACTORY, --artifactory ARTIFACTORY
list of directories where artifacts are searched
- -o SWU_FILE, --swu-file SWU_FILE
SWU output file, required for create, sign and mender
- -c CONFIG, --config CONFIG
configuration file
The sign, extract and mender commands read an existing SWU, given with -i/–swu-in-file after the command.
Description
swugenerator is a tool running on host to create and modify SWUpdate’s Update files (SWU). SWU file contains a meta description of the release (sw-description), and swugenerator adds components to a template passed from command line. This tool requires openssl to run and to sign the SWU. It is goal of the tool to fill the gap with Yocto/OE, where SWU generation is done by classes in the meta-swupdate layer, but other buildsystems like Debian or Buildroot have no tools to create a SWU.
The tool signs the SWU and can encrypt the artifacts. The tool parses the sw-description, in libconfig or in JSON (a sw-description starting with {), and provides the following features:
replace occurrencies of variables found in the CONFIG file
add sha256 to each artifact
check if an artifact should be encrypted and encrypts it
sign sw-description with one of the methods accepted by SWUpdate
pack all artifacts into a SWU file
It maybe run in two steps to create an unsigned swu file and then sign it later in a second call:
swugenerator -o output.swu -a . -s sw-description.in create swugenerator -o signed_output.swu -k CMS,key.pem,ca.crt sign -i output.swu
Names of encrypted artifacts
An encrypted artifact is stored with the suffix .enc, and its filename in sw-description is changed accordingly, so that the same file can be packed both encrypted and not. --keep-names keeps the original name, as scripts in sw-description may expect; a file used both encrypted and not is then refused.
CMS signing with several signers
-k CMS,... can be given more than once: the signature has then a signer for each, for example a classic and a post-quantum key. SWUpdate verifies all of them, so every certificate must be in its trust store. The signers must use the same password file:
swugenerator -o output.swu -a . -s sw-description.in \
-k CMS,rsa.key,rsa.crt -k CMS,mldsa.key,mldsa.crt --cms-md sha512 create
--cms-md sets the message digest of openssl cms (needed for keys without a default digest, such as ML-DSA; one digest is used for all signers), and --cms-certfile adds a file with intermediate certificates (can be repeated).
Extra files
Only the files that sw-description uses are packed. --add-file <name> (can be repeated) adds a file found in the artifactory as it is, even if sw-description does not use it; a file already in the SWU is not added twice.
Files of 4 GiB and more
The cpio formats of SWUpdate limit a file to 4 GiB - 1 byte. swugenerator packs bigger files with an extension of the New CRC format (magic 070704), where the upper 32 bits of the size are in the field rdevmajor. The other files keep the New CRC format. The SWU can be installed only with a SWUpdate version that supports the extension: older versions stop the update when they reach the file.
cpio -i cannot extract such files. The extract command extracts all files of a SWU as they are stored, encrypted or compressed artifacts are not decoded:
swugenerator extract -i output.swu -d outdir
Without -d, the files are extracted into the current directory. The checksums of the files are verified, and files that would be written outside the directory are refused.
Mender Artifact
A Mender Server delivers updates only as Mender Artifacts. The mender command puts an existing SWU, unchanged and with its signature, into a Mender Artifact (format version 3) as the payload of type swu, as mender-artifact write module-image -T swu does. SWUpdate’s Mender Suricatta module takes the SWU out of the artifact while it is downloaded:
swugenerator -o update.mender mender -i signed_output.swu -D board-a -D board-b -N release-2
Options of the mender command:
-i, --swu-in-file SWU_IN_FILE
SWU to wrap
-D, --device-type DEVICE_TYPE
compatible device type, can be repeated
-N, --artifact-name ARTIFACT_NAME
artifact name, default: version in sw-description
-T, --payload-type PAYLOAD_TYPE
payload type, default: swu
-C, --compression {gzip,xz,none}
compression of header and payload, default: gzip
The artifact is reproducible with SOURCE_DATE_EPOCH.
Installation
To install swugenerator clone the repository, and from the main project folder run pip (pip3 required): For new Linux distributions, replace it with pipx.
pip install .
To uninstall:
pip uninstall swugenerator
Metadata
Release files for swugenerator 0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| swugenerator-0.9.tar.gz | 81.5 kB | Without provenance | Details for swugenerator-0.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| swugenerator-0.9-py3-none-any.whl | Python 3 | none | any | Details for swugenerator-0.9-py3-none-any.whl |
Total release size: 130.5 kB
Release files / swugenerator-0.9.tar.gz
| Download URL | swugenerator-0.9.tar.gz |
|---|---|
| Size | 81.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ce83be33dc5d3a01db8a10ac31c432166ea3c878e071241b13c6e9ab2aa5653d
|
|
BLAKE2b-256 checksum How to use checksums |
1cb06df37b1d00c9a6937a103b5f08ae5838ef8d4787ff61ac6263823606a584
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / swugenerator-0.9-py3-none-any.whl
| Download URL | swugenerator-0.9-py3-none-any.whl |
|---|---|
| Size | 49.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
871b22983bfb7e8b2229267d998eaab70277e6178f3296db5d0f2f9358f1cdfb
|
|
BLAKE2b-256 checksum How to use checksums |
491865b5c3f420cbfb2ffe9281b42abc7ffe5e59541641d511e52628fb618eee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Security for swugenerator 0.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.