forked from qt-creator/qt-creator
Maemo: Add option to disable packaging.
Task-number: QTCREATORBUG-1636 Reviewed-by: kh1
This commit is contained in:
@@ -63,6 +63,7 @@ static const QLatin1String SimulatorPathKey(PREFIX ".Simulator");
|
||||
static const QLatin1String DeviceIdKey(PREFIX ".DeviceId");
|
||||
static const QLatin1String LastDeployedHostsKey(PREFIX ".LastDeployedHosts");
|
||||
static const QLatin1String LastDeployedFilesKey(PREFIX ".LastDeployedFiles");
|
||||
static const QLatin1String LastDeployedRemotePathsKey(PREFIX ".LastDeployedRemotePaths");
|
||||
static const QLatin1String LastDeployedTimesKey(PREFIX ".LastDeployedTimes");
|
||||
static const QLatin1String ProFileKey(".ProFile");
|
||||
|
||||
|
||||
@@ -58,16 +58,16 @@ MaemoPackageContents::MaemoPackageContents(MaemoPackageCreationStep *packageStep
|
||||
{
|
||||
}
|
||||
|
||||
MaemoPackageContents::Deployable MaemoPackageContents::deployableAt(int row) const
|
||||
MaemoDeployable MaemoPackageContents::deployableAt(int row) const
|
||||
{
|
||||
Q_ASSERT(row >= 0 && row < rowCount());
|
||||
return row == 0
|
||||
? Deployable(m_packageStep->localExecutableFilePath(),
|
||||
? MaemoDeployable(m_packageStep->localExecutableFilePath(),
|
||||
remoteExecutableFilePath())
|
||||
: m_deployables.at(row - 1);
|
||||
}
|
||||
|
||||
bool MaemoPackageContents::addDeployable(const Deployable &deployable)
|
||||
bool MaemoPackageContents::addDeployable(const MaemoDeployable &deployable)
|
||||
{
|
||||
if (m_deployables.contains(deployable) || deployableAt(0) == deployable)
|
||||
return false;
|
||||
@@ -103,7 +103,7 @@ QVariant MaemoPackageContents::data(const QModelIndex &index, int role) const
|
||||
if (!index.isValid() || index.row() >= rowCount())
|
||||
return QVariant();
|
||||
|
||||
const Deployable &d = deployableAt(index.row());
|
||||
const MaemoDeployable &d = deployableAt(index.row());
|
||||
if (index.column() == 0 && role == Qt::DisplayRole)
|
||||
return d.localFilePath;
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
||||
@@ -151,7 +151,7 @@ QVariantMap MaemoPackageContents::toMap() const
|
||||
map.insert(REMOTE_EXE_KEY, m_remoteExecutableFilePath);
|
||||
QStringList localFiles;
|
||||
QStringList remoteFiles;
|
||||
foreach (const Deployable &p, m_deployables) {
|
||||
foreach (const MaemoDeployable &p, m_deployables) {
|
||||
localFiles << p.localFilePath;
|
||||
remoteFiles << p.remoteFilePath;
|
||||
}
|
||||
@@ -170,7 +170,7 @@ void MaemoPackageContents::fromMap(const QVariantMap &map)
|
||||
qWarning("%s: serialized data inconsistent", Q_FUNC_INFO);
|
||||
const int count = qMin(localFiles.count(), remoteFiles.count());
|
||||
for (int i = 0; i < count; ++i)
|
||||
m_deployables << Deployable(localFiles.at(i), remoteFiles.at(i));
|
||||
m_deployables << MaemoDeployable(localFiles.at(i), remoteFiles.at(i));
|
||||
}
|
||||
|
||||
QString MaemoPackageContents::remoteExecutableFilePath() const
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#define MAEMOPACKAGECONTENTS_H
|
||||
|
||||
#include <QtCore/QAbstractTableModel>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QVariantMap>
|
||||
@@ -38,18 +39,12 @@
|
||||
namespace Qt4ProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class MaemoPackageCreationStep;
|
||||
|
||||
class MaemoPackageContents : public QAbstractTableModel
|
||||
struct MaemoDeployable
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
struct Deployable
|
||||
{
|
||||
Deployable(const QString &localFilePath, const QString &remoteFilePath)
|
||||
MaemoDeployable(const QString &localFilePath, const QString &remoteFilePath)
|
||||
: localFilePath(localFilePath), remoteFilePath(remoteFilePath) {}
|
||||
|
||||
bool operator==(const Deployable &other) const
|
||||
bool operator==(const MaemoDeployable &other) const
|
||||
{
|
||||
return localFilePath == other.localFilePath
|
||||
&& remoteFilePath == other.remoteFilePath;
|
||||
@@ -57,8 +52,19 @@ public:
|
||||
|
||||
QString localFilePath;
|
||||
QString remoteFilePath;
|
||||
};
|
||||
};
|
||||
inline uint qHash(const MaemoDeployable &d)
|
||||
{
|
||||
return qHash(qMakePair(d.localFilePath, d.remoteFilePath));
|
||||
}
|
||||
|
||||
|
||||
class MaemoPackageCreationStep;
|
||||
|
||||
class MaemoPackageContents : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MaemoPackageContents(MaemoPackageCreationStep *packageStep);
|
||||
|
||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
@@ -66,8 +72,8 @@ public:
|
||||
QVariantMap toMap() const;
|
||||
void fromMap(const QVariantMap &map);
|
||||
|
||||
Deployable deployableAt(int row) const;
|
||||
bool addDeployable(const Deployable &deployable);
|
||||
MaemoDeployable deployableAt(int row) const;
|
||||
bool addDeployable(const MaemoDeployable &deployable);
|
||||
void removeDeployableAt(int row);
|
||||
bool isModified() const { return m_modified; }
|
||||
void setUnModified() { m_modified = false; }
|
||||
@@ -85,7 +91,7 @@ private:
|
||||
|
||||
private:
|
||||
const MaemoPackageCreationStep * const m_packageStep;
|
||||
QList<Deployable> m_deployables;
|
||||
QList<MaemoDeployable> m_deployables;
|
||||
bool m_modified;
|
||||
mutable QString m_remoteExecutableFilePath;
|
||||
};
|
||||
|
||||
@@ -186,8 +186,7 @@ bool MaemoPackageCreationStep::createPackage()
|
||||
const QDir debianRoot = QDir(buildDir % QLatin1String("/debian/")
|
||||
% executableFileName().toLower());
|
||||
for (int i = 0; i < m_packageContents->rowCount(); ++i) {
|
||||
const MaemoPackageContents::Deployable &d
|
||||
= m_packageContents->deployableAt(i);
|
||||
const MaemoDeployable &d = m_packageContents->deployableAt(i);
|
||||
const QString targetFile = debianRoot.path() + '/' + d.remoteFilePath;
|
||||
const QString absTargetDir = QFileInfo(targetFile).dir().path();
|
||||
const QString relTargetDir = debianRoot.relativeFilePath(absTargetDir);
|
||||
|
||||
@@ -65,7 +65,6 @@ MaemoPackageCreationWidget::MaemoPackageCreationWidget(MaemoPackageCreationStep
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->skipCheckBox->setChecked(!m_step->isPackagingEnabled());
|
||||
m_ui->packageContentsView->setEnabled(m_step->isPackagingEnabled());
|
||||
m_ui->packageContentsView->setModel(step->packageContents());
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
connect(step->packageContents(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
|
||||
@@ -104,8 +103,7 @@ void MaemoPackageCreationWidget::addFile()
|
||||
const QString localFile = QFileDialog::getOpenFileName(this, title, baseDir);
|
||||
if (localFile.isEmpty())
|
||||
return;
|
||||
const MaemoPackageContents::Deployable
|
||||
deployable(QFileInfo(localFile).absoluteFilePath(), "/");
|
||||
const MaemoDeployable deployable(QFileInfo(localFile).absoluteFilePath(), "/");
|
||||
MaemoPackageContents * const contents = m_step->packageContents();
|
||||
if (!contents->addDeployable(deployable)) {
|
||||
QMessageBox::information(this, tr("File already in package"),
|
||||
@@ -141,7 +139,6 @@ void MaemoPackageCreationWidget::enableOrDisableRemoveButton()
|
||||
void MaemoPackageCreationWidget::handleSkipButtonToggled(bool checked)
|
||||
{
|
||||
m_step->setPackagingEnabled(!checked);
|
||||
m_ui->packageContentsView->setEnabled(m_step->isPackagingEnabled());
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -23,8 +23,7 @@
|
||||
<item>
|
||||
<widget class="QCheckBox" name="skipCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>Check this if you build the package externally. It still needs to be at the location listed above
|
||||
and the remote executable is assumed to be in the directory mentioned below.</string>
|
||||
<string>Check this if you want the files below to be deployed directly.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Skip Packaging Step</string>
|
||||
@@ -40,7 +39,7 @@ and the remote executable is assumed to be in the directory mentioned below.</st
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Package contents:</string>
|
||||
<string>Files to deploy:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -134,15 +134,18 @@ void MaemoRunConfiguration::addDeployTimesToMap(QVariantMap &map) const
|
||||
{
|
||||
QVariantList hostList;
|
||||
QVariantList fileList;
|
||||
QVariantList remotePathList;
|
||||
QVariantList timeList;
|
||||
typedef QMap<DeployablePerHost, QDateTime>::ConstIterator DepIt;
|
||||
typedef QHash<DeployablePerHost, QDateTime>::ConstIterator DepIt;
|
||||
for (DepIt it = m_lastDeployed.begin(); it != m_lastDeployed.end(); ++it) {
|
||||
hostList << it.key().first;
|
||||
hostList << it.key().first.localFilePath;
|
||||
remotePathList << it.key().first.remoteFilePath;
|
||||
fileList << it.key().second;
|
||||
timeList << it.value();
|
||||
}
|
||||
map.insert(LastDeployedHostsKey, hostList);
|
||||
map.insert(LastDeployedFilesKey, fileList);
|
||||
map.insert(LastDeployedRemotePathsKey, remotePathList);
|
||||
map.insert(LastDeployedTimesKey, timeList);
|
||||
}
|
||||
|
||||
@@ -165,28 +168,33 @@ void MaemoRunConfiguration::getDeployTimesFromMap(const QVariantMap &map)
|
||||
{
|
||||
const QVariantList &hostList = map.value(LastDeployedHostsKey).toList();
|
||||
const QVariantList &fileList = map.value(LastDeployedFilesKey).toList();
|
||||
const QVariantList &remotePathList
|
||||
= map.value(LastDeployedRemotePathsKey).toList();
|
||||
const QVariantList &timeList = map.value(LastDeployedTimesKey).toList();
|
||||
const int elemCount
|
||||
= qMin(qMin(hostList.size(), fileList.size()), timeList.size());
|
||||
= qMin(qMin(hostList.size(), fileList.size()),
|
||||
qMin(remotePathList.size(), timeList.size()));
|
||||
for (int i = 0; i < elemCount; ++i) {
|
||||
m_lastDeployed.insert(DeployablePerHost(hostList.at(i).toString(),
|
||||
fileList.at(i).toString()), timeList.at(i).toDateTime());
|
||||
const MaemoDeployable d(fileList.at(i).toString(),
|
||||
remotePathList.at(i).toString());
|
||||
m_lastDeployed.insert(DeployablePerHost(d, hostList.at(i).toString()),
|
||||
timeList.at(i).toDateTime());
|
||||
}
|
||||
}
|
||||
|
||||
bool MaemoRunConfiguration::currentlyNeedsDeployment(const QString &host,
|
||||
const QString &file) const
|
||||
const MaemoDeployable &deployable) const
|
||||
{
|
||||
const QDateTime &lastDeployed
|
||||
= m_lastDeployed.value(DeployablePerHost(host, file));
|
||||
= m_lastDeployed.value(DeployablePerHost(deployable, host));
|
||||
return !lastDeployed.isValid()
|
||||
|| QFileInfo(file).lastModified() > lastDeployed;
|
||||
|| QFileInfo(deployable.localFilePath).lastModified() > lastDeployed;
|
||||
}
|
||||
|
||||
void MaemoRunConfiguration::setDeployed(const QString &host,
|
||||
const QString &file)
|
||||
const MaemoDeployable &deployable)
|
||||
{
|
||||
m_lastDeployed.insert(DeployablePerHost(host, file),
|
||||
m_lastDeployed.insert(DeployablePerHost(deployable, host),
|
||||
QDateTime::currentDateTime());
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "maemoconstants.h"
|
||||
#include "maemodeviceconfigurations.h"
|
||||
#include "maemopackagecontents.h"
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
@@ -70,8 +71,8 @@ public:
|
||||
Qt4BuildConfiguration *activeQt4BuildConfiguration() const;
|
||||
|
||||
bool currentlyNeedsDeployment(const QString &host,
|
||||
const QString &file) const;
|
||||
void setDeployed(const QString &host, const QString &file);
|
||||
const MaemoDeployable &deployable) const;
|
||||
void setDeployed(const QString &host, const MaemoDeployable &deployable);
|
||||
|
||||
const MaemoPackageCreationStep *packageStep() const;
|
||||
|
||||
@@ -118,8 +119,8 @@ private:
|
||||
MaemoDeviceConfig m_devConfig;
|
||||
QStringList m_arguments;
|
||||
|
||||
typedef QPair<QString, QString> DeployablePerHost;
|
||||
QMap<DeployablePerHost, QDateTime> m_lastDeployed;
|
||||
typedef QPair<MaemoDeployable, QString> DeployablePerHost;
|
||||
QHash<DeployablePerHost, QDateTime> m_lastDeployed;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
|
||||
#include "maemoruncontrol.h"
|
||||
|
||||
#include "maemopackagecontents.h"
|
||||
#include "maemopackagecreationstep.h"
|
||||
#include "maemosshthread.h"
|
||||
#include "maemorunconfiguration.h"
|
||||
@@ -46,6 +45,7 @@
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtCore/QCryptographicHash>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QFuture>
|
||||
@@ -122,28 +122,56 @@ void AbstractMaemoRunControl::startDeployment(bool forDebugging)
|
||||
|
||||
if (m_stoppedByUser) {
|
||||
emit finished();
|
||||
} else {
|
||||
m_deployables.clear();
|
||||
if (m_runConfig->currentlyNeedsDeployment(m_devConfig.server.host,
|
||||
packageFilePath())) {
|
||||
m_deployables.append(Deployable(packageFileName(),
|
||||
QFileInfo(executableOnHost()).canonicalPath()));
|
||||
m_needsInstall = true;
|
||||
} else {
|
||||
m_needsInstall = false;
|
||||
m_deployables.clear();
|
||||
m_remoteLinks.clear();
|
||||
const MaemoPackageCreationStep * const packageStep
|
||||
= m_runConfig->packageStep();
|
||||
if (packageStep->isPackagingEnabled()) {
|
||||
const MaemoDeployable d(packageFilePath(),
|
||||
remoteDir() + '/' + packageFileName());
|
||||
m_needsInstall = addDeployableIfNeeded(d);
|
||||
} else {
|
||||
const MaemoPackageContents * const packageContents
|
||||
= packageStep->packageContents();
|
||||
for (int i = 0; i < packageContents->rowCount(); ++i) {
|
||||
const MaemoDeployable &d = packageContents->deployableAt(i);
|
||||
if (addDeployableIfNeeded(d))
|
||||
m_needsInstall = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (forDebugging) {
|
||||
const QFileInfo info(m_runConfig->dumperLib());
|
||||
if (info.exists()
|
||||
&& m_runConfig->currentlyNeedsDeployment(m_devConfig.server.host,
|
||||
info.filePath())) {
|
||||
m_deployables.append(Deployable(info.fileName(), info.canonicalPath()));
|
||||
QFileInfo dumperInfo(m_runConfig->dumperLib());
|
||||
if (dumperInfo.exists()) {
|
||||
const MaemoDeployable d(m_runConfig->dumperLib(),
|
||||
remoteDir() + '/' + dumperInfo.fileName());
|
||||
m_needsInstall = addDeployableIfNeeded(d);
|
||||
}
|
||||
}
|
||||
deploy();
|
||||
}
|
||||
}
|
||||
|
||||
bool AbstractMaemoRunControl::addDeployableIfNeeded(const MaemoDeployable &deployable)
|
||||
{
|
||||
if (m_runConfig->currentlyNeedsDeployment(m_devConfig.server.host,
|
||||
deployable)) {
|
||||
const QString fileName
|
||||
= QFileInfo(deployable.remoteFilePath).fileName();
|
||||
const QString sftpTargetFilePath = remoteDir() + '/' + fileName + '.'
|
||||
+ QCryptographicHash::hash(deployable.remoteFilePath.toUtf8(),
|
||||
QCryptographicHash::Md5).toHex();
|
||||
m_deployables.append(MaemoDeployable(deployable.localFilePath,
|
||||
sftpTargetFilePath));
|
||||
m_remoteLinks.insert(sftpTargetFilePath, deployable.remoteFilePath);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractMaemoRunControl::deploy()
|
||||
{
|
||||
Core::ICore::instance()->progressManager()
|
||||
@@ -152,14 +180,11 @@ void AbstractMaemoRunControl::deploy()
|
||||
if (!m_deployables.isEmpty()) {
|
||||
QList<Core::SftpTransferInfo> deploySpecs;
|
||||
QStringList files;
|
||||
foreach (const Deployable &deployable, m_deployables) {
|
||||
const QString srcFilePath
|
||||
= deployable.dir % QDir::separator() % deployable.fileName;
|
||||
const QString tgtFilePath
|
||||
= remoteDir() % QDir::separator() % deployable.fileName;
|
||||
files << srcFilePath;
|
||||
deploySpecs << Core::SftpTransferInfo(srcFilePath,
|
||||
tgtFilePath.toUtf8(), Core::SftpTransferInfo::Upload);
|
||||
foreach (const MaemoDeployable &deployable, m_deployables) {
|
||||
files << deployable.localFilePath;
|
||||
deploySpecs << Core::SftpTransferInfo(deployable.localFilePath,
|
||||
deployable.remoteFilePath.toUtf8(),
|
||||
Core::SftpTransferInfo::Upload);
|
||||
}
|
||||
emit appendMessage(this, tr("Files to deploy: %1.").arg(files.join(" ")), false);
|
||||
m_sshDeployer.reset(new MaemoSshDeployer(m_devConfig.server, deploySpecs));
|
||||
@@ -179,9 +204,10 @@ void AbstractMaemoRunControl::deploy()
|
||||
|
||||
void AbstractMaemoRunControl::handleFileCopied()
|
||||
{
|
||||
Deployable deployable = m_deployables.takeFirst();
|
||||
const MaemoDeployable &deployable = m_deployables.takeFirst();
|
||||
m_runConfig->setDeployed(m_devConfig.server.host,
|
||||
deployable.dir + QLatin1Char('/') + deployable.fileName);
|
||||
MaemoDeployable(deployable.localFilePath,
|
||||
m_remoteLinks.value(deployable.remoteFilePath)));
|
||||
m_progress.setProgressValue(m_progress.progressValue() + 1);
|
||||
}
|
||||
|
||||
@@ -320,8 +346,21 @@ QString AbstractMaemoRunControl::remoteSudo() const
|
||||
|
||||
QString AbstractMaemoRunControl::remoteInstallCommand() const
|
||||
{
|
||||
return QString::fromLocal8Bit("%1 dpkg -i %2").arg(remoteSudo())
|
||||
Q_ASSERT(m_needsInstall);
|
||||
QString cmd;
|
||||
for (QMap<QString, QString>::ConstIterator it = m_remoteLinks.begin();
|
||||
it != m_remoteLinks.end(); ++it) {
|
||||
cmd += QString::fromLocal8Bit("%1 ln -sf %2 %3 && ")
|
||||
.arg(remoteSudo(), it.key(), it.value());
|
||||
}
|
||||
if (m_runConfig->packageStep()->isPackagingEnabled()) {
|
||||
cmd += QString::fromLocal8Bit("%1 dpkg -i %2").arg(remoteSudo())
|
||||
.arg(packageFileName());
|
||||
} else if (!m_remoteLinks.isEmpty()) {
|
||||
return cmd.remove(cmd.length() - 4, 4); // Trailing " && "
|
||||
}
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
const QString AbstractMaemoRunControl::targetCmdLinePrefix() const
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#define MAEMORUNCONTROL_H
|
||||
|
||||
#include "maemodeviceconfigurations.h"
|
||||
#include "maemopackagecontents.h"
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
@@ -97,6 +98,8 @@ protected:
|
||||
const MaemoDeviceConfig m_devConfig;
|
||||
|
||||
private:
|
||||
bool addDeployableIfNeeded(const MaemoDeployable &deployable);
|
||||
|
||||
virtual void startInternal()=0;
|
||||
virtual void stopInternal()=0;
|
||||
virtual QString remoteCall() const=0;
|
||||
@@ -115,14 +118,8 @@ private:
|
||||
QScopedPointer<MaemoSshRunner> m_initialCleaner;
|
||||
bool m_stoppedByUser;
|
||||
|
||||
struct Deployable
|
||||
{
|
||||
Deployable(const QString &f, const QString &d)
|
||||
: fileName(f), dir(d) {}
|
||||
QString fileName;
|
||||
QString dir;
|
||||
};
|
||||
QList<Deployable> m_deployables;
|
||||
QList<MaemoDeployable> m_deployables;
|
||||
QMap<QString, QString> m_remoteLinks;
|
||||
bool m_needsInstall;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user