Commit 9fa5e97a authored by Heinz N. Gies's avatar Heinz N. Gies

dist support

parent 0a45db9d
......@@ -3,5 +3,4 @@ ui:
LEIN_ROOT=1 lein less once
LEIN_ROOT=1 lein with-profile rel cljsbuild once
package: ui
$(MAKE) -C rel/pkg package
generic/rel: ui
VERSION=0.9.3
COMPONENT_INTERNAL=cerberus
COMPONENT=fifo-cerberus
REBAR = $(shell pwd)/rebar3
REBAR_VSN = $(shell erl -noshell -eval '{ok, F} = file:consult("rebar.config"), [{release, {_, Vsn}, _}] = [O || {relx, [O | _]} <- F], io:format("~s", [Vsn]), init:stop().')
VARS_VSN = $(shell grep 'bugsnag_app_version' rel/vars.config | sed -e 's/.*,//' -e 's/[^0-9.p]//g' -e 's/[.]$$//')
APP_VSN = $(shell grep vsn apps/$(APP)/src/$(APP).app.src | sed 's/[^0-9.p]//g')
include config.mk
compile: $(REBAR) .git/hooks/pre-commit
$(REBAR) compile
.git/hooks/pre-commit: hooks/pre-commit
[ -f .git/hooks ] && cp hooks/pre-commit .git/hooks || true
pre-commit: test-scripts test-vsn lint xref dialyzer test
dialyzer: $(REBAR)
$(REBAR) dialyzer
xref: $(REBAR)
$(REBAR) xref
test-scripts:
for i in rel/files/*; do (head -1 $$i | grep -v sh > /dev/null) || bash -n $$i || exit 1; done;
test: $(REBAR)
$(REBAR) eunit
lint: $(REBAR)
$(REBAR) as lint lint
$(REBAR):
cp `which rebar3` $(REBAR)
upgrade: $(REBAR)
$(REBAR) upgrade
$(MAKE) tree
update: $(REBAR)
$(REBAR) update
rebar.lock: rebar.config $(REBAR)
$(REBAR) compile
tree: $(REBAR) rebar.lock
$(REBAR) tree | grep -v '=' | sed 's/ (.*//' > tree
tree-diff: tree
git diff test -- tree
update-fifo.mk:
cp _build/default/lib/fifo_utils/priv/fifo.mk .
###
### Packaging
###
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_V6 := $(shell sh -c 'uname -v 2>/dev/null | cut -c-6 || echo not')
ifeq ($(uname_S),Darwin)
PLATFORM = darwin
REBARPROFILE = darwin
export REBARPROFILE
endif
ifeq ($(uname_S),FreeBSD)
PLATFORM = freebsd
REBARPROFILE = freebsd
export REBARPROFILE
endif
ifeq ($(uname_V6),joyent)
PLATFORM = smartos
REBARPROFILE = smartos
export REBARPROFILE
endif
dist: ${PLATFORM} ;
generic/rel: version_header
$(REBAR) as ${REBARPROFILE} compile
$(REBAR) as ${REBARPROFILE} release
freebsd: ${PLATFORM}/rel
$(MAKE) -C rel/pkgng package
smartos: ${PLATFORM}/rel
$(MAKE) -C rel/pkg package
darwin: ${PLATFORM}/rel
freebsd/rel: generic/rel
smartos/rel: generic/rel
darwin/rel: generic/rel
dist-help:
@echo "FiFo dist tool"
@echo "You are running this on: ${PLATFORM}"
@echo
@echo "Currently supported platforms are: FreeBSD, SmartOS, Darwin/OSX"
@echo
@echo "SmartOS:"
@echo " rebar profile: smartos $(shell if grep profiles -A12 rebar.config | grep smartos > /dev/null; then echo OK; else echo MISSING; fi)"
@echo " packaging makefile: rel/pkg/Makefile $(shell if [ -f rel/pkg/Makefile ]; then echo OK; else echo MISSING; fi)"
@echo "FreeBSD:"
@echo " rebar profile: freebsd $(shell if grep profiles -A12 rebar.config | grep freebsd > /dev/null; then echo OK; else echo MISSING; fi)"
@echo " packaging makefile: rel/pkgng/Makefile $(shell if [ -f rel/pkgng/Makefile ]; then echo OK; else echo MISSING; fi)"
@echo "Darwin:"
@echo " rebar profile: darwin $(shell if grep profiles -A12 rebar.config | grep darwin > /dev/null; then echo OK; else echo MISSING; fi)"
@echo " packaging makefile: - no packaing -"
###
### Docs
###
docs:
$(REBAR) edoc
###
### Version
###
build-vsn:
@echo "$(REBAR_VSN)"
vsn:
@echo "## Config:"
@echo "$(VERSION)"
@echo "## apps/$(APP)/src/$(APP).app.src"
@echo "$(APP_VSN)"
@echo "## rebar.config"
@echo "$(REBAR_VSN)"
@echo "## rel/vars.config"
@echo "$(VARS_VSN)"
test-vsn:
@echo "Testing against package version: $(VERSION)"
@[ "$(VERSION)" = "$(APP_VSN)" ] && echo " - App version ok: $(APP_VSN)" || (echo "App version out of date" && false)
@[ "$(VERSION)" = "$(REBAR_VSN)" ] && echo " - Rebar version ok: $(PKG_VSN)" || (echo "Package version out of date" && false)
@[ "$(VERSION)" = "$(VARS_VSN)" ] && echo " - Vars version ok: $(VARS_VSN)" || (echo "Vars version out of date" && false)
VERSION=0.9.3
COMPONENT=fifo-cerberus
include ../../config.mk
include pkg.mk
.PHONY: package prepare clean
......
name: cerberus
version: "__VNS__"
origin: projectfifo/cerberus
comment: "Project FiFo's UI."
desc: "Project FiFo's UI."
maintainer: info@project-fifo.net
www: https://project-fifo.net
prefix: /
#!/usr/bin/bash
USER=sniffle
GROUP=$USER
echo Creating group ...
getent group $GROUP >/dev/null 2>&1 || pw groupadd $GROUP
echo Creating user ...
id $USER >/dev/null 2>&1 || pw useradd $USER -g $GROUP -d /data/$USER -s /usr/sbin/nologin
echo Creating directories ...
mkdir -p /data/$USER/db/ring
mkdir -p /data/$USER/etc
mkdir -p /data/$USER/log/sasl
chown -R $USER:$GROUP /data/$USER
mkdir -p /tmp/$USER
chown -R $USER:$GROUP /tmp/$USER/
echo Trying to guess configuration ...
IP=$(ifconfig $(netstat -r | grep default | awk '{ print $4 }') | grep 'inet' | awk -F ' ' '{ print $2 }')
DISTCONFFILE=/usr/local/lib/sniffle/etc/sniffle.conf
CONFFILE=/data/sniffle/etc/sniffle.conf
if [ ! -f "${CONFFILE}" ]
then
echo "Creating new configuration from example file."
cp ${DISTCONFFILE} ${CONFFILE}.example
cp ${CONFFILE}.example ${CONFFILE}
/usr/bin/sed -i bak -e "s/127.0.0.1/${IP}/g" ${CONFFILE}
else
echo "Please make sure you update your config according to the update manual!"
fi
OT=/data/sniffle/etc/rules.ot
if [ ! -f "${OT}" ]
then
echo "none() -> drop." > ${OT}
fi
+MANIFEST
deploy
*.txz
INSTALL_DIR=usr/local/lib
DEPS="coreutils" "sudo"
REBARPROFILE ?= default
include ../../config.mk
include pkgng.mk
.PHONY: package prepare clean
prepare:
-rm -r $(STAGE_DIR)
mkdir -p $(STAGE_DIR)/$(INSTALL_DIR)/$(COMPONENT)
cp -r ../../resources/public/* $(STAGE_DIR)/$(INSTALL_DIR)/$(COMPONENT)
cp ../../resources/index.html $(STAGE_DIR)/$(INSTALL_DIR)/$(COMPONENT)
cp ../../LICENSE* $(STAGE_DIR)/$(INSTALL_DIR)/$(COMPONENT)
TARGET_DIR ?=/opt/local
FILE ?=$(COMPONENT)-$(VERSION)$(SUFFIX)
BLOCK_SIZE ?=65536
STAGE_DIR ?=deploy
TMP_DIR ?=tmp
PKG_CATEGORY ?=fifo
PKG_HOMEPAGE ?=https://project-fifo.net
.PHONY: package_list dep_list clean-pkg
package: prepare $(STAGE_DIR)/+MANIFEST $(STAGE_DIR)/plist
cp +POST_INSTALL $(STAGE_DIR)/
pkg create -m $(STAGE_DIR)/ -r $(STAGE_DIR)/ -p $(STAGE_DIR)/plist -o .
$(STAGE_DIR)/plist:
-rm $(STAGE_DIR)/plist || true
(cd $(STAGE_DIR); find * -type f | sort | grep -v '^+' | grep -v '^plist$$') >> $(STAGE_DIR)/plist
clean-pkg:
$(STAGE_DIR)/+MANIFEST: +MANIFEST.in
sed -e 's/__VNS__/${VERSION}/' +MANIFEST.in > $(STAGE_DIR)/+MANIFEST
( echo 'deps: { '; \
for dep in ${DEPS}; do \
pkg query --glob " \"%n\" : { \"origin\" : \"%o\", \"version\" : \"%v\" }," "$$dep"; \
done ; \
echo '}' ) >> $(STAGE_DIR)/+MANIFEST
tmp/$(FILE).tgz: dep_list package_list +MANIFEST
-rm -r tmp
mkdir tmp
pkg_create -i install.sh -k deinstall.sh -D displayfile -B build-info -c comment -d description -f packlist -I $(TARGET_DIR) -p $(STAGE_DIR) -U tmp/$(FILE).tgz
clean: clean-pkg
-rm -r tmp build-info packlist
-rm -r $(STAGE_DIR)
-rm *.tgz
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment