backport 1.1.0(procfs-0.3.0) patches to support riscv64
Also add runtime requires: shadow, coreutils
This commit is contained in:
parent
58510813ce
commit
a8c4612eb5
65
add_cpuinfo_parsing_for_riscv.patch
Normal file
65
add_cpuinfo_parsing_for_riscv.patch
Normal file
@ -0,0 +1,65 @@
|
||||
commit 9e1fd818c15d3fd2f64cf594c3abb5df0885b1e0
|
||||
Author: Tobias Klauser <tklauser@distanz.ch>
|
||||
Date: Wed Jul 22 11:52:26 2020 +0200
|
||||
|
||||
Add CPUInfo parsing for RISCV
|
||||
|
||||
Currently only 64-bit RISCV is supported (GOARCH=riscv64) by the Go
|
||||
compiler, but the cpuinfo format would be the same for 32-bit RISCV.
|
||||
|
||||
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
||||
|
||||
---
|
||||
Rebased on node-exporter 1.0.1 by laokz <zhangkai@iscas.ac.cn>
|
||||
|
||||
diff --git a/vendor/github.com/prometheus/procfs/cpuinfo.go b/vendor/github.com/prometheus/procfs/cpuinfo.go
|
||||
index 935157e..b9fb589 100644
|
||||
--- a/vendor/github.com/prometheus/procfs/cpuinfo.go
|
||||
+++ b/vendor/github.com/prometheus/procfs/cpuinfo.go
|
||||
@@ -407,6 +407,46 @@ func parseCPUInfoPPC(info []byte) ([]CPUInfo, error) {
|
||||
return cpuinfo, nil
|
||||
}
|
||||
|
||||
+func parseCPUInfoRISCV(info []byte) ([]CPUInfo, error) {
|
||||
+ scanner := bufio.NewScanner(bytes.NewReader(info))
|
||||
+
|
||||
+ firstLine := firstNonEmptyLine(scanner)
|
||||
+ if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") {
|
||||
+ return nil, errors.New("invalid cpuinfo file: " + firstLine)
|
||||
+ }
|
||||
+ field := strings.SplitN(firstLine, ": ", 2)
|
||||
+ v, err := strconv.ParseUint(field[1], 0, 32)
|
||||
+ if err != nil {
|
||||
+ return nil, err
|
||||
+ }
|
||||
+ firstcpu := CPUInfo{Processor: uint(v)}
|
||||
+ cpuinfo := []CPUInfo{firstcpu}
|
||||
+ 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)
|
||||
+ case "hart":
|
||||
+ cpuinfo[i].CoreID = field[1]
|
||||
+ case "isa":
|
||||
+ cpuinfo[i].ModelName = field[1]
|
||||
+ }
|
||||
+ }
|
||||
+ return cpuinfo, nil
|
||||
+}
|
||||
+
|
||||
// firstNonEmptyLine advances the scanner to the first non-empty line
|
||||
// and returns the contents of that line
|
||||
func firstNonEmptyLine(scanner *bufio.Scanner) string {
|
||||
39
fix_build_on_riscv.patch
Normal file
39
fix_build_on_riscv.patch
Normal file
@ -0,0 +1,39 @@
|
||||
commit 910e68572b35da779e4f84cfa5261b0a67532d05
|
||||
Author: Tobias Klauser <tklauser@distanz.ch>
|
||||
Date: Mon Sep 7 12:37:51 2020 +0200
|
||||
|
||||
Fix build on RISCV
|
||||
|
||||
PR #318 forgot to wire parseCPUInfo to parseCPUInfoRISCV on
|
||||
GOARCH=riscv{,64}, leading to a build/test failure:
|
||||
|
||||
./cpuinfo.go:71:9: undefined: parseCPUInfo
|
||||
./cpuinfo_test.go:222:2: undefined: parseCPUInfo
|
||||
|
||||
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
||||
|
||||
diff --git a/vendor/github.com/prometheus/procfs/cpuinfo_riscvx.go b/vendor/github.com/prometheus/procfs/cpuinfo_riscvx.go
|
||||
new file mode 100644
|
||||
index 0000000..e83c2e2
|
||||
--- /dev/null
|
||||
+++ b/vendor/github.com/prometheus/procfs/cpuinfo_riscvx.go
|
||||
@@ -0,0 +1,19 @@
|
||||
+// Copyright 2020 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.
|
||||
+
|
||||
+// +build linux
|
||||
+// +build riscv riscv64
|
||||
+
|
||||
+package procfs
|
||||
+
|
||||
+var parseCPUInfo = parseCPUInfoRISCV
|
||||
@ -27,7 +27,7 @@
|
||||
|
||||
Name: golang-%{provider}-%{project}-%{repo}
|
||||
Version: 1.0.1
|
||||
Release: 2
|
||||
Release: 3
|
||||
Summary: Exporter for machine metrics
|
||||
License: ASL 2.0
|
||||
URL: https://%{provider_prefix}
|
||||
@ -36,13 +36,16 @@ Source1: sysconfig.node_exporter
|
||||
Source2: node_exporter.service
|
||||
Source3: node_exporter_textfile_wrapper.sh
|
||||
Source4: textfile_collectors_README
|
||||
Patch0: add_cpuinfo_parsing_for_riscv.patch
|
||||
Patch1: fix_build_on_riscv.patch
|
||||
|
||||
Provides: node_exporter = %{version}-%{release}
|
||||
|
||||
BuildRequires: systemd
|
||||
Requires: shadow coreutils
|
||||
|
||||
# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
|
||||
ExclusiveArch: %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 aarch64 %{arm}}
|
||||
ExclusiveArch: %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 aarch64 %{arm} riscv64}
|
||||
|
||||
%description
|
||||
%{summary}
|
||||
@ -88,7 +91,7 @@ providing packages with %{import_path} prefix.
|
||||
%endif
|
||||
|
||||
%prep
|
||||
%setup -q -n %{repo}-%{version}
|
||||
%autosetup -p1 -n %{repo}-%{version}
|
||||
mkdir -p _build/src/%{provider}.%{provider_tld}/%{project}
|
||||
ln -s $(pwd) _build/src/%{provider_prefix}
|
||||
|
||||
@ -248,6 +251,10 @@ chmod 771 /var/lib/node_exporter/textfile_collector
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Wed Feb 15 2023 laokz <zhangkai@iscas.ac.cn> - 1.0.1-3
|
||||
- Add runtime requires: shadow coreutils
|
||||
- Backport 1.1.0(procfs-0.3.0) patches to support riscv64
|
||||
|
||||
* Sat Feb 20 2021 yangzhao <yangzhao1@kylinos.cn> - 1.0.1-2
|
||||
- Remove unnecessary requirements
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user