~alpine/aports

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] community/alertmanager: fix LDFLAGS issues

Details
Message ID
<20200109191055.15187-1-sir@cmpwn.com>
DKIM signature
missing
Download raw message
Patch: +14 -17
This should(?) fix the build on aarch64.
---
 community/alertmanager/APKBUILD | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/community/alertmanager/APKBUILD b/community/alertmanager/APKBUILD
index e61bbb2526..c585d43871 100644
--- a/community/alertmanager/APKBUILD
+++ b/community/alertmanager/APKBUILD
@@ -1,7 +1,7 @@
# Maintainer: Drew DeVault <sir@cmpwn.com>
pkgname=alertmanager
pkgver=0.20.0
pkgrel=0
pkgrel=1
pkgdesc="Prometheus Alertmanager"
url="https://github.com/prometheus/alertmanager"
arch="all"
@@ -18,22 +18,19 @@ builddir="$srcdir/$pkgname-$pkgver"
options="!check" # timing-sensitive upstream tests

build() {
	ldflags="-extldflags $LDFLAGS \
			-X github.com/prometheus/common/version.Version=$pkgver \
			-X github.com/prometheus/common/version.Revision=$pkgrel \
			-X github.com/prometheus/common/version.Branch=Alpine \
			-X github.com/prometheus/common/version.BuildUser=Alpine \
			-X github.com/prometheus/common/version.BuildDate=2020-01-08"
	go build \
		-trimpath \
		-mod=vendor \
		-ldflags "$ldflags" \
		./cmd/alertmanager
	go build \
		-trimpath \
		-mod=vendor \
		-ldflags "$ldflags" \
		./cmd/amtool
	for cmd in amtool alertmanager
	do
		go build \
			-trimpath \
			-mod=vendor \
			-ldflags "-extldflags $LDFLAGS \
				-X github.com/prometheus/common/version.Version=$pkgver \
				-X github.com/prometheus/common/version.Revision=$pkgrel \
				-X github.com/prometheus/common/version.Branch=Alpine \
				-X github.com/prometheus/common/version.BuildUser=Alpine \
				-X github.com/prometheus/common/version.BuildDate=2020-01-08" \
			./cmd/$cmd
	done
}

check() {
-- 
2.24.1
Konstantin Kulikov <k.kulikov2@gmail.com>
Details
Message ID
<d4003b89-b915-a0c9-a5b7-f9e7e74dfab9@gmail.com>
In-Reply-To
<20200109191055.15187-1-sir@cmpwn.com> (view parent)
DKIM signature
missing
Download raw message
On 1/9/20 10:10 PM, Drew DeVault wrote:
> This should(?) fix the build on aarch64.
> ---
>   community/alertmanager/APKBUILD | 31 ++++++++++++++-----------------
>   1 file changed, 14 insertions(+), 17 deletions(-)
> 
> diff --git a/community/alertmanager/APKBUILD b/community/alertmanager/APKBUILD
> index e61bbb2526..c585d43871 100644
> --- a/community/alertmanager/APKBUILD
> +++ b/community/alertmanager/APKBUILD
> @@ -1,7 +1,7 @@
>   # Maintainer: Drew DeVault <sir@cmpwn.com>
>   pkgname=alertmanager
>   pkgver=0.20.0
> -pkgrel=0
> +pkgrel=1
>   pkgdesc="Prometheus Alertmanager"
>   url="https://github.com/prometheus/alertmanager"
>   arch="all"
> @@ -18,22 +18,19 @@ builddir="$srcdir/$pkgname-$pkgver"
>   options="!check" # timing-sensitive upstream tests
>   
>   build() {
> -	ldflags="-extldflags $LDFLAGS \
> -			-X github.com/prometheus/common/version.Version=$pkgver \
> -			-X github.com/prometheus/common/version.Revision=$pkgrel \
> -			-X github.com/prometheus/common/version.Branch=Alpine \
> -			-X github.com/prometheus/common/version.BuildUser=Alpine \
> -			-X github.com/prometheus/common/version.BuildDate=2020-01-08"
> -	go build \
> -		-trimpath \
> -		-mod=vendor \
> -		-ldflags "$ldflags" \
> -		./cmd/alertmanager
> -	go build \
> -		-trimpath \
> -		-mod=vendor \
> -		-ldflags "$ldflags" \
> -		./cmd/amtool
> +	for cmd in amtool alertmanager
> +	do
> +		go build \
> +			-trimpath \
> +			-mod=vendor \
> +			-ldflags "-extldflags $LDFLAGS \

I think LDFLAGS on aarch64 contains spaces and -extldflags expects 
single argument. My suggestion to remove ldflags var was incorrect, as 
whole argument to -ldflags still needs to be quoted.

To properly quote this string it is best to replace -extldflags $LDFLAGS
with -extldflags $(printf %q "$LDFLAGS").

If you're adamant against using printf, \"$LDFLAGS\" should work as long 
as contents of $LDFLAGS doesn't contain double quotes.

> +				-X github.com/prometheus/common/version.Version=$pkgver \
> +				-X github.com/prometheus/common/version.Revision=$pkgrel \
> +				-X github.com/prometheus/common/version.Branch=Alpine \
> +				-X github.com/prometheus/common/version.BuildUser=Alpine \
> +				-X github.com/prometheus/common/version.BuildDate=2020-01-08" \
> +			./cmd/$cmd
> +	done
>   }
>   
>   check() {
> 
Reply to thread Export thread (mbox)