#!/usr/bin/make -f
P := debian/ps3-system

%:
	dh $@

override_dh_auto_install:
	install -D -m 644 files/network/20-ps3-wired.network $(P)/usr/lib/systemd/network/20-ps3-wired.network
	install -D -m 644 files/network/21-ps3-wired-nm.network $(P)/usr/lib/systemd/network/21-ps3-wired-nm.network
	install -D -m 644 files/network/ps3-nfsroot-network.service $(P)/usr/lib/systemd/system/ps3-nfsroot-network.service
	install -d $(P)/usr/lib/ps3/sbin
	install -m 755 files/sbin/* $(P)/usr/lib/ps3/sbin/
	install -d $(P)/usr/sbin
	ln -s ../lib/ps3/sbin/ps3-gameos-mount $(P)/usr/sbin/ps3-gameos-mount
	ln -s ../lib/ps3/sbin/walnut-firstboot $(P)/usr/sbin/walnut-firstboot
	ln -s ../lib/ps3/sbin/walnut-bugreport $(P)/usr/sbin/walnut-bugreport
	install -D -m 644 debian/ps3vram.conf $(P)/usr/lib/modprobe.d/ps3vram.conf
	install -D -m 644 debian/60-ps3-memory.conf $(P)/usr/lib/sysctl.d/60-ps3-memory.conf
	install -D -m 644 debian/00-ps3.conf $(P)/usr/lib/NetworkManager/conf.d/00-ps3.conf
	install -D -m 644 debian/70-ds3-pair.rules $(P)/usr/lib/udev/rules.d/70-ds3-pair.rules
	install -D -m 644 debian/sshd-ps3.conf $(P)/etc/ssh/sshd_config.d/ps3.conf
	install -D -m 644 debian/kernel-img.conf $(P)/etc/kernel-img.conf
	install -D -m 644 files/apt/ps3.sources $(P)/etc/apt/sources.list.d/ps3.sources
	install -D -m 644 files/apt/debian.sources $(P)/etc/apt/sources.list.d/debian.sources
	install -D -m 644 files/apt/ps3.pref $(P)/etc/apt/preferences.d/ps3
	install -D -m 644 files/sound/alsoft.conf $(P)/etc/xdg/alsoft.conf

# Our units: enabled; swap and the boot-time oneshots are never stopped or restarted by upgrades
override_dh_installsystemd:
	dh_installsystemd --name=ssh-hostkeys --no-start
	dh_installsystemd --name=ps3gpu-nodes --no-stop-on-upgrade --no-restart-after-upgrade
	dh_installsystemd --name=ps3-swap --no-start --no-stop-on-upgrade --no-restart-after-upgrade
	dh_installsystemd --name=ps3-vswap --no-start --no-stop-on-upgrade --no-restart-after-upgrade
	dh_installsystemd --name=ps3-shutdown-log --no-stop-on-upgrade --no-restart-after-upgrade
	dh_installsystemd --name=walnut-firstboot --no-start
