mirror of
https://github.com/minio/minio.git
synced 2025-02-05 02:38:07 -05:00
Merge pull request #490 from abperiasamy/hashbin
Version is now based on MD5SUM of its binary
This commit is contained in:
commit
2eb1b8ad76
1
Makefile
1
Makefile
@ -33,7 +33,6 @@ cyclo:
|
|||||||
|
|
||||||
pre-build:
|
pre-build:
|
||||||
@echo "Running pre-build:"
|
@echo "Running pre-build:"
|
||||||
@(env bash $(PWD)/buildscripts/git-commit-id.sh)
|
|
||||||
|
|
||||||
build-all: verifiers
|
build-all: verifiers
|
||||||
@echo "Building Libraries:"
|
@echo "Building Libraries:"
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
CONST_FILE=build-constants.go
|
|
||||||
|
|
||||||
cat > $CONST_FILE <<EOF
|
|
||||||
/*
|
|
||||||
* ** DO NOT EDIT THIS FILE. THIS FILE IS AUTO GENERATED BY RUNNING MAKE **
|
|
||||||
*/
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
const (
|
|
||||||
minioGitCommitHash = "__GIT_COMMIT_HASH__"
|
|
||||||
)
|
|
||||||
EOF
|
|
||||||
|
|
||||||
commit_id=$(git log --format="%H" -n 1)
|
|
||||||
sed -i "s/__GIT_COMMIT_HASH__/$commit_id/" $CONST_FILE
|
|
28
hash-binary.go
Normal file
28
hash-binary.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"crypto/md5"
|
||||||
|
)
|
||||||
|
|
||||||
|
// mustHashBinarySelf computes MD5SUM of a binary file on disk
|
||||||
|
func hashBinary(progName string) (string, error) {
|
||||||
|
h := md5.New()
|
||||||
|
|
||||||
|
file, err := os.Open(progName) // For read access.
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
io.Copy(h, file)
|
||||||
|
return fmt.Sprintf("%x", h.Sum(nil)), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// mustHashBinarySelf computes MD5SUM of its binary file on disk
|
||||||
|
func mustHashBinarySelf() string {
|
||||||
|
hash, _ := hashBinary(os.Args[0])
|
||||||
|
return hash
|
||||||
|
}
|
7
main.go
7
main.go
@ -240,15 +240,18 @@ func getSystemData() map[string]string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Version is based on MD5SUM of its binary
|
||||||
|
var Version = mustHashBinarySelf()
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// set up iodine
|
// set up iodine
|
||||||
iodine.SetGlobalState("minio.git", minioGitCommitHash)
|
iodine.SetGlobalState("minio.version", Version)
|
||||||
iodine.SetGlobalState("minio.starttime", time.Now().Format(time.RFC3339))
|
iodine.SetGlobalState("minio.starttime", time.Now().Format(time.RFC3339))
|
||||||
|
|
||||||
// set up app
|
// set up app
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "minio"
|
app.Name = "minio"
|
||||||
app.Version = minioGitCommitHash
|
app.Version = Version
|
||||||
app.Author = "Minio.io"
|
app.Author = "Minio.io"
|
||||||
app.Usage = "Minimalist Object Storage"
|
app.Usage = "Minimalist Object Storage"
|
||||||
app.Flags = flags
|
app.Flags = flags
|
||||||
|
Loading…
x
Reference in New Issue
Block a user