Gentoo Archives: gentoo-catalyst

From: Georgy Yakovlev <gyakovlev@g.o>
To: gentoo-catalyst@l.g.o
Cc: Georgy Yakovlev <gyakovlev@g.o>
Subject: [gentoo-catalyst] [PATCH] catalyst: generate .sha256 file if any digest is enabled
Date: Fri, 05 Nov 2021 03:21:20
Message-Id: 20211105032111.689252-1-gyakovlev@gentoo.org
1 checksum format is simple one, identical to one
2 sha256sum from coreutils produces, lines starting with # are ignored.
3
4 example:[1]
5
6 # SHA256 HASH
7 xxxx..... stage3-....tar.xz
8
9 systemd upstream calls it suse-style .sha256 files.[0]
10 infra already supports inline signing of files.
11
12 Bug: https://bugs.gentoo.org/821568
13 [0] https://github.com/systemd/systemd/blob/aedec452b9e5dd197881f2164fb205dfe8bfdcec/src/import/pull-common.c#L236
14 [1] https://mirrors.edge.kernel.org/opensuse/distribution/leap/15.0/iso/openSUSE-Leap-15.0-DVD-x86_64.iso.sha256
15 Signed-off-by: Georgy Yakovlev <gyakovlev@g.o>
16 ---
17 catalyst/base/genbase.py | 3 +++
18 doc/catalyst-config.5.txt | 7 ++++---
19 2 files changed, 7 insertions(+), 3 deletions(-)
20
21 diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py
22 index 6d039a8f..1643b1dc 100644
23 --- a/catalyst/base/genbase.py
24 +++ b/catalyst/base/genbase.py
25 @@ -43,3 +43,6 @@ class GenBase():
26 for f in [path, path + '.CONTENTS.gz']:
27 for i in self.settings['digests']:
28 file.write(self.generate_hash(f, name=i))
29 +
30 + with io.open(path + '.sha256', 'w', encoding='utf-8') as sha256file:
31 + sha256file.write(self.generate_hash(path, name='sha256'))
32 diff --git a/doc/catalyst-config.5.txt b/doc/catalyst-config.5.txt
33 index 003d40b6..ca9335d6 100644
34 --- a/doc/catalyst-config.5.txt
35 +++ b/doc/catalyst-config.5.txt
36 @@ -38,9 +38,10 @@ Basic configuration
37 *digests*::
38 Create a `.DIGESTS` file containing the hash output from any of the
39 supported options below. Adding them all may take a long time.
40 -(example: `md5 sha1 sha512 whirlpool`). The set of supported hashes
41 -is dependent on the version of Python. To see the set of hashes
42 -supported by the version of Python in use, run
43 +(example: `md5 sha1 sha512 whirlpool`). Enabling ANY digest will
44 +generate `.sha256` file in addition `.DIGESTS` file. The set of
45 +supported hashes is dependent on the version of Python. To see the
46 +set of hashes supported by the version of Python in use, run
47 +
48 ---------------------------------
49 $ python3 -c 'import hashlib; print(hashlib.algorithms_available)'
50 --
51 2.33.1

Replies