summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--installerbuilder/common/installersettings.cpp7
-rw-r--r--installerbuilder/common/installersettings.h1
-rw-r--r--installerbuilder/installerbase/installerbasecommons.cpp3
-rw-r--r--installerbuilder/libinstaller/qinstaller.cpp36
-rw-r--r--installerbuilder/libinstaller/qinstallergui.cpp4
5 files changed, 36 insertions, 15 deletions
diff --git a/installerbuilder/common/installersettings.cpp b/installerbuilder/common/installersettings.cpp
index 7f104c4f6..19f3eeb25 100644
--- a/installerbuilder/common/installersettings.cpp
+++ b/installerbuilder/common/installersettings.cpp
@@ -68,6 +68,7 @@ public:
QString targetDir;
QString adminTargetDir;
QString icon;
+ QString removeTargetDir;
QString uninstallerName;
QString uninstallerIniFile;
QString configurationFileName;
@@ -163,6 +164,7 @@ InstallerSettings InstallerSettings::fromFileAndPrefix( const QString& path, con
s.d->targetDir = readChild( root, QLatin1String("TargetDir") );
s.d->adminTargetDir = readChild( root, QLatin1String("AdminTargetDir") );
s.d->icon = readChild( root, QLatin1String( "Icon" ) );
+ s.d->removeTargetDir = readChild(root, QLatin1String("RemoveTargetDir"), QLatin1String("true"));
s.d->uninstallerName = readChild( root, QLatin1String( "UninstallerName" ), QLatin1String("uninstall") );
s.d->uninstallerIniFile = readChild( root, QLatin1String("UninstallerIniFile"), s.d->uninstallerName + QLatin1String(".ini") );
s.d->privateKey = splitTrimmed( readChild( root, QLatin1String( "PrivateKey" ) ) ).toLatin1();
@@ -256,6 +258,11 @@ QString InstallerSettings::icon() const
#endif
}
+QString InstallerSettings::removeTargetDir() const
+{
+ return d->removeTargetDir;
+}
+
QString InstallerSettings::uninstallerName() const
{
if( d->uninstallerName.isEmpty() )
diff --git a/installerbuilder/common/installersettings.h b/installerbuilder/common/installersettings.h
index d73049345..939d35f00 100644
--- a/installerbuilder/common/installersettings.h
+++ b/installerbuilder/common/installersettings.h
@@ -70,6 +70,7 @@ namespace QInstaller {
QString targetDir() const;
QString adminTargetDir() const;
+ QString removeTargetDir() const;
QString uninstallerName() const;
QString uninstallerIniFile() const;
diff --git a/installerbuilder/installerbase/installerbasecommons.cpp b/installerbuilder/installerbase/installerbasecommons.cpp
index 2afb654c7..a279e9c95 100644
--- a/installerbuilder/installerbase/installerbasecommons.cpp
+++ b/installerbuilder/installerbase/installerbasecommons.cpp
@@ -107,6 +107,9 @@ bool TargetDirectoryPageImpl::validatePage()
QMessageBox::Ok);
return false;
}
+ QString remove = installer()->value(QLatin1String("RemoveTargetDir"));
+ if (!QVariant(remove).toBool())
+ return true;
const QFileInfo targetDirInfo = QFileInfo(targetDir());
const QDir dir( targetDir() );
diff --git a/installerbuilder/libinstaller/qinstaller.cpp b/installerbuilder/libinstaller/qinstaller.cpp
index aaf094e3c..cd94403cc 100644
--- a/installerbuilder/libinstaller/qinstaller.cpp
+++ b/installerbuilder/libinstaller/qinstaller.cpp
@@ -636,7 +636,8 @@ void Installer::Private::initialize()
m_vars.insert(QLatin1String("TargetDir"), replaceVariables(m_settings.adminTargetDir()));
else
#endif
- m_vars.insert(QLatin1String("TargetDir"), replaceVariables(m_settings.targetDir()));
+ m_vars.insert(QLatin1String("TargetDir"), replaceVariables(m_settings.targetDir()));
+ m_vars.insert(QLatin1String("RemoveTargetDir"), replaceVariables(m_settings.removeTargetDir()));
QSettings creatorSettings(QSettings::IniFormat, QSettings::UserScope, QLatin1String("Nokia"),
QLatin1String("QtCreator"));
@@ -1665,7 +1666,9 @@ void Installer::Private::runInstaller()
if (!q->gainAdminRights() || !performOperationThreaded(mkdirOp.data()))
throw Error(mkdirOp->errorString());
}
- addPerformed(mkdirOp.take());
+ QString remove = q->value(QLatin1String("RemoveTargetDir"));
+ if (QVariant(remove).toBool())
+ addPerformed(mkdirOp.take());
} else {
QTemporaryFile tempAdminFile(target + QLatin1String("/adminrights"));
if (!tempAdminFile.open() || !tempAdminFile.isWritable())
@@ -2150,19 +2153,22 @@ void Installer::Private::runUninstaller()
packages->removePackage((*it)->name());
(*it)->setValue(QLatin1String("CurrentState"), QLatin1String("Uninstalled"));
}
-
- // on !Windows, we need to remove TargetDir manually
- packageManagingMode = ! m_completeUninstall;
- verbose() << "Complete Uninstallation is chosen" << std::endl;
- const QString target = targetDir();
- if (!target.isEmpty()) {
- if (engineClientHandler->isServerRunning() && !engineClientHandler->isActive()) {
- // we were root at least once, so we remove the target dir as root
- q->gainAdminRights();
- removeDirectoryThreaded(target, true);
- q->dropAdminRights();
- } else {
- removeDirectoryThreaded(target, true);
+ QString remove = q->value(QLatin1String("RemoveTargetDir"));
+ if(QVariant(remove).toBool())
+ {
+ // on !Windows, we need to remove TargetDir manually
+ packageManagingMode = ! m_completeUninstall;
+ verbose() << "Complete Uninstallation is chosen" << std::endl;
+ const QString target = targetDir();
+ if (!target.isEmpty()) {
+ if (engineClientHandler->isServerRunning() && !engineClientHandler->isActive()) {
+ // we were root at least once, so we remove the target dir as root
+ q->gainAdminRights();
+ removeDirectoryThreaded(target, true);
+ q->dropAdminRights();
+ } else {
+ removeDirectoryThreaded(target, true);
+ }
}
}
diff --git a/installerbuilder/libinstaller/qinstallergui.cpp b/installerbuilder/libinstaller/qinstallergui.cpp
index ea11d1245..a3c25dcb1 100644
--- a/installerbuilder/libinstaller/qinstallergui.cpp
+++ b/installerbuilder/libinstaller/qinstallergui.cpp
@@ -1182,6 +1182,10 @@ bool TargetDirectoryPage::validatePage()
return false;
}
+ QString remove = installer()->value(QLatin1String("RemoveTargetDir"));
+ if (!QVariant(remove).toBool())
+ return true;
+
return MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
QLatin1String("overwriteTargetDirectory"), tr( "Warning" ),
tr( "You have selected an existing, non-empty folder for installation.\n"