From patchwork Mon Aug 31 06:23:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Stewart X-Patchwork-Id: 1354130 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=paral.in Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bg0X66xvZz9sPB for ; Mon, 31 Aug 2020 16:23:49 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 66B8385A46; Mon, 31 Aug 2020 06:23:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eTU7+dzFXlHy; Mon, 31 Aug 2020 06:23:43 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 4F0578589A; Mon, 31 Aug 2020 06:23:43 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id B02F01BF381 for ; Mon, 31 Aug 2020 06:23:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id A49E6855CC for ; Mon, 31 Aug 2020 06:23:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tVxg33LYUUcH for ; Mon, 31 Aug 2020 06:23:42 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 1DD61855CB for ; Mon, 31 Aug 2020 06:23:42 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id m8so49692pfh.3 for ; Sun, 30 Aug 2020 23:23:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Lwocv/eI+OXH6AiRHEN/elyl/Hi5n04un8g8EuNEsn8=; b=fXZ4zyGab6pL9BRJxAU/M06Ik54MneZXWSfx2MQTlcxVwaPDuE/DVlLfFWv3noWrRK OLCX6lcCU9mOE3UTulYOujQ9aLVGbPBq1dQxJGkhlrIEsiGDvYcYiuGeQ0VZHN0I9dAK +Iryb/DfJOG+2xGR56+OK+FuAtnYFpiyi3PUmElBJ8ei8+7QuGBryV+SNK4RtZFQD4D2 ATuqZt0GMYukuvevQdhv2i+666nMzGK1HbXK0XZEpXgw0sr0OkQlBk+N0yWQN4Iq+T0C R9yVb8Jtx/ym0LThv3/ojJp4SR6BASXoigvgy91sbgz3erln5zzB8YKTf4Z8VhmczXSh bNeA== X-Gm-Message-State: AOAM530JS6/Oafp9ZLgJvS1kUPsgpi2GHcbue8NNXdCzLOYXO6dpivYX VI4Advvv5/6Dx4CHgWOGpb+MwTSR4yvcheB4 X-Google-Smtp-Source: ABdhPJw8/qBtksCqSOS6nLdCCB8eqVOwXADR+HImZDHQ8ZZwqwDSuA9X49IJu4fUTP2YK1OI1nz3Yg== X-Received: by 2002:a63:ce56:: with SMTP id r22mr145290pgi.141.1598855021158; Sun, 30 Aug 2020 23:23:41 -0700 (PDT) Received: from localhost.localdomain (ip72-194-208-254.sb.sd.cox.net. [72.194.208.254]) by smtp.gmail.com with ESMTPSA id b5sm5996704pgi.83.2020.08.30.23.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2020 23:23:40 -0700 (PDT) From: Christian Stewart To: buildroot@buildroot.org Date: Sun, 30 Aug 2020 23:23:35 -0700 Message-Id: <20200831062335.1105977-1-christian@paral.in> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Subject: [Buildroot] [RFC PATCH v1 1/1] package/pkg-golang: download deps to vendor tree if not present X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mirza Krak , Peter Korsgaard , Christian Stewart , Christian Stewart , Anisse Astier , Thomas Petazzoni , "Yann E . MORIN" , Adam Duskett , Angelo Compagnucci Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" 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 --- 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