From 9fc037585703bc536affa4520196c4a47d1b79c4 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Wed, 7 Dec 2016 20:39:47 -0500 Subject: [PATCH 1/2] make: build for several platfom/arches Signed-off-by: Vincent Batts --- .travis.yml | 1 + Makefile | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/.travis.yml b/.travis.yml index d60f684..6fed8a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,3 +16,4 @@ install: true script: - make validation - make validation.tags + - make build.arches diff --git a/Makefile b/Makefile index 071de49..231326c 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ CWD := $(shell pwd) SOURCE_FILES := $(shell find . -type f -name "*.go") CLEAN_FILES := *~ TAGS := cvis +ARCHES := linux,386 linux,amd64 linux,arm linux,arm64 openbsd,amd64 windows,amd64 darwin,amd64 default: build validation @@ -60,6 +61,20 @@ build: $(BUILD) $(BUILD): $(SOURCE_FILES) go build ./cmd/$(BUILD) +./bin: + mkdir -p $@ + +CLEAN_FILES += bin + +build.arches: ./bin + @set -e ;\ + for pair in $(ARCHES); do \ + p=$$(echo $$pair | cut -d , -f 1);\ + a=$$(echo $$pair | cut -d , -f 2);\ + echo "Building $$p/$$a ...";\ + GOOS=$$p GOARCH=$$a go build -o ./bin/gomtree.$$p.$$a ./cmd/gomtree/ ;\ + done + clean: rm -rf $(BUILD) $(CLEAN_FILES) From f15c0ad8215a0b46d1f948b4fa5228592452fe97 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Wed, 7 Dec 2016 22:10:00 -0500 Subject: [PATCH 2/2] keywords: fix keyword failure for windows Signed-off-by: Vincent Batts --- keywords_unsupported.go | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/keywords_unsupported.go b/keywords_unsupported.go index aba791b..e890ccb 100644 --- a/keywords_unsupported.go +++ b/keywords_unsupported.go @@ -10,28 +10,32 @@ import ( ) var ( - unameKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (string, error) { + // this is bsd specific https://www.freebsd.org/cgi/man.cgi?query=chflags&sektion=2 + flagsKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (KeyVal, error) { + return emptyKV, nil + } + unameKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (KeyVal, error) { if hdr, ok := info.Sys().(*tar.Header); ok { - return fmt.Sprintf("uname=%s", hdr.Uname), nil + return KeyVal(fmt.Sprintf("uname=%s", hdr.Uname)), nil } - return "", nil + return emptyKV, nil } - uidKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (string, error) { + uidKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (KeyVal, error) { if hdr, ok := info.Sys().(*tar.Header); ok { - return fmt.Sprintf("uid=%d", hdr.Uid), nil + return KeyVal(fmt.Sprintf("uid=%d", hdr.Uid)), nil } - return "", nil + return emptyKV, nil } - gidKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (string, error) { + gidKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (KeyVal, error) { if hdr, ok := info.Sys().(*tar.Header); ok { - return fmt.Sprintf("gid=%d", hdr.Gid), nil + return KeyVal(fmt.Sprintf("gid=%d", hdr.Gid)), nil } - return "", nil + return emptyKV, nil } - nlinkKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (string, error) { - return "", nil + nlinkKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (KeyVal, error) { + return emptyKV, nil } - xattrKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (string, error) { - return "", nil + xattrKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (KeyVal, error) { + return emptyKV, nil } )