summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaciek Borzecki2018-04-18 10:14:09 +0200
committerMaciek Borzecki2018-04-18 10:16:20 +0200
commit5b0a5c57f66df6cd9f5e3eddbbbe6a63825965e8 (patch)
tree803850e5fdd13b5ff17051160726cb9f5d3924f4
parentbfedfe231208a3daadb127320fbcc2ab6495757c (diff)
downloadaur-5b0a5c57f66df6cd9f5e3eddbbbe6a63825965e8.tar.gz
snapd: switch to building with go instead of go-pie
Building statically linked PIE binaries appears to be broken in both Go upstream and Arch packages. The toolchain ignores CGO_ENABLED=0, does not fail when building and produces dynamically linked binaries. The output looks like this: $ CGO_ENABLED=0 go build -o snap-exec github.com/snapcore/snapd/cmd/snap-exec # github.com/snapcore/snapd/cmd/snap-exec loadinternal: cannot find runtime/cgo Since snap-exec *must* be built statically, switch to building with regular Go toolchain. Tweak static build command, instead of disabling cgo, leave it enabled and pass -static to ld. Signed-off-by: Maciek Borzecki <maciek.borzecki@gmail.com>
-rw-r--r--.SRCINFO2
-rw-r--r--PKGBUILD9
2 files changed, 6 insertions, 5 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 84fdf3b4e9c4..44d91daea8ba 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -7,7 +7,7 @@ pkgbase = snapd-git
arch = x86_64
license = GPL3
makedepends = git
- makedepends = go-pie
+ makedepends = go
makedepends = go-tools
makedepends = libseccomp
makedepends = libcap
diff --git a/PKGBUILD b/PKGBUILD
index bf306d70af53..871424f9feb4 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -12,7 +12,7 @@ pkgrel=1
arch=('x86_64')
url="https://github.com/snapcore/snapd"
license=('GPL3')
-makedepends=('git' 'go-pie' 'go-tools' 'libseccomp' 'libcap' 'systemd' 'xfsprogs' 'python-docutils')
+makedepends=('git' 'go' 'go-tools' 'libseccomp' 'libcap' 'systemd' 'xfsprogs' 'python-docutils')
# the following checkdepends are only required for static checks and unit tests,
# both are currently disabled
# checkdepends=('python' 'squashfs-tools' 'indent' 'shellcheck')
@@ -63,15 +63,16 @@ build() {
cd "$GOPATH/src/${_gourl}"
XDG_CONFIG_HOME="$srcdir" ./get-deps.sh
- gobuild="go build -x -v"
+ gobuild="go build -x -v -buildmode=pie"
+ gobuild_static="go build -x -v -buildmode=pie -ldflags=-extldflags=-static"
# Build/install snap and snapd
$gobuild -o $GOPATH/bin/snap "${_gourl}/cmd/snap"
$gobuild -o $GOPATH/bin/snapctl "${_gourl}/cmd/snapctl"
$gobuild -o $GOPATH/bin/snapd "${_gourl}/cmd/snapd"
$gobuild -o $GOPATH/bin/snap-seccomp "${_gourl}/cmd/snap-seccomp"
# build snap-exec and snap-update-ns completely static for base snaps
- $gobuild -o $GOPATH/bin/snap-update-ns -ldflags '-extldflags "-static"' "${_gourl}/cmd/snap-update-ns"
- CGO_ENABLED=0 $gobuild -o $GOPATH/bin/snap-exec "${_gourl}/cmd/snap-exec"
+ $gobuild_static -o $GOPATH/bin/snap-update-ns "${_gourl}/cmd/snap-update-ns"
+ $gobuild_static -o $GOPATH/bin/snap-exec "${_gourl}/cmd/snap-exec"
# Generate data files such as real systemd units, dbus service, environment
# setup helpers out of the available templates