SdbHelperThread *thread = new SdbHelperThread(this);
thread->setArguments(SDB_PUSH_COMMNAD , program, argList);
connect(thread, SIGNAL(started()), this, SLOT(handleThreadStarted()));
+ connect(thread, SIGNAL(error(QString)), this, SLOT(handleError(QString)));
connect(thread, SIGNAL(finished()), this, SLOT(handleThreadFinished()));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
thread->start();
}
-void SdbHelper::install(QFileInfo fi)
+void SdbHelper::install(QFileInfo &fi)
{
if (QString::compare(fi.suffix(), FILE_EXTENSION_RPM, Qt::CaseInsensitive) == 0) {
installRpm(fi);
thread->start();
}
-void SdbHelper::installRpm(QFileInfo fi)
+void SdbHelper::installRpm(QFileInfo &fi)
{
QString program;
QStringList argRootOn;
QStringList argInstall;
QStringList argRemove;
QStringList argRootOff;
+ QStringList argCheckMount;
QList<QStringList> argList;
QString baseName = fi.fileName();
QString destFileName = QString(GUEST_TMP_PATH + baseName);
return;
}
+ QProcess process;
+
+ argCheckMount << "-s" << sdbSerialName << "shell" << "mount";
+ argCheckMount << "|" << "grep" << "on / type";
+ argCheckMount << "|" << "/usr/bin/cut" << "-d" << "\"(\"" << "-f2";
+ argCheckMount << "|" << "/usr/bin/cut" << "-d" << "\")\"" << "-f1";
+ argList << argCheckMount;
+
//FIXME: (sdb) cannot check sdb root status
argRootOn << "-s" << sdbSerialName << "root" << "on";
argList << argRootOn;
qDebug() << program << argList;
SdbHelperThread *thread = new SdbHelperThread(this);
- thread->setArguments(SDB_INSTALL_COMMAND, program, argList);
+ thread->setArguments(SDB_INSTALL_RPM_COMMAND, program, argList);
connect(thread, SIGNAL(started()), this, SLOT(handleThreadStarted()));
+ connect(thread, SIGNAL(error(QString)), this, SLOT(handleError(QString)));
connect(thread, SIGNAL(finished()), this, SLOT(handleThreadFinished()));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
thread->start();
+ return;
}
+void SdbHelper::handleError(QString message)
+{
+ QMessageBox::warning(mainWindow, EMULATOR_TITLE, message,
+ QMessageBox::Ok | QMessageBox::Default);
+}
+
void SdbHelper::handleThreadStarted()
{
QString getSdbPath();
QString getGuestDefaultPushPath();
QString getSerialName();
- void install(QFileInfo fi);
+ void install(QFileInfo &fi);
void push(QList<QString> src, const QString &dest);
void openShell(QString title);
bool isProgressing();
QProcess *process;
DisplayBase *displaybase;
void setProgressing(bool isProgressing);
- void installRpm(QFileInfo fi);
+ void installRpm(QFileInfo &fi);
public slots:
void handleThreadStarted();
void handleThreadFinished();
void handleGeometryChanged(QRect rect);
+ void handleError(QString message);
};
#endif // SDBHELPER_H
errorMsg = QString::fromLocal8Bit(process->readAllStandardError());
qDebug() << "errorMsg" << errorMsg;
qDebug() << "outMsg" << outMsg;
+ if (command == SDB_INSTALL_RPM_COMMAND && i == 0 && outMsg.startsWith("ro")) {
+ qWarning() << "read only platform";
+ emit error(QString(MSG_MOUNT_WARNING));
+ return;
+ }
//FIXME: (sdb) general sdb installation failure message is printed with stdout */
- if (command == SDB_INSTALL_COMMAND && outMsg.contains(SDB_INSTALL_FAILURE)) {
+ if (command != SDB_PUSH_COMMNAD && outMsg.contains(SDB_INSTALL_FAILURE)) {
emit errorOccured(outMsg, process->exitCode());
return;
}
#define SDB_INSTALL_FAILURE "val[fail]"
#define SDB_PUSH_COMMNAD 1
#define SDB_INSTALL_COMMAND 2
+#define SDB_INSTALL_RPM_COMMAND 3
#define PROGRESSBAR_DEFAULT_WITDH 100
#define PROGRESSBAR_DEFAULT_HEIGHT 20
#define MSG_SDB_FAILED_PROCESSING "Failed while processing.\n\nError Message:\n"
#define MSG_SDB_ROOT_ON "This job needs root priviledge.\n"\
"Are you sure you want to continue?"
+#define MSG_MOUNT_WARNING "Unable to install rpm package!\nRoot filesystem is read-only.\n"\
+ "Remount the root filesystem with read-write and retry."
#define MSG_EMPTY_DIR "Target directory is empty.\n"
/* qFatal messages */