Implement metadata plugin for appfw 33/110633/9 accepted/tizen/common/20170123.182352 accepted/tizen/ivi/20170123.114806 accepted/tizen/mobile/20170123.114731 accepted/tizen/tv/20170123.114750 submit/tizen/20170123.081747
authorInhwan Lee <ideal.lee@samsung.com>
Tue, 17 Jan 2017 08:20:10 +0000 (17:20 +0900)
committerInhwan Lee <ideal.lee@samsung.com>
Mon, 23 Jan 2017 08:14:16 +0000 (17:14 +0900)
If application has specific metadata,
appfw will call plugin that implemented

Only working for AOT with below metadata
"http://tizen.org/metadata/prefer_dotnet_aot"

Change-Id: I31a13b678ecfff3f430c4fad2656e5f358479cbf

NativeLauncher/CMakeLists.txt [changed mode: 0644->0755]
NativeLauncher/inc/utils.h [changed mode: 0644->0755]
NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc [new file with mode: 0755]
NativeLauncher/util/utils.cc [changed mode: 0644->0755]
packaging/dotnet-launcher.spec [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 3c35c5f..5398487
@@ -7,7 +7,7 @@ IF(DEFINED NO_TIZEN)
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DNO_TIZEN")
 ELSE(DEFINED NO_TIZEN)
        INCLUDE(FindPkgConfig)
-       PKG_CHECK_MODULES(${PROJECT_NAME} REQUIRED aul pkgmgr-info pkgmgr-installer dlog ecore bundle dlog launchpad elementary)
+       PKG_CHECK_MODULES(${PROJECT_NAME} REQUIRED aul pkgmgr-info pkgmgr-installer dlog ecore bundle dlog launchpad elementary glib-2.0)
 ENDIF(DEFINED NO_TIZEN)
 
 FOREACH(flag ${${PROJECT_NAME}_CFLAGS})
@@ -99,10 +99,23 @@ ADD_LIBRARY(${INSTALLER_PLUGIN} SHARED ${${INSTALLER_PLUGIN}_SOURCE_FILES})
 SET_TARGET_PROPERTIES(${INSTALLER_PLUGIN}      PROPERTIES COMPILE_FLAGS "-fPIC")
 TARGET_LINK_LIBRARIES(${INSTALLER_PLUGIN} ${${PROJECT_NAME}_LDFLAGS})
 
+
+SET(PREFER_DOTNET_AOT_PLUGIN "prefer_dotnet_aot_plugin")
+SET(${PREFER_DOTNET_AOT_PLUGIN}_SOURCE_FILES
+       util/utils.cc
+       installer-plugin/common.cc
+       installer-plugin/prefer_dotnet_aot_plugin.cc
+)
+ADD_LIBRARY(${PREFER_DOTNET_AOT_PLUGIN} SHARED ${${PREFER_DOTNET_AOT_PLUGIN}_SOURCE_FILES})
+SET_TARGET_PROPERTIES(${PREFER_DOTNET_AOT_PLUGIN}      PROPERTIES COMPILE_FLAGS "-fPIC")
+TARGET_LINK_LIBRARIES(${PREFER_DOTNET_AOT_PLUGIN} ${${PROJECT_NAME}_LDFLAGS})
+
+
 IF(NOT DEFINED NO_TIZEN)
        INSTALL(TARGETS ${DOTNET_LAUNCHER} DESTINATION ${BINDIR})
        INSTALL(TARGETS ${NITOOL} DESTINATION ${BINDIR})
        INSTALL(TARGETS ${INSTALLER_PLUGIN} DESTINATION ${INSTALL_PLUGIN_DIR})
+       INSTALL(TARGETS ${PREFER_DOTNET_AOT_PLUGIN} DESTINATION ${INSTALL_MDPLUGIN_DIR})
        INSTALL(FILES dotnet.loader DESTINATION ${LOADERDIR})
        INSTALL(FILES dotnet.launcher DESTINATION ${LOADERDIR})
        INSTALL(FILES dotnet.debugger DESTINATION ${LOADERDIR})
old mode 100644 (file)
new mode 100755 (executable)
index 3e56112..b66a708
@@ -41,5 +41,4 @@ std::string JoinStrings(const std::vector<std::string>& strings, const char* con
 
 typedef std::function<void (const char*)> FileReader;
 void ScanFilesInDir(const char* directory, FileReader reader, unsigned int depth);
-
 #endif  // __UTILS_H__
diff --git a/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc b/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc
new file mode 100755 (executable)
index 0000000..f180739
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "common.h"
+#include "log.h"
+#include "utils.h"
+
+#ifdef  LOG_TAG
+#undef  LOG_TAG
+#endif
+#define LOG_TAG "NETCORE_INSTALLER_PLUGIN"
+
+#include <cstring>
+#include <vector>
+#include <sstream>
+#include <glib.h>
+
+typedef struct Metadata {
+    const char *key;
+    const char *value;
+} Metadata;
+
+const std::string VALUE_TRUE = "true";
+const std::string mdKey = "http://tizen.org/metadata/prefer_dotnet_aot";
+extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL (const char *pkgid, const char *appid, GList *list)
+{
+
+    GList *tag = NULL;
+    bool mdValue = false;
+    Metadata *mdInfo = NULL;
+    tag = g_list_first(list);
+    while (tag) {
+        mdInfo = (Metadata*)tag->data;
+        if(mdInfo->key == mdKey && mdInfo->value == VALUE_TRUE) {
+            _DBG("Prefer dotnet application AOT set TRUE");
+            mdValue = true;
+        }
+        tag = g_list_next(tag);
+    }
+
+    if (mdValue) {
+        if (create_ni_under_pkg_root(pkgid) != 0)
+        {
+            _ERR("Failed to get root path from [%s]", pkgid);
+            return -1;
+        } else {
+            _DBG("Complete make application to native image");
+        }
+    }
+    return 0;
+}
+
+extern "C" int PKGMGR_MDPARSER_PLUGIN_UPGRADE (const char *pkgid, const char *appid, GList *list)
+{
+    return PKGMGR_MDPARSER_PLUGIN_INSTALL(pkgid, appid, list);
+}
old mode 100644 (file)
new mode 100755 (executable)
index 48810d9..212f1d6
@@ -349,4 +349,4 @@ void ScanFilesInDir(const char* directory, FileReader reader, unsigned int depth
   }
 
   closedir(dir);
-}
+}
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index ac73341..7a40c06
@@ -16,6 +16,7 @@ BuildRequires: pkgconfig(launchpad)
 BuildRequires: pkgconfig(pkgmgr-info)
 BuildRequires: pkgconfig(pkgmgr-installer)
 BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(glib-2.0)
 BuildRequires: aul-devel
 BuildRequires: dotnet-build-tools
 
