Parse virtual root, symlink for apk
authorDuyoung Jang <duyoung.jang@samsung.com>
Tue, 28 May 2013 07:05:31 +0000 (16:05 +0900)
committerDuyoung Jang <duyoung.jang@samsung.com>
Tue, 28 May 2013 07:05:31 +0000 (16:05 +0900)
Change-Id: Ibac54ba072ac63d007dccc930d9e78484b6df1cb
Signed-off-by: Duyoung Jang <duyoung.jang@samsung.com>
inc/InstallerDefs.h
src/Context/InstallationContext.cpp
src/Context/InstallationContext.h
src/Manager/ConfigurationManager.cpp
src/Manager/PermissionManager.cpp
src/XmlHandler/ManifestHandler.cpp
src/XmlHandler/ManifestHandler.h

index 5c5843f..a4fa821 100755 (executable)
@@ -23,7 +23,7 @@
 
 #include "InstallerUtil.h"
 
-#define OSP_INSTALLER_VERSION "version=[20130527.2]"
+#define OSP_INSTALLER_VERSION "version=[20130528.1]"
 
 #define DIR_BIN                                L"/bin"
 #define DIR_INFO                       L"/info"
@@ -59,6 +59,7 @@
 #define FILE_EXT_INFO                          L"info"
 #define VERSION_INFO_FILE                      L"/info/version.info"
 #define COMPAT_INFO_FILE                       L"/info/compat.info"
+#define VIRTUAL_ROOT_INFO_FILE         L"/info/virtualroot.info"
 #define UISCALABILITY_INFO_FILE                L"/info/uiscalability.info"
 #define WEBSERVICE_INFO_FILE           L"/info/webservice.info"
 #define TYPE_INFO_FILE                         L"/info/type.info"
index a756c5c..621543a 100755 (executable)
@@ -55,6 +55,7 @@ InstallationContext::InstallationContext(void)
 ,__isAntiVirus(false)
 ,__isCsc(false)
 ,__isUninstallable(false)
+,__isVirtualRoot(false)
 ,__operation(INSTALLER_OPERATION_INSTALL)
 ,__storage(INSTALLATION_STORAGE_NONE)
 ,__rootCertType(ROOT_CERTIFICATE_NONE)
@@ -68,6 +69,7 @@ InstallationContext::InstallationContext(void)
 ,__pAuthorCertList(null)
 ,__pDistributorCertList(null)
 ,__pDistributorCertList2(null)
+,__pSymbolicLinkList(null)
 ,__certType(0)
 ,__pPkgmgrInstaller(null)
 {
@@ -127,6 +129,13 @@ InstallationContext::~InstallationContext(void)
                delete __pDistributorCertList2;
                __pDistributorCertList2 = null;
        }
+
+       if (__pSymbolicLinkList)
+       {
+               __pSymbolicLinkList->RemoveAll();
+               delete __pSymbolicLinkList;
+               __pSymbolicLinkList = null;
+       }
 }
 
 InstallerError
@@ -144,6 +153,10 @@ InstallationContext::Construct(void)
        __pDistributorCertList2 = new (std::nothrow) ArrayListT<String*>;
        TryReturn(__pDistributorCertList2, INSTALLER_ERROR_OUT_OF_MEMORY, "__pDistributorCertList2 is null.");
 
+       __pSymbolicLinkList = new (std::nothrow) MultiHashMapT<String*, String*>;
+       TryReturn(__pSymbolicLinkList, INSTALLER_ERROR_OUT_OF_MEMORY, "__pSymbolicLinkList is null.");
+       __pSymbolicLinkList->Construct();
+
        return INSTALLER_ERROR_NONE;
 }
 
index 2e62846..d6f939d 100755 (executable)
@@ -103,6 +103,7 @@ public:
        bool __isAntiVirus;
        bool __isCsc;
        bool __isUninstallable;
+       bool __isVirtualRoot;
 
        InstallerOperation __operation;
        InstallationStorage __storage;
@@ -121,6 +122,8 @@ public:
        Tizen::Base::Collection::ArrayListT<Tizen::Base::String *>* __pDistributorCertList;
        Tizen::Base::Collection::ArrayListT<Tizen::Base::String *>* __pDistributorCertList2;
 
+       Tizen::Base::Collection::MultiHashMapT<Tizen::Base::String*, Tizen::Base::String*>* __pSymbolicLinkList;
+
        Tizen::Base::String __coreXmlPath;
        Tizen::Base::String __inputPath;
        Tizen::Base::String __packagePath;
index 293f7ee..26422e6 100755 (executable)
@@ -79,6 +79,15 @@ ConfigurationManager::CreateFile(InstallationContext* pContext)
                InstallerUtil::CreateInfoFile(compatInfoFile, null);
        }
 
+       if (pContext->__isVirtualRoot == true)
+       {
+               AppLog("[VirtualRoot] is detected");
+
+               String virtualRootInfoFile;
+               virtualRootInfoFile.Format(1024, L"%ls%ls", rootPath.GetPointer(), VIRTUAL_ROOT_INFO_FILE);
+               InstallerUtil::CreateInfoFile(virtualRootInfoFile, null);
+       }
+
        String webServicePrivilege(TIZEN_PRIVILEGE_WEB_SERVICE);
        if (FindPrivilege(pContext, webServicePrivilege) == true)
        {
@@ -228,8 +237,6 @@ ConfigurationManager::CreateFile(InstallationContext* pContext)
                }
        }
 
-       bool firstPreloadedUpdate = false;
-
        String roXmlPath;
        roXmlPath.Format(1024, DIR_RO_PACKAGE_SYSTEM_MANIFEST, pContext->__packageId.GetPointer());
 
