#!/usr/bin/make -f
# -*- makefile-gmake -*-
#
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# This has to be exported to make some magic below work.
export DH_OPTIONS

%:
	dh $@

override_dh_auto_build:
	gpg \
	  --no-default-keyring \
	  --keyring ./apache-arrow-apt-source.kbx \
	  --import KEYS
	gpg \
	  --no-default-keyring \
	  --keyring ./apache-arrow-apt-source.kbx \
	  --armor \
	  --export > apache-arrow-apt-source.asc

	( \
	  distribution=$$(lsb_release --id --short | tr 'A-Z' 'a-z'); \
	  code_name=$$(lsb_release --codename --short); \
	  echo "Types: deb deb-src"; \
	  echo "URIs: https://packages.apache.org/artifactory/arrow/$${distribution}/"; \
	  echo "Suites: $${code_name}"; \
	  echo "Components: main"; \
	  echo "Signed-By: /usr/share/keyrings/apache-arrow-apt-source.asc"; \
	) > apache-arrow.sources

override_dh_install:
	install -d debian/tmp/usr/share/keyrings/
	install -m 0644 apache-arrow-apt-source.asc \
	  debian/tmp/usr/share/keyrings/

	install -d debian/tmp/etc/apt/sources.list.d/
	install -m 0644 apache-arrow.sources \
	  debian/tmp/etc/apt/sources.list.d/

	dh_install
