mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-08-01 15:07:49 +00:00
xbmc: prepare to migrate service addons to systemd
This commit is contained in:
parent
d755498b07
commit
ef978ab363
@ -449,6 +449,7 @@ post_makeinstall_target() {
|
||||
cp $PKG_DIR/scripts/xbmc-config $INSTALL/usr/lib/xbmc
|
||||
cp $PKG_DIR/scripts/xbmc-hacks $INSTALL/usr/lib/xbmc
|
||||
cp $PKG_DIR/scripts/xbmc-sources $INSTALL/usr/lib/xbmc
|
||||
cp $PKG_DIR/scripts/systemd-addon-wrapper $INSTALL/usr/lib/xbmc
|
||||
|
||||
mkdir -p $INSTALL/usr/bin
|
||||
cp $PKG_DIR/scripts/cputemp $INSTALL/usr/bin
|
||||
|
@ -0,0 +1,89 @@
|
||||
From ba7354da4a958e33928556a263e8b435da877689 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Saraev <stefan@saraev.ca>
|
||||
Date: Wed, 18 Dec 2013 21:32:31 +0200
|
||||
Subject: [PATCH] service addons: use a wrapper to setup systemd
|
||||
|
||||
---
|
||||
xbmc/addons/AddonDatabase.cpp | 3 +++
|
||||
xbmc/addons/AddonInstaller.cpp | 9 +++++++++
|
||||
xbmc/addons/AddonInstaller.h | 2 ++
|
||||
3 files changed, 14 insertions(+)
|
||||
|
||||
diff --git a/xbmc/addons/AddonDatabase.cpp b/xbmc/addons/AddonDatabase.cpp
|
||||
index 4202363..105749f 100644
|
||||
--- a/xbmc/addons/AddonDatabase.cpp
|
||||
+++ b/xbmc/addons/AddonDatabase.cpp
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "AddonDatabase.h"
|
||||
#include "addons/AddonManager.h"
|
||||
+#include "addons/AddonInstaller.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/Variant.h"
|
||||
#include "utils/StringUtils.h"
|
||||
@@ -581,6 +582,7 @@ bool CAddonDatabase::DisableAddon(const CStdString &addonID, bool disable /* = t
|
||||
boost::shared_ptr<CService> service = boost::dynamic_pointer_cast<CService>(addon);
|
||||
if (service)
|
||||
service->Stop();
|
||||
+ CAddonInstaller::Get().CallOEWrapper(addonID, true);
|
||||
}
|
||||
// restart the pvr manager when disabling a pvr add-on with the pvr manager enabled
|
||||
else if (CAddonMgr::Get().GetAddon(addonID, addon, ADDON_PVRDLL, false) && addon &&
|
||||
@@ -601,6 +603,7 @@ bool CAddonDatabase::DisableAddon(const CStdString &addonID, bool disable /* = t
|
||||
// If the addon is a service, start it
|
||||
if (CAddonMgr::Get().GetAddon(addonID, addon, ADDON_SERVICE, false) && addon && disabled)
|
||||
{
|
||||
+ CAddonInstaller::Get().CallOEWrapper(addonID, false);
|
||||
boost::shared_ptr<CService> service = boost::dynamic_pointer_cast<CService>(addon);
|
||||
if (service)
|
||||
service->Start();
|
||||
diff --git a/xbmc/addons/AddonInstaller.cpp b/xbmc/addons/AddonInstaller.cpp
|
||||
index 8c9f241..0d80537 100644
|
||||
--- a/xbmc/addons/AddonInstaller.cpp
|
||||
+++ b/xbmc/addons/AddonInstaller.cpp
|
||||
@@ -70,6 +70,13 @@ CAddonInstaller &CAddonInstaller::Get()
|
||||
return addonInstaller;
|
||||
}
|
||||
|
||||
+void CAddonInstaller::CallOEWrapper(const std::string& ID, bool disable)
|
||||
+{
|
||||
+ char cmd[255];
|
||||
+ snprintf(cmd, sizeof(cmd), "/usr/lib/openelec/systemd-addon-wrapper %s %d", ID.c_str(), disable);
|
||||
+ system(cmd);
|
||||
+}
|
||||
+
|
||||
void CAddonInstaller::OnJobComplete(unsigned int jobID, bool success, CJob* job)
|
||||
{
|
||||
if (success)
|
||||
@@ -713,6 +720,7 @@ void CAddonInstallJob::OnPostInstall(bool reloadAddon)
|
||||
AddonPtr addon;
|
||||
CAddonMgr::Get().GetAddon(m_addon->ID(), addon);
|
||||
boost::shared_ptr<CService> service = boost::dynamic_pointer_cast<CService>(addon);
|
||||
+ CAddonInstaller::Get().CallOEWrapper(m_addon->ID(), false);
|
||||
if (service)
|
||||
service->Start();
|
||||
}
|
||||
@@ -794,6 +802,7 @@ bool CAddonUnInstallJob::DoWork()
|
||||
boost::shared_ptr<CService> service = boost::dynamic_pointer_cast<CService>(m_addon);
|
||||
if (service)
|
||||
service->Stop();
|
||||
+ CAddonInstaller::Get().CallOEWrapper(m_addon->ID(), true);
|
||||
}
|
||||
|
||||
AddonPtr repoPtr = CAddonInstallJob::GetRepoForAddon(m_addon);
|
||||
diff --git a/xbmc/addons/AddonInstaller.h b/xbmc/addons/AddonInstaller.h
|
||||
index 39cab93..2938c7f 100644
|
||||
--- a/xbmc/addons/AddonInstaller.h
|
||||
+++ b/xbmc/addons/AddonInstaller.h
|
||||
@@ -29,6 +29,8 @@ class CAddonInstaller : public IJobCallback
|
||||
public:
|
||||
static CAddonInstaller &Get();
|
||||
|
||||
+ void CallOEWrapper(const std::string& ID, bool disable);
|
||||
+
|
||||
bool IsDownloading() const;
|
||||
void GetInstallList(ADDON::VECADDONS &addons) const;
|
||||
bool GetProgress(const CStdString &addonID, unsigned int &percent) const;
|
||||
--
|
||||
1.8.3.2
|
||||
|
36
packages/mediacenter/xbmc/scripts/systemd-addon-wrapper
Executable file
36
packages/mediacenter/xbmc/scripts/systemd-addon-wrapper
Executable file
@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
################################################################################
|
||||
# This file is part of OpenELEC - http://www.openelec.tv
|
||||
# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
|
||||
#
|
||||
# This Program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This Program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with OpenELEC.tv; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
|
||||
# http://www.gnu.org/copyleft/gpl.html
|
||||
################################################################################
|
||||
|
||||
if [ ! -d /storage/.config/system.d ] ; then
|
||||
mkdir -p /storage/.config/system.d
|
||||
fi
|
||||
|
||||
if [ -f "/storage/.xbmc/addons/$1/system.d/$1.service" ] ; then
|
||||
if [ $2 -eq 1 ] ; then
|
||||
# disable = true: cleanup
|
||||
systemctl stop "$1.service"
|
||||
systemctl disable "/storage/.xbmc/addons/$1/system.d/$1.service"
|
||||
else
|
||||
# disable = false: setup
|
||||
systemctl enable "/storage/.xbmc/addons/$1/system.d/$1.service"
|
||||
systemctl start "$1.service"
|
||||
fi
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user