commit:     a4c3e76f042074370e93beb05796a25da93574a1
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 15 19:38:15 2024 +0000
Commit:     Florian Schmaus <flow <AT> gentoo <DOT> org>
CommitDate: Mon Jul 15 19:38:15 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a4c3e76f

app-misc/openhab-bin: add update logic

Closes: https://bugs.gentoo.org/935737
Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>

 app-misc/openhab-bin/openhab-bin-4.1.2.ebuild | 29 +++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/app-misc/openhab-bin/openhab-bin-4.1.2.ebuild 
b/app-misc/openhab-bin/openhab-bin-4.1.2.ebuild
index 9c559963aaa1..9b1c384fe722 100644
--- a/app-misc/openhab-bin/openhab-bin-4.1.2.ebuild
+++ b/app-misc/openhab-bin/openhab-bin-4.1.2.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=8
 
-inherit systemd tmpfiles
+inherit edo systemd tmpfiles
 
 MY_PN=${PN%-bin}
 MY_P=${MY_PN}-${PV}
@@ -15,11 +15,13 @@ SRC_URI="
        
https://raw.githubusercontent.com/openhab/openhab-linuxpkg/10061acd36524afb12a033fea6dcf142b399bf56/resources/usr/bin/openhab-cli
                 -> openhab-cli-2024-01-14
 "
-KEYWORDS="~amd64 ~arm64"
 
+S="${WORKDIR}"
 LICENSE="EPL-2.0"
 SLOT="0"
 
+KEYWORDS="~amd64 ~arm64"
+
 MY_JAVA_DEPEND=">=virtual/jre-17"
 
 # app-arch/zip: used by "openhab-cli backup"
@@ -32,8 +34,6 @@ RDEPEND="
 
 BDEPEND="app-arch/unzip"
 
-S="${WORKDIR}"
-
 src_compile() {
        :
 }
@@ -100,4 +100,25 @@ EOF
 
 pkg_postinst() {
        tmpfiles_process openhab.conf
+
+       if [[ -z ${REPLACING_VERSIONS} && -z ${OPENHAB_POSTINST_UPDATE} ]]; then
+          return
+       fi
+
+       if [[ -d "${EROOT}"/run/systemd/system ]]; then
+               if systemctl is-active --quiet openhab; then
+                       local openhab_service_active=1
+                       einfo "Restarting OpenHAB service due to version update"
+                       edob systemctl daemon-reload
+                       edob systemctl stop openhab
+               fi
+
+               echo y | edob -m "Cleaning OpenHAB cache" \
+                                         openhab-cli clean-cache
+               assert "Failed to clean OpenHAB cache"
+
+               if [[ -v openhab_service_active ]]; then
+                       edob systemctl start openhab
+               fi
+       fi
 }

Reply via email to