forked from mirrors/nixpkgs
82 lines
3 KiB
Diff
82 lines
3 KiB
Diff
-Subject: [PATCH 2/2] Add nixpkgs patches
|
|
-Original patch by: Euan Kemp <euank@euank.com>
|
|
-Adapted by: superherointj
|
|
-
|
|
-This patch allows us to re-use upstream build scripts when building for nix.
|
|
----
|
|
- 2 files changed:
|
|
- scripts/build
|
|
- scripts/package-cli
|
|
-
|
|
diff --git a/scripts/build b/scripts/build
|
|
index 2f3d1dc496..4f4e5aa897 100755
|
|
--- a/scripts/build
|
|
+++ b/scripts/build
|
|
@@ -12,7 +12,8 @@ PKG_CONTAINERD="github.com/containerd/containerd"
|
|
PKG_K3S_CONTAINERD="github.com/k3s-io/containerd"
|
|
PKG_CRICTL="github.com/kubernetes-sigs/cri-tools"
|
|
|
|
-buildDate=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
|
|
+# nixpkgs: deterministic build date
|
|
+buildDate="$(date -d "$(git log -1 --format=%ai)" -u "+%Y-%m-%dT%H:%M:%SZ")"
|
|
|
|
VENDOR_PREFIX="${PKG}/vendor/"
|
|
VERSIONFLAGS="
|
|
@@ -89,17 +90,7 @@ cleanup() {
|
|
}
|
|
|
|
INSTALLBIN=$(pwd)/bin
|
|
-if [ ! -x ${INSTALLBIN}/cni ]; then
|
|
-(
|
|
- echo Building cni
|
|
- TMPDIR=$(mktemp -d)
|
|
- trap cleanup EXIT
|
|
- WORKDIR=$TMPDIR/src/github.com/containernetworking/plugins
|
|
- git clone -b $VERSION_CNIPLUGINS https://github.com/rancher/plugins.git $WORKDIR
|
|
- cd $WORKDIR
|
|
- GOPATH=$TMPDIR CGO_ENABLED=0 "${GO}" build -tags "$TAGS" -ldflags "$LDFLAGS $STATIC" -o $INSTALLBIN/cni
|
|
-)
|
|
-fi
|
|
+# nixpkgs: skip building cni, we build it separately
|
|
# echo Building agent
|
|
# CGO_ENABLED=1 "${GO}" build -tags "$TAGS" -ldflags "$VERSIONFLAGS $LDFLAGS $STATIC" -o bin/k3s-agent ./cmd/agent/main.go
|
|
echo Building server
|
|
@@ -116,10 +107,7 @@ ln -s containerd ./bin/ctr
|
|
#CGO_ENABLED=1 "${GO}" build -tags "$TAGS" -ldflags "$VERSIONFLAGS $LDFLAGS $STATIC_SQLITE" -o bin/ctr ./cmd/ctr/main.go
|
|
# echo Building containerd
|
|
# CGO_ENABLED=0 "${GO}" build -tags "$TAGS" -ldflags "$VERSIONFLAGS $LDFLAGS $STATIC" -o bin/containerd ./cmd/containerd/
|
|
-echo Building runc
|
|
-rm -f ./build/src/github.com/opencontainers/runc/runc
|
|
-make GOPATH=$(pwd)/build EXTRA_LDFLAGS="-w -s" BUILDTAGS="$RUNC_TAGS" -C ./build/src/github.com/opencontainers/runc $RUNC_STATIC
|
|
-cp -f ./build/src/github.com/opencontainers/runc/runc ./bin/runc
|
|
+# nixpkgs: we build runc separately
|
|
|
|
echo Building containerd-shim
|
|
rm -f ./vendor/github.com/containerd/containerd/bin/containerd-shim
|
|
diff --git a/scripts/package-cli b/scripts/package-cli
|
|
index ab4a6dac63..044b5587d0 100755
|
|
--- a/scripts/package-cli
|
|
+++ b/scripts/package-cli
|
|
@@ -50,15 +50,17 @@ 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}
|
|
-w -s
|
|
"
|
|
-STATIC="-extldflags '-static'"
|
|
-CGO_ENABLED=0 "${GO}" build -ldflags "$LDFLAGS $STATIC" -o ${CMD_NAME} ./cmd/k3s/main.go
|
|
+# STATIC="-extldflags '-static'"
|
|
+# nixpkgs: we can depend on dynamic linking because we have a good package manager
|
|
+"${GO}" build -ldflags "$LDFLAGS" -o ${CMD_NAME} ./cmd/k3s/main.go
|
|
|
|
stat ${CMD_NAME}
|
|
|
|
-./scripts/build-upload ${CMD_NAME} ${COMMIT}
|
|
+# nixpkgs: skip uploading
|
|
+# ./scripts/build-upload ${CMD_NAME} ${COMMIT}
|