[PATCH 1/2] image: Add system field.

  • Done
  • quality assurance status badge
Details
3 participants
  • Danny Milosavljevic
  • Mathieu Othacehe
  • Mathieu Othacehe
Owner
unassigned
Submitted by
Mathieu Othacehe
Severity
normal
Merged with
M
M
Mathieu Othacehe wrote on 3 Dec 2020 11:53
(address . guix-patches@gnu.org)
20201203105353.149482-2-othacehe@gnu.org
* gnu/image.scm (<system>): New field.
* gnu/system/image.scm (arm32-disk-image, arm64-disk-image): Set the system
field.
(system-image): Do not try to cross-compile if we are running on the
appropriate system.
* gnu/system/images/hurd.scm (hurd-disk-image): Set the system field.
---
gnu/image.scm | 3 +++
gnu/system/image.scm | 12 +++++++++++-
gnu/system/images/hurd.scm | 1 +
3 files changed, 15 insertions(+), 1 deletion(-)

Toggle diff (72 lines)
diff --git a/gnu/image.scm b/gnu/image.scm
index a60d83b175..a56710d540 100644
--- a/gnu/image.scm
+++ b/gnu/image.scm
@@ -33,6 +33,7 @@
image
image-name
image-format
+ image-system
image-target
image-size
image-operating-system
@@ -77,6 +78,8 @@
(name image-name ;symbol
(default #f))
(format image-format) ;symbol
+ (system image-system
+ (default #f))
(target image-target
(default #f))
(size image-size ;size in bytes as integer
diff --git a/gnu/system/image.scm b/gnu/system/image.scm
index 4972d9067b..f3d5734381 100644
--- a/gnu/system/image.scm
+++ b/gnu/system/image.scm
@@ -131,6 +131,7 @@
(define arm32-disk-image
(image
(format 'disk-image)
+ (system "armhf-linux")
(target "arm-linux-gnueabihf")
(partitions
(list (partition
@@ -143,6 +144,7 @@
(define arm64-disk-image
(image
(inherit arm32-disk-image)
+ (system "aarch64-linux")
(target "aarch64-linux-gnu")))
@@ -613,7 +615,15 @@ it can be used for bootloading."
"Return the derivation of IMAGE. It can be a raw disk-image or an ISO9660
image, depending on IMAGE format."
(define substitutable? (image-substitutable? image))
- (define target (image-target image))
+
+ ;; The image definition may provide the appropriate "system" architecture
+ ;; for the image. If we are already running on this system, the image can
+ ;; be built natively. If we are running on a different system, then we need
+ ;; to cross-compile, using the "target" provided by the image definition.
+ (define system (image-system image))
+ (define target (if (eq? system (%current-system))
+ #f
+ (image-target image)))
(with-parameters ((%current-target-system target))
(let* ((os (operating-system-for-image image))
diff --git a/gnu/system/images/hurd.scm b/gnu/system/images/hurd.scm
index 4417952c5d..6e7dbaa7a7 100644
--- a/gnu/system/images/hurd.scm
+++ b/gnu/system/images/hurd.scm
@@ -75,6 +75,7 @@
(define hurd-disk-image
(image
(format 'disk-image)
+ (system "i586-gnu")
(target "i586-pc-gnu")
(partitions
(list (partition
--
2.29.2
M
M
Mathieu Othacehe wrote on 3 Dec 2020 11:58
control message for bug #45021
(address . control@debbugs.gnu.org)
87mtyvyx41.fsf@cervin.i-did-not-set--mail-host-address--so-tickle-me
merge 45021 45020
quit
M
M
Mathieu Othacehe wrote on 3 Dec 2020 11:58
control message for bug #45022
(address . control@debbugs.gnu.org)
87lfefyx3q.fsf@cervin.i-did-not-set--mail-host-address--so-tickle-me
merge 45022 45020
quit
D
D
Danny Milosavljevic wrote on 3 Dec 2020 21:41
Re: [PATCH 1/2] image: Add system field.
(name . Mathieu Othacehe)(address . othacehe@gnu.org)(address . 45021@debbugs.gnu.org)
20201203214124.796b3651@scratchpost.org
Hi Mathieu,

On Thu, 3 Dec 2020 11:53:52 +0100
Mathieu Othacehe <othacehe@gnu.org> wrote:

Toggle quote (25 lines)
> diff --git a/gnu/image.scm b/gnu/image.scm
> index a60d83b175..a56710d540 100644
> --- a/gnu/image.scm
> +++ b/gnu/image.scm
> @@ -33,6 +33,7 @@
> image
> image-name
> image-format
> + image-system
> image-target
> image-size
> image-operating-system
> @@ -613,7 +615,15 @@ it can be used for bootloading."
> "Return the derivation of IMAGE. It can be a raw disk-image or an ISO9660
> image, depending on IMAGE format."
> (define substitutable? (image-substitutable? image))
> - (define target (image-target image))
> +
> + ;; The image definition may provide the appropriate "system" architecture
> + ;; for the image. If we are already running on this system, the image can
> + ;; be built natively. If we are running on a different system, then we need
> + ;; to cross-compile, using the "target" provided by the image definition.
> + (define system (image-system image))
> + (define target (if (eq? system (%current-system))

Should be string=? instead of eq?, otherwise it downloads a cross compiler
for armhf on armhf.

With that change, I tested this patchset on armhf--works fine then.

LGTM!
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl/JTXoACgkQ5xo1VCww
uqWZsAf/dmvRJ4BEFg/FQIpeAUJcHdIioBmEwB168mwjFB2Dx1xpzcd1wDkJXYs3
A750xCEwcT5huBh85gyehYkffE7ZSkYgkIzdK2l1CToUrwGv1jy3El0tEiEfjC+0
JkRbLXo0Kx+mnmYL+nxBK4cxYLIV1BISPibS1XEwVouG82GGGZswU2rxu2P0yJaM
SO8UyvwOvXrvG7BWfgF9K4i8M0kKNnIQDg7w2Z8HJhtbZLWo64KgEPvTscsT8UT2
btVsYkXcc1zN79HDL0tudOXSxccyH/g2GpxB7ud2dzlAJzXJNJsctUkOR2j0UsRu
Gyh0Qr/J6G/tINKom/LZuevP1AP/zw==
=K14P
-----END PGP SIGNATURE-----


M
M
Mathieu Othacehe wrote on 4 Dec 2020 09:12
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 45021@debbugs.gnu.org)
875z5iouqq.fsf@gnu.org
Hey Danny,

Toggle quote (3 lines)
> Should be string=? instead of eq?, otherwise it downloads a cross compiler
> for armhf on armhf.

I used "eq?" because if "system" is left to its default in some image
definition, then we would end-up comparing "#f" and a string.

Toggle quote (2 lines)
> With that change, I tested this patchset on armhf--works fine then.

Thanks for testing!

Mathieu
D
D
Danny Milosavljevic wrote on 4 Dec 2020 10:01
(name . Mathieu Othacehe)(address . othacehe@gnu.org)(address . 45021@debbugs.gnu.org)
20201204100110.3fb09f1c@scratchpost.org
Hi Mathieu,

On Fri, 04 Dec 2020 09:12:13 +0100
Mathieu Othacehe <othacehe@gnu.org> wrote:

Toggle quote (3 lines)
> I used "eq?" because if "system" is left to its default in some image
> definition, then we would end-up comparing "#f" and a string.

Yeah, but eq? only compares the "addresses" of things, not the content.

(eq? "a" "a") could totally be #f if one is unlucky.

For example try:

(eq? "a" (read))

and enter "a". The result will be #f.

On the other hand, (equal? "a" "a") would work; also (equal? "a" #f) would
not fail.
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl/J+tYACgkQ5xo1VCww
uqW0aAf/U/1n+zR4Io+GQAgr06SyeyneJO7mOsYg6W26JkjW8fNWGedgfu+s9uJ6
v17fID4pZFJ+T4DVshyM51LKZRmgnvLMElJ8grFEK62wKQF/DoAuv3xwybBU0RLs
473DZyCKe16DQEeX/nFDU/rl+5j8NpZS3RBefokK29UBXvjoEDDdTy7fxN23nXbK
RfaHyKhIbE1RbeodOf50QNAuMHiAhdG3tcSLOR3JkP++Tw9NKadAurrDvl1OaTai
N2yXDXN1xDNGaAtRvHISPW2qA8cZ0x/PN2FeFZqX2rItWcZ/A6KOX7gFlNu8hEar
EG27r/RiIq3fXGAbIylajnbH57AItQ==
=l3P5
-----END PGP SIGNATURE-----


M
M
Mathieu Othacehe wrote on 5 Dec 2020 11:24
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 45021@debbugs.gnu.org)
87v9dg5z55.fsf@gnu.org
Hey Danny,

Toggle quote (3 lines)
> On the other hand, (equal? "a" "a") would work; also (equal? "a" #f) would
> not fail.

Oh you're right, I always get confused with those equality procedures even
after all these years. I'll fix it before pushing.

Thanks,

Mathieu
?