diff --git a/Makefile b/Makefile index 4b57c6a74..92be131e8 100644 --- a/Makefile +++ b/Makefile @@ -26,8 +26,7 @@ else BUILD_STACK_TARGETS = build-in-docker endif -.PHONY: all apt-update install version copyfiles man-db plugins dependencies sshcommand plugn docker aufs stack count dokku-installer vagrant-acl-add vagrant-dokku go-build force - force :; +.PHONY: all apt-update install version copyfiles man-db plugins dependencies sshcommand plugn docker aufs stack count dokku-installer vagrant-acl-add vagrant-dokku go-build include tests.mk include deb.mk @@ -54,7 +53,7 @@ package_cloud: packer: packer build contrib/packer.json -go-build: force +go-build: basedir=$(PWD); \ for dir in plugins/*; do \ if [ -e $$dir/Makefile ]; then \ @@ -62,6 +61,14 @@ go-build: force fi ;\ done +go-clean: + basedir=$(PWD); \ + for dir in plugins/*; do \ + if [ -e $$dir/Makefile ]; then \ + $(MAKE) -C $$dir clean ;\ + fi ;\ + done + copyfiles: $(MAKE) go-build || exit 1 cp dokku /usr/local/bin/dokku @@ -81,7 +88,7 @@ copyfiles: PLUGIN_PATH=${CORE_PLUGINS_PATH} plugn enable $$plugin ;\ PLUGIN_PATH=${PLUGINS_PATH} plugn enable $$plugin ;\ done - find ./plugins/* -type f -executable -exec file -i '{}' \; | grep 'x-executable; charset=binary' | awk -F: '{ print $$1 }' | xargs rm -f + $(MAKE) go-clean chown dokku:dokku -R ${PLUGINS_PATH} ${CORE_PLUGINS_PATH} || true $(MAKE) addman diff --git a/plugins/repo/.gitignore b/plugins/repo/.gitignore new file mode 100644 index 000000000..0f6770b1e --- /dev/null +++ b/plugins/repo/.gitignore @@ -0,0 +1,2 @@ +/commands +/subcommands/* diff --git a/plugins/repo/Makefile b/plugins/repo/Makefile index fbc4069fb..6883702d6 100644 --- a/plugins/repo/Makefile +++ b/plugins/repo/Makefile @@ -1,5 +1,8 @@ .PHONY: build-in-docker build clean +GO_REPO_ROOT ?= /go/src/github.com/dokku/dokku +BUILD_IMAGE ?= golang:1.7.1 + build-in-docker: clean docker run --rm \ -v $$PWD/../..:$(GO_REPO_ROOT) \ @@ -7,8 +10,17 @@ build-in-docker: clean $(BUILD_IMAGE) \ bash -c "make build" || exit $$? -build: - cd src && go build -a -o ../commands +build: commands subcommands +subcommands: subcommands/gc subcommands/purge-cache + +commands: **/**/commands.go + go build -a -o commands src/commands/commands.go + +subcommands/gc: **/**/**/gc.go + go build -a -o subcommands/gc src/subcommands/gc/gc.go + +subcommands/purge-cache: **/**/**/purge-cache.go + go build -a -o subcommands/purge-cache src/subcommands/purge-cache/purge-cache.go clean: - rm -f commands + rm -rf commands subcommands diff --git a/plugins/repo/commands b/plugins/repo/commands deleted file mode 100755 index c261c436b..000000000 --- a/plugins/repo/commands +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -[[ " help repo:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" -source "$PLUGIN_AVAILABLE_PATH/repo/internal-functions" -set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x - -case "$1" in - help | repo:help) - repo_help_cmd "$@" - ;; - - *) - exit "$DOKKU_NOT_IMPLEMENTED_EXIT" - ;; - -esac diff --git a/plugins/repo/src/commands.go b/plugins/repo/src/commands/commands.go similarity index 94% rename from plugins/repo/src/commands.go rename to plugins/repo/src/commands/commands.go index 9a19bed8b..a01d546d5 100644 --- a/plugins/repo/src/commands.go +++ b/plugins/repo/src/commands/commands.go @@ -33,10 +33,6 @@ func main() { usage() case "help": fmt.Print(helpContent) - case "repo:gc": - gitGC() - case "repo:purge-cache": - purgeCache() default: dokkuNotImplementExitCode, err := strconv.Atoi(os.Getenv("DOKKU_NOT_IMPLEMENTED_EXIT")) if err != nil { diff --git a/plugins/repo/src/gc.go b/plugins/repo/src/subcommands/gc/gc.go similarity index 97% rename from plugins/repo/src/gc.go rename to plugins/repo/src/subcommands/gc/gc.go index 2cac3618a..873ed3e85 100644 --- a/plugins/repo/src/gc.go +++ b/plugins/repo/src/subcommands/gc/gc.go @@ -8,7 +8,7 @@ import ( ) // runs 'git gc --aggressive' against the application's repo -func gitGC() { +func main() { flag.Parse() appName := flag.Arg(1) if appName == "" { diff --git a/plugins/repo/src/purge-cache.go b/plugins/repo/src/subcommands/purge-cache/purge-cache.go similarity index 98% rename from plugins/repo/src/purge-cache.go rename to plugins/repo/src/subcommands/purge-cache/purge-cache.go index eefbb11d0..b4d4eb8b0 100644 --- a/plugins/repo/src/purge-cache.go +++ b/plugins/repo/src/subcommands/purge-cache/purge-cache.go @@ -9,7 +9,7 @@ import ( ) // deletes the contents of the build cache stored in the repository -func purgeCache() { +func main() { flag.Parse() appName := flag.Arg(1) if appName == "" { diff --git a/plugins/repo/subcommands/gc b/plugins/repo/subcommands/gc deleted file mode 100755 index fbeb9b153..000000000 --- a/plugins/repo/subcommands/gc +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" - -repo_gc() { - declare desc="runs 'git gc --aggressive' against the application's repo" - local cmd="repo:gc" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - local APP="$2"; local APP_DIR="$DOKKU_ROOT/$APP" - verify_app_name "$APP" - - GIT_DIR="$APP_DIR" git gc --aggressive -} - -repo_gc "$@"