From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id uDL1H1KR6GZYTgEAqHPOHw:P1 (envelope-from ) for ; Mon, 16 Sep 2024 20:13:06 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id uDL1H1KR6GZYTgEAqHPOHw (envelope-from ) for ; Mon, 16 Sep 2024 22:13:06 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=dD+XAoFY; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=WZV7WKAT; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1726517586; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=uwNXy6E6Ykc9mYCUXtFnfwhJAsQynkcndhUi/wF9RKE=; b=G+f8cYFbQovlzTg/cNV2POkqVSareu3hi2nqVZQBNG0xrVfPiiLUv++9+Z4husS0Jb61lu fd7+ScrHGZZkrri7RIsdjNqUT7DSInaz8WFnLq31dvWc+Kem9cd/X56IYuufKJ6F0WXhAz ACsduXZNSopSHotArk2PvNTiaji38rlg/QhlDD3+Wbj8jpmoYHpwO+vkAO+15S0MbtyBYL UsCBYbxXhWBi9cjm5bDf03w/naAKcJEnQLcha46C4uTUJg4wV3Emjig5o/yUPc41BIlYsy NBw+GbZHluskOOSdDdb2CqsRHaCsY5gD8BmJRJReB0miNq4U+3tdbQtBsEAdqg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1726517586; a=rsa-sha256; cv=none; b=C62yk6gH4PH4YVh/jK3xEbKI75bi2Krpi6cglI6yCi7qfl5zzxUpA+5mTQyeM5dnjZiHtO V53PcU0zZ/WyoOcg3tFUceLssfyCcqvm6C3cT6ykZrTadjfuCOivrfHhC3mMIKZVgaHXFK Z5DK9/cOEwDStm6bSRi/zBwWBShnrQBdyV8TxykuHUtbufZikfRarEYpkCB/NOOD0IovNd 8unpszxuTTqgY9vB0INuxXafT6/q1WfZh1eAcMac4VVh5ku3iB9Na3hye0JHW9kEX0R4sf IFBVE8a9+Hl2lha0agWDH69U3DOt6WsNbvuKBezxvkMDnXtK3U/+pxSgdScREg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=dD+XAoFY; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=WZV7WKAT; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2A8945A82E for ; Mon, 16 Sep 2024 22:13:06 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sqI5a-0002wL-Ob; Mon, 16 Sep 2024 16:12:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sqI5Z-0002qc-C7 for guix-patches@gnu.org; Mon, 16 Sep 2024 16:12:49 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sqI5Y-0002la-Db; Mon, 16 Sep 2024 16:12:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=uwNXy6E6Ykc9mYCUXtFnfwhJAsQynkcndhUi/wF9RKE=; b=dD+XAoFYRHqN8NLSLid2PD0TO42vIIyxc5LPJjW9EKvC16aALQebaFfwaGtbZn9RMna8CaQ41z954temwk7PnVY5s/B64AGI9X1WfM0XfsZ9fCxjxkpc1xV9IBzVGETJHk/xhYufKYIXtbWbOJmH7FiNgddYvBFcbRQg/37cVb6wK/UOZHzAR3gSbGrdGg40HxwcnMs9pDaMzYoUQ2XX4Eoj65kpRK/QClVfubVboCpFdisMckGHAT6JA+WrXuCZkvh6/KCqjUx012U4Fac1Ay33S22MpAausTfi6UePo1GSlCCpQPhj/djDHuiMRiT/7jozoOaKG+nATfQVaPeJBA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sqI5m-0005iG-31; Mon, 16 Sep 2024 16:13:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#73299] [PATCH v2 1/3] build/go: Replace symlinks with a copy of the file. Resent-From: Sharlatan Hellseher Original-Sender: "Debbugs-submit" Resent-CC: pelzflorian@pelzflorian.de, cox.katherine.e+guix@gmail.com, ludo@gnu.org, maxim.cournoyer@gmail.com, sharlatanus@gmail.com, guix-patches@gnu.org Resent-Date: Mon, 16 Sep 2024 20:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73299 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 73299@debbugs.gnu.org Cc: Sharlatan Hellseher , Efraim Flashner , Florian Pelz , Katherine Cox-Buday , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Maxim Cournoyer , Sharlatan Hellseher X-Debbugs-Original-Xcc: Florian Pelz , Katherine Cox-Buday , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Maxim Cournoyer , Sharlatan Hellseher Received: via spool by 73299-submit@debbugs.gnu.org id=B73299.172651754321893 (code B ref 73299); Mon, 16 Sep 2024 20:13:02 +0000 Received: (at 73299) by debbugs.gnu.org; 16 Sep 2024 20:12:23 +0000 Received: from localhost ([127.0.0.1]:53375 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqI59-0005h1-2X for submit@debbugs.gnu.org; Mon, 16 Sep 2024 16:12:23 -0400 Received: from mail-wr1-f42.google.com ([209.85.221.42]:51414) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqI53-0005gN-Fq for 73299@debbugs.gnu.org; Mon, 16 Sep 2024 16:12:18 -0400 Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-374c326c638so2162022f8f.2 for <73299@debbugs.gnu.org>; Mon, 16 Sep 2024 13:12:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726517458; x=1727122258; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uwNXy6E6Ykc9mYCUXtFnfwhJAsQynkcndhUi/wF9RKE=; b=WZV7WKATZWrx+jn6ZvLHSt/5DogasAyIX6yMLQX8US8zEUbpnSCZDURdTGE5N2xIuD YfPNpF1QdK4FLjCHW6xONzdSpQxfWyFFrhEBRX3upm/wB5u093OCQOXXkGUJIa9Bt76F NHjBgdt+72RxBSIktBON3cY7sL3E4ymG7YC31v66V577a7LV9qxEvSEaTblmrJqAXovM i1R1s+BwpMBYUrhShNMOmu+xb2dpNgzQqbLFmWN0K8PH3G/iIIMAPGOmnj7Kb16ARCTM ZzVPhaqqUFkX5BJMonDjAg4LQZeV1XybHST8RF5mAMXX6F7wfUMYYHYKV+c4/POS2pOV MEVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726517458; x=1727122258; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uwNXy6E6Ykc9mYCUXtFnfwhJAsQynkcndhUi/wF9RKE=; b=A/lleKt5gpa/u2gJHVe/9t8Ztp3ykM56HI8CLhmwsp0LzHxpj9ST9xAUm0pySi2mKP ipgXlXCAX19va23R/PVOyrVjB+jzAmYkWjxGceZqSJ8USQPByFKsDquKPf4qwY0lTnok bj1qJHjb1rgHyxi/KPNzq8ETboJDKHbVFvSjNEusNHBFhvdGL/x2/3oCKynFOcncsk97 mhdKxrgf7a62BSBvlTjAKIZT/jjxq+F26TndT7mPd+dD4dB/FvprKl165mUvw0eLTAxi H6+0MGEpIDxLRJVExztrvfGTcEwWs8B6f8t0NrSrdbX0AOCL+NiA+7jOjn2AHw0RZzIN QMRw== X-Gm-Message-State: AOJu0YwNENxu36/mwuRgReHIqSGsIX1S6wtSooQhUg2THH4QOb/pN6Od KRyOEePTT+A65vmlSNsbVLpYnqLS0VN6wHiysldHfiIqJ7owkwkxr12i3gdA X-Google-Smtp-Source: AGHT+IFg9jSEjGwal4XUGYqAeRtkNK+f7oSoyGHybgo25dkOc/ryx0HRrDSgytreOYrYKvpRmp6aMA== X-Received: by 2002:a05:6000:1049:b0:378:c887:5874 with SMTP id ffacd0b85a97d-378d625b559mr7116858f8f.59.1726517457088; Mon, 16 Sep 2024 13:10:57 -0700 (PDT) Received: from guxtil.incerto.xyz (cpc100684-bagu15-2-0-cust967.1-3.cable.virginm.net. [86.8.111.200]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378e73f62bfsm7922576f8f.51.2024.09.16.13.10.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2024 13:10:55 -0700 (PDT) From: Sharlatan Hellseher Date: Mon, 16 Sep 2024 21:10:48 +0100 Message-ID: <870204639eb63370aae42e86364899d333064749.1726516329.git.sharlatanus@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -3.51 X-Spam-Score: -3.51 X-Migadu-Scanner: mx13.migadu.com X-Migadu-Queue-Id: 2A8945A82E X-TUID: 8f4+bKu5xcBp From: Efraim Flashner * guix/build/go-build-system.scm (fix-embed-files): New procedure. (%standard-phases): Add 'fix-embed-files after 'unpack. * guix/build-system/go.scm (#:embed-files): New key parameter. * doc/guix.texi: (go-build-system): Document a new key. Co-authored-by: Sharlatan Hellseher Change-Id: I27bc46fa1a3f4675ff73b6cba4ef5c3d177c22b1 --- doc/guix.texi | 8 ++++++++ guix/build-system/go.scm | 6 ++++++ guix/build/go-build-system.scm | 30 ++++++++++++++++++++++++++++-- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 4abe258af0..e780bde6cf 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -130,6 +130,9 @@ Copyright @copyright{} 2024 Dariqq@* Copyright @copyright{} 2024 Denis 'GNUtoo' Carikli@* Copyright @copyright{} 2024 Fabio Natali@* +Copyright @copyright{} 2024 Troy Figiel@* +Copyright @copyright{} 2024 Sharlatan Hellseher@* + Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -9580,6 +9583,11 @@ Build Systems @code{#:test-flags} parameter, default is @code{'()}. See @code{go help test} and @code{go help testflag} for more details. +The key @code{#:embed-files}, default is @code{'()}, provides a list of +future embedded files or regexps matching files. They will be copied to +build directory after @code{unpack} phase. See +@url{https://pkg.go.dev/embed} for more details. + @end defvar @defvar glib-or-gtk-build-system diff --git a/guix/build-system/go.scm b/guix/build-system/go.scm index e6e8b84e48..97581a14c6 100644 --- a/guix/build-system/go.scm +++ b/guix/build-system/go.scm @@ -6,6 +6,8 @@ ;;; Copyright © 2021, 2023 Efraim Flashner ;;; Copyright © 2021 Sarah Morgensen ;;; Copyright © 2024 Christina O'Donnell +;;; Copyright © 2024 Troy Figiel +;;; Copyright © 2024 Sharlatan Hellseher ;;; ;;; This file is part of GNU Guix. ;;; @@ -197,6 +199,7 @@ (define* (go-build name inputs (outputs '("out")) (search-paths '()) (install-source? #t) + (embed-files ''()) (import-path "") (unpack-path "") (build-flags ''()) @@ -226,6 +229,7 @@ (define* (go-build name inputs #:substitutable? #$substitutable? #:goarch #$goarch #:goos #$goos + #:embed-files #$embed-files #:search-paths '#$(sexp->gexp (map search-path-specification->sexp search-paths)) @@ -264,6 +268,7 @@ (define* (go-cross-build name (system (%current-system)) (goarch (first (go-target target))) (goos (last (go-target target))) + (embed-files ''()) (guile #f) (imported-modules %go-build-system-modules) (modules '((guix build go-build-system) @@ -297,6 +302,7 @@ (define* (go-cross-build name #:target #$target #:goarch #$goarch #:goos #$goos + #:embed-files #$embed-files #:inputs %build-target-inputs #:native-inputs %build-host-inputs #:search-paths '#$(map search-path-specification->sexp diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm index 3f0f5700a1..14cb5ae687 100644 --- a/guix/build/go-build-system.scm +++ b/guix/build/go-build-system.scm @@ -4,10 +4,12 @@ ;;; Copyright © 2019 Maxim Cournoyer ;;; Copyright © 2020 Jack Hill ;;; Copyright © 2020 Jakub Kądziołka -;;; Copyright © 2020, 2021, 2023 Efraim Flashner +;;; Copyright © 2020, 2021, 2023, 2024 Efraim Flashner ;;; Copyright © 2021 Sarah Morgensen ;;; Copyright © 2024 Ekaitz Zarraga ;;; Copyright © 2024 Picnoir +;;; Copyright © 2024 Troy Figiel +;;; Copyright © 2024 Sharlatan Hellseher ;;; ;;; This file is part of GNU Guix. ;;; @@ -28,8 +30,9 @@ (define-module (guix build go-build-system) #:use-module ((guix build gnu-build-system) #:prefix gnu:) #:use-module (guix build union) #:use-module (guix build utils) - #:use-module (ice-9 match) + #:use-module (ice-9 format) #:use-module (ice-9 ftw) + #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:use-module (rnrs io ports) #:use-module (rnrs bytevectors) @@ -201,6 +204,28 @@ (define* (setup-go-environment #:key inputs outputs goos goarch #:allow-other-ke (delete-file-recursively tmpdir)) #t) +(define* (fix-embed-files #:key embed-files #:allow-other-keys) + "Golang can't determine the valid directory of the module of embed file +which is symlinked during setup environment phase, but easy resolved after +coping file from the store to the build directory of the current package. Take +a list of files or regexps matching files from EMBED-FILES paramter, failover +to 'editions_defaults.binpb' which is a part of ." + ;; see details in Golang source: + ;; + ;; - URL: + ;; - commit: 82c14346d89ec0eeca114f9ca0e88516b2cda454 + ;; - file: src/cmd/go/internal/load/pkg.go#L2059 + (let ((embed-files (format #f "^(~{~a|~}~a)$" + embed-files + "editions_defaults.binpb"))) + (for-each (lambda (file) + (when (eq? (stat:type (lstat file)) + 'symlink) + (let ((file-store-path (readlink file))) + (delete-file file) + (copy-recursively file-store-path file)))) + (find-files "src" embed-files)))) + (define* (unpack #:key source import-path unpack-path #:allow-other-keys) "Relative to $GOPATH, unpack SOURCE in UNPACK-PATH, or IMPORT-PATH when UNPACK-PATH is unset. If the SOURCE archive has a single top level directory, @@ -321,6 +346,7 @@ (define %standard-phases (delete 'patch-generated-file-shebangs) (add-before 'unpack 'setup-go-environment setup-go-environment) (replace 'unpack unpack) + (add-after 'unpack 'fix-embed-files fix-embed-files) (replace 'build build) (replace 'check check) (replace 'install install) -- 2.46.0