Skip to content

Commit

Permalink
Updated build script, changed deb and rpm config path to /etc/grafana,
Browse files Browse the repository at this point in the history
  • Loading branch information
torkelo committed Mar 4, 2015
1 parent 6bf4eda commit 3029474
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
48 changes: 25 additions & 23 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package main
import (
"bytes"
"crypto/md5"
"encoding/json"
"flag"
"fmt"
"io"
Expand All @@ -29,7 +30,7 @@ var (
workingDir string

installRoot = "/opt/grafana"
configRoot = "/etc/opt/grafana"
configRoot = "/etc/grafana"
grafanaLogDir = "/var/log/grafana"
)

Expand Down Expand Up @@ -71,14 +72,14 @@ func main() {
test("./pkg/...")
grunt("test")

case "latest":
version += "-" + getGitSha()

case "package":
//verifyGitRepoIsClean()
grunt("release", "--pkgVer="+version)
createRpmAndDeb()

case "latest":
makeLatestDistCopies()

case "clean":
clean()

Expand All @@ -88,28 +89,28 @@ func main() {
}
}

func makeLatestDistCopies() {
runError("cp", "dist/grafana_"+version+"_amd64.deb", "dist/grafana_latest_amd64.deb")
runError("cp", "dist/grafana-"+strings.Replace(version, "-", "_", 5)+"-1.x86_64.rpm", "dist/grafana-latest-1.x84_64.rpm")
runError("cp", "dist/grafana-"+version+".x86_64.tar.gz", "dist/grafana-latest.x84_64.tar.gz")
}

func readVersionFromPackageJson() {
v, err := runError("git", "describe", "--tags", "--dirty")
reader, err := os.Open("package.json")
if err != nil {
return "unknown-ver"
log.Fatal("Failed to open package.json")
return
}
defer reader.Close()

jsonObj := map[string]interface{}{}
jsonParser := json.NewDecoder(reader)

if err := jsonParser.Decode(&jsonObj); err != nil {
log.Fatal("Failed to decode package.json")
}
version = v

// reader, err := os.Open("package.json")
// if err != nil {
// log.Fatal("Failed to open package.json")
// return
// }
// defer reader.Close()
//
// jsonObj := map[string]interface{}{}
// jsonParser := json.NewDecoder(reader)
//
// if err := jsonParser.Decode(&jsonObj); err != nil {
// log.Fatal("Failed to decode package.json")
// }
//
// version = jsonObj["version"].(string)

version = jsonObj["version"].(string)
}

func createRpmAndDeb() {
Expand Down Expand Up @@ -345,6 +346,7 @@ func runError(cmd string, args ...string) ([]byte, error) {
if err != nil {
return nil, err
}

return bytes.TrimSpace(bs), nil
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"company": "Coding Instinct AB"
},
"name": "grafana",
"version": "2.0.0-prebeta",
"version": "2.0.0-prebeta1",
"repository": {
"type": "git",
"url": "http://github.com/torkelo/grafana.git"
Expand Down
2 changes: 1 addition & 1 deletion scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fi
DAEMON_NAME="grafana"
DAEMON_USER="grafana"
DAEMON_PATH="/opt/grafana/current/grafana"
DAEMON_OPTS="--config=/etc/opt/grafana/grafana.ini web"
DAEMON_OPTS="--config=/etc/grafana/grafana.ini web"
DAEMON_PWD="/opt/grafana/current"
DAEMON_PID="/var/run/${DAEMON_NAME}.pid"
DAEMON_NICE=0
Expand Down
4 changes: 2 additions & 2 deletions wercker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ build:
go run build.go clean test build
# create packages
- script:
name: create packages
name: create packages latest
code: |
sudo gem install fpm
sudo apt-get update
sudo apt-get install -y rpm
go run build.go latest package
go run build.go package latest
# save packages
- script:
name: copy output
Expand Down

0 comments on commit 3029474

Please sign in to comment.