#!/usr/bin/make -f

export TDIARY_DIR="$(CURDIR)/debian/tdiary-contrib/usr/share/tdiary"

%:
	dh $@ --buildsystem ruby --with ruby

override_dh_install:
	dh_install
	-find $(TDIARY_DIR) -name license.txt -exec rm {} +
	-for plugin in coderwall.rb select_style.rb ; \
	 do rm "$(TDIARY_DIR)/contrib/plugin/$$plugin"; done
	-rm "$(TDIARY_DIR)/contrib/js/yahoo_kousei.js"
	-rm "$(TDIARY_DIR)/contrib/util/image-gallery/js/SmoothGallery/scripts/mootools-1.2-more.js"
	-rm "$(TDIARY_DIR)/contrib/util/image-gallery/js/SmoothGallery/scripts/mootools-1.2.1-core-yc.js"

override_dh_fixperms:
	dh_fixperms
	## Those should be fixed in upstream...
	-for file in util/tdiary-grep/grep.rb plugin/git-register.rb plugin/windex.rb;\
	 do chmod 755 "$(TDIARY_DIR)/contrib/$$file"; done
	-for file in plugin/comment_pushbullet.rb io/dbi_io/dbi_io.rb style/hatena_style.rb io/dbi_io/README.ja io/dbi_io/tdiary_table.sql; \
	 do chmod 644 "$(TDIARY_DIR)/contrib/$$file"; done
