From dc05868d6c03ee3153300d689a2968d25460d531 Mon Sep 17 00:00:00 2001 From: yzewei Date: Fri, 15 Sep 2023 09:17:47 +0800 Subject: [PATCH] add loong64 support (cherry picked from commit 92878b3dadc0f5e2774c1964684a074ea4c838c2) --- 0016-port-to-loong64.patch | 331 +++++++++++++++++++++++++++++++++++++ kubernetes.spec | 22 ++- 2 files changed, 352 insertions(+), 1 deletion(-) create mode 100644 0016-port-to-loong64.patch diff --git a/0016-port-to-loong64.patch b/0016-port-to-loong64.patch new file mode 100644 index 0000000..27fca9a --- /dev/null +++ b/0016-port-to-loong64.patch @@ -0,0 +1,331 @@ +From 3fa8cfdb8d8f0de1dedf026f38dd82862010cb7e Mon Sep 17 00:00:00 2001 +From: yzewei +Date: Tue, 12 Sep 2023 15:39:33 +0800 +Subject: [PATCH] port to loong64 + +--- + build/build-image/cross/VERSION | 2 +- + build/common.sh | 8 +- + hack/lib/golang.sh | 4 + + hack/lib/util.sh | 5 +- + hack/local-up-cluster.sh | 5 +- + .../grpc-gateway/internal/BUILD.bazel | 23 +++++ + .../grpc-gateway/runtime/BUILD.bazel | 84 +++++++++++++++++++ + .../grpc-gateway/utilities/BUILD.bazel | 21 +++++ + .../remote/syscall_dup_linux_loong64.go | 11 +++ + .../internal/remote/syscall_dup_unix.go | 1 + + .../libcontainer/system/syscall_linux_64.go | 2 +- + vendor/go.etcd.io/bbolt/bolt_loong64.go | 9 ++ + 12 files changed, 167 insertions(+), 8 deletions(-) + create mode 100644 vendor/github.com/grpc-ecosystem/grpc-gateway/internal/BUILD.bazel + create mode 100644 vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/BUILD.bazel + create mode 100644 vendor/github.com/grpc-ecosystem/grpc-gateway/utilities/BUILD.bazel + create mode 100644 vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_linux_loong64.go + create mode 100644 vendor/go.etcd.io/bbolt/bolt_loong64.go + +diff --git a/build/build-image/cross/VERSION b/build/build-image/cross/VERSION +index 0952a065..a0f9a4b4 100644 +--- a/build/build-image/cross/VERSION ++++ b/build/build-image/cross/VERSION +@@ -1 +1 @@ +-v1.15.5-1 ++latest +diff --git a/build/common.sh b/build/common.sh +index a7a84b6e..2f92a11e 100755 +--- a/build/common.sh ++++ b/build/common.sh +@@ -42,8 +42,8 @@ source "${KUBE_ROOT}/hack/lib/init.sh" + readonly KUBE_BUILD_IMAGE_REPO=kube-build + readonly KUBE_BUILD_IMAGE_CROSS_TAG="$(cat "${KUBE_ROOT}/build/build-image/cross/VERSION")" + +-readonly KUBE_DOCKER_REGISTRY="${KUBE_DOCKER_REGISTRY:-k8s.gcr.io}" +-readonly KUBE_BASE_IMAGE_REGISTRY="${KUBE_BASE_IMAGE_REGISTRY:-k8s.gcr.io/build-image}" ++readonly KUBE_DOCKER_REGISTRY="${KUBE_DOCKER_REGISTRY:-cr.loongnix.cn/kubernetes}" ++readonly KUBE_BASE_IMAGE_REGISTRY="${KUBE_BASE_IMAGE_REGISTRY:-cr.loongnix.cn/k8s-build-image}" + + # This version number is used to cause everyone to rebuild their data containers + # and build image. This is especially useful for automated build systems like +@@ -93,8 +93,8 @@ readonly KUBE_CONTAINER_RSYNC_PORT=8730 + # + # $1 - server architecture + kube::build::get_docker_wrapped_binaries() { +- local debian_iptables_version=buster-v1.3.0 +- local go_runner_version=buster-v2.2.2 ++ local debian_iptables_version=latest ++ local go_runner_version=latest + ### If you change any of these lists, please also update DOCKERIZED_BINARIES + ### in build/BUILD. And kube::golang::server_image_targets + local targets=( +diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh +index 6d467a8e..ad2abcf8 100755 +--- a/hack/lib/golang.sh ++++ b/hack/lib/golang.sh +@@ -27,6 +27,7 @@ readonly KUBE_SUPPORTED_SERVER_PLATFORMS=( + linux/arm64 + linux/s390x + linux/ppc64le ++ linux/loong64 + ) + + # The node platforms we build for +@@ -36,6 +37,7 @@ readonly KUBE_SUPPORTED_NODE_PLATFORMS=( + linux/arm64 + linux/s390x + linux/ppc64le ++ linux/loong64 + windows/amd64 + ) + +@@ -48,6 +50,7 @@ readonly KUBE_SUPPORTED_CLIENT_PLATFORMS=( + linux/arm64 + linux/s390x + linux/ppc64le ++ linux/loong64 + darwin/amd64 + windows/amd64 + windows/386 +@@ -61,6 +64,7 @@ readonly KUBE_SUPPORTED_TEST_PLATFORMS=( + linux/arm64 + linux/s390x + linux/ppc64le ++ linux/loong64 + darwin/amd64 + windows/amd64 + ) +diff --git a/hack/lib/util.sh b/hack/lib/util.sh +index 4893e632..4af78044 100755 +--- a/hack/lib/util.sh ++++ b/hack/lib/util.sh +@@ -185,8 +185,11 @@ kube::util::host_arch() { + ppc64le*) + host_arch=ppc64le + ;; ++ loongarch64*) ++ host_arch=loong64 ++ ;; + *) +- kube::log::error "Unsupported host arch. Must be x86_64, 386, arm, arm64, s390x or ppc64le." ++ kube::log::error "Unsupported host arch. Must be x86_64, 386, arm, arm64, s390x, loong64 or ppc64le." + exit 1 + ;; + esac +diff --git a/hack/local-up-cluster.sh b/hack/local-up-cluster.sh +index f1296aa2..3e57d189 100755 +--- a/hack/local-up-cluster.sh ++++ b/hack/local-up-cluster.sh +@@ -327,8 +327,11 @@ function detect_binary { + ppc64le*) + host_arch=ppc64le + ;; ++ loongarch64*) ++ host_arch=loong64 ++ ;; + *) +- echo "Unsupported host arch. Must be x86_64, 386, arm, arm64, s390x or ppc64le." >&2 ++ echo "Unsupported host arch. Must be x86_64, 386, arm, arm64, s390x, loong64 or ppc64le." >&2 + exit 1 + ;; + esac +diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/internal/BUILD.bazel b/vendor/github.com/grpc-ecosystem/grpc-gateway/internal/BUILD.bazel +new file mode 100644 +index 00000000..7513d232 +--- /dev/null ++++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/internal/BUILD.bazel +@@ -0,0 +1,23 @@ ++load("@io_bazel_rules_go//go:def.bzl", "go_library") ++load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") ++ ++package(default_visibility = ["//visibility:public"]) ++ ++proto_library( ++ name = "internal_proto", ++ srcs = ["stream_chunk.proto"], ++ deps = ["@com_google_protobuf//:any_proto"], ++) ++ ++go_proto_library( ++ name = "internal_go_proto", ++ importpath = "github.com/grpc-ecosystem/grpc-gateway/internal", ++ proto = ":internal_proto", ++) ++ ++go_library( ++ name = "go_default_library", ++ embed = [":internal_go_proto"], ++ importpath = "github.com/grpc-ecosystem/grpc-gateway/internal", ++) ++ +diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/BUILD.bazel b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/BUILD.bazel +new file mode 100644 +index 00000000..9e451a38 +--- /dev/null ++++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/BUILD.bazel +@@ -0,0 +1,84 @@ ++oad("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++ ++package(default_visibility = ["//visibility:public"]) ++ ++go_library( ++ name = "go_default_library", ++ srcs = [ ++ "context.go", ++ "convert.go", ++ "doc.go", ++ "errors.go", ++ "fieldmask.go", ++ "handler.go", ++ "marshal_httpbodyproto.go", ++ "marshal_json.go", ++ "marshal_jsonpb.go", ++ "marshal_proto.go", ++ "marshaler.go", ++ "marshaler_registry.go", ++ "mux.go", ++ "pattern.go", ++ "proto2_convert.go", ++ "proto_errors.go", ++ "query.go", ++ ], ++ importpath = "github.com/grpc-ecosystem/grpc-gateway/runtime", ++ deps = [ ++ "//internal:go_default_library", ++ "//utilities:go_default_library", ++ "@com_github_golang_protobuf//jsonpb:go_default_library_gen", ++ "@com_github_golang_protobuf//proto:go_default_library", ++ "@com_github_golang_protobuf//protoc-gen-go/generator:go_default_library_gen", ++ "@go_googleapis//google/api:httpbody_go_proto", ++ "@io_bazel_rules_go//proto/wkt:any_go_proto", ++ "@io_bazel_rules_go//proto/wkt:duration_go_proto", ++ "@io_bazel_rules_go//proto/wkt:field_mask_go_proto", ++ "@io_bazel_rules_go//proto/wkt:timestamp_go_proto", ++ "@io_bazel_rules_go//proto/wkt:wrappers_go_proto", ++ "@org_golang_google_grpc//codes:go_default_library", ++ "@org_golang_google_grpc//grpclog:go_default_library", ++ "@org_golang_google_grpc//metadata:go_default_library", ++ "@org_golang_google_grpc//status:go_default_library", ++ ], ++) ++ ++go_test( ++ name = "go_default_test", ++ size = "small", ++ srcs = [ ++ "context_test.go", ++ "errors_test.go", ++ "fieldmask_test.go", ++ "handler_test.go", ++ "marshal_httpbodyproto_test.go", ++ "marshal_json_test.go", ++ "marshal_jsonpb_test.go", ++ "marshal_proto_test.go", ++ "marshaler_registry_test.go", ++ "mux_test.go", ++ "pattern_test.go", ++ "query_test.go", ++ ], ++ embed = [":go_default_library"], ++ deps = [ ++ "//examples/proto/examplepb:go_default_library", ++ "//internal:go_default_library", ++ "//utilities:go_default_library", ++ "@com_github_golang_protobuf//jsonpb:go_default_library_gen", ++ "@com_github_golang_protobuf//proto:go_default_library", ++ "@com_github_golang_protobuf//ptypes:go_default_library_gen", ++ "@go_googleapis//google/api:httpbody_go_proto", ++ "@go_googleapis//google/rpc:errdetails_go_proto", ++ "@io_bazel_rules_go//proto/wkt:duration_go_proto", ++ "@io_bazel_rules_go//proto/wkt:empty_go_proto", ++ "@io_bazel_rules_go//proto/wkt:field_mask_go_proto", ++ "@io_bazel_rules_go//proto/wkt:struct_go_proto", ++ "@io_bazel_rules_go//proto/wkt:timestamp_go_proto", ++ "@io_bazel_rules_go//proto/wkt:wrappers_go_proto", ++ "@org_golang_google_grpc//:go_default_library", ++ "@org_golang_google_grpc//codes:go_default_library", ++ "@org_golang_google_grpc//metadata:go_default_library", ++ "@org_golang_google_grpc//status:go_default_library", ++ ], ++) +diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/utilities/BUILD.bazel b/vendor/github.com/grpc-ecosystem/grpc-gateway/utilities/BUILD.bazel +new file mode 100644 +index 00000000..7109d793 +--- /dev/null ++++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/utilities/BUILD.bazel +@@ -0,0 +1,21 @@ ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++ ++package(default_visibility = ["//visibility:public"]) ++ ++go_library( ++ name = "go_default_library", ++ srcs = [ ++ "doc.go", ++ "pattern.go", ++ "readerfactory.go", ++ "trie.go", ++ ], ++ importpath = "github.com/grpc-ecosystem/grpc-gateway/utilities", ++) ++ ++go_test( ++ name = "go_default_test", ++ size = "small", ++ srcs = ["trie_test.go"], ++ embed = [":go_default_library"], ++) +diff --git a/vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_linux_loong64.go b/vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_linux_loong64.go +new file mode 100644 +index 00000000..05e43955 +--- /dev/null ++++ b/vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_linux_loong64.go +@@ -0,0 +1,11 @@ ++// +build linux,loong64 ++ ++package remote ++ ++import "syscall" ++ ++// linux_loong64 doesn't have syscall.Dup2 which ginkgo uses, so ++// use the nearly identical syscall.Dup3 instead ++func syscallDup(oldfd int, newfd int) (err error) { ++ return syscall.Dup3(oldfd, newfd, 0) ++} +diff --git a/vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_unix.go b/vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_unix.go +index 981aa746..35817ce8 100644 +--- a/vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_unix.go ++++ b/vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_unix.go +@@ -1,5 +1,6 @@ + // +build !linux !arm64 + // +build !linux !riscv64 ++// +build !linux !loong64 + // +build !windows + // +build !solaris + +diff --git a/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_64.go b/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_64.go +index e05e30ad..14d33f10 100644 +--- a/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_64.go ++++ b/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_64.go +@@ -1,5 +1,5 @@ + // +build linux +-// +build arm64 amd64 mips mipsle mips64 mips64le ppc ppc64 ppc64le riscv64 s390x ++// +build arm64 amd64 mips mipsle mips64 mips64le ppc ppc64 ppc64le riscv64 s390x loong64 + + package system + +diff --git a/vendor/go.etcd.io/bbolt/bolt_loong64.go b/vendor/go.etcd.io/bbolt/bolt_loong64.go +new file mode 100644 +index 00000000..c5bb7cb8 +--- /dev/null ++++ b/vendor/go.etcd.io/bbolt/bolt_loong64.go +@@ -0,0 +1,9 @@ ++// +build loong64 ++ ++package bbolt ++ ++// maxMapSize represents the largest mmap size supported by Bolt. ++const maxMapSize = 0xFFFFFFFFFFFF // 256TB ++ ++// maxAllocSize is the size used when creating array pointers. ++const maxAllocSize = 0x7FFFFFFF +-- +2.33.0 + diff --git a/kubernetes.spec b/kubernetes.spec index 1411703..b815ca4 100644 --- a/kubernetes.spec +++ b/kubernetes.spec @@ -3,7 +3,7 @@ Name: kubernetes Version: 1.20.2 -Release: 20 +Release: 21 Summary: Container cluster management License: ASL 2.0 URL: https://k8s.io/kubernetes @@ -39,6 +39,9 @@ Patch6011: 0012-Return-error-for-localhost-seccomp-type-with-no-loca.patch Patch6012: 0013-Validate-etcd-paths.patch Patch6013: 0014-fix-node-address-validation.patch Patch6014: 0015-Add-ephemeralcontainer-to-imagepolicy-securityaccoun.patch +%ifarch loongarch64 +Patch6015: 0016-port-to-loong64.patch +%endif %description Container cluster management. @@ -100,6 +103,18 @@ Help documents for kubernetes. %prep %autosetup -n kubernetes-1.20.2 -p1 +%ifarch loongarch64 +curl -OL https://github.com/golang/sys/archive/refs/tags/v0.5.0.zip +rm -rf vendor/golang.org/x/sys +unzip v0.5.0.zip -d vendor/golang.org/x +mv vendor/golang.org/x/sys-0.5.0 vendor/golang.org/x/sys +rm v0.5.0.zip +curl -OL https://github.com/golang/net/archive/refs/tags/v0.5.0.zip +rm -rf vendor/golang.org/x/net +unzip v0.5.0.zip -d vendor/golang.org/x +mv vendor/golang.org/x/net-0.5.0 vendor/golang.org/x/net +rm v0.5.0.zip +%endif mkdir -p src/k8s.io/kubernetes mv $(ls | grep -v "^src$") src/k8s.io/kubernetes/. @@ -270,6 +285,11 @@ getent passwd kube >/dev/null || useradd -r -g kube -d / -s /sbin/nologin \ %systemd_postun kubelet kube-proxy %changelog +* Tue Sep 12 2023 ZeweiY - 1.20.2-21 +- CVE:NA +- SUG:NA +- DESC:add loong64 support + * Tue Jul 04 2023 zhangxiaoyu - 1.20.2-20 - Type:bugfix - CVE:NA -- Gitee