#!/usr/bin/make -f

# Verbose mode
# export DH_VERBOSE=1

RELEASE_VERSION := 2005

%:
	dh $@ --with python2,javahelper

override_dh_auto_build:
	[ -d excluded_files/cobbler ] || mkdir -p excluded_files/cobbler
	[ -d excluded_files/koan ] || mkdir -p excluded_files/koan
	mv -f cobbler/sub_process.py excluded_files/cobbler
	mv -f koan/sub_process.py excluded_files/koan
	mv -f koan/opt_parse.py excluded_files/koan
	mv -f koan/text_wrap.py excluded_files/koan
	python setup.py build
	ant -f cobbler4j/build.xml

override_dh_auto_clean:
	dh_auto_clean
	ant -f cobbler4j/build.xml clean
	if [ -d excluded_files/cobbler ] ; then \
      mv excluded_files/cobbler/* cobbler ;\
    fi
	if [ -d excluded_files/koan ] ; then \
      mv excluded_files/koan/* koan ;\
    fi
	if [ -d excluded_files ] ; then \
      rm -rf excluded_files ;\
    fi

override_dh_auto_test:
	nosetests cobbler/*.py || true

override_dh_auto_install:
	python setup.py install -f --install-layout=deb --root=$(CURDIR)/debian/tmp

get-orig-source:
	python setup.py sdist
	tar -zxvf $(CURDIR)/dist/cobbler-2.1.0.tar.gz -C $(CURDIR)/dist
	rm $(CURDIR)/dist/cobbler-2.1.0.tar.gz
	mkdir -p $(CURDIR)/dist/cobbler-2.1.0/cobbler4j
	cp -rp $(CURDIR)/cobbler4j/* $(CURDIR)/dist/cobbler-2.1.0/cobbler4j
	mv $(CURDIR)/dist/cobbler-2.1.0 $(CURDIR)/dist/cobbler-2.1.0~bzr$(RELEASE_VERSION)
	cd $(CURDIR)/dist ; tar zcvf ../../cobbler-2.1.0~bzr$(RELEASE_VERSION).orig.tar.gz cobbler-2.1.0~bzr$(RELEASE_VERSION)
