Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #524 from kshlm/update-build-scripts
Browse files Browse the repository at this point in the history
Update build scripts
  • Loading branch information
kshlm authored Jan 12, 2018
2 parents 9cc929f + 8568a60 commit 8b4b8a9
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 58 deletions.
20 changes: 8 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,34 @@ GD2 = glusterd2

BUILDDIR = build
BASH_COMPLETIONDIR = /etc/bash_completion.d

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)

CLI_BASH_COMPLETION_GEN_BIN = $(BUILDDIR)/generate_bash_completion
CLI_BASH_COMPLETION_BUILD = $(BUILDDIR)/$(CLI_BIN).sh
CLI_BASH_COMPLETION_INSTALL = $(BASH_COMPLETIONDIR)/$(CLI_BIN).sh
CLI_BASH_COMPLETION_INSTALL = $(DESTDIR)$(BASH_COMPLETIONDIR)/$(CLI_BIN).sh

GD2_CONF = $(GD2).toml
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
GD2CONF_INSTALL = $(DESTDIR)$(SYSCONFDIR)/$(GD2)/$(GD2_CONF)

GD2STATEDIR = $(LOCALSTATEDIR)/$(GD2)
GD2LOGDIR = $(LOGDIR)/$(GD2)
GD2TEMPLATESDIR = $(TEMPLATES_INSTALL)

PLUGINS ?= yes

.PHONY: all build check check-go check-reqs install vendor-update vendor-install verify release check-protoc $(GD2_BIN) $(GD2_BUILD) $(CLI_BIN) $(CLI_BUILD) cli $(GD2_CONF) gd2conf test dist dist-vendor

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:
Expand Down Expand Up @@ -62,14 +60,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
install -D $(CLI_BASH_COMPLETION_BUILD) $(CLI_BASH_COMPLETION_INSTALL)
@echo

Expand Down
6 changes: 2 additions & 4 deletions e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions e2e/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions extras/make/paths.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

31 changes: 12 additions & 19 deletions extras/rpms/glusterd2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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 <[email protected]> - 4.0dev-10
- Use standard paths to build and install

* Wed Nov 08 2017 Kaushal M <[email protected]> - 4.0dev-9
- Build with vendored tarball.

Expand Down
4 changes: 0 additions & 4 deletions extras/rpms/glusterd2.toml

This file was deleted.

4 changes: 0 additions & 4 deletions glusterd2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -62,7 +61,6 @@ func parseFlags() {
flag.String("key-file", "", "Private key for the SSL/TLS certificate.")

store.InitFlags()
volgen.InitFlags()

flag.Parse()
}
Expand Down Expand Up @@ -109,8 +107,6 @@ func setDefaults() error {
}
config.SetDefault("peeraddress", host+":"+port)

volgen.SetDefaults()

return nil
}

Expand Down
2 changes: 0 additions & 2 deletions scripts/gen-gd2conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,5 +19,4 @@ cat >$OUTPUT <<EOF
localstatedir = "$GD2STATEDIR"
logdir = "$GD2LOGDIR"
logfile = "$GD2.log"
templatesdir = "$GD2TEMPLATESDIR"
EOF
8 changes: 5 additions & 3 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8b4b8a9

Please sign in to comment.