SET_TARGET_PROPERTIES(${PREFER_NUGET_CACHE_PLUGIN} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_LIB})
TARGET_LINK_LIBRARIES(${PREFER_NUGET_CACHE_PLUGIN} ${${PROJECT_NAME}_LDFLAGS} ${DOTNET_LAUNCHER_UTIL} ${TAC_COMMON})
+SET(DELETE_UNUSED_LIBRARY_PLUGIN "delete_unused_library_plugin")
+SET(${DELETE_UNUSED_LIBRARY_PLUGIN}_SOURCE_FILES
+ installer-plugin/delete_unused_library_plugin.cc
+)
+ADD_LIBRARY(${DELETE_UNUSED_LIBRARY_PLUGIN} SHARED ${${DELETE_UNUSED_LIBRARY_PLUGIN}_SOURCE_FILES})
+SET_TARGET_PROPERTIES(${DELETE_UNUSED_LIBRARY_PLUGIN} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_LIB})
+TARGET_LINK_LIBRARIES(${DELETE_UNUSED_LIBRARY_PLUGIN} ${${PROJECT_NAME}_LDFLAGS} ${DOTNET_LAUNCHER_UTIL})
+
CONFIGURE_FILE(dotnet-launcher.pc.in dotnet-launcher.pc @ONLY)
INSTALL(TARGETS ${DOTNET_LAUNCHER_UTIL} DESTINATION ${LIBDIR})
INSTALL(TARGETS ${DOTNETTOOL} DESTINATION ${BINDIR})
INSTALL(TARGETS ${PREFER_DOTNET_AOT_PLUGIN} DESTINATION ${INSTALL_MDPLUGIN_DIR})
INSTALL(TARGETS ${PREFER_NUGET_CACHE_PLUGIN} DESTINATION ${INSTALL_MDPLUGIN_DIR})
+INSTALL(TARGETS ${DELETE_UNUSED_LIBRARY_PLUGIN} DESTINATION ${INSTALL_PLUGIN_DIR})
INSTALL(FILES dotnet.loader DESTINATION ${LOADERDIR})
INSTALL(FILES dotnet.launcher DESTINATION ${LOADERDIR})
INSTALL(FILES dotnet.debugger DESTINATION ${LOADERDIR})
+type="tag";name="ui-application";path="/etc/package-manager/parserlib/libdelete_unused_library_plugin.so"
+type="tag";name="service-application";path="/etc/package-manager/parserlib/libdelete_unused_library_plugin.so"
+type="tag";name="widget-application";path="/etc/package-manager/parserlib/libdelete_unused_library_plugin.so"
+type="tag";name="watch-application";path="/etc/package-manager/parserlib/libdelete_unused_library_plugin.so"
type="metadata";name="http://tizen.org/metadata/prefer_nuget_cache";path="/etc/package-manager/parserlib/metadata/libprefer_nuget_cache_plugin.so"
type="metadata";name="http://tizen.org/metadata/prefer_dotnet_aot";path="/etc/package-manager/parserlib/metadata/libprefer_dotnet_aot_plugin.so"
--- /dev/null
+/*
+ * Copyright (c) 2020 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 "log.h"
+#include "utils.h"
+
+#include <regex>
+#include <vector>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "DOTNET_INSTALLER_PLUGIN"
+
+typedef struct _xmlDoc xmlDoc;
+typedef xmlDoc* xmlDocPtr;
+
+bool pluginInstalled = false;
+
+extern "C" int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr doc, const char* pkgId)
+{
+ // Can be multiple apps in one package
+ if (pluginInstalled) {
+ _INFO("Plugin already installed");
+ return 0;
+ }
+ pluginInstalled = true;
+
+ std::string appType = getAppType(pkgId);
+ if (appType.empty()) {
+ _ERR("Failed to get app type from [%s]", pkgId);
+ return 0;
+ }
+
+ if (appType.find("dotnet") == std::string::npos) {
+ return 0;
+ }
+
+ std::string rootPath = getRootPath(pkgId);
+ if (rootPath.empty()) {
+ _ERR("Failed to get root path from [%s]", pkgId);
+ return 0;
+ }
+
+ std::string runtimesDir = concatPath(rootPath, "bin/runtimes");
+ if (!bf::exists(runtimesDir)) {
+ return 0;
+ }
+
+ char buffer[128];
+ sprintf(buffer, "(tizen|linux|unix|base|any)(.\\d.\\d.\\d)?(-%s)?", ARCHITECTURE_IDENTIFIER);
+ std::regex pattern(buffer);
+
+ std::vector<std::string> unusedDir;
+ try {
+ for (auto& path : bf::recursive_directory_iterator(runtimesDir)) {
+ std::string filepath = path.path().string();
+ std::string targetDir = filepath.substr(filepath.rfind("/runtimes/") + 10);
+ if (!std::regex_match(targetDir.substr(0, targetDir.find('/')), pattern)) {
+ if (isDirectory(filepath)) {
+ unusedDir.push_back(filepath);
+ }
+ }
+ }
+ } catch (const bf::filesystem_error& error) {
+ _ERR("Failed to recursive directory: %s", error.what());
+ }
+
+ for (auto& path : unusedDir) {
+ if (!removeAll(path)) {
+ _ERR("Failed to remove of %s", path.c_str());
+ }
+ }
+ unusedDir.clear();
+
+ return 0;
+}
+extern "C" int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr doc, const char* pkgId)
+{
+ return PKGMGR_PARSER_PLUGIN_INSTALL(doc, pkgId);
+}
+extern "C" int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr doc, const char* pkgId)
+{
+ return 0;
+}
+extern "C" int PKGMGR_PARSER_PLUGIN_REMOVED(xmlDocPtr doc, const char* pkgId)
+{
+ return 0;
+}
+extern "C" int PKGMGR_PARSER_PLUGIN_CLEAN(xmlDocPtr doc, const char* pkgId)
+{
+ return 0;
+}
+extern "C" int PKGMGR_PARSER_PLUGIN_UNDO(xmlDocPtr doc, const char* pkgId)
+{
+ return 0;
+}
+extern "C" int PKGMGR_PARSER_PLUGIN_PRE_INSTALL(const char *pkgId)
+{
+ return 0;
+}
+extern "C" int PKGMGR_PARSER_PLUGIN_PRE_UPGRADE(const char *pkgId)
+{
+ return 0;
+}
+extern "C" int PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL(const char *pkgId)
+{
+ return 0;
+}
+extern "C" int PKGMGR_PARSER_PLUGIN_POST_INSTALL(const char *pkgId)
+{
+ return 0;
+}
+extern "C" int PKGMGR_PARSER_PLUGIN_POST_UPGRADE(const char *pkgId)
+{
+ return 0;
+}
+extern "C" int PKGMGR_PARSER_PLUGIN_POST_UNINSTALL(const char *pkgId)
+{
+ return 0;
+}
*/
#include <fstream>
-#include <regex>
#include <json/json.h>
#include <pkgmgr-info.h>
#include <pkgmgr_installer_info.h>
std::vector<std::string> getLibrariesInfo(const std::string& rootPath)
{
std::vector<std::string> LibrariesInfo;
- std::vector<std::string> unusedDir;
std::string runtimesDir = concatPath(rootPath, "bin/runtimes");
if (!bf::exists(runtimesDir))
return LibrariesInfo;
- char buffer[128];
- sprintf(buffer, "(tizen|linux|unix|base|any)(.\\d.\\d.\\d)?(-%s)?", ARCHITECTURE_IDENTIFIER);
- std::regex pattern(buffer);
-
- try {
- for (auto& path : bf::recursive_directory_iterator(runtimesDir)) {
- std::string filepath = path.path().string();
- std::size_t pos = filepath.rfind("/runtimes/");
- if (pos != std::string::npos) {
- std::string targetDir = filepath.substr(pos + 10);
- if (!std::regex_match(targetDir.substr(0, targetDir.find('/')), pattern)) {
- if (isDirectory(filepath))
- unusedDir.push_back(filepath);
- continue;
- }
- }
- if (filepath.rfind(".so") == std::string::npos)
- continue;
-
+ auto convert = [&LibrariesInfo](const std::string& filepath, const std::string& filename) {
+ if (filepath.rfind(".so") != std::string::npos) {
std::string buffer = SHA256(filepath);
LibrariesInfo.push_back(filepath + ":" + buffer);
- _INFO("Library : [%s] / SHA256 : [%s]", filepath.substr(filepath.rfind('/') + 1).c_str(), buffer.c_str());
+ _INFO("Library : [%s] / SHA256 : [%s]", filename.c_str(), buffer.c_str());
}
- } catch (const bf::filesystem_error& error) {
- _ERR("Failed to recursive directory: %s", error.what());
- }
-
- for (auto& path : unusedDir) {
- if (!removeAll(path)) {
- _ERR("Failed to remove of %s", path.c_str());
- }
- }
- unusedDir.clear();
+ };
+ scanFilesInDirectory(runtimesDir, convert, -1);
return LibrariesInfo;
}
%define _runtime_dir /usr/share/dotnet.tizen/netcoreapp
%define _framework_dir /usr/share/dotnet.tizen/framework
%define _install_mdplugin_dir /etc/package-manager/parserlib/metadata
+%define _install_plugin_dir /etc/package-manager/parserlib
%define _native_lib_dir /usr/share/dotnet.tizen/lib
%define _dotnet_dir /opt/usr/dotnet
%define _system_base_addr_file /opt/usr/dotnet.system.base.addr
-DFRAMEWORK_DIR=%{_framework_dir} \
-DCROSSGEN_PATH=%{_runtime_dir}/crossgen \
-DINSTALL_MDPLUGIN_DIR=%{_install_mdplugin_dir} \
+ -DINSTALL_PLUGIN_DIR=%{_install_plugin_dir} \
-DDOTNET_DIR=%{_dotnet_dir} \
-DVERSION=%{version} \
-DNATIVE_LIB_DIR=%{_native_lib_dir} \
%{_bindir}/dotnettool
%{_install_mdplugin_dir}/libprefer_nuget_cache_plugin.so
%{_install_mdplugin_dir}/libprefer_dotnet_aot_plugin.so
+%{_install_plugin_dir}/libdelete_unused_library_plugin.so
%{_bindir}/dotnet-launcher
%{_bindir}/dotnet-loader
%{_bindir}/dotnet