#!/usr/bin/make -f

export GEM2DEB_TEST_RUNNER = --check-dependencies
export DH_RUBY = --gem-install

major-rubyversion=$(shell ruby -v | cut -d ' ' -f 2 | cut -d '.' -f 1)
minor-rubyversion=$(shell ruby -v | cut -d ' ' -f 2 | cut -d '.' -f 2)
minormax-rubyversion=$(shell echo $$(( $(minor-rubyversion) + 1 )) )


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

execute_after_dh_auto_clean:
	rm -rf vendor/bundle

override_dh_auto_install:
	# no gemspec, no auto install

override_dh_auto_build:
	bundle config set --local path vendor/bundle
	bundle config set --local without test
	bundle install
	bundle config --local frozen true

override_dh_gencontrol:
	dh_gencontrol -- -Vruby:Depends="ruby (>= 1:$(major-rubyversion).$(minor-rubyversion)), ruby (<< 1:$(major-rubyversion).$(minormax-rubyversion))"

execute_after_dh_fixperms:
	chmod 600 debian/beef-xss/etc/beef-xss/config.yaml
	chmod 700 debian/beef-xss/var/lib/beef-xss
