diff --git a/.gitignore b/.gitignore index 3cffde1c..ab0e4ad3 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ CMakeFiles/ __/ # Ignoring autogenerated files -*.cmake Makefile qrc_*.cpp *.qrc.depends diff --git a/CompileHowto.md b/CompileHowto.md index b0c49cb0..205f9a47 100644 --- a/CompileHowto.md +++ b/CompileHowto.md @@ -81,17 +81,9 @@ bin/hyperiond ### Download Creates hyperion directory and checkout the code from github -You might want to add `--depth 1` to the `git` command if you only want to compile the current source and have no need for the entire git repository - ``` export HYPERION_DIR="hyperion" -git clone --recursive https://github.com/hyperion-project/hyperion.ng.git "$HYPERION_DIR" -``` - -**Note:** If you forget the --recursive in above statement or you are updating an existing clone you need to clone the flatbuffers submodule by runnning the follwing two statements: -``` -git submodule init -git submodule update +git clone --recursive --depth 1 https://github.com/hyperion-project/hyperion.ng.git "$HYPERION_DIR" ``` ### Preparations @@ -113,7 +105,7 @@ cmake -DCMAKE_BUILD_TYPE=Release .. *Developers on x86* linux should use: ``` -cmake -DPLATFORM=x86-dev -DCMAKE_BUILD_TYPE=Release .. +cmake -DPLATFORM=x11-dev -DCMAKE_BUILD_TYPE=Release .. ``` To use framebuffer instead of dispmanx (for example on the *cubox-i*): diff --git a/bin/service/hyperion.systemd.RO b/bin/service/hyperion.systemd.RO index b763a107..179871c6 100644 --- a/bin/service/hyperion.systemd.RO +++ b/bin/service/hyperion.systemd.RO @@ -9,7 +9,7 @@ Environment=LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. ExecStart=./hyperiond /storage/.config/hyperion/hyperion.config.json TimeoutStopSec=5 KillMode=mixed -Restart=always +Restart=on-failure RestartSec=2 [Install] diff --git a/cmake/FindDebBuilder.cmake b/cmake/FindDebBuilder.cmake new file mode 100644 index 00000000..e2f2c9ac --- /dev/null +++ b/cmake/FindDebBuilder.cmake @@ -0,0 +1,23 @@ +# - Find package for .deb building +# Find the .deb building executable and extract the version number +# +# OUTPUT Variables +# +# DEB_BUILDER_FOUND +# True if the deb builder package was found +# DEB_BUILDER_EXECUTABLE +# The deb builder executable location +# DEB_BUILDER_VERSION +# A string denoting the version of deb builder that has been found + +find_program ( DEB_BUILDER_EXECUTABLE dpkg-deb ) + +if ( DEB_BUILDER_EXECUTABLE ) + SET( DEB_BUILDER_FOUND TRUE ) + execute_process ( COMMAND ${DEB_BUILDER_EXECUTABLE} --version OUTPUT_VARIABLE DEB_VERSION_RAW ERROR_QUIET ) + if (DEB_VERSION_RAW) + string ( REGEX REPLACE "^RPM-Version ([0-9]+.[0-9]+.[0-9]+),.*" "\\1" DEB_BUILDER_VERSION ${DEB_VERSION_RAW}) + else () + set ( DEB_BUILDER_VERSION "unknown" ) + endif() +endif () diff --git a/cmake/FindRpmBuilder.cmake b/cmake/FindRpmBuilder.cmake new file mode 100644 index 00000000..07a22468 --- /dev/null +++ b/cmake/FindRpmBuilder.cmake @@ -0,0 +1,23 @@ +# - Find package for .rpm building +# Find the .rpm building executable and extract the version number +# +# OUTPUT Variables +# +# RPM_BUILDER_FOUND +# True if the rpm package was found +# RPM_BUILDER_EXECUTABLE +# The rpm executable location +# RPM_BUILDER_VERSION +# A string denoting the version of rpm that has been found + +find_program ( RPM_BUILDER_EXECUTABLE rpm ) + +if ( RPM_BUILDER_EXECUTABLE ) + SET( RPM_BUILDER_FOUND TRUE ) + execute_process ( COMMAND ${RPM_BUILDER_EXECUTABLE} --version OUTPUT_VARIABLE RPM_VERSION_RAW ERROR_QUIET ) + if (RPM_VERSION_RAW) + string ( REGEX REPLACE "^RPM-Version ([0-9]+.[0-9]+.[0-9]+),.*" "\\1" RPM_BUILDER_VERSION ${RPM_VERSION_RAW}) + else () + set ( RPM_BUILDER_VERSION "unknown" ) + endif() +endif () diff --git a/cmake/debian/postinst b/cmake/debian/postinst index 862610d5..eb9fa7ec 100644 --- a/cmake/debian/postinst +++ b/cmake/debian/postinst @@ -91,6 +91,14 @@ ln -fs $BINSP/hyperion-x11 $BINTP/hyperion-x11 2>/dev/null ln -fs $BINSP/hyperion-aml $BINTP/hyperion-aml 2>/dev/null ln -fs $BINSP/hyperion-qt $BINTP/hyperion-qt 2>/dev/null +# install desktop icons +echo "---> Install Hyperion desktop icons" +mkdir /usr/share/pixmaps/hyperion 2>/dev/null +cp /usr/share/hyperion/desktop/*.png /usr/share/pixmaps/hyperion 2>/dev/null +desktop-file-install /usr/share/hyperion/desktop/hyperiond.desktop 2>/dev/null + +# cleanup desktop icons +rm -r /usr/share/hyperion/desktop 2>/dev/null #Check, if dtparam=spi=on is in place if [ $CPU_RPI -eq 1 ]; then diff --git a/cmake/debian/prerm b/cmake/debian/prerm index 19b099b1..388c79ae 100644 --- a/cmake/debian/prerm +++ b/cmake/debian/prerm @@ -40,4 +40,11 @@ fi # In case we don't use a service kill all instances killall hyperiond 2> /dev/null +# delete desktop icons; desktop-file-edit is a workaround to hide the entry and delete it afterwards manual. +# TODO Better way for deletion and keep the desktop in sync without logout/login or desktop dependend cmds? +echo "---> Delete Hyperion desktop icons" +desktop-file-edit --set-key=NoDisplay --set-value=true /usr/share/applications/hyperiond.desktop 2>/dev/null +rm -v /usr/share/applications/hyperion* 2>/dev/null +rm -rv /usr/share/pixmaps/hyperion 2>/dev/null + exit 0 diff --git a/cmake/desktop/hyperiond.desktop b/cmake/desktop/hyperiond.desktop new file mode 100644 index 00000000..d47a38d3 --- /dev/null +++ b/cmake/desktop/hyperiond.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Name=Hyperion +GenericName=Hyperion Ambient Lighting +Comment=Hyperion mimics the well known Ambilight from Philips +Icon=/usr/share/pixmaps/hyperion/hyperiond_128.png +Terminal=false +TryExec=hyperiond +Exec=hyperiond +Type=Application +StartupNotify=false +Categories=Application; diff --git a/cmake/desktop/hyperiond_128.png b/cmake/desktop/hyperiond_128.png new file mode 100644 index 00000000..8da3dd17 Binary files /dev/null and b/cmake/desktop/hyperiond_128.png differ diff --git a/cmake/packages.cmake b/cmake/packages.cmake index 21b63a74..6eb6be82 100644 --- a/cmake/packages.cmake +++ b/cmake/packages.cmake @@ -1,15 +1,28 @@ # cmake file for generating distribution packages +# default packages to build IF (APPLE) SET ( CPACK_GENERATOR "TGZ" "Bundle") ELSEIF (UNIX) - SET ( CPACK_GENERATOR "DEB" "TGZ" "STGZ") # "RPM" + SET ( CPACK_GENERATOR "TGZ" "STGZ") ELSEIF (WIN32) - SET ( CPACK_GENERATOR "ZIP" "NSIS") + SET ( CPACK_GENERATOR "ZIP") +ENDIF() + +# Determine packages by found generator executables +find_package(RpmBuilder) +find_package(DebBuilder) +IF(RPM_BUILDER_FOUND) + message("CPACK: Found RPM builder") + SET ( CPACK_GENERATOR ${CPACK_GENERATOR} "RPM") +ENDIF() +IF(DEB_BUILDER_FOUND) + message("CPACK: Found DEB builder") + SET ( CPACK_GENERATOR ${CPACK_GENERATOR} "DEB") ENDIF() # Apply to all packages, some of these can be overwritten with generator specific content -# https://cmake.org/cmake/help/v3.0/module/CPack.html +# https://cmake.org/cmake/help/v3.5/module/CPack.html SET ( CPACK_PACKAGE_NAME "Hyperion" ) SET ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Hyperion is an open source ambient light implementation" ) @@ -27,18 +40,22 @@ SET ( CPACK_CREATE_DESKTOP_LINKS "hyperiond;Hyperion" ) # Specific CPack Package Generators # https://cmake.org/Wiki/CMake:CPackPackageGenerators -# .deb files for dpkg +# .deb files for apt SET ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/cmake/debian/preinst;${CMAKE_CURRENT_SOURCE_DIR}/cmake/debian/postinst;${CMAKE_CURRENT_SOURCE_DIR}/cmake/debian/prerm" ) SET ( CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5core5a (>= 5.5.0), libqt5network5 (>= 5.5.0), libqt5gui5 (>= 5.5.0), libqt5serialport5 (>= 5.5.0), libqt5sql5 (>= 5.5.0), libqt5sql5-sqlite (>= 5.5.0), libavahi-core7 (>= 0.6.31), libavahi-compat-libdnssd1 (>= 0.6.31), libusb-1.0-0, libpython3.5, libc6" ) SET ( CPACK_DEBIAN_PACKAGE_SECTION "Miscellaneous" ) # .rpm for rpm +https://cmake.org/cmake/help/v3.5/module/CPackRPM.html SET ( CPACK_RPM_PACKAGE_RELEASE 1) -SET ( CPACK_RPM_PACKAGE_LICENSE "unknown") -SET ( CPACK_RPM_PACKAGE_GROUP "unknown") -SET ( CPACK_RPM_PACKAGE_REQUIRES "libqt5core5a >= 5.5.0, libqt5network5 >= 5.5.0, libqt5gui5 >= 5.5.0, libqt5serialport5 >= 5.5.0, libqt5sql5 >= 5.5.0, libqt5sql5-sqlite >= 5.5.0, libavahi-core7 >= 0.6.31, libavahi-compat-libdnssd1 >= 0.6.31, libusb-1.0-0, libpython3.5, libc6") +SET ( CPACK_RPM_PACKAGE_LICENSE "MIT") +SET ( CPACK_RPM_PACKAGE_GROUP "Applications") +SET ( CPACK_RPM_PACKAGE_REQUIRES "qt5-qtbase >= 5.5.0, qt5-qtbase-gui >= 5.5.0, qt5-qtserialport >= 5.5.0, avahi-libs >= 0.6.31, avahi-compat-libdns_sd >= 0.6.31, libusbx, python35 >= 3.5.0") +# Notes: This is a dependency list for Fedora 27, different .rpm OSes use different names for their deps +SET ( CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/rpm/preinst" ) SET ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/rpm/postinst" ) +SET ( CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/rpm/prerm" ) # OSX "Bundle" generator TODO Add more osx generators # https://cmake.org/cmake/help/v3.10/module/CPackBundle.html diff --git a/cmake/rpm/postinst b/cmake/rpm/postinst index 0a4f066f..eb9fa7ec 100644 --- a/cmake/rpm/postinst +++ b/cmake/rpm/postinst @@ -91,6 +91,15 @@ ln -fs $BINSP/hyperion-x11 $BINTP/hyperion-x11 2>/dev/null ln -fs $BINSP/hyperion-aml $BINTP/hyperion-aml 2>/dev/null ln -fs $BINSP/hyperion-qt $BINTP/hyperion-qt 2>/dev/null +# install desktop icons +echo "---> Install Hyperion desktop icons" +mkdir /usr/share/pixmaps/hyperion 2>/dev/null +cp /usr/share/hyperion/desktop/*.png /usr/share/pixmaps/hyperion 2>/dev/null +desktop-file-install /usr/share/hyperion/desktop/hyperiond.desktop 2>/dev/null + +# cleanup desktop icons +rm -r /usr/share/hyperion/desktop 2>/dev/null + #Check, if dtparam=spi=on is in place if [ $CPU_RPI -eq 1 ]; then BOOT_DIR="/boot" diff --git a/cmake/rpm/preinst b/cmake/rpm/preinst new file mode 100644 index 00000000..3dbfdd2f --- /dev/null +++ b/cmake/rpm/preinst @@ -0,0 +1,61 @@ +#!/bin/sh + +echo "---Hyperion ambient light preinst ---" + +# search for users in system, returns first entry +FOUND_USR=`who | grep -o '^\w*\b'` || "root" + +# stop running daemon before we install +if pgrep hyperiond > /dev/null 2>&1 +then + if grep -m1 systemd /proc/1/comm > /dev/null + then + echo "--> stop init deamon: systemd" + # systemd + systemctl stop hyperiond"@${FOUND_USR}" 2> /dev/null + + elif [ -e /sbin/initctl ] + then + echo "--> stop init deamon: upstart" + # upstart + initctl stop hyperiond + + else + echo "--> stop init deamon: sysV" + # sysV + service hyperiond stop 2>/dev/null + fi +fi + +# In case we don't use a service kill all instances +killall hyperiond 2> /dev/null + +exit 0 + + +#$USR=hyperionIS; + +#addToGroup() +##{ +# getent group $1 && adduser $USR $1; +#} + +#check if user exists +#if id $USR >/dev/null 2>&1; then +# echo "--> hyperion user exists, skip creation"; +#else + ## create user +# echo "--> Create Hyperion user"; +# adduser --system --group $USR; +#fi + +# add user to groups if required +## secondary user groups that are required to access system things +#addToGroup(dialout); +#addToGroup(video); +#addToGroup(audio); +#addToGroup(systemd-journal); +# platform specific groups +#addToGroup(i2c); +#addToGroup(spi); +#addToGroup(gpio); diff --git a/cmake/rpm/prerm b/cmake/rpm/prerm new file mode 100644 index 00000000..388c79ae --- /dev/null +++ b/cmake/rpm/prerm @@ -0,0 +1,50 @@ +#!/bin/sh + +echo "---Hyperion ambient light prerm ---" + +# search for users in system, returns first entry +FOUND_USR=`who | grep -o '^\w*\b'` || "root" + +# stop running daemon before we delete it +HYPERION_RUNNING=false +pgrep hyperiond > /dev/null 2>&1 && HYPERION_RUNNING=true + +if grep -m1 systemd /proc/1/comm > /dev/null +then + echo "---> stop init deamon: systemd" + # systemd + $HYPERION_RUNNING && systemctl stop hyperiond"@${FOUND_USR}" 2> /dev/null + # disable user specific symlink + echo "---> Disable service and remove entry" + systemctl -q disable hyperiond"@${FOUND_USR}" + rm -v /etc/systemd/system/hyperiond@.service 2>/dev/null + +elif [ -e /sbin/initctl ] +then + echo "---> stop init deamon: upstart" + # upstart + $HYPERION_RUNNING && initctl stop hyperiond + echo "---> Remove upstart service" + rm -v /etc/init/hyperion* 2>/dev/null + initctl reload-configuration + +else + echo "---> stop init deamon: sysV" + # sysV + $HYPERION_RUNNING && service hyperiond stop 2>/dev/null + echo "---> Remove sysV service" + update-rc.d -f hyperion remove + rm /etc/init.d/hyperion* 2>/dev/null +fi + +# In case we don't use a service kill all instances +killall hyperiond 2> /dev/null + +# delete desktop icons; desktop-file-edit is a workaround to hide the entry and delete it afterwards manual. +# TODO Better way for deletion and keep the desktop in sync without logout/login or desktop dependend cmds? +echo "---> Delete Hyperion desktop icons" +desktop-file-edit --set-key=NoDisplay --set-value=true /usr/share/applications/hyperiond.desktop 2>/dev/null +rm -v /usr/share/applications/hyperion* 2>/dev/null +rm -rv /usr/share/pixmaps/hyperion 2>/dev/null + +exit 0 diff --git a/libsrc/flatbufserver/FlatBufferServer.cpp b/libsrc/flatbufserver/FlatBufferServer.cpp index 5522588a..a84b3537 100644 --- a/libsrc/flatbufserver/FlatBufferServer.cpp +++ b/libsrc/flatbufserver/FlatBufferServer.cpp @@ -97,7 +97,7 @@ void FlatBufferServer::stopServer() if(_server->isListening()) { // close client connections - for(auto client : _openConnections) + for(const auto& client : _openConnections) { client->forceClose(); } diff --git a/src/hyperiond/CMakeLists.txt b/src/hyperiond/CMakeLists.txt index ec849602..6c9689f6 100644 --- a/src/hyperiond/CMakeLists.txt +++ b/src/hyperiond/CMakeLists.txt @@ -52,11 +52,11 @@ if (ENABLE_AMLOGIC) endif () if (ENABLE_X11) - target_link_libraries(hyperiond x11-grabber ) + target_link_libraries(hyperiond x11-grabber) endif () if (ENABLE_QT) - target_link_libraries(hyperiond qt-grabber ) + target_link_libraries(hyperiond qt-grabber) endif () install ( TARGETS hyperiond DESTINATION "share/hyperion/bin/" COMPONENT "${PLATFORM}" ) @@ -64,6 +64,10 @@ install ( DIRECTORY ${CMAKE_SOURCE_DIR}/bin/service DESTINATION "share/hyperion/ install ( FILES ${CMAKE_SOURCE_DIR}/effects/readme.txt DESTINATION "share/hyperion/effects" COMPONENT "${PLATFORM}" ) install ( FILES ${CMAKE_SOURCE_DIR}/resources/icons/hyperion-icon-32px.png DESTINATION "share/hyperion/icons" COMPONENT "${PLATFORM}" ) +# Desktop file for hyperiond +install ( FILES ${CMAKE_SOURCE_DIR}/cmake/desktop/hyperiond_128.png DESTINATION "share/hyperion/desktop" COMPONENT "${PLATFORM}" ) +install ( FILES ${CMAKE_SOURCE_DIR}/cmake/desktop/hyperiond.desktop DESTINATION "share/hyperion/desktop" COMPONENT "${PLATFORM}" ) + if(CMAKE_HOST_UNIX) install(CODE "EXECUTE_PROCESS(COMMAND ln -sf \"../share/hyperion/bin/hyperiond\" \"${CMAKE_BINARY_DIR}/symlink_hyperiond\" )" COMPONENT "${PLATFORM}" ) install(FILES ${CMAKE_BINARY_DIR}/symlink_hyperiond DESTINATION "bin" RENAME hyperiond COMPONENT "${PLATFORM}" ) diff --git a/src/hyperiond/hyperiond.cpp b/src/hyperiond/hyperiond.cpp index e01c9a40..9b8a8a7a 100644 --- a/src/hyperiond/hyperiond.cpp +++ b/src/hyperiond/hyperiond.cpp @@ -371,10 +371,10 @@ void HyperionDaemon::handleSettingsUpdate(const settings::type& type, const QJso const QJsonArray & v4lArray = config.array(); for ( signed idx=0; idx