summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorSascha Grunert <sgrunert@suse.com>2020-03-20 10:55:23 +0100
committerSascha Grunert <sgrunert@suse.com>2020-05-11 13:11:07 +0200
commitc21258b70ed91ab5ff8b1d345123fed1011a49c9 (patch)
treed5f74fb3191ee33f8565f18971cf37426e57afa6 /Makefile
parent18b273b72ba76d485eb1b4d5df48bff1685953ff (diff)
downloadpodman-c21258b70ed91ab5ff8b1d345123fed1011a49c9.tar.gz
podman-c21258b70ed91ab5ff8b1d345123fed1011a49c9.tar.bz2
podman-c21258b70ed91ab5ff8b1d345123fed1011a49c9.zip
Add podman static build
We’re now able to build a static podman binary based on a custom nix derivation. This is integrated in cirrus as well, whereas a later target would be to provide a self-contained static binary bundle which can be installed on any Linux x64-bit system. Fixes: https://github.com/containers/libpod/issues/1399 Signed-off-by: Sascha Grunert <sgrunert@suse.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile26
1 files changed, 25 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index d1eb56aa8..e991d4b35 100644
--- a/Makefile
+++ b/Makefile
@@ -74,7 +74,7 @@ LDFLAGS_PODMAN ?= \
-X $(LIBPOD)/define.buildInfo=$(BUILD_INFO) \
-X $(LIBPOD)/config._installPrefix=$(PREFIX) \
-X $(LIBPOD)/config._etcDir=$(ETCDIR) \
- -extldflags "$(LDFLAGS)"
+ $(EXTRA_LDFLAGS)
#Update to LIBSECCOMP_COMMIT should reflect in Dockerfile too.
LIBSECCOMP_COMMIT := v2.3.3
# Rarely if ever should integration tests take more than 50min,
@@ -217,6 +217,30 @@ bin/podman.cross.%: .gopathok
GOARCH="$${TARGET##*.}" \
$(GO_BUILD) -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags '$(BUILDTAGS_CROSS)' -o "$@" $(PROJECT)/cmd/podman
+# Update nix/nixpkgs.json its latest master commit
+.PHONY: nixpkgs
+nixpkgs:
+ @nix run -f channel:nixpkgs-unstable nix-prefetch-git -c nix-prefetch-git \
+ --no-deepClone https://github.com/nixos/nixpkgs > nix/nixpkgs.json
+
+NIX_IMAGE ?= quay.io/podman/nix-podman:1.0.0
+
+# Build the nix image as base for static builds
+.PHONY: nix-image
+nix-image:
+ $(CONTAINER_RUNTIME) build -t $(NIX_IMAGE) -f Containerfile-nix .
+
+# Build podman statically linked based on the default nix container image
+.PHONY: build-static
+build-static:
+ $(CONTAINER_RUNTIME) run \
+ --rm -it \
+ -v $(shell pwd):/work \
+ -w /work $(NIX_IMAGE) \
+ sh -c "nix build -f nix && \
+ mkdir -p bin && \
+ cp result-*bin/bin/podman bin/podman-static"
+
.PHONY: run-docker-py-tests
run-docker-py-tests:
$(eval testLogs=$(shell mktemp))