add riscv support
This commit is contained in:
parent
dc54fb170e
commit
2ffbdfb3bf
10
promu.spec
10
promu.spec
@ -2,7 +2,7 @@
|
||||
|
||||
Name: promu
|
||||
Version: 0.7.0
|
||||
Release: 3
|
||||
Release: 4
|
||||
Summary: Prometheus Utility Tool
|
||||
License: ASL 2.0
|
||||
URL: https://github.com/prometheus/promu
|
||||
@ -10,6 +10,8 @@ URL: https://github.com/prometheus/promu
|
||||
Source0: https://github.com/prometheus/promu/archive/v%{version}.tar.gz
|
||||
Patch0: add-parameters-to-solve-the-strip.patch
|
||||
|
||||
#RISC-V support
|
||||
Patch100: riscv64-support.patch
|
||||
|
||||
BuildRequires: golang >= 1.13
|
||||
BuildRequires: gcc
|
||||
@ -23,6 +25,9 @@ promu is the utility tool for building and releasing Prometheus projects
|
||||
%prep
|
||||
%setup -q -T -n %{name}-%{version} -b 0
|
||||
%patch0 -p1
|
||||
%ifarch riscv64
|
||||
%patch100 -p1
|
||||
%endif
|
||||
|
||||
%build
|
||||
export GOFLAGS="-mod=vendor -buildmode=pie"
|
||||
@ -36,6 +41,9 @@ install -D -m 755 %{name}-%{version} %{buildroot}%{_bindir}/promu
|
||||
%{_bindir}/promu
|
||||
|
||||
%changelog
|
||||
* Wed Jun 14 2023 EastDong <xudong23@iscas.ac.cn> - 0.7.0-4
|
||||
- backport to support riscv
|
||||
|
||||
* Fri Mar 10 2023 caodongxia <caodongxia@h-partners.com> - 0.7.0-3
|
||||
- remove linkmode external
|
||||
|
||||
|
||||
84
riscv64-support.patch
Normal file
84
riscv64-support.patch
Normal file
@ -0,0 +1,84 @@
|
||||
diff --git a/vendor/github.com/prometheus/procfs/cpuinfo.go b/vendor/github.com/prometheus/procfs/cpuinfo.go
|
||||
index 31d42f7..02693d1 100644
|
||||
--- a/vendor/github.com/prometheus/procfs/cpuinfo.go
|
||||
+++ b/vendor/github.com/prometheus/procfs/cpuinfo.go
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
+ "fmt"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -407,6 +408,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, fmt.Errorf("invalid cpuinfo file: %q", 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 {
|
||||
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
|
||||
Loading…
x
Reference in New Issue
Block a user