mirror of
https://github.com/minio/mc.git
synced 2025-11-12 01:02:26 +03:00
Moving to 'go run make.go', all builds are release builds for now
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
cover.out
|
cover.out
|
||||||
mc
|
mc
|
||||||
|
version.go
|
||||||
|
|||||||
18
Makefile
18
Makefile
@@ -40,14 +40,11 @@ deadcode:
|
|||||||
pre-build:
|
pre-build:
|
||||||
@echo "Running pre-build:"
|
@echo "Running pre-build:"
|
||||||
|
|
||||||
build-all: getdeps verifiers
|
gomake-all: getdeps verifiers
|
||||||
@echo "Building Libraries:"
|
@echo "Installing mc:"
|
||||||
@godep go generate ./...
|
@go run make.go release
|
||||||
@godep go build -a ./... # no stale packages
|
@go run make.go install
|
||||||
|
@mkdir -p $(HOME)/.mc
|
||||||
test-all: pre-build build-all
|
|
||||||
@echo "Running Test Suites:"
|
|
||||||
@godep go test -race ./...
|
|
||||||
|
|
||||||
save:
|
save:
|
||||||
@godep save ./...
|
@godep save ./...
|
||||||
@@ -58,10 +55,7 @@ restore:
|
|||||||
env:
|
env:
|
||||||
@godep go env
|
@godep go env
|
||||||
|
|
||||||
install: test-all
|
install: gomake-all
|
||||||
@echo "Installing mc:"
|
|
||||||
@godep go install -a -ldflags "-X main.BuildDate `go run buildscripts/date.go`" github.com/minio/mc
|
|
||||||
@mkdir -p $(HOME)/.mc
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@rm -fv cover.out
|
@rm -fv cover.out
|
||||||
|
|||||||
@@ -58,9 +58,9 @@ func doUpdateCheck(config *hostConfig) (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "No new update available at this time", nil
|
return "No new update available at this time", nil
|
||||||
}
|
}
|
||||||
current, _ := time.Parse(time.RFC3339Nano, BuildDate)
|
current, _ := time.Parse(time.RFC3339Nano, Version)
|
||||||
if current.IsZero() {
|
if current.IsZero() {
|
||||||
return "BuildDate is empty, must be a custom build cannot update", nil
|
return "Version is empty, must be a custom build cannot update. Please download releases from http://dl.minio.io:9000 for proper updates", nil
|
||||||
}
|
}
|
||||||
if latest.Time.After(current) {
|
if latest.Time.After(current) {
|
||||||
printUpdateNotify("new", "old")
|
printUpdateNotify("new", "old")
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minio Client (C) 2015 Minio, Inc.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/md5"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
)
|
|
||||||
|
|
||||||
// hashBinary computes MD5SUM of a binary file on disk
|
|
||||||
func hashBinary(progName string) (string, error) {
|
|
||||||
path, err := exec.LookPath(progName)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
m := md5.New()
|
|
||||||
|
|
||||||
file, err := os.Open(path) // For read access.
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
io.Copy(m, file)
|
|
||||||
return fmt.Sprintf("%x", m.Sum(nil)), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// mustHashBinarySelf masks any error returned by hashBinary
|
|
||||||
func mustHashBinarySelf() string {
|
|
||||||
hash, _ := hashBinary(os.Args[0])
|
|
||||||
return hash
|
|
||||||
}
|
|
||||||
20
main.go
20
main.go
@@ -23,7 +23,6 @@ import (
|
|||||||
"os/user"
|
"os/user"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
@@ -56,18 +55,6 @@ func checkConfig() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build date
|
|
||||||
var BuildDate string
|
|
||||||
|
|
||||||
// getBuildDate -
|
|
||||||
func getBuildDate() string {
|
|
||||||
t, _ := time.Parse(time.RFC3339Nano, BuildDate)
|
|
||||||
if t.IsZero() {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return t.Format(time.RFC1123)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get os/arch/platform specific information.
|
// Get os/arch/platform specific information.
|
||||||
// Returns a map of current os/arch/platform/memstats
|
// Returns a map of current os/arch/platform/memstats
|
||||||
func getSystemData() map[string]string {
|
func getSystemData() map[string]string {
|
||||||
@@ -94,9 +81,6 @@ func getSystemData() map[string]string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Version is based on MD5SUM of its binary
|
|
||||||
var Version = mustHashBinarySelf()
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// register all the commands
|
// register all the commands
|
||||||
registerCmd(lsCmd) // List contents of a bucket
|
registerCmd(lsCmd) // List contents of a bucket
|
||||||
@@ -120,7 +104,7 @@ func main() {
|
|||||||
app.Usage = "Minio Client for object storage and filesystems"
|
app.Usage = "Minio Client for object storage and filesystems"
|
||||||
app.Version = Version
|
app.Version = Version
|
||||||
app.Commands = commands
|
app.Commands = commands
|
||||||
app.Compiled = getBuildDate()
|
app.Compiled = getVersion()
|
||||||
app.Flags = flags
|
app.Flags = flags
|
||||||
app.Author = "Minio.io"
|
app.Author = "Minio.io"
|
||||||
app.Before = func(ctx *cli.Context) error {
|
app.Before = func(ctx *cli.Context) error {
|
||||||
@@ -176,9 +160,7 @@ GLOBAL FLAGS:
|
|||||||
{{range .Flags}}{{.}}
|
{{range .Flags}}{{.}}
|
||||||
{{end}}{{end}}
|
{{end}}{{end}}
|
||||||
VERSION:
|
VERSION:
|
||||||
{{.Version}}
|
|
||||||
{{if .Compiled}}
|
{{if .Compiled}}
|
||||||
BUILD:
|
|
||||||
{{.Compiled}}{{end}}
|
{{.Compiled}}{{end}}
|
||||||
{{range $key, $value := .ExtraInfo}}
|
{{range $key, $value := .ExtraInfo}}
|
||||||
{{$key}}:
|
{{$key}}:
|
||||||
|
|||||||
119
make.go
Normal file
119
make.go
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
// +build ignore
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Minio Client (C) 2014, 2015 Minio, Inc.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"text/template"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/minio/cli"
|
||||||
|
"github.com/minio/mc/pkg/console"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Version struct {
|
||||||
|
Date string
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeVersion(version Version) error {
|
||||||
|
var versionTemplate = `// -------- DO NOT EDIT --------
|
||||||
|
// this is an autogenerated file
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
// Version autogenerated
|
||||||
|
var Version = {{if .Date}}"{{.Date}}"{{else}}""{{end}}
|
||||||
|
|
||||||
|
// getVersion -
|
||||||
|
func getVersion() string {
|
||||||
|
t, _ := time.Parse(time.RFC3339Nano, Version)
|
||||||
|
if t.IsZero() {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return t.Format(time.RFC1123)
|
||||||
|
}
|
||||||
|
`
|
||||||
|
t := template.Must(template.New("version").Parse(versionTemplate))
|
||||||
|
versionFile, err := os.OpenFile("version.go", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer versionFile.Close()
|
||||||
|
err = t.Execute(versionFile, version)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func runGoBuild(ctx *cli.Context) {
|
||||||
|
if ctx.Args().First() == "help" {
|
||||||
|
cli.ShowCommandHelpAndExit(ctx, "build", 1) // last argument is exit code
|
||||||
|
}
|
||||||
|
mcBuild := exec.Command("godep", "go", "build", "-a", "./...")
|
||||||
|
mcTest := exec.Command("godep", "go", "test", "-race", "./...")
|
||||||
|
mcInstall := exec.Command("godep", "go", "install", "-a", "github.com/minio/mc")
|
||||||
|
mcBuildErr := mcBuild.Run()
|
||||||
|
if mcBuildErr != nil {
|
||||||
|
console.Fatalln(mcBuildErr)
|
||||||
|
}
|
||||||
|
var mcTestOut bytes.Buffer
|
||||||
|
mcTest.Stdout = &mcTestOut
|
||||||
|
mcTestErr := mcTest.Run()
|
||||||
|
if mcTestErr != nil {
|
||||||
|
console.Fatalln(mcTestErr)
|
||||||
|
}
|
||||||
|
fmt.Print(mcTestOut.String())
|
||||||
|
mcInstallErr := mcInstall.Run()
|
||||||
|
if mcInstallErr != nil {
|
||||||
|
console.Fatalln(mcInstallErr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func runReleaseCmd(ctx *cli.Context) {
|
||||||
|
if ctx.Args().First() == "help" {
|
||||||
|
cli.ShowCommandHelpAndExit(ctx, "release", 1) // last argument is exit code
|
||||||
|
}
|
||||||
|
version := Version{Date: time.Now().UTC().Format(time.RFC3339Nano)}
|
||||||
|
err := writeVersion(version)
|
||||||
|
if err != nil {
|
||||||
|
console.Fatalln(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
app := cli.NewApp()
|
||||||
|
app.Usage = "Minio Client for object storage and filesystems"
|
||||||
|
app.Commands = []cli.Command{
|
||||||
|
{
|
||||||
|
Name: "release",
|
||||||
|
Action: runReleaseCmd,
|
||||||
|
}, {
|
||||||
|
Name: "install",
|
||||||
|
Action: runGoBuild,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
app.Author = "Minio.io"
|
||||||
|
app.RunAndExitOnError()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user