From c37545c7c25f2af5b1f6abe985226de3bc76f99e Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Fri, 12 Jan 2018 10:46:10 +0530 Subject: [PATCH 1/6] Remove templates from build and install Not currently required with volgen2. May be reintroduced later on. --- Makefile | 8 +------- glusterd2/config.go | 4 ---- scripts/gen-gd2conf.sh | 2 -- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 908ce2cdb..645320b37 100644 --- a/Makefile +++ b/Makefile @@ -17,12 +17,8 @@ GD2CONF_BUILDSCRIPT=./scripts/gen-gd2conf.sh GD2CONF_BUILD = $(BUILDDIR)/$(GD2_CONF) GD2CONF_INSTALL = $(SYSCONFDIR)/$(GD2)/$(GD2_CONF) -TEMPLATESDIR = glusterd2/volgen/templates -TEMPLATES_INSTALL = $(DATADIR)/$(GD2)/templates - GD2STATEDIR = $(LOCALSTATEDIR)/$(GD2) GD2LOGDIR = $(LOGDIR)/$(GD2) -GD2TEMPLATESDIR = $(TEMPLATES_INSTALL) PLUGINS ?= yes @@ -57,14 +53,12 @@ $(CLI_BUILD): $(GD2_CONF) gd2conf: $(GD2CONF_BUILD) $(GD2CONF_BUILD): - @GD2STATEDIR=$(GD2STATEDIR) GD2LOGDIR=$(GD2LOGDIR) GD2TEMPLATESDIR=$(GD2TEMPLATESDIR) $(GD2CONF_BUILDSCRIPT) + @GD2STATEDIR=$(GD2STATEDIR) GD2LOGDIR=$(GD2LOGDIR) $(GD2CONF_BUILDSCRIPT) install: install -D $(GD2_BUILD) $(GD2_INSTALL) install -D $(CLI_BUILD) $(CLI_INSTALL) install -D $(GD2CONF_BUILD) $(GD2CONF_INSTALL) - install -d $(TEMPLATES_INSTALL) $(TEMPLATESDIR) - install -D -t $(TEMPLATES_INSTALL) $(TEMPLATESDIR)/*.graph @echo vendor-update: diff --git a/glusterd2/config.go b/glusterd2/config.go index 893655529..012d3d13c 100644 --- a/glusterd2/config.go +++ b/glusterd2/config.go @@ -10,7 +10,6 @@ import ( "github.com/gluster/glusterd2/glusterd2/gdctx" "github.com/gluster/glusterd2/glusterd2/store" - "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/pkg/logging" log "github.com/sirupsen/logrus" @@ -62,7 +61,6 @@ func parseFlags() { flag.String("key-file", "", "Private key for the SSL/TLS certificate.") store.InitFlags() - volgen.InitFlags() flag.Parse() } @@ -109,8 +107,6 @@ func setDefaults() error { } config.SetDefault("peeraddress", host+":"+port) - volgen.SetDefaults() - return nil } diff --git a/scripts/gen-gd2conf.sh b/scripts/gen-gd2conf.sh index 10b6e137c..df2abe3b0 100755 --- a/scripts/gen-gd2conf.sh +++ b/scripts/gen-gd2conf.sh @@ -8,7 +8,6 @@ LOGDIR=${LOGDIR:-$PREFIX/var/log} GD2="glusterd2" GD2STATEDIR=${GD2STATEDIR:-$LOCALSTATEDIR/$GD2} GD2LOGDIR=${GD2LOGDIR:-$LOGDIR/$GD2} -GD2TEMPLATESDIR=${GD2TEMPLATESDIR:-$DATADIR/$GD2/templates} OUTDIR=${1:-build} mkdir -p $OUTDIR @@ -20,5 +19,4 @@ cat >$OUTPUT < Date: Fri, 12 Jan 2018 11:01:43 +0530 Subject: [PATCH 2/6] Correctly prepare standard path variables in make --- extras/make/paths.mk | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/extras/make/paths.mk b/extras/make/paths.mk index c07091882..5865289fd 100644 --- a/extras/make/paths.mk +++ b/extras/make/paths.mk @@ -4,15 +4,15 @@ # and # https://fedoraproject.org/wiki/Packaging:RPMMacros?rd=Packaging/RPMMacros -PREFIX = /usr/local -EXEC_PREFIX = $(PREFIX) +PREFIX ?= /usr/local +EXEC_PREFIX ?= $(PREFIX) -BINDIR = $(EXEC_PREFIX)/bin -SBINDIR = $(EXEC_PREFIX)/sbin +BINDIR ?= $(EXEC_PREFIX)/bin +SBINDIR ?= $(EXEC_PREFIX)/sbin -DATADIR = $(PREFIX)/share -LOCALSTATEDIR = $(PREFIX)/var/lib -LOGDIR = $(PREFIX)/var/log +DATADIR ?= $(PREFIX)/share +LOCALSTATEDIR ?= $(PREFIX)/var/lib +LOGDIR ?= $(PREFIX)/var/log -SYSCONFDIR = $(PREFIX)/etc +SYSCONFDIR ?= $(PREFIX)/etc From 836b6dad8171b497eb5b281366b743e24d818ff7 Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Fri, 12 Jan 2018 11:02:21 +0530 Subject: [PATCH 3/6] Support DESTDIR for `make install` --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 645320b37..b48725f31 100644 --- a/Makefile +++ b/Makefile @@ -6,16 +6,16 @@ BUILDDIR = build GD2_BIN = $(GD2) GD2_BUILD = $(BUILDDIR)/$(GD2_BIN) -GD2_INSTALL = $(SBINDIR)/$(GD2_BIN) +GD2_INSTALL = $(DESTDIR)$(SBINDIR)/$(GD2_BIN) CLI_BIN = glustercli CLI_BUILD = $(BUILDDIR)/$(CLI_BIN) -CLI_INSTALL = $(SBINDIR)/$(CLI_BIN) +CLI_INSTALL = $(DESTDIR)$(SBINDIR)/$(CLI_BIN) GD2_CONF = $(GD2).toml GD2CONF_BUILDSCRIPT=./scripts/gen-gd2conf.sh GD2CONF_BUILD = $(BUILDDIR)/$(GD2_CONF) -GD2CONF_INSTALL = $(SYSCONFDIR)/$(GD2)/$(GD2_CONF) +GD2CONF_INSTALL = $(DESTDIR)$(SYSCONFDIR)/$(GD2)/$(GD2_CONF) GD2STATEDIR = $(LOCALSTATEDIR)/$(GD2) GD2LOGDIR = $(LOGDIR)/$(GD2) From dabac2fa995e72f5faf1f4c12e19c4739fb03cf8 Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Fri, 12 Jan 2018 15:28:42 +0530 Subject: [PATCH 4/6] Update rpm spec to use make correctly --- Makefile | 3 ++- extras/rpms/glusterd2.spec | 31 ++++++++++++------------------- extras/rpms/glusterd2.toml | 4 ---- 3 files changed, 14 insertions(+), 24 deletions(-) delete mode 100644 extras/rpms/glusterd2.toml diff --git a/Makefile b/Makefile index 5d9f9a6ce..6d58b1837 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ GD2 = glusterd2 BUILDDIR = build BASH_COMPLETIONDIR = /etc/bash_completion.d + GD2_BIN = $(GD2) GD2_BUILD = $(BUILDDIR)/$(GD2_BIN) GD2_INSTALL = $(DESTDIR)$(SBINDIR)/$(GD2_BIN) @@ -30,7 +31,7 @@ PLUGINS ?= yes all: build -build: check-go check-reqs vendor-install glusterd2 glustercli glusterd2.toml +build: check-go check-reqs vendor-install $(GD2_BIN) $(CLI_BIN) $(GD2_CONF) check: check-go check-reqs check-protoc check-go: diff --git a/extras/rpms/glusterd2.spec b/extras/rpms/glusterd2.spec index e1407a02f..8cd3addef 100644 --- a/extras/rpms/glusterd2.spec +++ b/extras/rpms/glusterd2.spec @@ -7,15 +7,16 @@ %global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo} %global import_path %{provider_prefix} +%global gd2make %{__make} PREFIX=%{_prefix} EXEC_PREFIX=%{_exec_prefix} BINDIR=%{_bindir} SBINDIR=%{_sbindir} DATADIR=%{_datadir} LOCALSTATEDIR=%{_sharedstatedir} LOGDIR=%{_localstatedir}/log SYSCONFDIR=%{_sysconfdir} + Name: %{repo} Version: 4.0dev -Release: 9 +Release: 10 Summary: The GlusterFS management daemon (preview) License: GPLv2 or LGPLv3+ URL: https://%{provider_prefix} # Use vendored tarball instead of plain git archive Source0: https://%{provider_prefix}/releases/download/v%{version}-%{release}/%{name}-v%{version}-%{release}-vendor.tar.xz -Source1: glusterd2.toml ExclusiveArch: x86_64 @@ -35,34 +36,25 @@ Preview release of the next generation GlusterFS management framework and daemon %build export GOPATH=$(pwd):%{gopath} - mkdir -p src/%(dirname %{import_path}) ln -s ../../../ src/%{import_path} pushd src/%{import_path} # Build glusterd2 -make glusterd2 -make glustercli +%{gd2make} glusterd2 +%{gd2make} glustercli +%{gd2make} glusterd2.toml popd %install -# TODO: Use make install to install -#Install glusterd2 & glustercli binary -install -D -p -m 0755 build/%{name} %{buildroot}%{_sbindir}/%{name} -install -D -p -m 0755 build/glustercli %{buildroot}%{_sbindir}/glustercli +#Install glusterd2 & glustercli binaries and the config +%{gd2make} DESTDIR=%{buildroot} install #Install systemd unit install -D -p -m 0644 extras/systemd/%{name}.service %{buildroot}%{_unitdir}/%{name}.service -#Install glusterd config into etc -install -d -m 0755 %{buildroot}%{_sysconfdir}/%{name} -install -m 0644 -t %{buildroot}%{_sysconfdir}/%{name} %{SOURCE1} # Create /var/lib/glusterd2 install -d -m 0755 %{buildroot}%{_sharedstatedir}/%{name} # logdir install -d -m 0755 %{buildroot}%{_localstatedir}/log/%{name} -#Install templates -install -d -m 0755 %{buildroot}%{_datadir}/%{name}/templates -install -D -m 0644 -t %{buildroot}%{_datadir}/%{name}/templates glusterd2/volgen/templates/*.graph - %post %systemd_post %{name}.service @@ -80,11 +72,12 @@ install -D -m 0644 -t %{buildroot}%{_datadir}/%{name}/templates glusterd2/volgen %{_unitdir}/%{name}.service %dir %{_sharedstatedir}/%{name} %dir %{_localstatedir}/log/%{name} -%dir %{_datadir}/%{name} -%dir %{_datadir}/%{name}/templates -%{_datadir}/%{name}/templates/* +%{_sysconfdir}/bash_completion.d/glustercli.sh %changelog +* Fri Jan 12 2018 Kaushal M - 4.0dev-10 +- Use standard paths to build and install + * Wed Nov 08 2017 Kaushal M - 4.0dev-9 - Build with vendored tarball. diff --git a/extras/rpms/glusterd2.toml b/extras/rpms/glusterd2.toml deleted file mode 100644 index 3cc27ef9b..000000000 --- a/extras/rpms/glusterd2.toml +++ /dev/null @@ -1,4 +0,0 @@ -localstatedir = "/var/lib/glusterd2" -logdir = "/var/log/glusterd2" -logfile = "glusterd2.log" -templatesdir = "/usr/share/glusterd2/templates" From 8d2c12ee4274f1ce2b544adece8b095d91cb1cb1 Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Fri, 12 Jan 2018 16:01:58 +0530 Subject: [PATCH 5/6] Fix release script --- scripts/release.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/release.sh b/scripts/release.sh index 39af9beeb..55f094bad 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -6,10 +6,10 @@ VERSION=$($(dirname $0)/pkg-version --full) OS=$(go env GOOS) ARCH=$(go env GOARCH) -BIN=$(basename $(go list -f '{{.ImportPath}}')) +GD2=glusterd2 RELEASEDIR=releases/$VERSION -TAR=$RELEASEDIR/$BIN-$VERSION-$OS-$ARCH.tar +TAR=$RELEASEDIR/$GD2-$VERSION-$OS-$ARCH.tar ARCHIVE=$TAR.xz TMPDIR=$(mktemp -d) @@ -37,7 +37,9 @@ echo cp build/glusterd2 $TMPDIR cp build/glustercli $TMPDIR -cp -a glusterd2/volgen/templates $TMPDIR +cp build/glusterd2.toml $TMPDIR/glusterd2.toml.example +mkdir $TMPDIR/bash_completion +cp build/glustercli.sh $TMPDIR/bash_completion/glustercli.sh echo # Create release archive From afcb0c522915c3880add9693e6d49393d0c9d8b1 Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Fri, 12 Jan 2018 16:18:42 +0530 Subject: [PATCH 6/6] Remove templatesdir from e2e --- e2e/main_test.go | 6 ++---- e2e/utils_test.go | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/e2e/main_test.go b/e2e/main_test.go index db41a55fc..ffa27a863 100644 --- a/e2e/main_test.go +++ b/e2e/main_test.go @@ -9,17 +9,15 @@ import ( ) var ( - binDir, templatesDir string - functest bool + binDir string + functest bool ) func TestMain(m *testing.M) { defBinDir, _ := filepath.Abs("../build") - defTemplatesDir, _ := filepath.Abs("../glusterd2/volgen/templates") flag.BoolVar(&functest, "functest", false, "Run or skip functional test") flag.StringVar(&binDir, "bindir", defBinDir, "The directory containing glusterd2 binary") - flag.StringVar(&templatesDir, "templatesdir", defTemplatesDir, "The directory containing the graph templates") flag.Parse() if !functest { diff --git a/e2e/utils_test.go b/e2e/utils_test.go index 6bca54eb5..cdd52820a 100644 --- a/e2e/utils_test.go +++ b/e2e/utils_test.go @@ -113,8 +113,7 @@ func spawnGlusterd(configFilePath string, cleanStart bool) (*gdProcess, error) { g.Cmd = exec.Command(path.Join(binDir, "glusterd2"), "--config", configFilePath, "--logdir", path.Join(g.Workdir, "log"), - "--logfile", "glusterd2.log", - "--templatesdir", templatesDir) + "--logfile", "glusterd2.log") if err := g.Cmd.Start(); err != nil { return nil, err