Skip to content

Instantly share code, notes, and snippets.

@mklymyshyn
Created April 10, 2012 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mklymyshyn/2353046 to your computer and use it in GitHub Desktop.
Save mklymyshyn/2353046 to your computer and use it in GitHub Desktop.
Build AvocadoDB on Ubuntu
SHELL=/bin/bash
DST_ID=avocadodb
REPO=git://github.com/triAGENS/AvocadoDB.git
# defaults
BASE_DIR=$(HOME)/_build/$(DST_ID)
DST_DIR=/usr/local/_build/$(DST_ID)
DB_DIR=/tmp/vocabase
PIDFILE=$(DST_DIR)/app.pid
LOGFILE=$(DST_DIR)/output.log
HISTORY=$(BASE_DIR)/latest-build-hash
LAST_BUILT_COMMIT=$(shell cat $(HISTORY))
LAST_COMMIT=$(shell git ls-remote $(REPO) | head -n 1 | awk '{print $$1}')
.PHONY: install update clone configure build all stop start
clone:
cd `dirname $(BASE_DIR)` && \
git clone $(REPO) $(DST_ID) || echo "Project already clonned"
update:
cd $(BASE_DIR) && \
git pull $(REPO)
@echo Checking for updated HEAD $(LAST_COMMIT)
if [[ "$(LAST_COMMIT)" == "$(LAST_BUILT_COMMIT)" ]]; then exit 1; fi
echo "$(LAST_COMMIT)" > $(HISTORY)
configure:
cd $(BASE_DIR) && ./configure --prefix=$(DST_DIR)
build:
cd $(BASE_DIR) && make
install:
cd $(BASE_DIR) && make install
cd $(BASE_DIR) && make clean
start:
@echo Cleaning up
[ -d "$(DB_DIR)" ] && rm -rf $(DB_DIR) || echo "Directory $(DB_DIR) already cleaned up"
mkdir $(DB_DIR)
@echo Starting...
bash -c '$(DST_DIR)/sbin/avocado $(DB_DIR) 1> $(LOGFILE) & echo $$! > $(PIDFILE) &'
@echo Started
@echo DB Dir: $(DB_DIR)
@echo Logs are in $(LOGFILE)
@echo PID File in $(PIDFILE)
stop:
kill `cat $(PIDFILE)`
@echo Stopped
all: clone update configure build install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment