-case "${1}" in
- configure)
- if [ -d /lib/systemd/system ]
- then
- # Python packages put all data files in /usr, so we copy
- # them to /lib at install time.
- py_unit="/usr/share/doc/${pkg}/${pkg}.service"
- if [ -e "${py_unit}" ]
- then
- cp "${py_unit}" /lib/systemd/system/
+case "${pkgtype}-${1}" in
+ deb-configure | rpm-1)
+ dest_dir="/lib/systemd/system"
+ if ! [ -d "${dest_dir}" ]; then
+ exit 0
+ fi
+
+ # Find the unit file we need to install.
+ unit_file="${pkg}.service"
+ for dir in \
+ "${prefix}/share/doc/${pkg}" \
+ "${dest_dir}"; do
+ if [ -e "${dir}/${unit_file}" ]; then
+ src_dir="${dir}"
+ break