LogoKolab Groupware OBS > Projects
Log In

View File debian.rules of Package guam-selfcontained (Project Kolab:Winterfell)

#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

DESTDIR   = $(CURDIR)/debian/guam

%:
	dh $@ --with=systemd

override_dh_auto_build:
	export DEBUG=1
	export HEX_OFFLINE=true
	export REBAR_CACHE_DIR="cache/rebar3/"

	# Rebuild all beam files (The otp version from the tarball may not match)
	rm -rf _build
	./rebar3 compile

	./rebar3 release \
		--dev-mode false \
		--relname guam \
		--relvsn $(DEB_VERSION_UPSTREAM) \
		--verbose

override_dh_auto_clean:
    # do nothing, rebar3 clean would clear the artifacts that we need above
    #./rebar3 clean || :

override_dh_auto_test:
	export DEBUG=1
	export HEX_OFFLINE=true
	export REBAR_CACHE_DIR="cache/rebar3/"
	./rebar3 eunit -v || :
	./rebar3 ct -v || :

override_dh_auto_install:
	mkdir -p $(DESTDIR)/usr/sbin \
		$(DESTDIR)/etc/guam \
		$(DESTDIR)/lib/systemd/system \
		$(DESTDIR)/var/log/ \
		$(DESTDIR)/usr/lib/erlang/lib/kolab_guam-$(DEB_VERSION_UPSTREAM)/ \
		$(DESTDIR)/usr/lib/erlang/bin \
		$(DESTDIR)/var/log/guam
	chmod o= $(DESTDIR)/var/log/guam

	# Service scripts
	install -p -m 644 contrib/guam.service \
			$(DESTDIR)/lib/systemd/system/guam.service

	rm _build/default/rel/guam/releases/$(DEB_VERSION_UPSTREAM)/sys.config
	rm _build/default/rel/guam/releases/$(DEB_VERSION_UPSTREAM)/vm.args

	cp -a _build/default/rel/guam/releases \
		$(DESTDIR)/usr/lib/erlang/lib/kolab_guam-$(DEB_VERSION_UPSTREAM)/

	# Configuration
	if [ -f "/etc/plesk-release" ]; then \
		cp ../SOURCES/plesk.sys.config \
			$(DESTDIR)/etc/guam/sys.config ; \
	else \
		sed -i -e 's/pki\/tls\/private\/localhost\.pem/ssl\/certs\/ssl-cert-snakeoil.pem/' \
			-e 's/pki\/tls\/private\/localhost\.ca\.pem/ssl\/certs\/ssl-cert-snakeoil.pem/' \
			-e 's/pki\/tls\/private\/localhost\.key/ssl\/private\/ssl-cert-snakeoil.key/' \
			_build/default/rel/guam/etc/sys.config ; \
		cp _build/default/rel/guam/etc/sys.config \
			$(DESTDIR)/etc/guam/sys.config ; \
	fi

	ln -s ../../../../../../../etc/guam/sys.config \
		$(DESTDIR)/usr/lib/erlang/lib/kolab_guam-$(DEB_VERSION_UPSTREAM)/releases/$(DEB_VERSION_UPSTREAM)/sys.config

	cp _build/default/rel/guam/vm.args $(DESTDIR)/etc/guam/vm.args

	ln -s ../../../../../../../etc/guam/vm.args \
		$(DESTDIR)/usr/lib/erlang/lib/kolab_guam-$(DEB_VERSION_UPSTREAM)/releases/$(DEB_VERSION_UPSTREAM)/vm.args

	ln -s ../../../../../var/log/guam $(DESTDIR)/usr/lib/erlang/lib/kolab_guam-$(DEB_VERSION_UPSTREAM)/log

	cp -a _build/default/rel/guam/bin \
		$(DESTDIR)/usr/lib/erlang/lib/kolab_guam-$(DEB_VERSION_UPSTREAM)/

	# Remove the sources
	find _build/default/rel/guam/lib/ -type d -name "src" -exec rm -Rf {} +

	# Copy over all lib dirs
	cp -av _build/default/rel/guam/lib $(DESTDIR)/usr/lib/erlang/lib/kolab_guam-$(DEB_VERSION_UPSTREAM)/lib

	# Copy over the release directory as well
	cp -av _build/default/rel/guam/releases/ $(DESTDIR)/usr/lib/erlang/lib/kolab_guam-$(DEB_VERSION_UPSTREAM)/

	echo '#!/bin/bash' > $(DESTDIR)/usr/sbin/guam
	echo 'exec /usr/lib/erlang/lib/kolab_guam-$(DEB_VERSION_UPSTREAM)/bin/guam $$*' \
		 >> $(DESTDIR)/usr/sbin/guam
	chmod +x $(DESTDIR)/usr/sbin/guam

	ln -s ../lib/kolab_guam-$(DEB_VERSION_UPSTREAM)/bin/guam \
		$(DESTDIR)/usr/lib/erlang/bin/kolab_guam

override_dh_gencontrol:
	dh_gencontrol