Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

Commit

Permalink
Update Makefile according to recent changes, add more meta informatio…
Browse files Browse the repository at this point in the history
…n to binary

Signed-off-by: Igor Shishkin <me@teran.ru>
  • Loading branch information
teran committed May 20, 2019
1 parent b49ef94 commit d0bb05d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
29 changes: 16 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export GOPATH := $(PWD)
export GOBIN := $(GOPATH)/bin
export PACKAGES := $(shell env GOPATH=$(GOPATH) go list ./src/imgsum/...)
export REVISION := $(shell git describe --exact-match --tags $(git log -n1 --pretty='%h') || git rev-parse --verify --short HEAD)
export PACKAGES := $(shell env GOPATH=$(GOPATH) go list ./...)
export VERSION := $(shell git describe --exact-match --tags $(git log -n1 --pretty='%h') || git rev-parse --verify --short HEAD || echo ${VERSION})
export COMMIT := $(shell git rev-parse --verify --short HEAD)
export DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")

all: clean predependencies dependencies build
all: clean dependencies build

clean:
rm -vf bin/*
Expand All @@ -17,28 +17,28 @@ build-linux: build-linux-amd64 build-linux-i386
build-windows: build-windows-amd64 build-windows-i386

build-macos-amd64:
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X main.Version=${REVISION}" -o bin/imgsum-darwin-amd64 imgsum/cmd
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o bin/imgsum-darwin-amd64 .

build-macos-i386:
GOOS=darwin GOARCH=386 CGO_ENABLED=0 go build -ldflags "-X main.Version=${REVISION}" -o bin/imgsum-darwin-i386 imgsum/cmd
GOOS=darwin GOARCH=386 CGO_ENABLED=0 go build -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o bin/imgsum-darwin-i386 .

build-linux-amd64:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X main.Version=${REVISION}" -o bin/imgsum-linux-amd64 imgsum/cmd
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o bin/imgsum-linux-amd64 .

build-linux-i386:
GOOS=linux GOARCH=386 CGO_ENABLED=0 go build -ldflags "-X main.Version=${REVISION}" -o bin/imgsum-linux-i386 imgsum/cmd
GOOS=linux GOARCH=386 CGO_ENABLED=0 go build -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o bin/imgsum-linux-i386 .

build-windows-amd64:
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X main.Version=${REVISION}" -o bin/imgsum-windows-amd64.exe imgsum/cmd
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o bin/imgsum-windows-amd64.exe .

build-windows-i386:
GOOS=windows GOARCH=386 CGO_ENABLED=0 go build -ldflags "-X main.Version=${REVISION}" -o bin/imgsum-windows-i386.exe imgsum/cmd
GOOS=windows GOARCH=386 CGO_ENABLED=0 go build -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o bin/imgsum-windows-i386.exe .

dependencies:
cd src && trash
dep ensure

predependencies:
go get -u github.com/rancher/trash
go get -u github.com/golang/dep/cmd/dep

sign:
gpg --detach-sign --digest-algo SHA512 --no-tty --batch --output bin/imgsum-darwin-amd64.sig bin/imgsum-darwin-amd64
Expand All @@ -48,6 +48,9 @@ sign:
gpg --detach-sign --digest-algo SHA512 --no-tty --batch --output bin/imgsum-windows-amd64.exe.sig bin/imgsum-windows-amd64.exe
gpg --detach-sign --digest-algo SHA512 --no-tty --batch --output bin/imgsum-windows-i386.exe.sig bin/imgsum-windows-i386.exe

test:
go test ./...

verify:
gpg --verify bin/imgsum-darwin-amd64.sig bin/imgsum-darwin-amd64
gpg --verify bin/imgsum-darwin-i386.sig bin/imgsum-darwin-i386
Expand Down
19 changes: 12 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strings"
"sync"

"imgsum/image"
"github.com/teran/imgsum/image"
)

type JsonOutput struct {
Expand All @@ -24,8 +24,13 @@ type JsonInput struct {
Files []string `json:"files"`
}

var wg sync.WaitGroup
var Version = "No version specified(probably trunk build)"
var (
wg sync.WaitGroup

version = "No version specified(probably trunk build)"
commit = "master"
date = "0000-00-00T00:00:00Z"
)

func calculate(file string) error {
i, err := image.NewImage(file)
Expand Down Expand Up @@ -126,10 +131,10 @@ func main() {
deduplicate_mode := flag.Bool("find-duplicates", false, "")
json_input := flag.Bool("json-input", false, "")
json_output := flag.Bool("json-output", false, "")
version := flag.Bool("version", false, "")
versionFlag := flag.Bool("version", false, "")

flag.Parse()
if flag.NArg() < 1 && !*json_input && !*version {
if flag.NArg() < 1 && !*json_input && !*versionFlag {
flag.Usage()
os.Exit(1)
}
Expand All @@ -138,8 +143,8 @@ func main() {
for file := range flag.Args() {
deduplicate(flag.Arg(file), *json_output)
}
} else if *version == true {
fmt.Println(Version)
} else if *versionFlag == true {
fmt.Printf("Version: %s\nBuild date: %s\nBuild commit: %s\n", version, date, commit)
} else {
var files []string
if *json_input {
Expand Down

0 comments on commit d0bb05d

Please sign in to comment.