#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# FTBFS if $LANG is unset
export LANG=C

%:
	dh $@ --with python2

override_dh_auto_configure:
	if [ -e wicd/wpath.py ]; then cp -pf wicd/wpath.py debian/; fi
	python setup.py configure \
		--no-install-acpi \
		--no-install-docs \
		--no-install-gnome-shell-extensions \
		--lib=/usr/share/wicd \
		--share=/usr/share/wicd \
		--wicdgroup=netdev \
		--loggroup=adm \
		--logperms=0640

override_dh_auto_build:
	dh_auto_build
	python setup.py compile_translations

override_dh_auto_clean:
	dh_auto_clean
	-find . \( -name "*.pyc" -o -name "*.pyo" \) -delete
	-rm -rf build/ init/ scripts/ translations/ install.log
	if [ -e debian/wpath.py ]; then mv -f debian/wpath.py wicd/; fi

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

	find $(CURDIR)/debian/tmp -name "*.png" -exec chmod 644 {} \;
	find $(CURDIR)/debian/tmp/etc/wicd/ -type f -exec chmod 644 {} \;
	find $(CURDIR)/debian/tmp \( -name "*.glade" -o -name "*.conf" -o -name "*.desktop" \) -exec chmod 644 {} \;

	find $(CURDIR)/debian/tmp/ -name ".empty_on_purpose" -delete

	-rm -rf $(CURDIR)/debian/tmp/var/run

override_dh_installinit:
	dh_python2 -i
	dh_installinit -i --name=wicd --restart-after-upgrade

override_dh_bugfiles:
	dh_bugfiles -A

override_dh_python2:
	dh_python2
	dh_python2 -p wicd-curses /usr/share/wicd/curses
	dh_python2 -p wicd-daemon /usr/share/wicd/daemon
	dh_python2 -p wicd-gtk /usr/share/wicd/gtk
	dh_python2 -p wicd-cli /usr/share/wicd/cli
