From patchwork Thu Dec 20 09:31:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Marusich X-Patchwork-Id: 495 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 77AAB169A5; Thu, 20 Dec 2018 09:33:25 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) by mira.cbaines.net (Postfix) with ESMTP id B692216915 for ; Thu, 20 Dec 2018 09:33:24 +0000 (GMT) Received: from localhost ([::1]:36210 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZuhn-0001uD-ML for patchwork@mira.cbaines.net; Thu, 20 Dec 2018 04:33:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34913) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZuhj-0001td-6e for guix-patches@gnu.org; Thu, 20 Dec 2018 04:33:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZuhX-0004jh-1N for guix-patches@gnu.org; Thu, 20 Dec 2018 04:33:17 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:51206) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gZuhS-0004hW-0Q for guix-patches@gnu.org; Thu, 20 Dec 2018 04:33:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gZuhR-0008HV-Rx for guix-patches@gnu.org; Thu, 20 Dec 2018 04:33:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#30806] Packaging Terraform, a Golang package Resent-From: Chris Marusich Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 20 Dec 2018 09:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30806 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: moreinfo To: Christopher Baines , Pierre Neidhardt Received: via spool by 30806-submit@debbugs.gnu.org id=B30806.154529832231764 (code B ref 30806); Thu, 20 Dec 2018 09:33:01 +0000 Received: (at 30806) by debbugs.gnu.org; 20 Dec 2018 09:32:02 +0000 Received: from localhost ([127.0.0.1]:55464 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gZugT-0008G5-Ig for submit@debbugs.gnu.org; Thu, 20 Dec 2018 04:32:02 -0500 Received: from mail-pf1-f180.google.com ([209.85.210.180]:35110) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gZugR-0008Fg-7S for 30806@debbugs.gnu.org; Thu, 20 Dec 2018 04:32:00 -0500 Received: by mail-pf1-f180.google.com with SMTP id z9so644060pfi.2 for <30806@debbugs.gnu.org>; Thu, 20 Dec 2018 01:31:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=t3c07t/sIwzBa9XE4QJzBAx9p9jiwZtgTRX7ZTkT7X4=; b=qgbYytLoL1eHf59w8cu/Sl9w/JXEtUQweUZrDRUMhXHHNE/sdYeVQ6NMFW3vUipQQk y6Aemq/UHdl8J/lDUk2BF5blzL7lo4B1OGZmBdXUnnjnFFKzO6mTObvUeNvzFcncTZbz Ap/QvvDJLvUXcUuF5/q6g+9e6NrceZVByzMqBqQ0BP2vnVjVpkhjInIfPx+p7nB8mhCA +2jyFMiAeH++B4eswEl6Xl25VuqSl7YAW7kVttc7Uh70LJYag/dk2+pCD9Q3vfP0RV5D SJtRjHOmtPd1X0acvCkAbejbZV2vVHRY14zXZKaPheqNrY9rCe5qWhSPcBTkjDUktf9G jDjQ== 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:references:date:in-reply-to :message-id:user-agent:mime-version; bh=t3c07t/sIwzBa9XE4QJzBAx9p9jiwZtgTRX7ZTkT7X4=; b=bqoK396Zb1B8qL5ZDOj4PVHb6wlRqmOvECdmA1fhBvGE2TFPgJNGJdikatqe9DN/hY Ao/VDW1JqNTlqaCw2V3LdHMFIdpPnDYN4jxl6oZ8WjiHITYbiERPwJWlO/kcl5YigYxf sVCUXowEOIrScUJDvbTkKNbXHX5cUok9pjqSrseO43O55Yde7Wi2UxFfK4hF07ctVEJC AuqqueXu/3vNy9N9GPbQyN/fmnjJwviQ1SfhSxklceQmvj1ltY3XPT8vll5iiXn30U76 xhCEJqeJ0xa0IOgJKkHl5Mx1+E8R3qBaVb8bhDEcCk6v5DD0Jdgd0opIZ8jVrRlIFcZN QoXQ== X-Gm-Message-State: AA+aEWZfi8XpOMiO3JY8A3IqEvai+2kuqtH716OVv33XqZkmC6I+3Qgg 9MXfzda8qQ5KDTEiKWaHdwmXiMtL X-Google-Smtp-Source: AFSGD/UI4bqBJm7btQqkzqHTDO2H8IpDacTzKUf4YmE1OhkFp/EKVVFp9nV8+g28mWr5p2Xv8nIXxg== X-Received: by 2002:a63:ab08:: with SMTP id p8mr22010259pgf.87.1545298311875; Thu, 20 Dec 2018 01:31:51 -0800 (PST) Received: from garuda.local (c-73-53-106-26.hsd1.wa.comcast.net. [73.53.106.26]) by smtp.gmail.com with ESMTPSA id c72sm17879331pfb.107.2018.12.20.01.31.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Dec 2018 01:31:50 -0800 (PST) From: Chris Marusich References: <875zvqjjnl.fsf@gmail.com> <875zvpm6d3.fsf@cbaines.net> Date: Thu, 20 Dec 2018 01:31:48 -0800 In-Reply-To: <875zvpm6d3.fsf@cbaines.net> (Christopher Baines's message of "Wed, 19 Dec 2018 23:42:00 +0000") Message-ID: <87bm5g4k8r.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: guix-devel@gnu.org, 30806@debbugs.gnu.org Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hello Chris and Pierre! Thank you for your tips regarding Golang and Terraform. I've built it - both ad-hoc and using a slightly modified version of Chris' original package definition. I'm still getting used to Golang's build system and our own golang-build-system, so please bear with me! I was able to run the official Terraform build steps on the latest Terraform release by issuing the following commands - but I'm not sure if this actually produced the terraform program: mkdir terraform cd terraform/ wget https://github.com/hashicorp/terraform/archive/v0.11.11.tar.gz tar -xf v0.11.11.tar.gz mkdir -p src/github.com/hashicorp cp -r terraform-0.11.11 src/github.com/hashicorp/terraform guix package -i go make git bash grep findutils which coreutils diffutils -p .guix-profile mkdir gobin eval "$(guix package --search-paths=exact --profile=$(realpath --no-symlinks .guix-profile))" export GOPATH="$(pwd)" export GOBIN="$GOPATH/bin" export PATH="$PATH:$GOBIN" cd src/github.com/hashicorp/terraform/ make tools make Those last two commands are the ones listed in Terraform's README.md. It looks like the final command, "make" will execute the "fmtcheck", "generate", and "test" recipes in that order. Here are the relevant parts of the Makefile: --8<---------------cut here---------------start------------->8--- default: test [...] # test runs the unit tests # we run this one package at a time here because running the entire suite in # one command creates memory usage issues when running in Travis-CI. test: fmtcheck generate go list $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=2m -parallel=4 [...] # generate runs `go generate` to build the dynamically generated # source files. generate: @which stringer > /dev/null; if [ $$? -ne 0 ]; then \ go get -u golang.org/x/tools/cmd/stringer; \ fi go generate ./... @go fmt command/internal_plugin_list.go > /dev/null [...] fmtcheck: @sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'" --8<---------------cut here---------------end--------------->8--- So, in essence this runs "go generate", "go fmt", and "go test". The script gofmtcheck.sh seems to be a read-only linter to assist the Terraform maintainers in finding badly formatted Golang files. This is slightly different from the installation procedure that our go-build-system runs. When you build the attached package (which packages an older version of terraform for now), our go-build-system runs steps like the following (in order from top to bottom): * Phase: unpack: Make a "src/github.com/hashicorp/terraform" directory. * Phase: setup-environment: set GOPATH to (getcwd) and GOBIN to $out/bin. * Phase: build: go install -v -x '-ldflags=-s -w' github.com/hashicorp/terraform * Phase: check: go test github.com/hashicorp/terraform All in all, this has raised some questions in my mind: 1) Is it bad that our package definition isn't running "go generate" or "go fmt"? Do you know if "go install" does this for us somehow? I don't think "stringer" or "mockgen" are present in the build environment, but our "go install" invocation seems to build terraform even without them. I wonder if the built terraform is broken in some ways because we didn't run the code generation/formatting steps. 2) After I ran "make" ad-hoc, I couldn't find a built "terraform" executable anywhere. Where is it? Am missing something obvious, or could it be that the official documentation incomplete and I need to ask upstream for advice? 3) The official instructions seem to arbitrarily choose to run the build in parallel, using 4 threads, which means this package won't play nice with build arguments like --cores. I suppose I might need to work with upstream to fix that. This feels so close, and yet so far. Hopefully we only have a little more to do to get Terraform packaged well! Thank you again for your help. From 71d654e2738c6ef870441d4234632bd30e93c74a Mon Sep 17 00:00:00 2001 From: Chris Marusich Date: Thu, 20 Dec 2018 01:24:59 -0800 Subject: [PATCH] gnu: Add terraform. This patch is slightly modified from Christopher Baines' original patch to accommodate some changes that have taken place recently in the Guix source tree. But it's essentially the same. It is still probably not suitable for inclusion in Guix just yet. * gnu/packages/terraform.scm (terraform): New variable. --- gnu/packages/terraform.scm | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/gnu/packages/terraform.scm b/gnu/packages/terraform.scm index f14b152fd..de2288dda 100644 --- a/gnu/packages/terraform.scm +++ b/gnu/packages/terraform.scm @@ -47,3 +47,43 @@ the inputs and outputs for modules of the Terraform infrastructure management tool. These can be shown, or written to a file in JSON or Markdown formats.") (home-page "https://github.com/segmentio/terraform-docs") (license license:expat))) + +(define-public terraform + (package + (name "terraform") + (version "0.11.3") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/hashicorp/terraform") + (commit (string-append "v" version)))) + (sha256 + (base32 + "0637x7jcm62pdnivmh4rggly6dmlvdh3jpsd1z4vba15gbm203nz")))) + (build-system go-build-system) + (arguments + '(#:import-path "github.com/hashicorp/terraform" + #:phases + (modify-phases %standard-phases + ;; I'm not sure what purpose they serve, but they are readonly, so + ;; they break the reset-gzip-timestamps phase. + (add-after 'install 'delete-test-fixtures + (lambda* (#:key outputs #:allow-other-keys) + ;; If delete-file-recursively fails, it won't throw an exception. + ;; However, if it doesn't do its job, the build will fail, so + ;; we'll know one way or another. + (delete-file-recursively + (string-append + (assoc-ref outputs "out") + "/src/github.com/hashicorp/terraform/config/module/test-fixtures")) + #t))))) + (synopsis "Tool for building and changing computing infrastructure") + (description + "Terraform uses descriptions of infrastructure written in @acronym{HCL, +Hashicorp Configuration Language} which describe graphs of resources, +including information about dependencies. From this, Terraform can plan and +apply changes to the described resources. + +Terraform uses plugins that provide intergrations to different providers.") + (home-page "https://www.terraform.io/") + (license license:mpl2.0))) -- 2.20.0