public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-catalyst] [PATCH] Add option to generate BSD-style tagged hashes (can be verified by modern coreutils)
@ 2021-02-24 21:30 Andreas K. Hüttel
  2021-03-18 11:40 ` Daniel Cordero
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas K. Hüttel @ 2021-02-24 21:30 UTC (permalink / raw
  To: gentoo-catalyst; +Cc: Andreas K. Hüttel

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
---
 catalyst/base/genbase.py | 6 +++++-
 catalyst/defaults.py     | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py
index c7dd87bc..52418877 100644
--- a/catalyst/base/genbase.py
+++ b/catalyst/base/genbase.py
@@ -24,7 +24,11 @@ class GenBase():
                 h.update(data)
 
         filename = os.path.split(filepath)[1]
-        return f'# {name.upper()} HASH\n{h.hexdigest()}  {filename}\n'
+
+	if self.settings['digest_format'] == 'bsd':
+		return f'# {name.upper()} HASH\n{name.upper()} ({filename}) = {h.hexdigest()}\n'
+	else:
+		return f'# {name.upper()} HASH\n{h.hexdigest()}  {filename}\n'
 
     def gen_contents_file(self, path):
         c = self.settings['contents_map']
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index ccb0a584..2cede562 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -11,6 +11,7 @@ from DeComp.definitions import DECOMPRESSOR_PROGRAM_OPTIONS, LIST_XATTRS_OPTIONS
 valid_config_file_values = frozenset([
     "compression_mode",
     "digests",
+    "digest_format",
     "distcc_hosts",
     "distdir",
     "envscript",
@@ -35,6 +36,7 @@ confdefaults = {
     "compressor_options": XATTRS_OPTIONS['linux'],
     "decomp_opt": DECOMPRESSOR_PROGRAM_OPTIONS['linux'],
     "decompressor_search_order": DECOMPRESSOR_SEARCH_ORDER,
+    "digest_format": 'linux',
     "distdir": portage.settings['DISTDIR'],
     "icecream": "/var/cache/icecream",
     'list_xattrs_opt': LIST_XATTRS_OPTIONS['linux'],
-- 
2.30.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [gentoo-catalyst] [PATCH] Add option to generate BSD-style tagged hashes (can be verified by modern coreutils)
  2021-02-24 21:30 [gentoo-catalyst] [PATCH] Add option to generate BSD-style tagged hashes (can be verified by modern coreutils) Andreas K. Hüttel
@ 2021-03-18 11:40 ` Daniel Cordero
  2021-03-25  3:07   ` Matt Turner
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Cordero @ 2021-03-18 11:40 UTC (permalink / raw
  To: gentoo-catalyst; +Cc: Andreas K. Hüttel

On Wed, Feb 24, 2021 at 10:30:26PM +0100, Andreas K. Hüttel wrote:
> ---
>  catalyst/base/genbase.py | 6 +++++-
>  catalyst/defaults.py     | 2 ++
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py
> index c7dd87bc..52418877 100644
> --- a/catalyst/base/genbase.py
> +++ b/catalyst/base/genbase.py
> @@ -24,7 +24,11 @@ class GenBase():
>                  h.update(data)
>  
>          filename = os.path.split(filepath)[1]
> -        return f'# {name.upper()} HASH\n{h.hexdigest()}  {filename}\n'
> +
> +	if self.settings['digest_format'] == 'bsd':

GenBase.generate_hash is a @staticmethod, and no variable called 'self'
is passed to it:

class GenBase():
    ...
    @staticmethod
    def generate_hash(filepath, name):
        ...


Traceback (most recent call last):
  File "/run/media/system/substrate/bindist/catalyst/bin/catalyst", line 27, in <module>
    main(sys.argv[1:])
  File "/run/media/system/substrate/bindist/catalyst/catalyst/main.py", line 256, in main
    return _main(parser, opts)
  File "/run/media/system/substrate/bindist/catalyst/catalyst/main.py", line 366, in _main
    success = build_target(addlargs)
  File "/run/media/system/substrate/bindist/catalyst/catalyst/main.py", line 79, in build_target
    target = getattr(module, target)(conf_values, addlargs)
  File "/run/media/system/substrate/bindist/catalyst/catalyst/targets/stage1.py", line 24, in __init__
    StageBase.__init__(self, spec, addlargs)
  File "/run/media/system/substrate/bindist/catalyst/catalyst/base/stagebase.py", line 183, in __init__
    self.set_source_path()
  File "/run/media/system/substrate/bindist/catalyst/catalyst/base/stagebase.py", line 463, in set_source_path
    self.generate_hash(self.settings["source_path"], "sha1")
  File "/run/media/system/substrate/bindist/catalyst/catalyst/base/genbase.py", line 28, in generate_hash
    if self.settings['digest_format'] == 'bsd':
NameError: name 'self' is not defined

> +		return f'# {name.upper()} HASH\n{name.upper()} ({filename}) = {h.hexdigest()}\n'
> +	else:
> +		return f'# {name.upper()} HASH\n{h.hexdigest()}  {filename}\n'
>  
>      def gen_contents_file(self, path):
>          c = self.settings['contents_map']
> diff --git a/catalyst/defaults.py b/catalyst/defaults.py
> index ccb0a584..2cede562 100644
> --- a/catalyst/defaults.py
> +++ b/catalyst/defaults.py
> @@ -11,6 +11,7 @@ from DeComp.definitions import DECOMPRESSOR_PROGRAM_OPTIONS, LIST_XATTRS_OPTIONS
>  valid_config_file_values = frozenset([
>      "compression_mode",
>      "digests",
> +    "digest_format",
>      "distcc_hosts",
>      "distdir",
>      "envscript",
> @@ -35,6 +36,7 @@ confdefaults = {
>      "compressor_options": XATTRS_OPTIONS['linux'],
>      "decomp_opt": DECOMPRESSOR_PROGRAM_OPTIONS['linux'],
>      "decompressor_search_order": DECOMPRESSOR_SEARCH_ORDER,
> +    "digest_format": 'linux',
>      "distdir": portage.settings['DISTDIR'],
>      "icecream": "/var/cache/icecream",
>      'list_xattrs_opt': LIST_XATTRS_OPTIONS['linux'],
> -- 
> 2.30.1
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [gentoo-catalyst] [PATCH] Add option to generate BSD-style tagged hashes (can be verified by modern coreutils)
  2021-03-18 11:40 ` Daniel Cordero
