Add loong64 support
This commit is contained in:
parent
17a37c4a03
commit
2c6d7bf37c
200
Add-loong64-support-for-runc-procfs-and-crc32.patch
Normal file
200
Add-loong64-support-for-runc-procfs-and-crc32.patch
Normal file
@ -0,0 +1,200 @@
|
||||
From 1740c129b687031aac3f9383ca242d82877a3a4a Mon Sep 17 00:00:00 2001
|
||||
From: Jingyun Hua <huajingyun@loongson.cn>
|
||||
Date: Tue, 6 Jun 2023 12:58:28 +0000
|
||||
Subject: [PATCH] Add loong64 support for runc,procfs and crc32
|
||||
|
||||
Signed-off-by: Jingyun Hua <huajingyun@loongson.cn>
|
||||
---
|
||||
.../klauspost/crc32/crc32_generic.go | 2 +-
|
||||
.../libcontainer/system/syscall_linux_64.go | 2 +-
|
||||
.../github.com/prometheus/procfs/cpuinfo.go | 36 +++++++++++++++++++
|
||||
.../prometheus/procfs/cpuinfo_loong64.go | 19 ++++++++++
|
||||
.../libcontainer/system/syscall_linux_64.go | 2 +-
|
||||
.../github.com/prometheus/procfs/cpuinfo.go | 36 +++++++++++++++++++
|
||||
.../prometheus/procfs/cpuinfo_loong64.go | 19 ++++++++++
|
||||
7 files changed, 113 insertions(+), 3 deletions(-)
|
||||
create mode 100644 cmd/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go
|
||||
create mode 100644 vendor/github.com/prometheus/procfs/cpuinfo_loong64.go
|
||||
|
||||
diff --git a/cmd/vendor/github.com/klauspost/crc32/crc32_generic.go b/cmd/vendor/github.com/klauspost/crc32/crc32_generic.go
|
||||
index d6f8f85..c4d06a2 100644
|
||||
--- a/cmd/vendor/github.com/klauspost/crc32/crc32_generic.go
|
||||
+++ b/cmd/vendor/github.com/klauspost/crc32/crc32_generic.go
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
-// +build 386 arm arm64 ppc64 ppc64le appengine
|
||||
+// +build 386 arm arm64 ppc64 ppc64le appengine loong64
|
||||
|
||||
package crc32
|
||||
|
||||
diff --git a/cmd/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_64.go b/cmd/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_64.go
|
||||
index e05e30a..14d33f1 100644
|
||||
--- a/cmd/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_64.go
|
||||
+++ b/cmd/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/cmd/vendor/github.com/prometheus/procfs/cpuinfo.go b/cmd/vendor/github.com/prometheus/procfs/cpuinfo.go
|
||||
index 31d42f7..2c2a27f 100644
|
||||
--- a/cmd/vendor/github.com/prometheus/procfs/cpuinfo.go
|
||||
+++ b/cmd/vendor/github.com/prometheus/procfs/cpuinfo.go
|
||||
@@ -362,6 +362,42 @@ func parseCPUInfoMips(info []byte) ([]CPUInfo, error) {
|
||||
return cpuinfo, nil
|
||||
}
|
||||
|
||||
+func parseCPUInfoLoong(info []byte) ([]CPUInfo, error) {
|
||||
+ scanner := bufio.NewScanner(bytes.NewReader(info))
|
||||
+ // find the first "processor" line
|
||||
+ firstLine := firstNonEmptyLine(scanner)
|
||||
+ if !strings.HasPrefix(firstLine, "system type") || !strings.Contains(firstLine, ":") {
|
||||
+ return nil, errors.New("invalid cpuinfo file: " + firstLine)
|
||||
+ }
|
||||
+ field := strings.SplitN(firstLine, ": ", 2)
|
||||
+ cpuinfo := []CPUInfo{}
|
||||
+ systemType := field[1]
|
||||
+ i := 0
|
||||
+ for scanner.Scan() {
|
||||
+ line := scanner.Text()
|
||||
+ if !strings.Contains(line, ":") {
|
||||
+ continue
|
||||
+ }
|
||||
+ field := strings.SplitN(line, ": ", 2)
|
||||
+ switch strings.TrimSpace(field[0]) {
|
||||
+ case "processor":
|
||||
+ v, err := strconv.ParseUint(field[1], 0, 32)
|
||||
+ if err != nil {
|
||||
+ return nil, err
|
||||
+ }
|
||||
+ i = int(v)
|
||||
+ cpuinfo = append(cpuinfo, CPUInfo{}) // start of the next processor
|
||||
+ cpuinfo[i].Processor = uint(v)
|
||||
+ cpuinfo[i].VendorID = systemType
|
||||
+ case "CPU Family":
|
||||
+ cpuinfo[i].CPUFamily = field[1]
|
||||
+ case "Model Name":
|
||||
+ cpuinfo[i].ModelName = field[1]
|
||||
+ }
|
||||
+ }
|
||||
+ return cpuinfo, nil
|
||||
+}
|
||||
+
|
||||
func parseCPUInfoPPC(info []byte) ([]CPUInfo, error) {
|
||||
scanner := bufio.NewScanner(bytes.NewReader(info))
|
||||
|
||||
diff --git a/cmd/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go b/cmd/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go
|
||||
new file mode 100644
|
||||
index 0000000..d88442f
|
||||
--- /dev/null
|
||||
+++ b/cmd/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go
|
||||
@@ -0,0 +1,19 @@
|
||||
+// Copyright 2022 The Prometheus Authors
|
||||
+// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
+// you may not use this file except in compliance with the License.
|
||||
+// You may obtain a copy of the License at
|
||||
+//
|
||||
+// http://www.apache.org/licenses/LICENSE-2.0
|
||||
+//
|
||||
+// Unless required by applicable law or agreed to in writing, software
|
||||
+// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
+// See the License for the specific language governing permissions and
|
||||
+// limitations under the License.
|
||||
+
|
||||
+//go:build linux
|
||||
+// +build linux
|
||||
+
|
||||
+package procfs
|
||||
+
|
||||
+var parseCPUInfo = parseCPUInfoLoong
|
||||
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 e05e30a..14d33f1 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/github.com/prometheus/procfs/cpuinfo.go b/vendor/github.com/prometheus/procfs/cpuinfo.go
|
||||
index 31d42f7..2c2a27f 100644
|
||||
--- a/vendor/github.com/prometheus/procfs/cpuinfo.go
|
||||
+++ b/vendor/github.com/prometheus/procfs/cpuinfo.go
|
||||
@@ -362,6 +362,42 @@ func parseCPUInfoMips(info []byte) ([]CPUInfo, error) {
|
||||
return cpuinfo, nil
|
||||
}
|
||||
|
||||
+func parseCPUInfoLoong(info []byte) ([]CPUInfo, error) {
|
||||
+ scanner := bufio.NewScanner(bytes.NewReader(info))
|
||||
+ // find the first "processor" line
|
||||
+ firstLine := firstNonEmptyLine(scanner)
|
||||
+ if !strings.HasPrefix(firstLine, "system type") || !strings.Contains(firstLine, ":") {
|
||||
+ return nil, errors.New("invalid cpuinfo file: " + firstLine)
|
||||
+ }
|
||||
+ field := strings.SplitN(firstLine, ": ", 2)
|
||||
+ cpuinfo := []CPUInfo{}
|
||||
+ systemType := field[1]
|
||||
+ i := 0
|
||||
+ for scanner.Scan() {
|
||||
+ line := scanner.Text()
|
||||
+ if !strings.Contains(line, ":") {
|
||||
+ continue
|
||||
+ }
|
||||
+ field := strings.SplitN(line, ": ", 2)
|
||||
+ switch strings.TrimSpace(field[0]) {
|
||||
+ case "processor":
|
||||
+ v, err := strconv.ParseUint(field[1], 0, 32)
|
||||
+ if err != nil {
|
||||
+ return nil, err
|
||||
+ }
|
||||
+ i = int(v)
|
||||
+ cpuinfo = append(cpuinfo, CPUInfo{}) // start of the next processor
|
||||
+ cpuinfo[i].Processor = uint(v)
|
||||
+ cpuinfo[i].VendorID = systemType
|
||||
+ case "CPU Family":
|
||||
+ cpuinfo[i].CPUFamily = field[1]
|
||||
+ case "Model Name":
|
||||
+ cpuinfo[i].ModelName = field[1]
|
||||
+ }
|
||||
+ }
|
||||
+ return cpuinfo, nil
|
||||
+}
|
||||
+
|
||||
func parseCPUInfoPPC(info []byte) ([]CPUInfo, error) {
|
||||
scanner := bufio.NewScanner(bytes.NewReader(info))
|
||||
|
||||
diff --git a/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go b/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go
|
||||
new file mode 100644
|
||||
index 0000000..d88442f
|
||||
--- /dev/null
|
||||
+++ b/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go
|
||||
@@ -0,0 +1,19 @@
|
||||
+// Copyright 2022 The Prometheus Authors
|
||||
+// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
+// you may not use this file except in compliance with the License.
|
||||
+// You may obtain a copy of the License at
|
||||
+//
|
||||
+// http://www.apache.org/licenses/LICENSE-2.0
|
||||
+//
|
||||
+// Unless required by applicable law or agreed to in writing, software
|
||||
+// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
+// See the License for the specific language governing permissions and
|
||||
+// limitations under the License.
|
||||
+
|
||||
+//go:build linux
|
||||
+// +build linux
|
||||
+
|
||||
+package procfs
|
||||
+
|
||||
+var parseCPUInfo = parseCPUInfoLoong
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -2,15 +2,18 @@
|
||||
|
||||
Name: cadvisor
|
||||
Version: 0.37.0
|
||||
Release: 3
|
||||
Release: 4
|
||||
Summary: Analyzes resource usage and performance characteristics of running containers.
|
||||
License: ASL 2.0
|
||||
URL: https://github.com/google/cadvisor
|
||||
|
||||
Source0: https://github.com/google/cadvisor/archive/v%{version}.tar.gz
|
||||
Source1: vendor.tar.gz
|
||||
#source2 version sys@v0.0.0-20220908164124-27713097b956
|
||||
Source2: sys.tar.gz
|
||||
Patch0: use_preinstalled_go-bindata.patch
|
||||
Patch1: add-parameters-to-solve-the-strip.patch
|
||||
Patch2: Add-loong64-support-for-runc-procfs-and-crc32.patch
|
||||
|
||||
BuildRequires: golang >= 1.13
|
||||
|
||||
@ -31,6 +34,13 @@ and network statistics. This data is exported by container and machine-wide.
|
||||
%setup -q -T -n %{name}-%{version} -b 0 -b 1
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%ifarch loongarch64
|
||||
rm -rf vendor/golang.org/x/sys
|
||||
rm -rf cmd/vendor/golang.org/x/sys/
|
||||
tar -xf %{SOURCE2} -C vendor/golang.org/x/
|
||||
tar -xf %{SOURCE2} -C cmd/vendor/golang.org/x/
|
||||
%endif
|
||||
|
||||
%build
|
||||
export GOFLAGS="-mod=vendor -buildmode=pie"
|
||||
@ -46,6 +56,9 @@ install -D -m 755 cadvisor %{buildroot}%{_bindir}/cadvisor
|
||||
|
||||
|
||||
%changelog
|
||||
* Tue Jul 11 2023 huajingyun <huajingyun@loongson.cn> - 0.37.0-4
|
||||
- Add loong64 support
|
||||
|
||||
* Tue Mar 07 2023 jiangxinyu <jiangxinyu@kylinos.cn> - 0.37.0-3
|
||||
- Add strip and pie
|
||||
|
||||
|
||||
BIN
sys.tar.gz
Normal file
BIN
sys.tar.gz
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user