diff options
author | Munkyu Im <munkyu.im@samsung.com> | 2017-05-28 17:44:03 +0900 |
---|---|---|
committer | Munkyu Im <munkyu.im@samsung.com> | 2017-05-29 22:17:54 +0900 |
commit | 954281c06a855c052a1145e0a97df46e4f30242a (patch) | |
tree | d10e7ccc3d7c05409ca810316cc7c9ceaabc6c21 | |
parent | a53604a58590b57396fb08461f0a50cfdcd8beb2 (diff) | |
download | qemu-954281c06a855c052a1145e0a97df46e4f30242a.tar.gz qemu-954281c06a855c052a1145e0a97df46e4f30242a.tar.bz2 qemu-954281c06a855c052a1145e0a97df46e4f30242a.zip |
install: add checking mount system for rpm file
User cannot install rpm file under read only root file system.
In this case, shows warning message.
Change-Id: I530c5c585301f8796e35d025cdf6c8d6a3d0051b
Signed-off-by: Munkyu Im <munkyu.im@samsung.com>
-rw-r--r-- | tizen/src/ui/menu/sdbhelper.cpp | 24 | ||||
-rw-r--r-- | tizen/src/ui/menu/sdbhelper.h | 5 | ||||
-rw-r--r-- | tizen/src/ui/menu/sdbhelperthread.cpp | 7 | ||||
-rw-r--r-- | tizen/src/ui/menu/sdbhelperthread.h | 1 | ||||
-rw-r--r-- | tizen/src/ui/resource/ui_strings.h | 3 |
5 files changed, 34 insertions, 6 deletions
diff --git a/tizen/src/ui/menu/sdbhelper.cpp b/tizen/src/ui/menu/sdbhelper.cpp index c1da058892..31d158f16d 100644 --- a/tizen/src/ui/menu/sdbhelper.cpp +++ b/tizen/src/ui/menu/sdbhelper.cpp @@ -123,12 +123,13 @@ void SdbHelper::push(QList<QString> srcList, const QString &dest) 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); @@ -152,7 +153,7 @@ void SdbHelper::install(QFileInfo fi) thread->start(); } -void SdbHelper::installRpm(QFileInfo fi) +void SdbHelper::installRpm(QFileInfo &fi) { QString program; QStringList argRootOn; @@ -160,6 +161,7 @@ void SdbHelper::installRpm(QFileInfo fi) QStringList argInstall; QStringList argRemove; QStringList argRootOff; + QStringList argCheckMount; QList<QStringList> argList; QString baseName = fi.fileName(); QString destFileName = QString(GUEST_TMP_PATH + baseName); @@ -172,6 +174,14 @@ void SdbHelper::installRpm(QFileInfo fi) 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; @@ -191,12 +201,20 @@ void SdbHelper::installRpm(QFileInfo fi) 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() { diff --git a/tizen/src/ui/menu/sdbhelper.h b/tizen/src/ui/menu/sdbhelper.h index cb16241818..67c2eebcaf 100644 --- a/tizen/src/ui/menu/sdbhelper.h +++ b/tizen/src/ui/menu/sdbhelper.h @@ -44,7 +44,7 @@ public: 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(); @@ -67,12 +67,13 @@ private: 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 diff --git a/tizen/src/ui/menu/sdbhelperthread.cpp b/tizen/src/ui/menu/sdbhelperthread.cpp index dec4171205..2de9cc8e34 100644 --- a/tizen/src/ui/menu/sdbhelperthread.cpp +++ b/tizen/src/ui/menu/sdbhelperthread.cpp @@ -66,9 +66,14 @@ void SdbHelperThread::run() 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; } diff --git a/tizen/src/ui/menu/sdbhelperthread.h b/tizen/src/ui/menu/sdbhelperthread.h index 162ce1813a..dcdb4f48b1 100644 --- a/tizen/src/ui/menu/sdbhelperthread.h +++ b/tizen/src/ui/menu/sdbhelperthread.h @@ -57,6 +57,7 @@ private: signals: void errorOccured(QString errString, int exitCode); void finished(QString outMsg); + void error(QString message); public slots: void handleErrorOccured(QString errString, int exitCode); diff --git a/tizen/src/ui/resource/ui_strings.h b/tizen/src/ui/resource/ui_strings.h index a17e9aaeed..b7892d70c5 100644 --- a/tizen/src/ui/resource/ui_strings.h +++ b/tizen/src/ui/resource/ui_strings.h @@ -140,6 +140,7 @@ #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 @@ -172,6 +173,8 @@ #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 */ |