abinfo "Generate completions and manpages ..."
mkdir -pv "$SRCDIR"/completions
COMPLETE=bash "$PKGDIR"/usr/bin/oma > "$SRCDIR"/completions/oma.bash
COMPLETE=zsh "$PKGDIR"/usr/bin/oma > "$SRCDIR"/completions/_oma
COMPLETE=fish "$PKGDIR"/usr/bin/oma > "$SRCDIR"/completions/oma.fish
# FIXME: Replace with a more generative routine.
for genlang in en_US zh_CN zh_TW; do
	env LANG="${genlang}" "$PKGDIR"/usr/bin/oma generate-manpages
done

if ! ab_match_archgroup retro; then
	abinfo "Installing command-not-found handler shell script to /etc/bashrc.d ..."
	mkdir -pv "$PKGDIR"/etc/bashrc.d
	cp -v "$SRCDIR"/data/command-not-found/command-not-found.sh \
		"$PKGDIR"/etc/bashrc.d/command-not-found.sh
fi

abinfo "Installing command-not-found handler (bash) ..."
mkdir -pv "$PKGDIR"/etc/profile.d
cp -v "$SRCDIR"/data/command-not-found/command-not-found.sh \
	"$PKGDIR"/etc/profile.d/command-not-found.sh

abinfo "Installing command-not-found handler (fish) ..."
mkdir -pv "$PKGDIR"/usr/share/fish/vendor_conf.d/
cp -v "$SRCDIR"/data/command-not-found/command-not-found.fish \
	"$PKGDIR"/usr/share/fish/vendor_conf.d/command-not-found.fish

abinfo "Installing man to /usr/share/man/man1 ..."
mkdir -pv "$PKGDIR"/usr/share/man/man1
mv -v "$SRCDIR"/man/en_US/* \
	"$SRCDIR"/man/
rm -rv "$SRCDIR"/man/en_US
# FIXME: Replace with a more generative routine.
for manlang in zh_CN zh_TW; do
	mkdir -pv "$PKGDIR"/usr/share/man/${manlang}/man1
	cp -av "$SRCDIR"/man/${manlang}/* \
		"$PKGDIR"/usr/share/man/${manlang}/man1
done
cp -av "$SRCDIR"/man/*.1 \
	"$PKGDIR"/usr/share/man/man1/

abinfo "Installing Policykit config file ..."
mkdir -pv "$PKGDIR"/usr/share/polkit-1/actions
cp -v "$SRCDIR"/data/policykit/io.aosc.oma.apply.policy \
	"$PKGDIR"/usr/share/polkit-1/actions

abinfo "Installing bash completions ..."
mkdir -pv "$PKGDIR"/usr/share/bash-completion/completions
cp -v "$SRCDIR"/completions/oma.bash \
	"$PKGDIR"/usr/share/bash-completion/completions/oma.bash

abinfo "Installing zsh completions ..."
mkdir -pv "$PKGDIR"/usr/share/zsh/functions/Completion/Linux
cp -v "$SRCDIR"/completions/_oma \
	"$PKGDIR"/usr/share/zsh/functions/Completion/Linux/_oma

abinfo "Installing fish completions ..."
mkdir -pv "$PKGDIR"/usr/share/fish/vendor_completions.d/
cp -v "$SRCDIR"/completions/oma.fish \
	"$PKGDIR"/usr/share/fish/vendor_completions.d/oma.fish

abinfo "Installing config file ..."
cp -v "$SRCDIR"/data/config/oma.toml \
	"$PKGDIR"/etc/oma.toml
install -Dvm644 "$SRCDIR"/data/apt.conf.d/50oma.conf \
	-t "$PKGDIR"/etc/apt/apt.conf.d

abinfo "Installing D-Bus config file ..."
install -Dvm644 "$SRCDIR"/data/dbus/oma-dbus.conf \
	-t "$PKGDIR"/usr/share/dbus-1/system.d
