#!/usr/bin/make -f
DEST=$(CURDIR)/debian/leafview
UPSTREAM=$(CURDIR)/upstream-root
%:
	dh $@
override_dh_auto_build:
override_dh_auto_install:
	install -d $(DEST)/usr/lib/leafview $(DEST)/usr/bin $(DEST)/usr/share/icons
	install -m 0644 $(UPSTREAM)/opt/LeafView/resources/app.asar $(DEST)/usr/lib/leafview/app.asar
	cp -a $(UPSTREAM)/opt/LeafView/resources/app.asar.unpacked $(DEST)/usr/lib/leafview/
	printf '%s\n' '#!/bin/sh' 'set -eu' 'unset ELECTRON_RUN_AS_NODE' 'exec /usr/lib/electron-runtime-44/electron /usr/lib/leafview/app.asar "$$@"' > $(DEST)/usr/bin/leafview
	chmod 0755 $(DEST)/usr/bin/leafview
	install -D -m 0644 debian/leafview.desktop $(DEST)/usr/share/applications/leafview.desktop
	cp -a $(UPSTREAM)/usr/share/icons/hicolor $(DEST)/usr/share/icons/
	test -s $(DEST)/usr/share/icons/hicolor/256x256/apps/leafview.png
	test ! -e $(DEST)/usr/lib/leafview/app-update.yml
	! find $(DEST)/usr/lib/leafview -type f \( -name electron -o -name chrome-sandbox -o -name chrome_crashpad_handler -o -name resources.pak -o -name libffmpeg.so -o -name '*.node' \) -print -quit | grep -q .
override_dh_auto_test:
	# Covered by test/test-shared-electron-leafview.sh.

