2018-01-25 19:11:32 +08:00
|
|
|
SHELL = bash
|
2018-06-23 16:11:24 +08:00
|
|
|
BRANCH := $(or $(APPVEYOR_REPO_BRANCH),$(TRAVIS_BRANCH),$(shell git rev-parse --abbrev-ref HEAD))
|
2018-09-01 23:49:05 +08:00
|
|
|
LAST_TAG := $(shell git describe --tags --abbrev=0)
|
|
|
|
ifeq ($(BRANCH),$(LAST_TAG))
|
|
|
|
BRANCH := master
|
|
|
|
endif
|
2018-06-23 16:11:24 +08:00
|
|
|
TAG_BRANCH := -$(BRANCH)
|
|
|
|
BRANCH_PATH := branch/
|
|
|
|
ifeq ($(subst HEAD,,$(subst master,,$(BRANCH))),)
|
|
|
|
TAG_BRANCH :=
|
|
|
|
BRANCH_PATH :=
|
|
|
|
endif
|
|
|
|
TAG := $(shell echo $$(git describe --abbrev=8 --tags | sed 's/-\([0-9]\)-/-00\1-/; s/-\([0-9][0-9]\)-/-0\1-/'))$(TAG_BRANCH)
|
2014-07-04 04:43:14 +08:00
|
|
|
NEW_TAG := $(shell echo $(LAST_TAG) | perl -lpe 's/v//; $$_ += 0.01; $$_ = sprintf("v%.2f", $$_)')
|
2018-09-01 21:02:09 +08:00
|
|
|
ifneq ($(TAG),$(LAST_TAG))
|
|
|
|
TAG := $(TAG)-beta
|
|
|
|
endif
|
2016-10-05 00:10:20 +08:00
|
|
|
GO_VERSION := $(shell go version)
|
2016-10-31 23:50:02 +08:00
|
|
|
GO_FILES := $(shell go list ./... | grep -v /vendor/ )
|
2018-08-18 04:02:50 +08:00
|
|
|
# Run full tests if go >= go1.11
|
|
|
|
FULL_TESTS := $(shell go version | perl -lne 'print "go$$1.$$2" if /go(\d+)\.(\d+)/ && ($$1 > 1 || $$2 >= 11)')
|
2018-06-23 16:11:24 +08:00
|
|
|
BETA_PATH := $(BRANCH_PATH)$(TAG)
|
|
|
|
BETA_URL := https://beta.rclone.org/$(BETA_PATH)/
|
|
|
|
BETA_UPLOAD_ROOT := memstore:beta-rclone-org
|
|
|
|
BETA_UPLOAD := $(BETA_UPLOAD_ROOT)/$(BETA_PATH)
|
2017-05-19 22:46:13 +08:00
|
|
|
# Pass in GOTAGS=xyz on the make command line to set build tags
|
|
|
|
ifdef GOTAGS
|
|
|
|
BUILDTAGS=-tags "$(GOTAGS)"
|
|
|
|
endif
|
2014-04-25 01:11:08 +08:00
|
|
|
|
2017-05-13 16:59:41 +08:00
|
|
|
.PHONY: rclone vars version
|
2017-02-27 19:53:03 +08:00
|
|
|
|
2014-07-19 20:12:20 +08:00
|
|
|
rclone:
|
2017-02-27 19:53:03 +08:00
|
|
|
touch fs/version.go
|
2017-05-19 22:46:13 +08:00
|
|
|
go install -v --ldflags "-s -X github.com/ncw/rclone/fs.Version=$(TAG)" $(BUILDTAGS)
|
2017-02-27 19:53:03 +08:00
|
|
|
cp -av `go env GOPATH`/bin/rclone .
|
2014-07-19 20:12:20 +08:00
|
|
|
|
2016-09-08 15:04:13 +08:00
|
|
|
vars:
|
|
|
|
@echo SHELL="'$(SHELL)'"
|
2018-06-23 16:11:24 +08:00
|
|
|
@echo BRANCH="'$(BRANCH)'"
|
2016-09-08 15:04:13 +08:00
|
|
|
@echo TAG="'$(TAG)'"
|
|
|
|
@echo LAST_TAG="'$(LAST_TAG)'"
|
|
|
|
@echo NEW_TAG="'$(NEW_TAG)'"
|
2016-10-05 00:10:20 +08:00
|
|
|
@echo GO_VERSION="'$(GO_VERSION)'"
|
2018-01-26 20:02:44 +08:00
|
|
|
@echo FULL_TESTS="'$(FULL_TESTS)'"
|
2016-10-08 18:23:21 +08:00
|
|
|
@echo BETA_URL="'$(BETA_URL)'"
|
2016-09-08 15:04:13 +08:00
|
|
|
|
2017-05-13 16:59:41 +08:00
|
|
|
version:
|
|
|
|
@echo '$(TAG)'
|
|
|
|
|
2016-07-13 19:25:19 +08:00
|
|
|
# Full suite of integration tests
|
2014-07-19 20:12:20 +08:00
|
|
|
test: rclone
|
2018-01-16 19:21:12 +08:00
|
|
|
go install github.com/ncw/rclone/fstest/test_all
|
2018-02-02 17:50:58 +08:00
|
|
|
-go test -v -count 1 $(BUILDTAGS) $(GO_FILES) 2>&1 | tee test.log
|
2018-01-13 00:30:54 +08:00
|
|
|
-test_all github.com/ncw/rclone/fs/operations github.com/ncw/rclone/fs/sync 2>&1 | tee fs/test_all.log
|
2017-09-27 23:13:33 +08:00
|
|
|
@echo "Written logs in test.log and fs/test_all.log"
|
2014-03-29 06:34:13 +08:00
|
|
|
|
2016-07-13 19:25:19 +08:00
|
|
|
# Quick test
|
|
|
|
quicktest:
|
2017-05-19 22:46:13 +08:00
|
|
|
RCLONE_CONFIG="/notfound" go test $(BUILDTAGS) $(GO_FILES)
|
2018-01-26 20:02:44 +08:00
|
|
|
ifdef FULL_TESTS
|
2017-05-19 22:46:13 +08:00
|
|
|
RCLONE_CONFIG="/notfound" go test $(BUILDTAGS) -cpu=2 -race $(GO_FILES)
|
2017-06-19 15:07:50 +08:00
|
|
|
endif
|
2016-07-13 19:25:19 +08:00
|
|
|
|
|
|
|
# Do source code quality checks
|
2015-09-23 01:47:16 +08:00
|
|
|
check: rclone
|
2018-01-26 20:02:44 +08:00
|
|
|
ifdef FULL_TESTS
|
2017-08-29 21:22:07 +08:00
|
|
|
go vet $(BUILDTAGS) -printfuncs Debugf,Infof,Logf,Errorf ./...
|
2017-12-03 20:04:37 +08:00
|
|
|
errcheck $(BUILDTAGS) ./...
|
2016-10-31 23:50:02 +08:00
|
|
|
find . -name \*.go | grep -v /vendor/ | xargs goimports -d | grep . ; test $$? -eq 1
|
2017-12-03 20:04:37 +08:00
|
|
|
go list ./... | xargs -n1 golint | grep -E -v '(StorageUrl|CdnUrl)' ; test $$? -eq 1
|
2016-10-05 00:10:20 +08:00
|
|
|
else
|
2018-01-26 20:02:44 +08:00
|
|
|
@echo Skipping source quality tests as version of go too old
|
2016-10-05 00:10:20 +08:00
|
|
|
endif
|
2015-09-23 01:47:16 +08:00
|
|
|
|
2018-05-04 22:19:07 +08:00
|
|
|
gometalinter_install:
|
|
|
|
go get -u github.com/alecthomas/gometalinter
|
|
|
|
gometalinter --install --update
|
|
|
|
|
|
|
|
# We aren't using gometalinter as the default linter yet because
|
|
|
|
# 1. it doesn't support build tags: https://github.com/alecthomas/gometalinter/issues/275
|
|
|
|
# 2. can't get -printfuncs working with the vet linter
|
|
|
|
gometalinter:
|
|
|
|
gometalinter ./...
|
|
|
|
|
2016-07-13 19:25:19 +08:00
|
|
|
# Get the build dependencies
|
|
|
|
build_dep:
|
2018-01-26 20:02:44 +08:00
|
|
|
ifdef FULL_TESTS
|
2016-07-13 19:25:19 +08:00
|
|
|
go get -u github.com/kisielk/errcheck
|
|
|
|
go get -u golang.org/x/tools/cmd/goimports
|
2018-04-25 23:17:54 +08:00
|
|
|
go get -u github.com/golang/lint/golint
|
2016-10-05 00:10:20 +08:00
|
|
|
endif
|
2016-07-13 19:25:19 +08:00
|
|
|
|
2018-03-23 20:42:44 +08:00
|
|
|
# Get the release dependencies
|
|
|
|
release_dep:
|
2018-04-28 21:21:30 +08:00
|
|
|
go get -u github.com/goreleaser/nfpm/...
|
2018-04-28 19:38:30 +08:00
|
|
|
go get -u github.com/aktau/github-release
|
2018-03-23 20:42:44 +08:00
|
|
|
|
2016-07-13 19:25:19 +08:00
|
|
|
# Update dependencies
|
|
|
|
update:
|
2018-08-28 22:30:47 +08:00
|
|
|
GO111MODULE=on go get -u ./...
|
2018-09-21 22:46:48 +08:00
|
|
|
GO111MODULE=on go mod tidy
|
|
|
|
GO111MODULE=on go mod vendor
|
2016-07-13 19:25:19 +08:00
|
|
|
|
2018-09-01 17:19:03 +08:00
|
|
|
doc: rclone.1 MANUAL.html MANUAL.txt rcdocs commanddocs
|
2014-04-25 01:11:08 +08:00
|
|
|
|
2015-06-06 17:05:21 +08:00
|
|
|
rclone.1: MANUAL.md
|
|
|
|
pandoc -s --from markdown --to man MANUAL.md -o rclone.1
|
2014-04-25 01:11:08 +08:00
|
|
|
|
2018-10-02 03:48:54 +08:00
|
|
|
MANUAL.md: bin/make_manual.py docs/content/*.md commanddocs backenddocs
|
2016-10-04 18:37:31 +08:00
|
|
|
./bin/make_manual.py
|
2014-04-25 01:11:08 +08:00
|
|
|
|
2015-06-06 17:05:21 +08:00
|
|
|
MANUAL.html: MANUAL.md
|
|
|
|
pandoc -s --from markdown --to html MANUAL.md -o MANUAL.html
|
|
|
|
|
|
|
|
MANUAL.txt: MANUAL.md
|
|
|
|
pandoc -s --from markdown --to plain MANUAL.md -o MANUAL.txt
|
2014-04-25 01:11:08 +08:00
|
|
|
|
2016-08-04 04:36:28 +08:00
|
|
|
commanddocs: rclone
|
|
|
|
rclone gendocs docs/content/commands/
|
|
|
|
|
2018-10-02 03:48:54 +08:00
|
|
|
backenddocs: rclone bin/make_backend_docs.py
|
|
|
|
./bin/make_backend_docs.py
|
|
|
|
|
2018-04-24 03:44:44 +08:00
|
|
|
rcdocs: rclone
|
|
|
|
bin/make_rc_docs.sh
|
|
|
|
|
2014-04-25 01:11:08 +08:00
|
|
|
install: rclone
|
|
|
|
install -d ${DESTDIR}/usr/bin
|
2014-07-19 20:12:20 +08:00
|
|
|
install -t ${DESTDIR}/usr/bin ${GOPATH}/bin/rclone
|
2014-04-25 01:11:08 +08:00
|
|
|
|
2014-03-29 06:34:13 +08:00
|
|
|
clean:
|
2014-04-25 01:11:08 +08:00
|
|
|
go clean ./...
|
2014-03-29 06:34:13 +08:00
|
|
|
find . -name \*~ | xargs -r rm -f
|
2014-04-18 05:32:39 +08:00
|
|
|
rm -rf build docs/public
|
2018-01-16 19:21:12 +08:00
|
|
|
rm -f rclone fs/operations/operations.test fs/sync/sync.test fs/test_all.log test.log
|
2014-03-29 06:34:13 +08:00
|
|
|
|
|
|
|
website:
|
2014-04-18 05:32:39 +08:00
|
|
|
cd docs && hugo
|
2014-03-29 06:34:13 +08:00
|
|
|
|
|
|
|
upload_website: website
|
2014-07-19 20:12:20 +08:00
|
|
|
rclone -v sync docs/public memstore:www-rclone-org
|
2014-03-29 06:34:13 +08:00
|
|
|
|
2018-03-17 23:06:04 +08:00
|
|
|
tarball:
|
2018-04-02 17:56:13 +08:00
|
|
|
git archive -9 --format=tar.gz --prefix=rclone-$(TAG)/ -o build/rclone-$(TAG).tar.gz $(TAG)
|
2018-03-17 23:06:04 +08:00
|
|
|
|
|
|
|
sign_upload:
|
2018-04-28 21:59:40 +08:00
|
|
|
cd build && md5sum rclone-v* | gpg --clearsign > MD5SUMS
|
|
|
|
cd build && sha1sum rclone-v* | gpg --clearsign > SHA1SUMS
|
|
|
|
cd build && sha256sum rclone-v* | gpg --clearsign > SHA256SUMS
|
2018-03-17 23:06:04 +08:00
|
|
|
|
|
|
|
check_sign:
|
|
|
|
cd build && gpg --verify MD5SUMS && gpg --decrypt MD5SUMS | md5sum -c
|
|
|
|
cd build && gpg --verify SHA1SUMS && gpg --decrypt SHA1SUMS | sha1sum -c
|
|
|
|
cd build && gpg --verify SHA256SUMS && gpg --decrypt SHA256SUMS | sha256sum -c
|
|
|
|
|
2014-03-29 06:34:13 +08:00
|
|
|
upload:
|
2018-09-02 01:22:19 +08:00
|
|
|
rclone -P copy build/ memstore:downloads-rclone-org/$(TAG)
|
|
|
|
rclone lsf build --files-only --include '*.{zip,deb,rpm}' --include version.txt | xargs -i bash -c 'i={}; j="$$i"; [[ $$i =~ (.*)(-v[0-9\.]+-)(.*) ]] && j=$${BASH_REMATCH[1]}-current-$${BASH_REMATCH[3]}; rclone copyto -v "memstore:downloads-rclone-org/$(TAG)/$$i" "memstore:downloads-rclone-org/$$j"'
|
2014-03-29 06:34:13 +08:00
|
|
|
|
2015-11-24 05:58:54 +08:00
|
|
|
upload_github:
|
2016-10-04 18:37:31 +08:00
|
|
|
./bin/upload-github $(TAG)
|
2015-11-24 05:58:54 +08:00
|
|
|
|
2014-04-25 01:11:08 +08:00
|
|
|
cross: doc
|
2017-05-19 22:46:13 +08:00
|
|
|
go run bin/cross-compile.go -release current $(BUILDTAGS) $(TAG)
|
2014-03-29 06:34:13 +08:00
|
|
|
|
2016-02-21 18:29:48 +08:00
|
|
|
beta:
|
2018-09-01 21:02:09 +08:00
|
|
|
go run bin/cross-compile.go $(BUILDTAGS) $(TAG)
|
|
|
|
rclone -v copy build/ memstore:pub-rclone-org/$(TAG)
|
|
|
|
@echo Beta release ready at https://pub.rclone.org/$(TAG)/
|
2015-11-12 00:55:49 +08:00
|
|
|
|
2017-05-13 16:59:41 +08:00
|
|
|
log_since_last_release:
|
|
|
|
git log $(LAST_TAG)..
|
|
|
|
|
2017-08-05 06:20:26 +08:00
|
|
|
compile_all:
|
2018-01-26 20:02:44 +08:00
|
|
|
ifdef FULL_TESTS
|
2018-09-01 21:02:09 +08:00
|
|
|
go run bin/cross-compile.go -parallel 8 -compile-only $(BUILDTAGS) $(TAG)
|
2017-08-05 06:20:26 +08:00
|
|
|
else
|
2018-01-26 20:02:44 +08:00
|
|
|
@echo Skipping compile all as version of go too old
|
2017-08-05 06:20:26 +08:00
|
|
|
endif
|
|
|
|
|
2018-02-20 23:11:41 +08:00
|
|
|
appveyor_upload:
|
2018-06-23 16:11:24 +08:00
|
|
|
rclone --config bin/travis.rclone.conf -v copy --exclude '*beta-latest*' build/ $(BETA_UPLOAD)
|
|
|
|
ifndef BRANCH_PATH
|
|
|
|
rclone --config bin/travis.rclone.conf -v copy --include '*beta-latest*' --include version.txt build/ $(BETA_UPLOAD_ROOT)
|
2018-02-20 23:11:41 +08:00
|
|
|
endif
|
|
|
|
@echo Beta release ready at $(BETA_URL)
|
|
|
|
|
2018-06-22 16:52:16 +08:00
|
|
|
BUILD_FLAGS := -exclude "^(windows|darwin)/"
|
|
|
|
ifeq ($(TRAVIS_OS_NAME),osx)
|
|
|
|
BUILD_FLAGS := -include "^darwin/" -cgo
|
|
|
|
endif
|
|
|
|
|
2016-10-05 00:10:20 +08:00
|
|
|
travis_beta:
|
2018-06-22 16:52:16 +08:00
|
|
|
ifeq ($(TRAVIS_OS_NAME),linux)
|
2018-02-26 19:24:56 +08:00
|
|
|
go run bin/get-github-release.go -extract nfpm goreleaser/nfpm 'nfpm_.*_Linux_x86_64.tar.gz'
|
2018-06-22 16:52:16 +08:00
|
|
|
endif
|
2017-02-21 01:08:07 +08:00
|
|
|
git log $(LAST_TAG).. > /tmp/git-log.txt
|
2018-09-01 21:02:09 +08:00
|
|
|
go run bin/cross-compile.go -release beta-latest -git-log /tmp/git-log.txt $(BUILD_FLAGS) -parallel 8 $(BUILDTAGS) $(TAG)
|
2018-06-23 16:11:24 +08:00
|
|
|
rclone --config bin/travis.rclone.conf -v copy --exclude '*beta-latest*' build/ $(BETA_UPLOAD)
|
|
|
|
ifndef BRANCH_PATH
|
|
|
|
rclone --config bin/travis.rclone.conf -v copy --include '*beta-latest*' --include version.txt build/ $(BETA_UPLOAD_ROOT)
|
2018-02-20 23:11:41 +08:00
|
|
|
endif
|
2016-10-08 18:23:21 +08:00
|
|
|
@echo Beta release ready at $(BETA_URL)
|
2016-10-05 00:10:20 +08:00
|
|
|
|
2018-09-01 17:19:03 +08:00
|
|
|
# Fetch the binary builds from travis and appveyor
|
|
|
|
fetch_binaries:
|
2018-09-02 01:22:19 +08:00
|
|
|
rclone -P sync $(BETA_UPLOAD) build/
|
2017-07-23 01:16:46 +08:00
|
|
|
|
2016-01-16 22:10:57 +08:00
|
|
|
serve: website
|
2014-04-18 05:32:39 +08:00
|
|
|
cd docs && hugo server -v -w
|
2014-04-25 01:11:08 +08:00
|
|
|
|
2016-02-01 01:50:13 +08:00
|
|
|
tag: doc
|
2014-04-25 01:11:08 +08:00
|
|
|
@echo "Old tag is $(LAST_TAG)"
|
|
|
|
@echo "New tag is $(NEW_TAG)"
|
2017-03-18 19:16:43 +08:00
|
|
|
echo -e "package fs\n\n// Version of rclone\nvar Version = \"$(NEW_TAG)\"\n" | gofmt > fs/version.go
|
2018-02-13 19:19:19 +08:00
|
|
|
echo -n "$(NEW_TAG)" > docs/layouts/partials/version.html
|
2018-03-07 23:18:13 +08:00
|
|
|
git tag -s -m "Version $(NEW_TAG)" $(NEW_TAG)
|
2018-08-27 19:18:35 +08:00
|
|
|
bin/make_changelog.py $(LAST_TAG) $(NEW_TAG) > docs/content/changelog.md.new
|
|
|
|
mv docs/content/changelog.md.new docs/content/changelog.md
|
2017-03-18 19:16:43 +08:00
|
|
|
@echo "Edit the new changelog in docs/content/changelog.md"
|
2018-08-27 19:18:35 +08:00
|
|
|
@echo "Then commit all the changes"
|
2015-06-06 17:05:21 +08:00
|
|
|
@echo git commit -m \"Version $(NEW_TAG)\" -a -v
|
2014-04-25 01:11:08 +08:00
|
|
|
@echo "And finally run make retag before make cross etc"
|
|
|
|
|
|
|
|
retag:
|
2018-03-07 23:18:13 +08:00
|
|
|
git tag -f -s -m "Version $(LAST_TAG)" $(LAST_TAG)
|
2017-03-18 19:30:04 +08:00
|
|
|
|
|
|
|
startdev:
|
2017-03-18 19:16:43 +08:00
|
|
|
echo -e "package fs\n\n// Version of rclone\nvar Version = \"$(LAST_TAG)-DEV\"\n" | gofmt > fs/version.go
|
|
|
|
git commit -m "Start $(LAST_TAG)-DEV development" fs/version.go
|
2014-07-27 00:18:29 +08:00
|
|
|
|
2017-05-12 17:03:35 +08:00
|
|
|
winzip:
|
|
|
|
zip -9 rclone-$(TAG).zip rclone.exe
|