k3s: fix build for aarch64
The upstream project already builds and releases for aarch64. This makes the couple small tweaks that I found necessary for k3s to cross-compile for aarch64. I also ran it through nixpkgs-fmt.
This commit is contained in:
parent
10134fc301
commit
e61dc85117
@ -1,6 +1,22 @@
|
|||||||
{ stdenv, lib, makeWrapper, socat, iptables, iproute, bridge-utils
|
{ stdenv
|
||||||
, conntrack-tools, buildGoPackage, git, runc, libseccomp, pkgconfig
|
, lib
|
||||||
, ethtool, utillinux, ipset, fetchFromGitHub, fetchurl, fetchzip
|
, makeWrapper
|
||||||
|
, socat
|
||||||
|
, iptables
|
||||||
|
, iproute
|
||||||
|
, bridge-utils
|
||||||
|
, conntrack-tools
|
||||||
|
, buildGoPackage
|
||||||
|
, git
|
||||||
|
, runc
|
||||||
|
, libseccomp
|
||||||
|
, pkgconfig
|
||||||
|
, ethtool
|
||||||
|
, utillinux
|
||||||
|
, ipset
|
||||||
|
, fetchFromGitHub
|
||||||
|
, fetchurl
|
||||||
|
, fetchzip
|
||||||
, fetchgit
|
, fetchgit
|
||||||
}:
|
}:
|
||||||
|
|
||||||
@ -153,6 +169,12 @@ let
|
|||||||
nativeBuildInputs = [ git pkgconfig ];
|
nativeBuildInputs = [ git pkgconfig ];
|
||||||
buildInputs = [ k3sBuildStage1 k3sPlugins runc ];
|
buildInputs = [ k3sBuildStage1 k3sPlugins runc ];
|
||||||
|
|
||||||
|
# k3s appends a suffix to the final distribution binary for some arches
|
||||||
|
archSuffix =
|
||||||
|
if stdenv.hostPlatform.system == "x86_64-linux" then ""
|
||||||
|
else if stdenv.hostPlatform.system == "aarch64-linux" then "-arm64"
|
||||||
|
else throw "k3s isn't being built for ${stdenv.hostPlatform.system} yet.";
|
||||||
|
|
||||||
# In order to build the thick k3s binary (which is what
|
# In order to build the thick k3s binary (which is what
|
||||||
# ./scripts/package-cli does), we need to get all the binaries that script
|
# ./scripts/package-cli does), we need to get all the binaries that script
|
||||||
# expects in place.
|
# expects in place.
|
||||||
@ -182,7 +204,7 @@ let
|
|||||||
pushd go/src/${goPackagePath}
|
pushd go/src/${goPackagePath}
|
||||||
|
|
||||||
mkdir -p "$out/bin"
|
mkdir -p "$out/bin"
|
||||||
install -m 0755 -t "$out/bin" ./dist/artifacts/k3s
|
install -m 0755 -T ./dist/artifacts/k3s${archSuffix} "$out/bin/k3s"
|
||||||
|
|
||||||
popd
|
popd
|
||||||
'';
|
'';
|
||||||
@ -203,11 +225,19 @@ stdenv.mkDerivation rec {
|
|||||||
# https://github.com/kubernetes/kubernetes/issues/26093#issuecomment-237202494
|
# https://github.com/kubernetes/kubernetes/issues/26093#issuecomment-237202494
|
||||||
# Note the list in that issue is stale and some aren't relevant for k3s.
|
# Note the list in that issue is stale and some aren't relevant for k3s.
|
||||||
k3sRuntimeDeps = [
|
k3sRuntimeDeps = [
|
||||||
socat iptables iproute bridge-utils ethtool utillinux ipset conntrack-tools
|
socat
|
||||||
|
iptables
|
||||||
|
iproute
|
||||||
|
bridge-utils
|
||||||
|
ethtool
|
||||||
|
utillinux
|
||||||
|
ipset
|
||||||
|
conntrack-tools
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
k3sBuild makeWrapper
|
k3sBuild
|
||||||
|
makeWrapper
|
||||||
] ++ k3sRuntimeDeps;
|
] ++ k3sRuntimeDeps;
|
||||||
|
|
||||||
unpackPhase = "true";
|
unpackPhase = "true";
|
||||||
|
@ -55,10 +55,17 @@ index 72d3c07ece..3e5455b262 100755
|
|||||||
echo Building containerd-shim
|
echo Building containerd-shim
|
||||||
make -C ./vendor/github.com/containerd/containerd bin/containerd-shim
|
make -C ./vendor/github.com/containerd/containerd bin/containerd-shim
|
||||||
diff --git a/scripts/package-cli b/scripts/package-cli
|
diff --git a/scripts/package-cli b/scripts/package-cli
|
||||||
index 4c66ce32df..6d1e0c03cb 100755
|
index 4c66ce32df..280b428bb8 100755
|
||||||
--- a/scripts/package-cli
|
--- a/scripts/package-cli
|
||||||
+++ b/scripts/package-cli
|
+++ b/scripts/package-cli
|
||||||
@@ -55,10 +55,10 @@ LDFLAGS="
|
@@ -49,16 +49,16 @@ fi
|
||||||
|
|
||||||
|
CMD_NAME=dist/artifacts/k3s${BIN_SUFFIX}
|
||||||
|
|
||||||
|
-go generate
|
||||||
|
+CGO_ENABLED=0 env -u GOARCH go generate
|
||||||
|
LDFLAGS="
|
||||||
|
-X github.com/rancher/k3s/pkg/version.Version=$VERSION
|
||||||
-X github.com/rancher/k3s/pkg/version.GitCommit=${COMMIT:0:8}
|
-X github.com/rancher/k3s/pkg/version.GitCommit=${COMMIT:0:8}
|
||||||
-w -s
|
-w -s
|
||||||
"
|
"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user