[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, doc/

2021-11-24 Thread Georgy Yakovlev
commit: 7457cd3b1a5f3ed4a566bbf23e36c939af06967c
Author: Georgy Yakovlev  gentoo  org>
AuthorDate: Fri Nov  5 02:14:00 2021 +
Commit: Georgy Yakovlev  gentoo  org>
CommitDate: Thu Nov 25 02:43:21 2021 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=7457cd3b

catalyst: generate .sha256 file if any digest is enabled

checksum format is simple one, identical to one
sha256sum from coreutils produces, lines starting with # are ignored.

example:[1]

# SHA256 HASH
.  stage3-tar.xz

systemd upstream calls it suse-style .sha256 files.[0]
infra already supports inline signing of files.

Bug: https://bugs.gentoo.org/821568
[0] 
https://github.com/systemd/systemd/blob/aedec452b9e5dd197881f2164fb205dfe8bfdcec/src/import/pull-common.c#L236
[1] 
https://mirrors.edge.kernel.org/opensuse/distribution/leap/15.0/iso/openSUSE-Leap-15.0-DVD-x86_64.iso.sha256
Signed-off-by: Georgy Yakovlev  gentoo.org>

 catalyst/base/genbase.py  | 3 +++
 doc/catalyst-config.5.txt | 7 ---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py
index 6d039a8f..1643b1dc 100644
--- a/catalyst/base/genbase.py
+++ b/catalyst/base/genbase.py
@@ -43,3 +43,6 @@ class GenBase():
 for f in [path, path + '.CONTENTS.gz']:
 for i in self.settings['digests']:
 file.write(self.generate_hash(f, name=i))
+
+with io.open(path + '.sha256', 'w', encoding='utf-8') as sha256file:
+sha256file.write(self.generate_hash(path, name='sha256'))

diff --git a/doc/catalyst-config.5.txt b/doc/catalyst-config.5.txt
index 003d40b6..ca9335d6 100644
--- a/doc/catalyst-config.5.txt
+++ b/doc/catalyst-config.5.txt
@@ -38,9 +38,10 @@ Basic configuration
 *digests*::
 Create a `.DIGESTS` file containing the hash output from any of the
 supported options below.  Adding them all may take a long time.
-(example: `md5 sha1 sha512 whirlpool`).  The set of supported hashes
-is dependent on the version of Python. To see the set of hashes
-supported by the version of Python in use, run
+(example: `md5 sha1 sha512 whirlpool`).  Enabling ANY digest will
+generate `.sha256` file in addition `.DIGESTS` file.  The set of
+supported hashes is dependent on the version of Python. To see the
+set of hashes supported by the version of Python in use, run
 +
 -
 $ python3 -c 'import hashlib; print(hashlib.algorithms_available)'



[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, doc/, catalyst/

2017-12-06 Thread Robin H. Johnson
commit: d0fc244d633375faeaf4da81350c9818a1b291f0
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Wed Dec  6 08:45:30 2017 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Wed Dec  6 18:05:00 2017 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d0fc244d

Allow unversioned cache directories

The generation of cachedirs up to this point includes the version_stamp
from the specfile.

If the version is being automatically incremented (eg daily builds),
then it generates unique cache directories for each build, and doesn't
reuse old cache.

Example versioned cache directories:
/release/buildroot/amd64-dev/packages/default/stage1-amd64-20171203
/release/buildroot/amd64-dev/packages/default/stage1-amd64-20171204
/release/buildroot/amd64-dev/packages/default/stage1-amd64-20171206

This should be using a common cache directory:
/release/buildroot/amd64-dev/packages/default/stage1-amd64

Signed-off-by: Robin H. Johnson  gentoo.org>
Signed-off-by: Brian Dolbec  gentoo.org>

 catalyst/base/stagebase.py | 23 ++-
 catalyst/main.py   |  8 
 doc/catalyst-config.5.txt  |  9 +
 3 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 7a41973c..a6a32f5a 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -318,9 +318,15 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings["target_profile"] = self.settings["profile"]
 
def set_target_subpath(self):
-   self.settings["target_subpath"] = self.settings["rel_type"] + 
"/" + \
-   self.settings["target"] + "-" + 
self.settings["subarch"] + "-" + \
-   self.settings["version_stamp"] + '/'
+   common = self.settings["rel_type"] + "/" + \
+   self.settings["target"] + "-" + 
self.settings["subarch"]
+   self.settings["target_subpath"] = \
+   common + \
+   "-" + self.settings["version_stamp"] + \
+   "/"
+   self.settings["target_subpath_unversioned"] = \
+   common + \
+   "/"
 
def set_source_subpath(self):
if not isinstance(self.settings['source_subpath'], str):
@@ -333,19 +339,26 @@ class StageBase(TargetBase, ClearBase, GenBase):
if not isinstance(self.settings['pkgcache_path'], str):
self.settings["pkgcache_path"] = \
normpath(self.settings["pkgcache_path"])
-   else:
+   elif "versioned_cache" in self.settings["options"]:
self.settings["pkgcache_path"] = \
normpath(self.settings["storedir"] + 
"/packages/" + \
self.settings["target_subpath"] + "/")
+   else:
+   self.settings["pkgcache_path"] = \
+   normpath(self.settings["storedir"] + 
"/packages/" + \
+   self.settings["target_subpath_unversioned"] + 
"/")
 
def set_kerncache_path(self):
if "kerncache_path" in self.settings:
if not isinstance(self.settings['kerncache_path'], str):
self.settings["kerncache_path"] = \

normpath(self.settings["kerncache_path"])
-   else:
+   elif "versioned_cache" in self.settings["options"]:
self.settings["kerncache_path"] = 
normpath(self.settings["storedir"] + \
"/kerncache/" + self.settings["target_subpath"])
+   else:
+   self.settings["kerncache_path"] = 
normpath(self.settings["storedir"] + \
+   "/kerncache/" + 
self.settings["target_subpath_unversioned"])
 
def set_target_path(self):
self.settings["target_path"] = 
normpath(self.settings["storedir"] + \

diff --git a/catalyst/main.py b/catalyst/main.py
index b8ae662d..3a428d3a 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -190,6 +190,14 @@ $ catalyst -f stage1-specfile.spec"""
group.add_argument('-T', '--purgetmponly',
default=False, action='store_true',
help='clear tmp dirs and autoresume flags and exit')
+group.add_argument('--versioned-cachedir',
+dest='versioned_cachedir', action='store_true',
+help='use stage version on cache directory name')
+group.add_argument('--unversioned-cachedir',
+dest='versioned_cachedir', action='store_false',
+help='do not use stage version on cache directory name')
+