#!/usr/bin/make -f
# -*- makefile -*-
include /usr/share/cdbs/1/rules/debhelper.mk

SHELL := /bin/bash
BUILD_ROOT=$(CURDIR)/debian/$(cdbs_curpkg)
rubylibdir=$(shell ruby -rrbconfig -e "puts RbConfig::CONFIG['vendordir']")
DIST := $(shell lsb_release -i | awk '{print tolower($$3)}')
RELEASE := $(shell lsb_release -r | awk '{print $$2}')
export DESTDIR=$(BUILD_ROOT)
export prefix=/usr
export bindir=/usr/bin
export rubylibdir
export confdir=/etc
export datadir=$(prefix)/share
export localstatedir=/var
export sharedstatedir=/var/lib
export realname=puppetserver
export EZ_VERBOSE=1

install/puppetserver::
	bash install.sh install_deb
	if [[ ${DIST} == debian ]] ; then \
		if [[ $$(echo "${RELEASE}>=7" | bc -l) -eq 1 || ${RELEASE} == testing || ${RELEASE} == unstable ]] ; then \
			bash install.sh logrotate ; \
		else \
			bash install.sh logrotate_legacy ; \
		fi ; \
	elif [[ ${DIST} == ubuntu ]] ; then \
		if [[ $$(echo "${RELEASE}>=13.04" | bc -l) -eq 1 ]] ; then \
			bash install.sh logrotate ; \
		else \
			bash install.sh logrotate_legacy ; \
		fi ; \
	fi