@@ -33,6 +34,7 @@ Requires(preun): /usr/bin/systemctl
 %define _runtime_dir /opt/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.0
 %define _preload_dir /opt/usr/share/dotnet.tizen/preload
 %define _install_plugin_dir /usr/etc/package-manager/parserlib
+%define _install_mdplugin_dir /etc/package-manager/parserlib/metadata
 
 ExcludeArch: %{ix86} aarch64
 
@@ -57,6 +59,7 @@ cmake \
        -DCORECLR_LAUNCHER_ASSEMBLY_PATH=%{_bindir}/Tizen.Runtime.Coreclr.dll \
        -DMONO_LAUNCHER_ASSEMBLY_PATH=%{_bindir}/Tizen.Runtime.Mono.dll \
        -DINSTALL_PLUGIN_DIR=%{_install_plugin_dir} \
+       -DINSTALL_MDPLUGIN_DIR=%{_install_mdplugin_dir} \
        -DVERSION=%{version} \
        NativeLauncher
 
@@ -90,5 +93,6 @@ install -p -m 644 Tizen.Runtime/bin/Tizen.Runtime.Mono.dll %{buildroot}%{_bindir
 %caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/dotnet-launcher
 %caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/nitool
 %caps(cap_mac_admin,cap_setgid=ei) %{_install_plugin_dir}/libui-application.so
+%caps(cap_mac_admin,cap_setgid=ei) %{_install_mdplugin_dir}/libprefer_dotnet_aot_plugin.so
 %caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/Tizen.Runtime.Coreclr.dll
 %caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/Tizen.Runtime.Mono.dll