From 9dda66960fb1985c814bc3d685be59ad400799e3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Arkadiusz=20Mi=C5=9Bkiewicz?= Date: Sun, 21 Jan 2018 19:35:31 +0100 Subject: [PATCH] - initial; from FC --- domoticz-openzwave-Dev.patch | 146 +++++++++++++++++++++++ domoticz-openzwave.patch | 49 ++++++++ domoticz-python.patch | 76 ++++++++++++ domoticz-tinyxpath.patch | 220 +++++++++++++++++++++++++++++++++++ domoticz-version.patch | 9 ++ domoticz.conf | 14 +++ domoticz.service | 14 +++ domoticz.spec | 174 +++++++++++++++++++++++++++ 8 files changed, 702 insertions(+) create mode 100644 domoticz-openzwave-Dev.patch create mode 100644 domoticz-openzwave.patch create mode 100644 domoticz-python.patch create mode 100644 domoticz-tinyxpath.patch create mode 100644 domoticz-version.patch create mode 100644 domoticz.conf create mode 100644 domoticz.service create mode 100644 domoticz.spec diff --git a/domoticz-openzwave-Dev.patch b/domoticz-openzwave-Dev.patch new file mode 100644 index 0000000..9152d5c --- /dev/null +++ b/domoticz-openzwave-Dev.patch @@ -0,0 +1,146 @@ +diff --git a/hardware/OpenZWave.cpp b/hardware/OpenZWave.cpp +index 1f5c341c..51b2865b 100644 +--- a/hardware/OpenZWave.cpp ++++ b/hardware/OpenZWave.cpp +@@ -1641,19 +1641,83 @@ void COpenZWave::AddValue(const OpenZWave::ValueID &vID, const NodeInfo *pNodeIn + if (newInstance != 0) + { + _device.instanceID = newInstance; +- if (m_pManager->GetValueAsByte(vID, &byteValue) == true) ++ //Door lock device ++ if ( ++ (vLabel == "Access Control") || ++ (vLabel == "UserCode") ++ ) + { +- _device.devType = ZDTYPE_SWITCH_NORMAL; +- if (byteValue == 0) +- _device.intvalue = 0; +- else +- _device.intvalue = 255; +- InsertDevice(_device); ++ if( ValueID::ValueType_List == vID.GetType() ) ++ { ++ try ++ { ++ std::string vListStr; ++ if (m_pManager->GetValueListSelection(vID, &vListStr)) ++ { ++ _device.devType = ZDTYPE_SWITCH_NORMAL; ++ _device.Alarm_Type = 6; ++ _device.intvalue = 0; ++ if (vListStr == "Access Control - RF Lock") ++ _device.intvalue = 24; ++ else if (vListStr == "Access Control - RF Unlock") ++ _device.intvalue = 25; ++ else if (vListStr == "Access Control - Manual Lock") ++ _device.intvalue = 21; ++ else if (vListStr == "Access Control - Manual Unlock") ++ _device.intvalue = 22; ++ else if (vListStr == "Access Control - KeyPad Lock") ++ _device.intvalue = 18; ++ else if (vListStr == "Access Control - KeyPad Unlock") ++ _device.intvalue = 19; ++ else if (vListStr == "Not Active") ++ _device.intvalue = 1; ++ else ++ _log.Log(LOG_STATUS, "OpenZWave: Value_Added: Unhandled List Selection: %s", vListStr.c_str()); ++ InsertDevice(_device); ++ } ++ } ++ catch (...) ++ { ++ _log.Log(LOG_STATUS, "OpenZWave: Value_Added: GetValueListSelection Exception"); ++ } ++ } ++ else { ++ _log.Log(LOG_STATUS, "OpenZWave: Value_Added: Unhandled Value for Label: %s", vLabel.c_str()); ++ } ++ } ++ else if( ValueID::ValueType_Byte == vID.GetType() ) ++ { ++ if (m_pManager->GetValueAsByte(vID, &byteValue) == true) ++ { ++ _device.devType = ZDTYPE_SWITCH_NORMAL; ++ if (byteValue == 0) ++ _device.intvalue = 0; ++ else ++ _device.intvalue = 255; ++ InsertDevice(_device); ++ } + } ++ else ++ { ++ _log.Log(LOG_STATUS, "OpenZWave: Value_Added: Unhandled Value: X, Type: %i", vID.GetType()); ++ } + } + else + { +- if (vLabel != "SourceNodeId") ++ if (vLabel == "UserCode") { ++ if ((vType == OpenZWave::ValueID::ValueType_Raw) || (vType == OpenZWave::ValueID::ValueType_String)) ++ { ++ std::string strValue; ++ if (m_pManager->GetValueAsString(vID, &strValue) == true) ++ _log.Log(LOG_STATUS, "OpenZWave: Value_Added: UserCode: %s", strValue.c_str()); ++ } ++ else ++ { ++ if (m_pManager->GetValueAsByte(vID, &byteValue) == true) ++ _log.Log(LOG_STATUS, "OpenZWave: Value_Added: UserCode: %i", byteValue); ++ } ++ } ++ else if (vLabel != "SourceNodeId") + { + _log.Log(LOG_STATUS, "OpenZWave: Value_Added: Unhandled Label: %s, Unit: %s", vLabel.c_str(), vUnits.c_str()); + } +@@ -2395,7 +2459,7 @@ void COpenZWave::UpdateValue(const OpenZWave::ValueID &vID) + unsigned char byteValue = 0; + int32 intValue = 0; + std::string strValue = ""; +- int32 lValue = 0; ++ std::string lValue = ""; + + if (vType == OpenZWave::ValueID::ValueType_Decimal) + { +@@ -2833,16 +2897,40 @@ void COpenZWave::UpdateValue(const OpenZWave::ValueID &vID) + } + else if (vLabel == "Access Control") + { ++ if (!lValue.empty()) { ++ if (lValue == "Access Control - RF Lock") ++ byteValue = 24; ++ else if (lValue == "Access Control - RF Unlock") ++ byteValue = 25; ++ else if (lValue == "Access Control - Manual Lock") ++ byteValue = 21; ++ else if (lValue == "Access Control - Manual Unlock") ++ byteValue = 22; ++ else if (lValue == "Access Control - KeyPad Lock") ++ byteValue = 18; ++ else if (lValue == "Access Control - KeyPad Unlock") ++ byteValue = 19; ++ else if (lValue == "Not Active") ++ byteValue = 0; ++ else ++ byteValue = 0; ++ } ++ + switch (byteValue) { + case 0x00: // Previous Events cleared + case 0x06: //Keypad unlock/Arm Home ++ case 0x12: // KeyPad lock ++ case 0x15: // Manual Lock + case 0x17: // Door closed ++ case 0x18: // RF operated lock + case 0xfe: // Unkown event; returned when retrieving the current state. + intValue = 0; + break; + + case 0x05: //Keypad Lock/Arm Away ++ case 0x13: // KeyPad unlock + case 0x16: // Door open ++ case 0x19: // RF operated unlock + default: // all others, interpret as alarm + intValue = 255; + break; diff --git a/domoticz-openzwave.patch b/domoticz-openzwave.patch new file mode 100644 index 0000000..e819762 --- /dev/null +++ b/domoticz-openzwave.patch @@ -0,0 +1,49 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 42082192..f16726f8 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -598,7 +598,7 @@ endif() + IF(OpenZWave) + message(STATUS ${OpenZWave}) + target_link_libraries(domoticz ${OpenZWave}) +- include_directories(${CMAKE_SOURCE_DIR}/hardware/openzwave) ++ include_directories(${OPENZWAVE_INCLUDE_DIRS}) + add_definitions(-DWITH_OPENZWAVE) + # open-zwave needs libudev + IF(CMAKE_SYSTEM_NAME STREQUAL "Darwin") +diff --git a/hardware/openzwave/control_panel/ozwcp.cpp b/hardware/openzwave/control_panel/ozwcp.cpp +index ffd8d742..79c708ce 100644 +--- a/hardware/openzwave/control_panel/ozwcp.cpp ++++ b/hardware/openzwave/control_panel/ozwcp.cpp +@@ -39,11 +39,11 @@ + #include + #include + #include +-#include "Options.h" +-#include "Manager.h" +-#include "Node.h" +-#include "Group.h" +-#include "Notification.h" ++#include ++#include ++#include ++#include ++#include + + #include + #include +diff --git a/hardware/openzwave/control_panel/ozwcp.h b/hardware/openzwave/control_panel/ozwcp.h +index 29ebc0e3..7a027815 100644 +--- a/hardware/openzwave/control_panel/ozwcp.h ++++ b/hardware/openzwave/control_panel/ozwcp.h +@@ -37,8 +37,8 @@ + + #include + #include +-#include "Driver.h" +-#include "Notification.h" ++#include ++#include + + using namespace OpenZWave; + diff --git a/domoticz-python.patch b/domoticz-python.patch new file mode 100644 index 0000000..e6332de --- /dev/null +++ b/domoticz-python.patch @@ -0,0 +1,76 @@ +From f7b229ce873ff71e2b48e855075153dc1026750d Mon Sep 17 00:00:00 2001 +From: Michael Cronenworth +Date: Mon, 7 Aug 2017 14:37:28 -0500 +Subject: [PATCH] Follow PEP-384 when finding and opening python3 library + +Instead of maintaining a list of all Python versions the Python 3 +standard defines that there MUST be a stable ABI and we can always +rely on a "python3.dll" or a "libpython3.so" existing. + +This also fixes library loading on Linux distributions that use +SO versioned libraries. +--- + hardware/plugins/DelayedLink.h | 28 ++-------------------------- + 1 file changed, 2 insertions(+), 26 deletions(-) + +diff --git a/hardware/plugins/DelayedLink.h b/hardware/plugins/DelayedLink.h +index 25c83f034..ecf19da09 100644 +--- a/hardware/plugins/DelayedLink.h ++++ b/hardware/plugins/DelayedLink.h +@@ -126,16 +126,10 @@ namespace Plugins { + if (!shared_lib_) shared_lib_ = LoadLibrary("python35_d.dll"); + if (!shared_lib_) shared_lib_ = LoadLibrary("python34_d.dll"); + # else +- if (!shared_lib_) shared_lib_ = LoadLibrary("python37.dll"); +- if (!shared_lib_) shared_lib_ = LoadLibrary("python36.dll"); +- if (!shared_lib_) shared_lib_ = LoadLibrary("python35.dll"); +- if (!shared_lib_) shared_lib_ = LoadLibrary("python34.dll"); ++ if (!shared_lib_) shared_lib_ = LoadLibrary("python3.dll"); + # endif + #else +- if (!shared_lib_) FindLibrary("python3.7", true); +- if (!shared_lib_) FindLibrary("python3.6", true); +- if (!shared_lib_) FindLibrary("python3.5", true); +- if (!shared_lib_) FindLibrary("python3.4", true); ++ if (!shared_lib_) FindLibrary("python3", true); + #endif + if (shared_lib_) + { +@@ -232,24 +226,12 @@ namespace Plugins { + library = "lib" + sLibrary + ".so"; + shared_lib_ = dlopen(library.c_str(), RTLD_LAZY | RTLD_GLOBAL); + } +- // look in directories covered by ldconfig but 'm' variant +- if (!shared_lib_) +- { +- library = "lib" + sLibrary + "m.so"; +- shared_lib_ = dlopen(library.c_str(), RTLD_LAZY | RTLD_GLOBAL); +- } + // look in /usr/lib directories + if (!shared_lib_) + { + library = "/usr/lib/" + sLibrary + "/"; + FindLibrary(library, false); + } +- // look in /usr/lib directories but 'm' variant +- if (!shared_lib_) +- { +- library = "/usr/lib/" + sLibrary + "m/"; +- FindLibrary(library, false); +- } + // look in /usr/local/lib directory (handles build from source) + if (!shared_lib_) + { +@@ -257,12 +239,6 @@ namespace Plugins { + shared_lib_ = dlopen(library.c_str(), RTLD_LAZY | RTLD_GLOBAL); + + } +- // look in /usr/local/lib directory (handles build from source) but 'm' variant +- if (!shared_lib_) +- { +- library = "/usr/local/lib/lib" + sLibrary + "m.so"; +- shared_lib_ = dlopen(library.c_str(), RTLD_LAZY | RTLD_GLOBAL); +- } + } + else + { diff --git a/domoticz-tinyxpath.patch b/domoticz-tinyxpath.patch new file mode 100644 index 0000000..6d4fe3f --- /dev/null +++ b/domoticz-tinyxpath.patch @@ -0,0 +1,220 @@ +From 694241f7905967bf69af3a31265180c00b73e28c Mon Sep 17 00:00:00 2001 +From: Michael Cronenworth +Date: Fri, 11 Aug 2017 10:08:27 -0500 +Subject: [PATCH] build: Detect and allow external tinyxpath library usage + +Signed-off-by: Michael Cronenworth +--- + CMakeLists.txt | 57 +++++++++++++++++++++--------- + hardware/AnnaThermostat.cpp | 3 +- + hardware/RAVEn.cpp | 3 +- + hardware/openzwave/control_panel/ozwcp.cpp | 3 +- + hardware/plugins/PluginManager.cpp | 3 +- + hardware/plugins/Plugins.cpp | 3 +- + main/LuaCommon.cpp | 7 +++- + main/LuaHandler.cpp | 3 +- + removed from Fedora patch msbuild/domoticz.vcxproj | 6 ++-- + 9 files changed, 62 insertions(+), 26 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index bc231d8f6..334f203a6 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -451,22 +451,6 @@ webserver/proxyclient.cpp + json/json_reader.cpp + json/json_value.cpp + json/json_writer.cpp +-tinyxpath/action_store.cpp +-tinyxpath/htmlutil.cpp +-tinyxpath/lex_util.cpp +-tinyxpath/node_set.cpp +-tinyxpath/tinystr.cpp +-tinyxpath/tinyxml.cpp +-tinyxpath/tinyxmlerror.cpp +-tinyxpath/tinyxmlparser.cpp +-tinyxpath/tokenlist.cpp +-tinyxpath/xml_util.cpp +-tinyxpath/xpath_expression.cpp +-tinyxpath/xpath_processor.cpp +-tinyxpath/xpath_stream.cpp +-tinyxpath/xpath_stack.cpp +-tinyxpath/xpath_static.cpp +-tinyxpath/xpath_syntax.cpp + ) + add_executable(domoticz ${domoticz_SRCS}) + +@@ -538,6 +522,47 @@ else() + MESSAGE(STATUS "==== LibUSB not found, support for TE923/Voltcraft disabled!") + ENDIF(LIBUSB_FOUND) + ++option(USE_BUILTIN_TINYXPATH "Use builtin tinyxpath library" YES) ++IF(USE_BUILTIN_TINYXPATH) ++ include_directories(tinyxpath) ++ target_sources( ++ domoticz ++ PUBLIC ++ tinyxpath/action_store.cpp ++ tinyxpath/htmlutil.cpp ++ tinyxpath/lex_util.cpp ++ tinyxpath/node_set.cpp ++ tinyxpath/tinystr.cpp ++ tinyxpath/tinyxml.cpp ++ tinyxpath/tinyxmlerror.cpp ++ tinyxpath/tinyxmlparser.cpp ++ tinyxpath/tokenlist.cpp ++ tinyxpath/xml_util.cpp ++ tinyxpath/xpath_expression.cpp ++ tinyxpath/xpath_processor.cpp ++ tinyxpath/xpath_stream.cpp ++ tinyxpath/xpath_stack.cpp ++ tinyxpath/xpath_static.cpp ++ tinyxpath/xpath_syntax.cpp ++ ) ++else() ++ pkg_check_modules(TinyXML QUIET tinyxml) ++ IF(TinyXML_FOUND) ++ MESSAGE(STATUS "TinyXML found at: ${TinyXML_LIBRARIES}") ++ IF(EXISTS "/usr/include/tinyxpath/xpath_processor.h") ++ MESSAGE(STATUS "TinyXPath found") ++ target_link_libraries(domoticz ${TinyXML_LIBRARIES}) ++ target_link_libraries(domoticz tinyxpath) ++ include_directories(/usr/include/tinyxpath) ++ add_definitions(-DWITH_EXTERNAL_TINYXPATH) ++ else() ++ MESSAGE(FATAL_ERROR "TinyXPath not found but USE_BUILTIN_TINYXPATH=NO") ++ ENDIF() ++ else() ++ MESSAGE(FATAL_ERROR "TinyXML not found but USE_BUILTIN_TINYXPATH=NO") ++ ENDIF(TinyXML_FOUND) ++ENDIF(USE_BUILTIN_TINYXPATH) ++ + # + # Find MD5/RMD160/SHA library + # +diff --git a/hardware/AnnaThermostat.cpp b/hardware/AnnaThermostat.cpp +index 9c8cf26ef..9c91513ba 100644 +--- a/hardware/AnnaThermostat.cpp ++++ b/hardware/AnnaThermostat.cpp +@@ -8,7 +8,8 @@ + #include "../main/SQLHelper.h" + #include "../httpclient/HTTPClient.h" + #include "../main/mainworker.h" +-#include "../tinyxpath/tinyxml.h" ++ ++#include + + #define round(a) ( int ) ( a + .5 ) + +diff --git a/hardware/RAVEn.cpp b/hardware/RAVEn.cpp +index 3ffe4f724..36f97bffb 100644 +--- a/hardware/RAVEn.cpp ++++ b/hardware/RAVEn.cpp +@@ -6,7 +6,8 @@ + #include "../main/RFXtrx.h" + #include "../main/localtime_r.h" + #include "../main/mainworker.h" +-#include "../tinyxpath/tinyxml.h" ++ ++#include + + //Rainforest RAVEn USB ZigBee Smart Meter Adapter + //https://rainforestautomation.com/rfa-z106-raven/ +diff --git a/hardware/openzwave/control_panel/ozwcp.cpp b/hardware/openzwave/control_panel/ozwcp.cpp +index 9a948c976..8fd4f77f0 100644 +--- a/hardware/openzwave/control_panel/ozwcp.cpp ++++ b/hardware/openzwave/control_panel/ozwcp.cpp +@@ -45,11 +45,10 @@ + #include "Group.h" + #include "Notification.h" + +-#include "../../tinyxpath/tinyxml.h" +- + #include + #include + #include ++#include + + //#include "microhttpd.h" + #include "ozwcp.h" +diff --git a/hardware/plugins/PluginManager.cpp b/hardware/plugins/PluginManager.cpp +index ea7bbe48a..9af41e42e 100644 +--- a/hardware/plugins/PluginManager.cpp ++++ b/hardware/plugins/PluginManager.cpp +@@ -5,6 +5,8 @@ + // + #ifdef ENABLE_PYTHON + ++#include ++ + #include "PluginManager.h" + #include "Plugins.h" + #include "PluginMessages.h" +@@ -17,7 +19,6 @@ + #include "../main/mainworker.h" + #include "../main/EventSystem.h" + #include "../json/json.h" +-#include "../tinyxpath/tinyxml.h" + #include "../main/localtime_r.h" + #ifdef WIN32 + # include +diff --git a/hardware/plugins/Plugins.cpp b/hardware/plugins/Plugins.cpp +index dc2420d6a..8cba255a2 100644 +--- a/hardware/plugins/Plugins.cpp ++++ b/hardware/plugins/Plugins.cpp +@@ -5,6 +5,8 @@ + // + #ifdef ENABLE_PYTHON + ++#include ++ + #include "Plugins.h" + #include "PluginMessages.h" + #include "PluginProtocols.h" +@@ -15,7 +17,6 @@ + #include "../main/Logger.h" + #include "../main/SQLHelper.h" + #include "../main/mainworker.h" +-#include "../tinyxpath/tinyxml.h" + #include "../main/localtime_r.h" + + #include "../../notifications/NotificationHelper.h" +diff --git a/main/LuaCommon.cpp b/main/LuaCommon.cpp +index ec99429a5..76085aed6 100644 +--- a/main/LuaCommon.cpp ++++ b/main/LuaCommon.cpp +@@ -16,7 +16,8 @@ extern "C" { + #endif + } + +-#include "../tinyxpath/xpath_processor.h" ++#include ++ + #include "../json/json.h" + #include "SQLHelper.h" + #include "mainworker.h" +@@ -44,7 +45,11 @@ int CLuaCommon::l_domoticz_applyXPath(lua_State* lua_state) + return 0; + } + TinyXPath::xpath_processor processor(root, xpath.c_str()); ++#ifdef WITH_EXTERNAL_TINYXPATH ++ TIXML_STRING xresult = processor.S_compute_xpath(); ++#else + TiXmlString xresult = processor.S_compute_xpath(); ++#endif + lua_pushstring(lua_state, xresult.c_str()); + return 1; + } +diff --git a/main/LuaHandler.cpp b/main/LuaHandler.cpp +index 8fdcb278b..a66cafee7 100644 +--- a/main/LuaHandler.cpp ++++ b/main/LuaHandler.cpp +@@ -16,7 +16,8 @@ extern "C" { + #endif + } + +-#include "../tinyxpath/xpath_processor.h" ++#include ++ + #include "../json/json.h" + #include "SQLHelper.h" + #include "mainworker.h" diff --git a/domoticz-version.patch b/domoticz-version.patch new file mode 100644 index 0000000..79c2628 --- /dev/null +++ b/domoticz-version.patch @@ -0,0 +1,9 @@ +--- a/appversion.default 2017-07-30 05:19:41.000000000 -0500 ++++ b/appversion.default 2017-07-31 11:36:32.150644222 -0500 +@@ -1,3 +1,3 @@ +-#define APPVERSION 5876 +-#define APPHASH "b97777b" +-#define APPDATE 1478691222 ++#define APPVERSION 8153 ++#define APPHASH "494fff7" ++#define APPDATE 1501409981 diff --git a/domoticz.conf b/domoticz.conf new file mode 100644 index 0000000..2c7b47e --- /dev/null +++ b/domoticz.conf @@ -0,0 +1,14 @@ +WWW_PORT=8080 +SSL_PORT=8443 +SSLCERT="/var/lib/domoticz/domoticz.pem" +SSLPASS="" +SSLMETHOD="" +SSLOPTIONS="" +SSLDHPARAM="" +WWW_ROOT="/usr/share/domoticz/www" +DBASE="/var/lib/domoticz/domoticz.db" +USERDATA="/usr/share/domoticz/" +VERBOSE=0 +LOG="/var/log/domoticz.log" +LOGLEVEL="1" + diff --git a/domoticz.service b/domoticz.service new file mode 100644 index 0000000..c3a29ac --- /dev/null +++ b/domoticz.service @@ -0,0 +1,14 @@ +[Unit] +Description=Domoticz Home Automation Server + +[Service] +User=domoticz +Group=domoticz +EnvironmentFile=/etc/sysconfig/domoticz +ExecStart=/usr/bin/domoticz -www $WWW_PORT -sslwww $SSL_PORT -sslcert $SSLCERT -sslpass $SSLPASS -sslmethod $SSLMETHOD -ssloptions $SSLOPTIONS -ssldhparam $SSLDHPARAM -wwwroot $WWW_ROOT -dbase $DBASE -userdata $USERDATA -verbose $VERBOSE -log $LOG -loglevel $LOGLEVEL +WorkingDirectory=/usr/share/domoticz +# Give the right to open priviliged ports. This allows you to run on a port <1024 without root permissions (user/group setting above) +#CapabilityBoundingSet=CAP_NET_BIND_SERVICE + +[Install] +WantedBy=multi-user.target diff --git a/domoticz.spec b/domoticz.spec new file mode 100644 index 0000000..b1050e9 --- /dev/null +++ b/domoticz.spec @@ -0,0 +1,174 @@ +Summary: Open source Home Automation System +Name: domoticz +Version: 3.8153 +Release: 0.1 +License: GPLv3+ and ASL 2.0 and Boost and BSD and MIT +Group: Base +URL: http://www.domoticz.com +Source0: https://github.com/domoticz/domoticz/archive/%{version}.tar.gz +# Source0-md5: ad7b1d0491cd17e54bbe7368bcfd5170 +Source1: %{name}.service +Source2: %{name}.conf +# Source says its version 3.5876, but it's really 3.8153 +Patch1: %{name}-version.patch +# Use system tinyxpath (https://github.com/domoticz/domoticz/pull/1759) +Patch2: %{name}-tinyxpath.patch +# Use system openzwave includes +Patch3: %{name}-openzwave.patch +# Work against Dev branch of OpenZWave upstream +Patch4: %{name}-openzwave-Dev.patch +# Fix python detection (https://github.com/domoticz/domoticz/pull/1749) +Patch5: %{name}-python.patch +BuildRequires: boost-devel +BuildRequires: cmake +BuildRequires: curl-devel +BuildRequires: libmosquitto-devel +BuildRequires: libmosquittopp-devel +BuildRequires: libopenzwave-devel >= 1.5.0 +BuildRequires: libstdc++-devel +BuildRequires: libusb-devel +BuildRequires: lua-devel +BuildRequires: openssl-devel +BuildRequires: python3-devel +BuildRequires: sqlite-devel +BuildRequires: systemd-devel +BuildRequires: tinyxpath-devel +BuildRequires: zlib-devel + +Requires(pre): shadow-utils +Requires(post): systemd +Requires(postun): systemd +Requires(preun): systemd + +Requires: google-droid-sans-fonts +Suggests: system-python-libs >= 3.4 + +Provides: bundled(js-ace) +Provides: bundled(js-angular-ui-bootstrap) = 0.13.4 +Provides: bundled(js-angularamd) = 0.2.1 +Provides: bundled(js-angularjs) = 1.5.8 +Provides: bundled(js-blockly) +Provides: bundled(js-bootbox) +Provides: bundled(js-bootstrap) = 3.2.0 +Provides: bundled(js-colpick) +Provides: bundled(js-d3) +Provides: bundled(js-datatables-datatools) = 2.2.3 +Provides: bundled(js-dateformat) = 1.2.3 +Provides: bundled(js-filesaver) = 0.0-git20140725 +Provides: bundled(js-highcharts) = 4.2.6 +Provides: bundled(js-html5shiv) = 3.6.2 +Provides: bundled(js-i18next) = 1.8.0 +Provides: bundled(js-ion-sound) = 3.0.6 +Provides: bundled(js-jquery) = 1.12.0 +Provides: bundled(js-jquery-noty) = 2.1.0 +Provides: bundled(js-less) = 1.3.0 +Provides: bundled(js-ngdraggable) +Provides: bundled(js-nggrid) +Provides: bundled(js-ozwcp) +Provides: bundled(js-require) = 2.1.14 +Provides: bundled(js-respond) = 1.1.0 +Provides: bundled(js-wow) = 0.1.9 +Provides: bundled(js-zeroclipboard) = 1.0.4 + +%description +Domoticz is a Home Automation System that lets you monitor and +configure various devices like: Lights, Switches, various +sensors/meters like Temperature, Rain, Wind, UV, Electra, Gas, Water +and much more. Notifications/Alerts can be sent to any mobile device + +%prep +%setup -q +%patch1 -p1 -b.version +%patch2 -p1 -b.tinyxpath +%patch3 -p1 -b.openzwave +%patch4 -p1 -b.openzwave-Dev +%patch5 -p1 -b.python +rm -f hardware/openzwave/*.h +rm -rf hardware/openzwave/aes +rm -rf hardware/openzwave/command_classes +rm -rf hardware/openzwave/platform +rm -rf hardware/openzwave/value_classes +rm -rf sqlite/ +rm -rf tinyxpath/ + +%build +install -d build && cd build +%cmake \ + -DUSE_STATIC_LIBSTDCXX=NO \ + -DUSE_STATIC_OPENZWAVE=NO \ + -DUSE_BUILTIN_LUA=NO \ + -DUSE_BUILTIN_MQTT=NO \ + -DUSE_BUILTIN_SQLITE=NO \ + -DUSE_BUILTIN_TINYXPATH=NO \ + -DUSE_STATIC_BOOST=NO \ + -DCMAKE_INSTALL_PREFIX=%{_datadir}/%{name} \ + .. +%{__make} + +%install +rm -rf $RPM_BUILD_ROOT +%{__make} -C build \ + install + +# remove docs, we grab them in files below +rm -f $RPM_BUILD_ROOT%{_datadir}/%{name}/*.txt + +# move binary to standard directory +install -d $RPM_BUILD_ROOT%{_bindir}/ +mv $RPM_BUILD_ROOT%{_datadir}/%{name}/%{name} $RPM_BUILD_ROOT%{_bindir}/ + +# install systemd service and config +install -d $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/ +install -d $RPM_BUILD_ROOT%{systemdunitdir}/ +cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}/ +cp -p %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/%{name} + +# create database/ssl cert directory +install -d $RPM_BUILD_ROOT%{_sharedstatedir}/%{name}/ + +# Disable the app's self-update script + +# Unbundle DroidSans.ttf +rm -f $RPM_BUILD_ROOT%{_datadir}/%{name}/www/styles/elemental/fonts/DroidSans.ttf +ln -s %{_fontdir}/google-droid/DroidSans.ttf \ + $RPM_BUILD_ROOT%{_datadir}/%{name}/www/styles/elemental/fonts/ +rm -f $RPM_BUILD_ROOT%{_datadir}/%{name}/www/styles/element-light/fonts/DroidSans.ttf +ln -s %{_fontdir}/google-droid/DroidSans.ttf \ + $RPM_BUILD_ROOT%{_datadir}/%{name}/www/styles/element-light/fonts/ +rm -f $RPM_BUILD_ROOT%{_datadir}/%{name}/www/styles/element-dark/fonts/DroidSans.ttf +ln -s %{_fontdir}/google-droid/DroidSans.ttf \ + $RPM_BUILD_ROOT%{_datadir}/%{name}/www/styles/element-dark/fonts/ + +# OpenZWave Control Panel temp file +ln -s %{_sharedstatedir}/%{name}/ozwcp.poll.XXXXXX.xml \ + $RPM_BUILD_ROOT%{_datadir}/%{name}/ozwcp.poll.XXXXXX.xml + +%clean +rm -rf $RPM_BUILD_ROOT + +%pre +getent group domoticz >/dev/null || groupadd -r domoticz +getent passwd domoticz >/dev/null || \ +useradd -r -g domoticz -d %{_datadir}/%{name} -s /sbin/nologin \ +-c "Domoticz Home Automation Server" domoticz +# For OpenZWave USB access (/dev/ttyACM#) +usermod -G domoticz,dialout domoticz + +%post +%systemd_post %{name}.service + +%preun +%systemd_preun %{name}.service + +%postun +%systemd_postun_with_restart %{name}.service + +%files +%defattr(644,root,root,755) +%doc License.txt +%doc README.md History.txt +%attr(755,root,root) %{_bindir}/%{name} +%config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name} +%{_datadir}/%{name}/ +%attr(755,domoticz,domoticz) %{_sharedstatedir}/%{name}/ +%{systemdunitdir}/%{name}.service -- 2.44.0