Various changes relating to build on Fedora Linux. 27/40427/3
authorDariusz Michaluk <d.michaluk@samsung.com>
Fri, 29 May 2015 12:44:12 +0000 (14:44 +0200)
committerDariusz Michaluk <d.michaluk@samsung.com>
Mon, 8 Jun 2015 13:58:11 +0000 (15:58 +0200)
[Bug/Feature]   Support different versions of json-c.
                Unify installation paths.
                Fix compiler warnings.
                Support different platform type in RPM spec file.
                Small changes in deamon and service configuration.
[Cause]         N/A
[Solution]      N/A
[Verification]  Build, run tests, run server on Tizen and Fedora.
                Select platform type with --define 'platform_type FEDORA or TIZEN'

Change-Id: I6ef85e9605d2069701ee68dd8e8946f0346387f5

17 files changed:
CMakeLists.txt
client/CMakeLists.txt
libs/config/CMakeLists.txt
libs/config/from-json-visitor.hpp
libs/config/from-kvjson-visitor.hpp
libs/config/to-json-visitor.hpp
libs/logger/ccolor.cpp
packaging/vasum.spec
server/CMakeLists.txt
server/configs/daemon.conf.in
server/configs/systemd/vasum.service.in
server/configs/templates/tizen-common-wayland.sh
tests/integration_tests/network_tests/network_common.py
tests/unit_tests/CMakeLists.txt
tests/unit_tests/configs/CMakeLists.txt
tests/unit_tests/configs/systemd/vasum-socket-test.service.in [moved from tests/unit_tests/configs/systemd/vasum-socket-test.service with 72% similarity]
wrapper/CMakeLists.txt

index d42f496..e865117 100644 (file)
@@ -91,6 +91,11 @@ ADD_DEFINITIONS(-DPROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}")
 ADD_DEFINITIONS(-DUSE_EXEC)
 ADD_DEFINITIONS(-D__STDC_LIMIT_MACROS)
 
+PKG_SEARCH_MODULE(JSON_C REQUIRED json json-c)
+IF(JSON_C_VERSION GREATER 0.11)
+    ADD_DEFINITIONS(-DJSON_C_VERSION_NEW)
+ENDIF(JSON_C_VERSION GREATER 0.11)
+
 IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
     # Warn about documentation problems
     ADD_DEFINITIONS("-Wdocumentation")
@@ -151,32 +156,29 @@ SET(TESTS_FOLDER ${PROJECT_SOURCE_DIR}/tests)
 SET(CLI_FOLDER ${PROJECT_SOURCE_DIR}/cli)
 SET(WRAPPER_FOLDER ${PROJECT_SOURCE_DIR}/wrapper)
 
+
 IF(NOT DEFINED SYSCONF_INSTALL_DIR)
     SET(SYSCONF_INSTALL_DIR "/etc")
 ENDIF(NOT DEFINED SYSCONF_INSTALL_DIR)
 
 IF(NOT DEFINED LIB_INSTALL_DIR)
