koji: use the host name from /etc/redhat-release in CGImport metadata
As suggested by Brew maintainers Tomáš Kopeček and Lubomír Sedlář.
This commit is contained in:
parent
3480fe3093
commit
c64d46416e
2 changed files with 23 additions and 1 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
|
|
@ -193,6 +194,20 @@ func GetHostDistroName() (string, bool, error) {
|
|||
return name, beta, nil
|
||||
}
|
||||
|
||||
// GetRedHatRelease returns the content of /etc/redhat-release
|
||||
// without the trailing new-line.
|
||||
func GetRedHatRelease() (string, error) {
|
||||
raw, err := ioutil.ReadFile("/etc/redhat-release")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cannot read /etc/redhat-release: %v", err)
|
||||
}
|
||||
|
||||
//Remove the trailing new-line.
|
||||
redHatRelease := strings.TrimSpace(string(raw))
|
||||
|
||||
return redHatRelease, nil
|
||||
}
|
||||
|
||||
func readOSRelease(r io.Reader) (map[string]string, error) {
|
||||
osrelease := make(map[string]string)
|
||||
scanner := bufio.NewScanner(r)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue