Support Multi-Package Install Scenario
[platform/core/dotnet/launcher.git] / NativeLauncher / tool / tac_installer.cc
index 9644e08..88d7953 100644 (file)
@@ -48,8 +48,8 @@ static std::vector<std::string> createLibraries;
 static std::vector<std::string> updateTac;
 static std::vector<std::string> updateTlc;
 static tac_state tacState = TAC_STATE_NONE;
-static bool tacPluginInstalled = false;
-static bool tacPluginFinished = false;
+static std::string prevInstallPkgId = std::string("");
+static std::string prevFinishPkgId = std::string("");
 
 static void createSHA256Info(std::string sha256Info, std::string nugetPackage)
 {
@@ -379,11 +379,11 @@ int tacInstall(const std::string& pkgId, tac_state state, bool tacForce)
        _INFO("PackageID : %s", pkgId.c_str());
 
        // Can be multiple apps in one package
-       if (tacPluginInstalled) {
-               _INFO("TAC plugin already installed");
+       if (strcmp(pkgId.c_str(), prevInstallPkgId.c_str()) == 0) {
+               _INFO("TAC Plugin(INSTALL) already run for same pkgId (%s)", pkgId.c_str());
                return 0;
        }
-       tacPluginInstalled = true;
+       prevInstallPkgId = pkgId;
 
        std::string appType = getAppType(pkgId);
        if (strstr(appType.c_str(), "dotnet") == NULL) {
@@ -441,11 +441,11 @@ int tacUpgrade(const std::string& pkgId, tac_state state, bool tacForce)
        _INFO("PackageID : %s", pkgId.c_str());
 
        // Can be multiple apps in one package
-       if (tacPluginInstalled) {
-               _INFO("TAC plugin already upgraded");
+       if (strcmp(pkgId.c_str(), prevInstallPkgId.c_str()) == 0) {
+               _INFO("TAC Plugin(UPGRADE) already run for same pkgId (%s)", pkgId.c_str());
                return 0;
        }
-       tacPluginInstalled = true;
+       prevInstallPkgId = pkgId;
 
        std::string appType = getAppType(pkgId);
        if (strstr(appType.c_str(), "dotnet") == NULL) {
@@ -540,11 +540,11 @@ int tacUninstall(const std::string& pkgId, tac_state state)
        _INFO("PackageID : %s", pkgId.c_str());
 
        // Can be multiple apps in one package
-       if (tacPluginInstalled) {
-               _INFO("TAC plugin already uninstalled");
+       if (strcmp(pkgId.c_str(), prevInstallPkgId.c_str()) == 0) {
+               _INFO("TAC Plugin(UNINSTALL) already run for same pkgId (%s)", pkgId.c_str());
                return 0;
        }
-       tacPluginInstalled = true;
+       prevInstallPkgId = pkgId;
 
        tacState= state;
        if (tac_openDB() != 0) {
@@ -652,11 +652,11 @@ int tacUndo(const std::string& pkgId)
        _INFO("PackageID : %s", pkgId.c_str());
 
        // Can be multiple apps in one package
-       if (tacPluginFinished) {
-               _INFO("TAC plugin already finished(UNDO)");
+       if (strcmp(pkgId.c_str(), prevFinishPkgId.c_str()) == 0) {
+               _INFO("TAC Plugin(UNDO) already run for same pkgId (%s)", pkgId.c_str());
                return 0;
        }
-       tacPluginFinished = true;
+       prevFinishPkgId = pkgId;
 
        if (tacState == TAC_STATE_INSTALL) {
                install_Undo();
@@ -802,11 +802,11 @@ int tacClean(const std::string& pkgId)
        _INFO("PackageID : %s", pkgId.c_str());
 
        // Can be multiple apps in one package
-       if (tacPluginFinished) {
-               _INFO("TAC plugin already finished(CLEAN)");
+       if (strcmp(pkgId.c_str(), prevFinishPkgId.c_str()) == 0) {
+               _INFO("TAC Plugin(CLEAN) already run for same pkgId (%s)", pkgId.c_str());
                return 0;
        }
-       tacPluginFinished = true;
+       prevFinishPkgId = pkgId;
 
        if (tacState == TAC_STATE_INSTALL) {
                install_Clean();