-    SET(LIB_INSTALL_DIR "${CMAKE_INSTALL_FULL_LIBDIR}")
+    SET(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib")
 ENDIF(NOT DEFINED LIB_INSTALL_DIR)
 
 IF(NOT DEFINED INCLUDE_INSTALL_DIR)
-    SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
+    SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
 ENDIF(NOT DEFINED INCLUDE_INSTALL_DIR)
 
 IF(NOT DEFINED SCRIPT_INSTALL_DIR)
-    SET(SCRIPT_INSTALL_DIR "${CMAKE_INSTALL_FULL_SBINDIR}")
+    SET(SCRIPT_INSTALL_DIR "${CMAKE_INSTALL_SBINDIR}")
 ENDIF(NOT DEFINED SCRIPT_INSTALL_DIR)
 
-IF(NOT DEFINED SHARE_INSTALL_PREFIX)
-    SET(SHARE_INSTALL_PREFIX "${CMAKE_INSTALL_FULL_DATAROOTDIR}")
-ENDIF(NOT DEFINED SHARE_INSTALL_PREFIX)
-
 IF(NOT DEFINED SYSTEMD_UNIT_DIR)
     SET(SYSTEMD_UNIT_DIR "${LIB_INSTALL_DIR}/systemd/system")
 ENDIF(NOT DEFINED SYSTEMD_UNIT_DIR)
 
 IF(NOT DEFINED DATA_DIR)
-    SET(DATA_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}")
+    SET(DATA_DIR "${CMAKE_INSTALL_PREFIX}/share")
 ENDIF(NOT DEFINED DATA_DIR)
 
 SET(VSM_CONFIG_INSTALL_DIR ${SYSCONF_INSTALL_DIR}/vasum)
index c9f4c17..3fa44fd 100644 (file)
@@ -62,7 +62,7 @@ INSTALL(FILES       ${CMAKE_BINARY_DIR}/${PC_FILE}
         DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
 
 INSTALL(TARGETS     ${PROJECT_NAME}
-        DESTINATION ${CMAKE_INSTALL_LIBDIR}
+        DESTINATION ${LIB_INSTALL_DIR}
         COMPONENT   RuntimeLibraries)
 
 INSTALL(FILES       vasum-client.h
index 87c2af1..fcc5e23 100644 (file)
@@ -38,9 +38,11 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
 
 ## Link libraries ##############################################################
 PKG_CHECK_MODULES(CONFIG_DEPS REQUIRED sqlite3 glib-2.0)
+PKG_SEARCH_MODULE(JSON_C json json-c)
+
 INCLUDE_DIRECTORIES(${LIBS_FOLDER})
-INCLUDE_DIRECTORIES(SYSTEM ${CONFIG_DEPS_INCLUDE_DIRS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${CONFIG_DEPS_LIBRARIES})
+INCLUDE_DIRECTORIES(SYSTEM ${CONFIG_DEPS_INCLUDE_DIRS} ${JSON_C_INCLUDE_DIRS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${CONFIG_DEPS_LIBRARIES} ${JSON_C_LIBRARIES})
 
 ## Generate the pc file ########################################################
 CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_CURRENT_BINARY_DIR}/${PC_FILE} @ONLY)
index 2934adf..8831ef6 100644 (file)
 #include "config/is-visitable.hpp"
 #include "config/exception.hpp"
 
+#ifdef JSON_C_VERSION_NEW
+#include <json-c/json.h>
+#else //JSON_C_VERSION_NEW
 #include <json/json.h>
+#endif //JSON_C_VERSION_NEW
+
 #include <string>
 #include <vector>
 
index 35e1bf7..f9c11ef 100644 (file)
 
 #include "config/from-kvstore-visitor.hpp"
 #include "config/is-union.hpp"
+
+#ifdef JSON_C_VERSION_NEW
+#include <json-c/json.h>
+#else //JSON_C_VERSION_NEW
 #include <json/json.h>
+#endif //JSON_C_VERSION_NEW
 
 namespace config {
 
index f524900..1b68438 100644 (file)
 #include "config/is-visitable.hpp"
 #include "config/exception.hpp"
 
+#ifdef JSON_C_VERSION_NEW
+#include <json-c/json.h>
+#else //JSON_C_VERSION_NEW
 #include <json/json.h>
+#endif //JSON_C_VERSION_NEW
+
 #include <string>
 #include <vector>
 
@@ -108,7 +113,11 @@ private:
 
     static json_object* toJsonObject(double value)
     {
+#ifdef JSON_C_VERSION_NEW
+        return json_object_new_double_s(value, std::to_string(value).c_str());
+#else //JSON_C_VERSION_NEW
         return json_object_new_double(value);
+#endif //JSON_C_VERSION_NEW
     }
 
     static json_object* toJsonObject(const std::string& value)
index 7424044..9cc652d 100644 (file)
@@ -34,7 +34,7 @@ std::string getConsoleEscapeSequence(Attributes attr, Color color)
     char command[10];
 
     // Command is the control command to the terminal
-    snprintf(command, sizeof(command), "%c[%d;%dm", 0x1B, attr, color);
+    snprintf(command, sizeof(command), "%c[%u;%um", 0x1B, (unsigned int)attr, (unsigned int)color);
     return std::string(command);
 }
 
index 8f10a1c..bd7346c 100644 (file)
@@ -8,6 +8,8 @@
 %define disk_group disk
 # The group that has write access to /dev/tty* devices.
 %define tty_group tty
+# Default platform is Tizen, setup Fedora with --define 'platform_type FEDORA'
+%{!?platform_type:%define platform_type "TIZEN"}
 
 Name:           vasum
 Epoch:          1
@@ -19,13 +21,16 @@ Group:          Security/Other
 Summary:        Daemon for managing zones
 BuildRequires:  cmake
 BuildRequires:  boost-devel
-BuildRequires:  libjson-devel >= 0.10
-BuildRequires:  lxc-devel
 BuildRequires:  pkgconfig(glib-2.0)
-BuildRequires:  pkgconfig(sqlite3)
-Requires(post): libcap-tools
+BuildRequires:  lxc-devel
+Requires:       lxc
+%if %{platform_type} == "TIZEN"
 Requires:       iproute2
-Requires:       libjson >= 0.10
+Requires(post): libcap-tools
+%else
+Requires:       iproute
+Requires(post): libcap
+%endif
 Obsoletes:      vasum-daemon < 1:0
 
 %description
@@ -34,11 +39,12 @@ between them. A process from inside a zone can request a switch of context
 (display, input devices) to the other zone.
 
 %files
+%if %{platform_type} == "TIZEN"
 %manifest packaging/vasum.manifest
+%endif
 %defattr(644,root,root,755)
 %attr(755,root,root) %{_bindir}/vasum-server
 %dir /etc/vasum
-%dir /etc/vasum/zones
 %dir /etc/vasum/templates
 %config /etc/vasum/daemon.conf
 %attr(755,root,root) /etc/vasum/templates/*.sh
@@ -47,7 +53,7 @@ between them. A process from inside a zone can request a switch of context
 %{_unitdir}/vasum.socket
 %{_unitdir}/multi-user.target.wants/vasum.service
 %config /etc/dbus-1/system.d/org.tizen.vasum.host.conf
-%dir %{_datadir}/.zones
+%dir %{_datadir}/zones
 
 %prep
 %setup -q
@@ -77,7 +83,7 @@ make -k %{?jobs:-j%jobs}
 %make_install
 mkdir -p %{buildroot}/%{_unitdir}/multi-user.target.wants
 ln -s ../vasum.service %{buildroot}/%{_unitdir}/multi-user.target.wants/vasum.service
-mkdir -p %{buildroot}/%{_datadir}/.zones
+mkdir -p %{buildroot}/%{_datadir}/zones
 
 %clean
 rm -rf %{buildroot}
@@ -127,7 +133,9 @@ Library interface to the vasum daemon
 %postun -n vasum-client -p /sbin/ldconfig
 
 %files client
+%if %{platform_type} == "TIZEN"
 %manifest packaging/libvasum-client.manifest
+%endif
 %defattr(644,root,root,755)
 %attr(755,root,root) %{_libdir}/libvasum-client.so.%{version}
 %{_libdir}/libvasum-client.so.0
@@ -146,7 +154,9 @@ Requires:         vasum-client = %{epoch}:%{version}-%{release}
 Development package including the header files for the client library
 
 %files devel
+%if %{platform_type} == "TIZEN"
 %manifest packaging/vasum.manifest
+%endif
 %defattr(644,root,root,755)
 %{_libdir}/libvasum-client.so
 %{_libdir}/libvasum.so
@@ -164,7 +174,9 @@ Group:            Security/Other
 Zones support installed inside every zone.
 
 %files zone-support
+%if %{platform_type} == "TIZEN"
 %manifest packaging/vasum-zone-support.manifest
+%endif
 %defattr(644,root,root,755)
 %config /etc/dbus-1/system.d/org.tizen.vasum.zone.conf
 
@@ -179,7 +191,9 @@ Requires:         vasum-zone-support = %{epoch}:%{version}-%{release}
 Daemon running inside every zone.
 
 %files zone-daemon
+%if %{platform_type} == "TIZEN"
 %manifest packaging/vasum-zone-daemon.manifest
+%endif
 %defattr(644,root,root,755)
 %attr(755,root,root) %{_bindir}/vasum-zone-daemon
 %config /etc/dbus-1/system.d/org.tizen.vasum.zone.daemon.conf
@@ -217,7 +231,9 @@ Group:            Development/Libraries
 Requires:         vasum = %{epoch}:%{version}-%{release}
 Requires:         vasum-client = %{epoch}:%{version}-%{release}
 Requires:         python
+%if %{platform_type} == "TIZEN"
 Requires:         python-xml
+%endif
 Requires:         boost-test
 
 %description tests
@@ -236,7 +252,9 @@ systemctl disable vasum-socket-test.socket
 systemctl daemon-reload
 
 %files tests
+%if %{platform_type} == "TIZEN"
 %manifest packaging/vasum-server-tests.manifest
+%endif
 %defattr(644,root,root,755)
 %attr(755,root,root) %{_bindir}/vasum-server-unit-tests
 %attr(755,root,root) %{_bindir}/vasum-socket-test
@@ -327,6 +345,14 @@ The package provides libSimpleDbus development tools and libs.
 %package -n libConfig
 Summary:            Config library
 Group:              Security/Other
+BuildRequires:      pkgconfig(sqlite3)
+%if %{platform_type} == "TIZEN"
+BuildRequires:      libjson-devel >= 0.10
+Requires:           libjson >= 0.10
+%else
+BuildRequires:      json-c-devel
+Requires:           json-c
+%endif
 Requires(post):     /sbin/ldconfig
 Requires(postun):   /sbin/ldconfig
 
@@ -348,7 +374,11 @@ Group:          Development/Libraries
 Requires:       libConfig = %{epoch}:%{version}-%{release}
 Requires:       boost-devel
 Requires:       pkgconfig(libLogger)
-Requires:       libjson-devel
+%if %{platform_type} == "TIZEN"
+Requires:       libjson-devel >= 0.10
+%else
+Requires:       json-c-devel
+%endif
 
 %description -n libConfig-devel
 The package provides libConfig development tools and libs.
index 9a1985c..92672c1 100644 (file)
@@ -30,7 +30,7 @@ ADD_EXECUTABLE(${SERVER_CODENAME} ${project_SRCS} ${common_SRCS})
 
 ## Link libraries ##############################################################
 FIND_PACKAGE(Boost COMPONENTS program_options system filesystem regex)
-PKG_CHECK_MODULES(SERVER_DEPS REQUIRED lxc json gio-2.0)
+PKG_CHECK_MODULES(SERVER_DEPS REQUIRED lxc glib-2.0 gio-2.0)
 
 INCLUDE_DIRECTORIES(${COMMON_FOLDER})
 INCLUDE_DIRECTORIES(${LIBS_FOLDER})
index b94eb29..f3dd9fd 100644 (file)
@@ -1,13 +1,13 @@
 {
-    "dbPath" : "/usr/dbspace/vasum.db",
+    "dbPath" : "/etc/vasum/vasum.db",
     "zoneIds" : [],
-    "zonesPath" : "${DATA_DIR}/.zones",
+    "zonesPath" : "${DATA_DIR}/zones",
     "zoneImagePath" : "",
     "zoneTemplateDir" : "/etc/vasum/templates/",
     "runMountPointPrefix" : "/var/run/zones",
     "defaultId" : "",
     "availableVTs" : [3, 4, 5, 6],
-    "inputConfig" : {"enabled" : true,
+    "inputConfig" : {"enabled" : false,
                      "device" : "gpio_keys.6",
                      "code" : 116,
                      "numberOfEvents" : 2,
index 29ebbc8..1b6284f 100644 (file)
@@ -1,6 +1,5 @@
 [Unit]
 Description=Vasum Server
-ConditionVirtualization=no
 
 [Service]
 Type=simple
index 5c57aff..30b90cd 100755 (executable)
@@ -122,6 +122,8 @@ ${path}/systemd/user
 /bin/ln -s /dev/null ${path}/systemd/system/systemd-udevd.service
 /bin/ln -s /dev/null ${path}/systemd/system/systemd-udevd-kernel.socket
 /bin/ln -s /dev/null ${path}/systemd/system/systemd-udevd-control.socket
+/bin/ln -s /dev/null ${path}/systemd/system/vasum.service
+/bin/ln -s /dev/null ${path}/systemd/system/vasum.socket
 /bin/ln -s /dev/null ${path}/systemd/system/vconf-setup.service
 /bin/ln -s /usr/lib/systemd/system/tlm.service ${path}/systemd/system/multi-user.target.wants/tlm.service
 /bin/ln -s /dev/null ${path}/systemd/user/media-server-user.service
index acb120c..98e85b5 100755 (executable)
@@ -31,7 +31,7 @@ TEST_URL_INTERNET=["www.samsung.com", "www.google.com", "www.oracle.com"]
 
 #TODO read path from config (daemon.conf)
 # Path to test zone
-TEST_ZONE_PATH="/usr/share/.zones"
+TEST_ZONE_PATH="/usr/share/zones"
 
 # Device Ethernet device
 ETHERNET_DEVICE="usb0"
index 484e810..46a9a3b 100644 (file)
@@ -47,7 +47,7 @@ ADD_EXECUTABLE(${SOCKET_TEST_CODENAME} ${socket_test_SRCS} ${common_SRCS} ${clie
 ## Link libraries ##############################################################
 FIND_PACKAGE (Boost COMPONENTS unit_test_framework system filesystem regex)
 
-PKG_CHECK_MODULES(UT_SERVER_DEPS REQUIRED lxc json gio-2.0)
+PKG_CHECK_MODULES(UT_SERVER_DEPS REQUIRED lxc gio-2.0)
 INCLUDE_DIRECTORIES(${COMMON_FOLDER} ${SERVER_FOLDER} ${UNIT_TESTS_FOLDER} ${CLIENT_FOLDER}
                     ${LIBS_FOLDER} ${SOCKET_TEST_FOLDER})
 INCLUDE_DIRECTORIES(SYSTEM ${UT_SERVER_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
index a18914e..6bffac4 100644 (file)
@@ -34,6 +34,9 @@ CONFIGURE_FILE(templates/console-ipc.conf.in
                ${CMAKE_BINARY_DIR}/templates/console-ipc.conf @ONLY)
 FILE(GLOB ut_zone_templates_CONF_GEN ${CMAKE_BINARY_DIR}/templates/*.conf)
 
+CONFIGURE_FILE(systemd/vasum-socket-test.service.in
+               ${CMAKE_BINARY_DIR}/systemd/vasum-socket-test.service)
+
 
 ## Install #####################################################################
 INSTALL(FILES        ${ut_zone_CONF}
@@ -58,7 +61,7 @@ INSTALL(FILES        utils/file.txt
         DESTINATION  ${VSM_TEST_CONFIG_INSTALL_DIR}/utils)
 
 INSTALL(FILES        systemd/vasum-socket-test.socket
-                     systemd/vasum-socket-test.service
+                     ${CMAKE_BINARY_DIR}/systemd/vasum-socket-test.service
         DESTINATION  ${SYSTEMD_UNIT_DIR})
 
 INSTALL(FILES        dbus-1/system.d/org.tizen.vasum.tests.conf
@@ -3,7 +3,7 @@ Description=Vasum Socket tests mini-service
 
 [Service]
 Type=simple
-ExecStart=/usr/bin/vasum-socket-test
+ExecStart=${CMAKE_INSTALL_PREFIX}/bin/vasum-socket-test
 Sockets=vasum-socket-test.socket
 StartLimitInterval=0
 StartLimitBurst=0
index a8aa173..23fdba6 100644 (file)
@@ -70,7 +70,7 @@ INSTALL(FILES       ${CMAKE_BINARY_DIR}/${PC_FILE}
         DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
 
 INSTALL(TARGETS     ${PROJECT_NAME}
-        DESTINATION ${CMAKE_INSTALL_LIBDIR}
+        DESTINATION ${LIB_INSTALL_DIR}
         COMPONENT   RuntimeLibraries)
 
 INSTALL(FILES       vasum.h vasum_list.h