@ 2021-03-25  3:07   ` Matt Turner
  0 siblings, 0 replies; 3+ messages in thread
From: Matt Turner @ 2021-03-25  3:07 UTC (permalink / raw
  To: gentoo-catalyst; +Cc: Andreas K. Hüttel

On Thu, Mar 18, 2021 at 7:40 AM Daniel Cordero <gentoo.catalyst@xxoo.ws> wrote:
>
> On Wed, Feb 24, 2021 at 10:30:26PM +0100, Andreas K. Hüttel wrote:
> > ---
> >  catalyst/base/genbase.py | 6 +++++-
> >  catalyst/defaults.py     | 2 ++
> >  2 files changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py
> > index c7dd87bc..52418877 100644
> > --- a/catalyst/base/genbase.py
> > +++ b/catalyst/base/genbase.py
> > @@ -24,7 +24,11 @@ class GenBase():
> >                  h.update(data)
> >
> >          filename = os.path.split(filepath)[1]
> > -        return f'# {name.upper()} HASH\n{h.hexdigest()}  {filename}\n'
> > +
> > +     if self.settings['digest_format'] == 'bsd':
>
> GenBase.generate_hash is a @staticmethod, and no variable called 'self'
> is passed to it:
>
> class GenBase():
>     ...
>     @staticmethod
>     def generate_hash(filepath, name):
>         ...
>
>
> Traceback (most recent call last):
>   File "/run/media/system/substrate/bindist/catalyst/bin/catalyst", line 27, in <module>
>     main(sys.argv[1:])
>   File "/run/media/system/substrate/bindist/catalyst/catalyst/main.py", line 256, in main
>     return _main(parser, opts)
>   File "/run/media/system/substrate/bindist/catalyst/catalyst/main.py", line 366, in _main
>     success = build_target(addlargs)
>   File "/run/media/system/substrate/bindist/catalyst/catalyst/main.py", line 79, in build_target
>     target = getattr(module, target)(conf_values, addlargs)
>   File "/run/media/system/substrate/bindist/catalyst/catalyst/targets/stage1.py", line 24, in __init__
>     StageBase.__init__(self, spec, addlargs)
>   File "/run/media/system/substrate/bindist/catalyst/catalyst/base/stagebase.py", line 183, in __init__
>     self.set_source_path()
>   File "/run/media/system/substrate/bindist/catalyst/catalyst/base/stagebase.py", line 463, in set_source_path
>     self.generate_hash(self.settings["source_path"], "sha1")
>   File "/run/media/system/substrate/bindist/catalyst/catalyst/base/genbase.py", line 28, in generate_hash
>     if self.settings['digest_format'] == 'bsd':
> NameError: name 'self' is not defined
>
> > +             return f'# {name.upper()} HASH\n{name.upper()} ({filename}) = {h.hexdigest()}\n'
> > +     else:
> > +             return f'# {name.upper()} HASH\n{h.hexdigest()}  {filename}\n'
> >
> >      def gen_contents_file(self, path):
> >          c = self.settings['contents_map']
> > diff --git a/catalyst/defaults.py b/catalyst/defaults.py
> > index ccb0a584..2cede562 100644
> > --- a/catalyst/defaults.py
> > +++ b/catalyst/defaults.py
> > @@ -11,6 +11,7 @@ from DeComp.definitions import DECOMPRESSOR_PROGRAM_OPTIONS, LIST_XATTRS_OPTIONS
> >  valid_config_file_values = frozenset([
> >      "compression_mode",
> >      "digests",
> > +    "digest_format",
> >      "distcc_hosts",
> >      "distdir",
> >      "envscript",
> > @@ -35,6 +36,7 @@ confdefaults = {
> >      "compressor_options": XATTRS_OPTIONS['linux'],
> >      "decomp_opt": DECOMPRESSOR_PROGRAM_OPTIONS['linux'],
> >      "decompressor_search_order": DECOMPRESSOR_SEARCH_ORDER,
> > +    "digest_format": 'linux',
> >      "distdir": portage.settings['DISTDIR'],
> >      "icecream": "/var/cache/icecream",
> >      'list_xattrs_opt': LIST_XATTRS_OPTIONS['linux'],
> > --
> > 2.30.1
> >
> >

I've fixed this.

Not good...


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-25  3:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-24 21:30 [gentoo-catalyst] [PATCH] Add option to generate BSD-style tagged hashes (can be verified by modern coreutils) Andreas K. Hüttel
2021-03-18 11:40 ` Daniel Cordero
2021-03-25  3:07   ` Matt Turner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox