mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
build: updates publisher to support arm archs for deb and rpm.
This commit is contained in:
parent
7a30f72902
commit
f80810081b
@ -18,13 +18,16 @@ import (
|
||||
var apiUrl = flag.String("apiUrl", "https://grafana.com/api", "api url")
|
||||
var apiKey = flag.String("apiKey", "", "api key")
|
||||
var version = ""
|
||||
var versionRe = regexp.MustCompile(`grafana-(.*)(\.|_)(arm64|armv7|darwin|linux|windows|x86_64)`)
|
||||
var debVersionRe = regexp.MustCompile(`grafana_(.*)_(arm64|armv7|amd64)\.deb`)
|
||||
var versionRe = regexp.MustCompile(`grafana-(.*)(\.|_)(arm64|armhfp|aarch64|armv7|darwin|linux|windows|x86_64)`)
|
||||
var debVersionRe = regexp.MustCompile(`grafana_(.*)_(arm64|armv7|armhf|amd64)\.deb`)
|
||||
var builds = []build{}
|
||||
var architectureMapping = map[string]string{
|
||||
"amd64":"amd64",
|
||||
"armv7":"armv7",
|
||||
"armhfp":"armv7",
|
||||
"armhf":"armv7",
|
||||
"arm64":"arm64",
|
||||
"aarch64":"arm64",
|
||||
"amd64":"amd64",
|
||||
"x86_64":"amd64",
|
||||
}
|
||||
|
||||
@ -77,6 +80,8 @@ func mapPackage(path string, name string, shaBytes []byte) (build, error) {
|
||||
log.Printf("Version detected: %v", version)
|
||||
} else if (len(debResult) > 0) {
|
||||
version = string(debResult[1])
|
||||
} else {
|
||||
return build{}, fmt.Errorf("Unable to figure out version from '%v'", name)
|
||||
}
|
||||
|
||||
os := ""
|
||||
@ -95,6 +100,9 @@ func mapPackage(path string, name string, shaBytes []byte) (build, error) {
|
||||
if strings.HasSuffix(name, ".deb") {
|
||||
os = "deb"
|
||||
}
|
||||
if os == "" {
|
||||
return build{}, fmt.Errorf("Unable to figure out os from '%v'", name)
|
||||
}
|
||||
|
||||
arch := ""
|
||||
for archListed, archReal := range architectureMapping {
|
||||
@ -103,6 +111,9 @@ func mapPackage(path string, name string, shaBytes []byte) (build, error) {
|
||||
break
|
||||
}
|
||||
}
|
||||
if arch == "" {
|
||||
return build{}, fmt.Errorf("Unable to figure out arch from '%v'", name)
|
||||
}
|
||||
|
||||
return build{
|
||||
Os: os,
|
||||
@ -125,7 +136,8 @@ func packageWalker(path string, f os.FileInfo, err error) error {
|
||||
build, err := mapPackage(path, f.Name(), shaBytes)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
log.Printf("Could not map metadata from package: %v", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
builds = append(builds, build)
|
||||
|
@ -13,13 +13,13 @@ type testPackage struct {
|
||||
|
||||
var testData = []testPackage{
|
||||
{
|
||||
path: "grafana-5.2.0-474pre1.arm64.rpm",
|
||||
path: "grafana-5.2.0-474pre1.aarch64.rpm",
|
||||
version: "5.2.0-474pre1",
|
||||
os: "rhel",
|
||||
arch: "arm64",
|
||||
},
|
||||
{
|
||||
path: "grafana-5.2.0-474pre1.armv7.rpm",
|
||||
path: "grafana-5.2.0-474pre1.armhfp.rpm",
|
||||
version: "5.2.0-474pre1",
|
||||
os: "rhel",
|
||||
arch: "armv7",
|
||||
@ -73,7 +73,7 @@ var testData = []testPackage{
|
||||
arch: "arm64",
|
||||
},
|
||||
{
|
||||
path: "grafana_5.2.0-474pre1_armv7.deb",
|
||||
path: "grafana_5.2.0-474pre1_armhf.deb",
|
||||
version: "5.2.0-474pre1",
|
||||
os: "deb",
|
||||
arch: "armv7",
|
||||
@ -101,4 +101,10 @@ func TestFileWalker(t *testing.T) {
|
||||
t.Errorf("Testing (%v), expected %v to be %v.", packageInfo.path, actualPackageInfo.Arch, packageInfo.arch)
|
||||
}
|
||||
}
|
||||
|
||||
incorrectPackageName := "grafana_5.2.0-474pre1_armfoo.deb"
|
||||
_, err := mapPackage(incorrectPackageName, incorrectPackageName, []byte{})
|
||||
if err == nil {
|
||||
t.Errorf("Testing (%v), expected to fail due to an unrecognized arch, but signalled no error.", incorrectPackageName)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user