All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Stewart <christian@paral.in>
To: buildroot@busybox.net
Subject: [Buildroot] [RFC PATCH v1 1/1] package/pkg-golang: download deps to vendor tree if not present
Date: Sun, 30 Aug 2020 23:23:35 -0700	[thread overview]
Message-ID: <20200831062335.1105977-1-christian@paral.in> (raw)

NOTE: This patch is a RFC and is not intended for merging in its current state.
It is a naiive implementation of the "go mod vendor" download step as a
post-extract hook, for early testing and demonstration of the desired effect. I
don't yet know what a final implementation might look like.

Add a new hook to POST_EXTRACT_HOOKS for Go packages which will create the
"vendor" directory structure under $(@D)/vendor with Go package deps by running
the "go mod vendor" command.

This will download dependency sources and use $GOPATH/pkg as a caching
directory for lookups and downloads.

Go specifies commit hashes OR version tags in go.mod, and lists source code
checksums in go.sum. The Go module system has a robust security model for
preventing MITM attacks or changed Git tags on dependencies through this
checksumming and explicitly-specified versioning approach.

Reference: https://blog.golang.org/using-go-modules

Signed-off-by: Christian Stewart <christian@paral.in>
---
 package/pkg-golang.mk | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk
index 2d80e99619..88eb89a68e 100644
--- a/package/pkg-golang.mk
+++ b/package/pkg-golang.mk
@@ -98,6 +98,16 @@ endef
 
 $(2)_POST_EXTRACT_HOOKS += $(2)_APPLY_EXTRACT_GOMOD
 
+# WIP - download dependencies with the Go tool if vendor does not exist.
+define $(2)_DOWNLOAD_GOMOD
+	if [ ! -d $$(@D)/vendor ]; then \
+		cd $$(@D); \
+		go mod vendor; \
+	fi
+endef
+
+$(2)_POST_EXTRACT_HOOKS += $(2)_DOWNLOAD_GOMOD
+
 # Build step. Only define it if not already defined by the package .mk
 # file.
 ifndef $(2)_BUILD_CMDS
-- 
2.28.0

             reply	other threads:[~2020-08-31  6:23 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-31  6:23 Christian Stewart [this message]
2020-08-31  7:08 ` [Buildroot] [RFC PATCH v1 1/1] package/pkg-golang: download deps to vendor tree if not present Yann E. MORIN
2020-09-03 10:52   ` Sam Voss
2020-09-03 11:57     ` Thomas Petazzoni
2020-09-03 13:01       ` Sam Voss
2020-09-03 13:58         ` Thomas Petazzoni
2020-09-03 18:51       ` Christian Stewart
2020-09-03 13:28     ` Yann E. MORIN
2020-09-03 14:02       ` Thomas Petazzoni
2020-09-03 15:12         ` Yann E. MORIN
2020-09-03 16:13           ` Thomas Petazzoni
2020-09-03 19:18             ` Yann E. MORIN
2020-09-03 19:40               ` Christian Stewart
2020-09-03 20:43                 ` Yann E. MORIN
2020-09-03 21:47                   ` Christian Stewart
2020-09-04  8:06                     ` Yann E. MORIN
2020-09-04 16:07                       ` Christian Stewart
2020-09-04 20:25                         ` Sam Voss
2020-09-10 22:33                       ` Christian Stewart
2020-09-15 19:10                         ` Arnout Vandecappelle
2020-09-15 20:08                           ` Sam Voss

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200831062335.1105977-1-christian@paral.in \
    --to=christian@paral.in \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.