[PATCH] Fix deprecation warning for origin-sha256

  • Done
  • quality assurance status badge
Details
2 participants
  • Helio Machado
  • Ludovic Courtès
Owner
unassigned
Submitted by
Helio Machado
Severity
normal
H
L
L
Ludovic Courtès wrote on 17 Oct 2020 22:21
(name . Helio Machado)(address . 0x2b3bfa0@gmail.com)(address . 44038@debbugs.gnu.org)
87y2k44n8m.fsf@gnu.org
Hi,

Helio Machado <0x2b3bfa0@gmail.com> skribis:

Toggle quote (5 lines)
> This patch fixes the following build-time deprecation warning:
>
> guix/import/print.scm:77:21: warning: 'origin-sha256' is deprecated,
> use 'origin-hash' instead

Thanks for looking into it! The deprecation warning is a bit confusing
though in this case because ‘origin-hash’ is not exactly a drop-in
replacement for ‘origin-sha256’, as can be seen in the manual, so this
patch wouldn’t have the desired effect.

Instead, ‘print.scm’ could be changed to emit a (sha256 …) form when the
<content-hash> object is indeed a sha256 hash, and otherwise use a (hash
…) form.

See

Thanks,
Ludo’.
H
H
Helio Machado wrote on 19 Oct 2020 00:25
CANe01w6ujivzD8xgP_7banGyz+dLVSmU==cejA3xVeTePQ-1Bg@mail.gmail.com
Hello,

Sorry for the low-quality patch; it seemed so obvious that laziness won
over good sense.

The amended patch implements your suggestion and checks whether the used
hash is `sha256` or anything else, adapting the output accordingly in each
case.

Thank you for your patience,
Helio.

On Sat, 17 Oct 2020 at 22:21, Ludovic Courtès <ludo@gnu.org> wrote:

Toggle quote (26 lines)
> Hi,
>
> Helio Machado <0x2b3bfa0@gmail.com> skribis:
>
> > This patch fixes the following build-time deprecation warning:
> >
> > guix/import/print.scm:77:21: warning: 'origin-sha256' is deprecated,
> > use 'origin-hash' instead
>
> Thanks for looking into it! The deprecation warning is a bit confusing
> though in this case because ‘origin-hash’ is not exactly a drop-in
> replacement for ‘origin-sha256’, as can be seen in the manual, so this
> patch wouldn’t have the desired effect.
>
> Instead, ‘print.scm’ could be changed to emit a (sha256 …) form when the
> <content-hash> object is indeed a sha256 hash, and otherwise use a (hash
> …) form.
>
> See
> <
> https://guix.gnu.org/manual/devel/en/html_node/origin-Reference.html#index-content_002dhash
> >.
>
> Thanks,
> Ludo’.
>
Attachment: file
L
L
Ludovic Courtès wrote on 19 Oct 2020 10:57
(name . Helio Machado)(address . 0x2b3bfa0@gmail.com)(address . 44038-done@debbugs.gnu.org)
87k0vm1tla.fsf@gnu.org
Hi,

Helio Machado <0x2b3bfa0@gmail.com> skribis:

Toggle quote (8 lines)
> From 31c8a3ee7e6819ca01c875cfefd2818f727bc32e Mon Sep 17 00:00:00 2001
> From: Helio Machado <0x2b3bfa0+git@googlemail.com>
> Date: Mon, 19 Oct 2020 00:15:00 +0200
> Subject: [PATCH] guix/import: Fix deprecation warning for origin-sha256
>
> * guix/import/print.scm (source->code source version): Replace
> origin-sha256 by origin-hash

The non-SHA256 case would let the raw <content-hash> record through, so
I amended it as follows (also removing an unnecessary ‘format’ call).

Thanks!

Ludo’.
Toggle diff (19 lines)
diff --git a/guix/import/print.scm b/guix/import/print.scm
index e79f831c76..d21ce57aeb 100644
--- a/guix/import/print.scm
+++ b/guix/import/print.scm
@@ -83,9 +83,11 @@ when evaluated."
((? string? uri) (list uri))
(factorized factorized))))
,(if (equal? (content-hash-algorithm hash) 'sha256)
- `(sha256 (base32 ,(format #f "~a" (bytevector->nix-base32-string
- (content-hash-value hash)))))
- `(hash ,hash))
+ `(sha256 (base32 ,(bytevector->nix-base32-string
+ (content-hash-value hash))))
+ `(hash (content-hash ,(bytevector->nix-base32-string
+ (content-hash-value hash))
+ ,(content-hash-algorithm hash))))
;; FIXME: in order to be able to throw away the directory prefix,
;; we just assume that the patch files can be found with
;; "search-patches".
Closed
?