@@ -243,11 +250,6 @@ ConfigurationManager::CreateFile(InstallationContext* pContext)
        else
        {
                pContext->__coreXmlPath = rwXmlPath;
-               if ((File::IsFileExist(roXmlPath) == true) && (File::IsFileExist(rwXmlPath) == false))
-               {
-                       AppLog("First preloaded app update");
-                       firstPreloadedUpdate = true;
-               }
        }
 
        std::unique_ptr<char[]> pXmlPath(_StringConverter::CopyToCharArrayN(pContext->__coreXmlPath));
@@ -275,23 +277,6 @@ ConfigurationManager::CreateFile(InstallationContext* pContext)
        }
        else
        {
-#if 0
-               AppLog("pkgmgr_parser_parse_manifest_for_uninstallation() - START");
-               if (firstPreloadedUpdate == false)
-               {
-                       AppLog(" - uninstall path=[%s]", pXmlPath.get());
-                       pkgmgr_parser_parse_manifest_for_uninstallation(pXmlPath.get(), null);
-               }
-               else
-               {
-                       std::unique_ptr<char[]> pRoXmlPath(_StringConverter::CopyToCharArrayN(roXmlPath));
-                       AppLog(" - uninstall path=[%s]", pRoXmlPath.get());
-                       pkgmgr_parser_parse_manifest_for_uninstallation(pRoXmlPath.get(), null);
-               }
-
-               AppLog("pkgmgr_parser_parse_manifest_for_uninstallation() - END");
-#endif
-
                CreateCoreXmlFile(pContext);
        }
        
index fb88202..8973340 100755 (executable)
@@ -156,7 +156,7 @@ PermissionManager::SetDirectory(InstallationContext* pContext)
        if (File::IsFileExist(destPath) == false)
        {
                r = Directory::Create(destPath, false);
-               TryReturn(!IsFailed(r), INSTALLER_ERROR_INTERNAL_STATE, "Directory::Create() failed");
+               TryReturn(!IsFailed(r), false, "Directory::Create() failed");
        }
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
        smackManager.AddLabelDir(packageId, destPath);
@@ -190,6 +190,25 @@ PermissionManager::SetDirectory(InstallationContext* pContext)
                        return false;
                }
        }
+
+       if (pContext->__isVirtualRoot == true)
+       {
+               if (pContext->__pSymbolicLinkList->GetCount() > 0)
+               {
+                       std::unique_ptr< IMapEnumeratorT<String*, String*> > pEnum(pContext->__pSymbolicLinkList->GetMapEnumeratorN());
+                       TryReturn(pEnum, false, "pSymbolicLinkList->GetMapEnumeratorN() failed.");
+                       while (pEnum->MoveNext() == E_SUCCESS)
+                       {
+                               String* pKey = null;
+                               String* pValue = null;
+
+                               pEnum->GetKey(pKey);
+                               pEnum->GetValue(pValue);
+
+                               AppLog("SymbolicLink - Src = [%ls], Des = [%ls]", pKey->GetPointer(), pValue->GetPointer());
+                       }
+               }
+       }
        AppLog("------------------------------------------");
 
        return true;
index d7fa69d..b29d588 100755 (executable)
@@ -168,6 +168,14 @@ ManifestHandler::OnStartElement(const char *pName)
        {
                status = OnPermissionStartElement(pName);
        }
+       else if (strcasecmp(pName, "DirectoryConfig") == 0)
+       {
+               status = OnDirectoryConfigStartElement();
+       }
+       else if (strcasecmp(pName, "SymbolicLink") == 0)
+       {
+               status = OnSymbolicLinkStartElement();
+       }
 
        if (!status)
        {
@@ -623,6 +631,44 @@ ManifestHandler::OnMetadataStartElement()
 }
 
 bool
+ManifestHandler::OnDirectoryConfigStartElement()
+{
+       XmlAttribute* pAttr = GetAttribute();
+       TryReturn(pAttr, true, "pAttr is null.");
+
+       char* pVirtualRoot = pAttr->Find("VirtualRoot");
+       TryReturn(pVirtualRoot, false, "pVirtualRoot is null.");
+
+       if (strcasecmp(pVirtualRoot, "true") == 0)
+       {
+               __pContext->__isVirtualRoot = true;
+       }
+
+       AppLog("<DirectoryConfig VirtualRoot=\"%s\">", pVirtualRoot);
+
+       return true;
+}
+
+bool
+ManifestHandler::OnSymbolicLinkStartElement()
+{
+       XmlAttribute* pAttr = GetAttribute();
+       TryReturn(pAttr, true, "pAttr is null.");
+
+       char* pSource = pAttr->Find("Source");
+       TryReturn(pSource, false, "pSource is null.");
+
+       char* pDestination = pAttr->Find("Destination");
+       TryReturn(pDestination, false, "pDestination is null.");
+
+       __pContext->__pSymbolicLinkList->Add(new (std::nothrow) String(pSource), new (std::nothrow) String(pDestination));
+
+       AppLog("<SymbolicLink Source=\"%s\", Destination=\"%s\">", pSource, pDestination);
+
+       return true;
+}
+
+bool
 ManifestHandler::OnLiveboxesStartElement(const char *pName)
 {
        __pParser = new (std::nothrow) ManifestLiveboxesParser;
index b41cfa6..4fdfe48 100755 (executable)
@@ -78,6 +78,8 @@ private:
        bool OnContentStartElement(void);
 
        bool OnMetadataStartElement(void);
+       bool OnDirectoryConfigStartElement(void);
+       bool OnSymbolicLinkStartElement(void);
 
        // Parsers
        bool OnLiveboxesStartElement(const char* pName);