commit:     f3fdca23a349b3059cad5834e5e4fe9f945a52c6
Author:     Maciej Mrozowski <reavertm <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 12 22:51:22 2019 +0000
Commit:     Maciej Mrozowski <reavertm <AT> gentoo <DOT> org>
CommitDate: Tue Nov 12 23:50:51 2019 +0000
URL:        https://gitweb.gentoo.org/proj/kde.git/commit/?id=f3fdca23

kde-plasma/plasma-workspace: migrate {ssh,gpg}-agent scripts to new layout

Bug: https://bugs.gentoo.org/688366
Package-Manager: Portage-2.3.76, Repoman-2.3.16
Signed-off-by: Maciej Mrozowski <reavertm <AT> gentoo.org>

 .../plasma-workspace-5.17.49.9999.ebuild           | 50 ++++++++++++++++------
 .../plasma-workspace/plasma-workspace-9999.ebuild  | 50 ++++++++++++++++------
 2 files changed, 76 insertions(+), 24 deletions(-)

diff --git a/kde-plasma/plasma-workspace/plasma-workspace-5.17.49.9999.ebuild 
b/kde-plasma/plasma-workspace/plasma-workspace-5.17.49.9999.ebuild
index 317e618cc1..067f98d509 100644
--- a/kde-plasma/plasma-workspace/plasma-workspace-5.17.49.9999.ebuild
+++ b/kde-plasma/plasma-workspace/plasma-workspace-5.17.49.9999.ebuild
@@ -129,6 +129,12 @@ PATCHES=(
 
 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() {
        ecm_src_prepare
 
@@ -158,22 +164,42 @@ src_configure() {
 src_install() {
        ecm_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() {
+       ecm_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 () {
        ecm_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."
 }

diff --git a/kde-plasma/plasma-workspace/plasma-workspace-9999.ebuild 
b/kde-plasma/plasma-workspace/plasma-workspace-9999.ebuild
index fa7caa9f54..50cf5b65b4 100644
--- a/kde-plasma/plasma-workspace/plasma-workspace-9999.ebuild
+++ b/kde-plasma/plasma-workspace/plasma-workspace-9999.ebuild
@@ -126,6 +126,12 @@ PATCHES=( 
"${FILESDIR}/${PN}-5.14.2-split-libkworkspace.patch" )
 
 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() {
        ecm_src_prepare
 
@@ -156,22 +162,42 @@ src_configure() {
 src_install() {
        ecm_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() {
+       ecm_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 () {
        ecm_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."
 }

Reply via email to