--- plasma-workspace-5.17.2.ebuild 2019-10-29 23:44:57.111955169 +0100 +++ plasma-workspace-5.17.2-r1.ebuild 2019-11-12 19:09:23.000724484 +0100 @@ -123,6 +123,12 @@ RESTRICT+=" test" +# used for agent scripts migration +OLDST=/etc/plasma/startup/10-agent-startup.sh +NEWST=/etc/xdg/plasma-workspace/env/10-agent-startup.sh +OLDSH=/etc/plasma/shutdown/10-agent-shutdown.sh +NEWSH=/etc/xdg/plasma-workspace/shutdown/10-agent-shutdown.sh + src_prepare() { kde5_src_prepare @@ -152,22 +158,42 @@ src_install() { kde5_src_install - # startup and shutdown scripts - insinto /etc/plasma/startup - doins "${FILESDIR}/10-agent-startup.sh" + # default startup and shutdown scripts + insinto "$(dirname ${NEWST})" + doins "${FILESDIR}/$(basename ${NEWST})" + + insinto "$(dirname ${NEWSH})" + doins "${FILESDIR}/$(basename ${NEWSH})" + fperms +x "${NEWSH}" +} + +pkg_preinst() { + kde5_pkg_preinst - insinto /etc/plasma/shutdown - doins "${FILESDIR}/10-agent-shutdown.sh" + # migrate existing agent scripts to new layout if no files there yet + if [[ -r "${EROOT}${OLDST}" && ! -f "${EROOT}${NEWST}" ]]; then + mkdir -p "${EROOT}$(dirname ${NEWST})" && cp "${EROOT}${OLDST}" "${EROOT}${NEWST}" && \ + elog "${EROOT}${OLDST} has been migrated to ${EROOT}${NEWST}, please delete old file." + fi + if [[ -r "${EROOT}${OLDSH}" && ! -f "${EROOT}${NEWSH}" ]]; then + mkdir -p "${EROOT}$(dirname ${NEWSH})" && cp "${EROOT}${OLDSH}" "${EROOT}${NEWSH}" && \ + chmod +x "${EROOT}${NEWSH}" && \ + elog "${EROOT}${OLDSH} has been migrated to ${EROOT}${NEWSH}, please delete old file." + fi } pkg_postinst () { kde5_pkg_postinst - elog "To enable gpg-agent and/or ssh-agent in Plasma sessions, do the following:" - elog " * Copy the necessary files to your home directory:" - elog " - cp /etc/plasma/startup/10-agent-startup.sh ~/.config/plasma-workspace/env/" - elog " - cp /etc/plasma/shutdown/10-agent-shutdown.sh ~/.config/plasma-workspace/shutdown/" - elog " * Edit 10-agent-startup.sh and uncomment the lines enabling ssh-agent." - elog " * In 10-agent-shutdown.sh uncomment the respective lines to properly kill" - elog " the agent when the session ends." + # warn about any leftover user scripts + if [[ -d "${EROOT}"/etc/plasma/startup && -n "$(ls "${EROOT}"/etc/plasma/startup)" ]] || \ + [[ -d "${EROOT}"/etc/plasma/shutdown && -n "$(ls "${EROOT}"/etc/plasma/shutdown)" ]]; then + elog "You appear to have scripts in ${EROOT}/etc/plasma/{startup,shutdown}." + elog "They will no longer work since plasma-workspace-5.17" + fi + + elog " * Edit ${EROOT}${NEWST} and uncomment" + elog " the lines enabling ssh-agent." + elog " * Edit ${EROOT}${NEWSH} uncomment" + elog " the respective lines to properly kill the agent when the session ends." }