diff --git a/Rules.mk b/Rules.mk index ca9d1bf25d77cbd080ad6c7f6a36e74c5066a241..2b51c24f7e5c77ab719c65497fc5514fa2f38f7c 100644 --- a/Rules.mk +++ b/Rules.mk @@ -128,11 +128,12 @@ help: @echo '' @echo 'BUILD TARGETS:' @echo '' - @echo ' all - print this help message' - @echo ' build - Build binary at ./cmd/ipfs/ipfs' - @echo ' nofuse - Build binary with no fuse support' - @echo ' install - Build binary and install into $$GOPATH/bin' -# @echo ' dist_install - TODO: c.f. ./cmd/ipfs/dist/README.md' + @echo ' all - print this help message' + @echo ' build - Build binary at ./cmd/ipfs/ipfs' + @echo ' nofuse - Build binary with no fuse support' + @echo ' install - Build binary and install into $$GOPATH/bin' +# @echo ' dist_install - TODO: c.f. ./cmd/ipfs/dist/README.md' + @echo ' build_plugins - Build plugin binaries' @echo '' @echo 'CLEANING TARGETS:' @echo '' diff --git a/cmd/ipfs/Rules.mk b/cmd/ipfs/Rules.mk index 175b098eea2c0c0c7a3a5e29282409f7edbbc062..8c9a15a869267b2dfb47d3990aa79f24033a2a77 100644 --- a/cmd/ipfs/Rules.mk +++ b/cmd/ipfs/Rules.mk @@ -13,7 +13,10 @@ PATH := $(realpath $(d)):$(PATH) # DEPS_OO_$(d) += merkledag/pb/merkledag.pb.go namesys/pb/namesys.pb.go # DEPS_OO_$(d) += pin/internal/pb/header.pb.go unixfs/pb/unixfs.pb.go -$(d)_flags =-ldflags="-X "github.com/ipfs/go-ipfs/repo/config".CurrentCommit=$(shell git rev-parse --short HEAD)" +CONFIG_COMMIT ?= github.com/ipfs/go-ipfs/repo/config.CurrentCommit=$(shell git rev-parse --short HEAD) +CONFIG_PLUGIN_PATH ?= github.com/ipfs/go-ipfs/repo/config.SystemPluginPath=${PLUGIN_PATH} + +$(d)_flags =-ldflags="-X ${CONFIG_COMMIT} -X ${CONFIG_PLUGIN_PATH}" $(d)-try-build $(IPFS_BIN_$(d)): GOFLAGS += $(cmd/ipfs_flags) diff --git a/cmd/ipfs/main.go b/cmd/ipfs/main.go index 7b8b68b6ccdbd6a84e2b2286cbd4406bcedf3c09..aff2f79a5421da86b07ab20ca9a1fc8cc94512b1 100644 --- a/cmd/ipfs/main.go +++ b/cmd/ipfs/main.go @@ -52,7 +52,6 @@ const ( type cmdInvocation struct { req *cmds.Request node *core.IpfsNode - ctx *oldcmds.Context } type exitErr int @@ -181,7 +180,7 @@ func makeExecutor(req *cmds.Request, env interface{}) (cmds.Executor, error) { exctr = client.(cmds.Executor) } else { cctx := env.(*oldcmds.Context) - pluginpath := filepath.Join(cctx.ConfigRoot, "plugins") + pluginPath := filepath.Join(cctx.ConfigRoot, "plugins") // check if repo is accessible before loading plugins ok, err := checkPermissions(cctx.ConfigRoot) @@ -189,11 +188,17 @@ func makeExecutor(req *cmds.Request, env interface{}) (cmds.Executor, error) { return nil, err } if ok { - if _, err := loader.LoadPlugins(pluginpath); err != nil { + if _, err := loader.LoadPlugins(pluginPath); err != nil { log.Warning("error loading plugins: ", err) } } + if config.SystemPluginPath != "" { + if _, err := loader.LoadPlugins(config.SystemPluginPath); err != nil { + return nil, err + } + } + exctr = cmds.NewExecutor(req.Root) } diff --git a/repo/config/version.go b/repo/config/version.go index 43546fc11a937d82a3a00373f9044913f2d69027..586d8d855162767a050c07c61178af4882ea8cab 100644 --- a/repo/config/version.go +++ b/repo/config/version.go @@ -3,6 +3,9 @@ package config // CurrentCommit is the current git commit, this is set as a ldflag in the Makefile var CurrentCommit string +// SystemPluginPath is the a system-global plugin path, this is set as a ldflag in the Makefile +var SystemPluginPath string + // CurrentVersionNumber is the current application's version literal const CurrentVersionNumber = "0.4.14-dev"