Remove old qt libs if the qt installation folder is different.
authorBogDan Vatra <bogdan@kde.org>
Sat, 28 Dec 2013 15:11:28 +0000 (17:11 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 2 Jan 2014 14:46:35 +0000 (15:46 +0100)
Store and check the Qt instalattion folder.

Change-Id: I7a890da82d5b7a4ae467d157daa7c4e41b15a11b
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
src/androiddeployqt/main.cpp

index 9c40715..64ee5b9 100644 (file)
@@ -1394,14 +1394,33 @@ bool fetchRemoteModifications(Options *options, const QString &directory)
 {
     options->fetchedRemoteModificationDates = true;
 
-    FILE *adbCommand = runAdb(*options, QLatin1String(" ls ") + directory);
+    FILE *adbCommand = runAdb(*options, QLatin1String(" shell cat ") + directory + QLatin1String("/modification.txt"));
     if (adbCommand == 0)
         return false;
 
     char buffer[512];
+    QString qtPath;
+    while (fgets(buffer, sizeof(buffer), adbCommand) != 0)
+        qtPath += QString::fromUtf8(buffer, qstrlen(buffer));
+
+    pclose(adbCommand);
+
+    if (options->qtInstallDirectory != qtPath) {
+        adbCommand = runAdb(*options, QLatin1String(" shell rm -r ") + directory);
+        if (options->verbose) {
+            fprintf(stdout, "  -- Removing old Qt libs.\n");
+            while (fgets(buffer, sizeof(buffer), adbCommand) != 0)
+                fprintf(stdout, "%s", buffer);
+        }
+        pclose(adbCommand);
+    }
+
+    adbCommand = runAdb(*options, QLatin1String(" ls ") + directory);
+    if (adbCommand == 0)
+        return false;
+
     while (fgets(buffer, sizeof(buffer), adbCommand) != 0) {
         QByteArray line = QByteArray::fromRawData(buffer, qstrlen(buffer));
-
         if (line.count() < (3 * 8 + 3))
             continue;
         if (line.at(8) != ' '
@@ -1429,6 +1448,7 @@ bool fetchRemoteModifications(Options *options, const QString &directory)
             fprintf(stderr, "Cannot create modification timestamp.\n");
             return false;
         }
+        file.write(options->qtInstallDirectory.toUtf8());
     }
 
     return true;