You are not logged in.

#1 2025-09-09 16:14:58

cbc02009
Member
Registered: 2021-06-06
Posts: 8

smartctl_exporter AUR package does not set GOPATH variable correctly

The smartctl_exporter package sets a custom GOPATH location in the prepare() section of the PKGBUILD here on line 23 but then does not set the variable again in the build section. This causes the system to use the default GOPATH location, which does not match the one created in the prepare section.

Because of this the build fails:

 paru -S smartctl_exporter
:: Resolving dependencies...
:: Calculating conflicts...
:: Calculating inner conflicts...

Aur (1)                Old Version  New Version    Make Only
aur/smartctl_exporter               0.14.0-1       No

:: Proceed to review? [Y/n]:

:: Downloading PKGBUILDs...
 PKGBUILDs up to date
 nothing new to review
fetching devel info...
==> Making package: smartctl_exporter 0.14.0-1 (Tue 09 Sep 2025 12:09:27 PM EDT)
==> Retrieving sources...
  -> Found v0.14.0.tar.gz
  -> Found smartctl_exporter
  -> Found smartctl_exporter.service
==> Validating source files with sha256sums...
    v0.14.0.tar.gz ... Passed
    smartctl_exporter ... Passed
    smartctl_exporter.service ... Passed
==> Making package: smartctl_exporter 0.14.0-1 (Tue 09 Sep 2025 12:09:28 PM EDT)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Found v0.14.0.tar.gz
  -> Found smartctl_exporter
  -> Found smartctl_exporter.service
==> Validating source files with sha256sums...
    v0.14.0.tar.gz ... Passed
    smartctl_exporter ... Passed
    smartctl_exporter.service ... Passed
==> Removing existing $srcdir/ directory...
==> Extracting sources...
  -> Extracting v0.14.0.tar.gz with bsdtar
==> Starting prepare()...
==> Sources are ready.
smartctl_exporter-0.14.0-1: parsing pkg list...
==> Making package: smartctl_exporter 0.14.0-1 (Tue 09 Sep 2025 12:09:30 PM EDT)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> WARNING: Using existing $srcdir/ tree
==> Removing existing $pkgdir/ directory...
==> Starting build()...
/home/username/.cache/paru/clone/smartctl_exporter/PKGBUILD: line 34: cd: /home/username/.go/src/github.com/prometheus-community/smartctl_exporter: No such file or directory
==> ERROR: A failure occurred in build().
    Aborting...
error: failed to build 'smartctl_exporter-0.14.0-1':
error: packages failed to build: smartctl_exporter-0.14.0-1

copying the same line to the build section causes the package to build and install correctly using makepkg -si. I'd be happy to fix the package (if this isn't a PEBCAK issue) but I have no idea how to even begin doing that.

Offline

#2 2025-09-09 17:50:53

loqs
Member
Registered: 2014-03-06
Posts: 18,645

Re: smartctl_exporter AUR package does not set GOPATH variable correctly

The current PKGBUILD works for me in a clean chroot. What if you try `makepkg` directly or `pkgctl build` from devtools? You could also try a PKGBUILD that is closer to the Go package guidelines.

# Maintainer: Shalygin Konstantin <k0ste@k0ste.ru>
# Contributor: Shalygin Konstantin <k0ste@k0ste.ru>

pkgname='smartctl_exporter'
pkgver='0.14.0'
pkgrel='1'
pkgdesc='Prometheus exporter for S.M.A.R.T. metrics using smartctl'
arch=('x86_64' 'aarch64')
_uri="github.com/prometheus-community"
url="https://${_uri}/${pkgname}"
license=('GNU')
makedepends=('go')
depends=('smartmontools')
source=("${url}/archive/refs/tags/v${pkgver}.tar.gz"
	"${pkgname}"
	"${pkgname}.service")
sha256sums=('0c3a658b1a16117e31e808f6f8852ddc7df5be6edea1b17c08263069b72d88d8'
            '5645b05537feb19bd57218ed358403ee7e1bc7520a015a2a885730cff35b7367'
            '089ce0787b99c05d59b3f00447b50543851bd190f02679dd41a5ea094caea1cf')
backup=("etc/conf.d/${pkgname}")

prepare() {
  cd "${pkgname}-${pkgver}"
  GOPATH="${srcdir}"
  go mod download -modcacherw
}

build() {
  cd "${pkgname}-${pkgver}"
  go build \
    -trimpath \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-linkmode external -extldflags \"${LDFLAGS}\" \
    -X github.com/prometheus/common/version.Version=${pkgver} \
    -X github.com/prometheus/common/version.Branch=tarball \
    -X github.com/prometheus/common/version.BuildUser=archlinux@$pkgname \
    -X github.com/prometheus/common/version.BuildDate=$(date -u '+%Y%m%d-%H:%M:%S' --date=@${SOURCE_DATE_EPOCH})"
}

package() {
  install -Dm0755 "${pkgname}-${pkgver}/${pkgname}" -t "${pkgdir}/usr/bin"
  install -Dm0644 "${pkgname}" -t "${pkgdir}/etc/conf.d"
  install -Dm0644 "${pkgname}.service" -t "${pkgdir}/usr/lib/systemd/system"
}

Offline

Board footer

Powered by FluxBB