Package Details: opentofu 1.7.0-1

Git Clone URL: https://aur.archlinux.org/opentofu.git (read-only, click to copy)
Package Base: opentofu
Description: Lets you declaratively manage your cloud infrastructure
Upstream URL: https://github.com/opentofu/opentofu
Licenses: MPL-2.0
Submitter: tucho
Maintainer: carsme
Last Packager: carsme
Votes: 21
Popularity: 3.16
First Submitted: 2023-09-20 19:02 (UTC)
Last Updated: 2024-05-01 14:58 (UTC)

Dependencies (2)

Required by (0)

Sources (2)

Latest Comments

« First ‹ Previous 1 2

sauyon commented on 2023-10-06 16:52 (UTC)

namcap runs with no errors.

kemelzaidan commented on 2023-10-06 01:00 (UTC)

Here is my PKGBUILD: https://pastebin.com/AtRCFk7N

It is building fine with no namcap errors. Have you used namcap after the package creation?

sauyon commented on 2023-10-04 22:09 (UTC)

Seems like most packages do add glibc as a dependency. Readded, updated version to 1.6.0-alpha1 and pinned commit to that ref.

diff --git a/PKGBUILD b/PKGBUILD
index b93c244..ad50f43 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,28 +1,34 @@
 # Maintainer: Marcel Campello <marcel@prafrentex.com.br>
 pkgname=opentofu
-pkgver=1.6.0_dev
+pkgver=1.6.0_alpha1
+_commit=98bd62453522350e31ee420ff50f76a2977f9647  #refs/tags/v1.6.0-alpha1
 pkgrel=1
 pkgdesc="The open source infrastructure as code tool."
-arch=('any')
+arch=('x86_64')
 url="https://opentofu.org"
 license=('MPL2')
+depends=('glibc')
 makedepends=(
   'git'
   'go>=1.20.7'
 )
-source=("${pkgname}.zip::https://github.com/opentofu/opentofu/archive/refs/heads/main.zip")
+source=("git+https://github.com/opentofu/opentofu#commit=$_commit")
 sha256sums=('SKIP')

 build() {
-  export GOPATH="${srcdir}/go"
-  export CGO_ENABLED=0
+  cd "${pkgname}"

-  cd "${srcdir}/${pkgname}-main"
-  pwd
-  go install
+  go env -w CGO_ENABLED=0
+  go build -buildmode=pie -trimpath -mod=readonly -ldflags "-linkmode=external -extldflags -Wl,-z,relro,-z,now -w -s -X 'github.com/opentofu/opentofu/version.dev=no'" -o bin/ ./cmd/tofu
+  go env -u CGO_ENABLED
+}
+
+check() {
+  cd "${pkgname}"
+  go test ./...
 }

 package() {
-  cd "${srcdir}/go"
-  install bin/opentofu -t "${pkgdir}/usr/bin" -Dm 0755
+  cd "${pkgname}"
+  install bin/tofu -t "${pkgdir}/usr/bin" -Dm 0755
 }

sauyon commented on 2023-10-04 21:47 (UTC)

@kemelzaidan is glibc required as a dependency? It's in base.

Also, patch didn't apply cleanly for me for some reason, so I've created another one.

diff --git a/PKGBUILD b/PKGBUILD
index b93c244..f3a9df8 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,9 +1,9 @@
 # Maintainer: Marcel Campello <marcel@prafrentex.com.br>
 pkgname=opentofu
 pkgver=1.6.0_dev
-pkgrel=1
+pkgrel=2
 pkgdesc="The open source infrastructure as code tool."
-arch=('any')
+arch=('x86_64')
 url="https://opentofu.org"
 license=('MPL2')
 makedepends=(
@@ -14,15 +14,14 @@ source=("${pkgname}.zip::https://github.com/opentofu/opentofu/archive/refs/heads
 sha256sums=('SKIP')

 build() {
-  export GOPATH="${srcdir}/go"
-  export CGO_ENABLED=0
-
   cd "${srcdir}/${pkgname}-main"
-  pwd
-  go install
+
+  go env -w CGO_ENABLED=0
+  go build -buildmode=pie -ldflags "-linkmode=external -extldflags -Wl,-z,relro,-z,now -w -s -X 'github.com/opentofu/opentofu/version.dev=no'" -o bin/ ./cmd/tofu
+  go env -u CGO_ENABLED
 }

 package() {
-  cd "${srcdir}/go"
-  install bin/opentofu -t "${pkgdir}/usr/bin" -Dm 0755
+  cd "${srcdir}/${pkgname}-main"
+  install bin/tofu -t "${pkgdir}/usr/bin" -Dm 0755
 }

kemelzaidan commented on 2023-10-04 15:56 (UTC)

I believe that was not working because you were setting GOPATH environment variable with export and I'm using fish shell where export doesn't work. I used go env instead.

Your PKGBUILD also had some error. You can't use arch=("any") for a golang app since the compiled binary is not architecture independent.

Build flags were included to satisfy namcap errors. Apply the following patch to your PKGBUILD to fix it:

diff --git a/PKGBUILD b/PKGBUILD
index b93c244..54e1ef8 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,28 +1,28 @@
 # Maintainer: Marcel Campello <marcel@prafrentex.com.br>
 pkgname=opentofu
 pkgver=1.6.0_dev
-pkgrel=1
+pkgrel=2
 pkgdesc="The open source infrastructure as code tool."
-arch=('any')
+arch=('x86_64')
 url="https://opentofu.org"
 license=('MPL2')
+depends=('glibc')
 makedepends=(
   'git'
   'go>=1.20.7'
+  'glibc'
 )
 source=("${pkgname}.zip::https://github.com/opentofu/opentofu/archive/refs/heads/main.zip")
 sha256sums=('SKIP')

 build() {
-  export GOPATH="${srcdir}/go"
-  export CGO_ENABLED=0
-
+  go env -w CGO_ENABLED=0
   cd "${srcdir}/${pkgname}-main"
-  pwd
-  go install
+  go build -buildmode=pie -ldflags "-linkmode=external -extldflags -Wl,-z,relro,-z,now -w -s -X 'github.com/opentofu/opentofu/version.dev=no'" -o bin/ ./cmd/tofu
+  go env -u CGO_ENABLED
 }

 package() {
-  cd "${srcdir}/go"
-  install bin/opentofu -t "${pkgdir}/usr/bin" -Dm 0755
+  cd "${srcdir}/${pkgname}-main/"
+  install bin/tofu -t "${pkgdir}/usr/bin" -Dm 0755
 }

kemelzaidan commented on 2023-10-04 12:07 (UTC)

Having the following error:

Starting build()...
/home/kemel/.cache/yay/opentofu/src/opentofu-main
package github.com/opentofu/opentofu: build constraints exclude all Go files in /home/kemel/.cache/yay/opentofu/src/opentofu-main
==> ERROR: A failure occurred in build().
    Aborting...