abinfo "Deploying executable symlinks ..."
mkdir -pv "$PKGDIR"/usr/bin
for bin in \
	$(find "$PKGDIR"/usr/lib/postgresql-${MAJORVER}/bin -type f -executable -printf '%P\n')
	do
	ln -sv ../lib/postgresql-"$MAJORVER"/bin/"$bin" \
		"$PKGDIR"/usr/bin/"$bin"-"$MAJORVER"
done

abinfo "Deploying files ..."
for f in $(find "$SRCDIR"/autobuild -maxdepth 1 -type f -name '*.in' -printf '%P\n') ; do
	sed -e "s|@MAJORVER@|${MAJORVER}|g" \
		-e "s|@PREVMAJORVER@|$((MAJORVER -1))|g" \
		"$SRCDIR"/autobuild/$f \
		> "$SRCDIR"/autobuild/${f%%.in}
done
install -Dvm755 "$SRCDIR"/autobuild/postgresql-check-db-dir \
	"$PKGDIR"/usr/lib/postgresql-"$MAJORVER"/bin/postgresql-check-db-dir
install -Dvm644 "$SRCDIR"/autobuild/postgresqld.service \
	"$PKGDIR"/usr/lib/systemd/system/postgresqld-"$MAJORVER".service
install -Dvm644 "$SRCDIR"/autobuild/postgresqld.tmpfiles \
	"$PKGDIR"/usr/lib/tmpfiles.d/postgresqld-"$MAJORVER".conf
install -Dvm644 "$SRCDIR"/autobuild/postgresql.sysusers \
	"$PKGDIR"/usr/lib/sysusers.d/postgresql-"$MAJORVER".conf
