From a6829bbb2a949871c8876e5633228f1b4eaf9267 Mon Sep 17 00:00:00 2001 From: Liu Zhangjian Date: Tue, 27 May 2025 17:24:38 +0800 Subject: [PATCH] chore: Update logging - Enhanced logging throughout the application for better debugging and tracking of events. - Added .vscode, .cursor, and .specstory files to .gitignore to prevent unnecessary files from being tracked. - Improved initialization and error handling messages in various components for clarity. Log: Update logging --- .gitignore | 7 + src/app/bmwindow.cpp | 28 +++- src/app/main.cpp | 17 ++- src/app/view/deviceinfoitem.cpp | 3 + src/app/view/formatdialog.cpp | 11 ++ src/app/view/isoselectview.cpp | 21 ++- src/app/view/resultview.cpp | 28 ++-- src/app/view/usbselectview.cpp | 27 +++- src/libdbm/backend/bootmaker.cpp | 32 +++-- src/libdbm/bminterface.cpp | 14 +- src/libdbm/installer/qtX86Installer.cpp | 14 +- src/libdbm/installer/qtbaseinstaller.cpp | 138 +++++++++++++------- src/libdbm/installer/qtinstallerfactory.cpp | 14 +- src/libdbm/installer/qtmipsinstaller.cpp | 10 +- src/libdbm/util/devicemonitor.cpp | 33 +++-- src/libdbm/util/sevenzip.cpp | 30 +++-- src/libdbm/util/utils.cpp | 56 ++++++-- src/service/bootmakerservice.cpp | 62 ++++++--- src/service/main.cpp | 22 +++- 19 files changed, 416 insertions(+), 151 deletions(-) diff --git a/.gitignore b/.gitignore index 70092291..35bed4c7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,10 @@ osx *.log *.qm .DS_Store +.vscode +.cursor +# SpecStory explanation file +.specstory +.cursorindexingignore +# SpecStory explanation file +.specstory/.what-is-this.md diff --git a/src/app/bmwindow.cpp b/src/app/bmwindow.cpp index 98454dcf..48e6b936 100644 --- a/src/app/bmwindow.cpp +++ b/src/app/bmwindow.cpp @@ -53,6 +53,7 @@ BMWindow::BMWindow(QWidget *parent) : BMWindowBaseClass(parent), d_ptr(new BMWindowPrivate(this)) { Q_D(BMWindow); + qDebug() << "Initializing Boot Maker window"; setFixedSize(440, 550); @@ -62,6 +63,7 @@ BMWindow::BMWindow(QWidget *parent) #else d->interface = &BMInterface::ref(); #endif + qDebug() << "BMInterface initialized"; // init about info QString descriptionText = tr("Boot Maker is a simple tool to write system image files into USB flash drives and other media."); @@ -148,11 +150,13 @@ BMWindow::BMWindow(QWidget *parent) slot_ThemeChange(); connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::newProcessInstance, this, [ = ] { + qDebug() << "New process instance detected, activating window"; this->activateWindow(); }); connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &BMWindow :: slot_ThemeChange); connect(d->isoWidget, &ISOSelectView::isoFileSelected, this, [ = ] { + qDebug() << "ISO file selected, transitioning to USB selection view"; slideWidget(d->isoWidget, d->usbWidget); setProperty("bmISOFilePath", d->isoWidget->isoFilePath()); d->wsib->setCurrentPage(1); @@ -161,6 +165,7 @@ BMWindow::BMWindow(QWidget *parent) connect(d->isoWidget,&ISOSelectView::isoFileSelected,d->usbWidget,&UsbSelectView::getIsoFileSelectedPath); connect(d->usbWidget, &UsbSelectView::deviceSelected, this, [ = ](const QString & partition, bool format) { + qDebug() << "Device selected - Partition:" << partition << "Format:" << format; #ifdef Q_OS_WIN setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint); closeflags = false; @@ -177,7 +182,7 @@ BMWindow::BMWindow(QWidget *parent) #endif auto isoFilePath = property("bmISOFilePath").toString(); - qDebug() << "call interface install" << partition << format; + qDebug() << "Starting installation - ISO:" << isoFilePath << "Partition:" << partition << "Format:" << format; emit d->interface->startInstall(isoFilePath, "", partition, format); // Linux: wait for startInstallRet() polkit authorization check result, then animate the widget. }); @@ -186,10 +191,11 @@ BMWindow::BMWindow(QWidget *parent) // Check polkit authorization success, not availiable on windows. connect(d->interface, &BMInterface::startInstallRet, this, [ = ](bool success) { if (success) { + qDebug() << "Installation authorization successful, transitioning to progress view"; slideWidget(d->usbWidget, d->progressWidget); d->wsib->setCurrentPage(2); } else { - qWarning() << "call interface install return failed"; + qWarning() << "Installation authorization failed"; d->usbWidget->resetStartInstall(); d->usbWidget->setEnabled(true); @@ -200,12 +206,14 @@ BMWindow::BMWindow(QWidget *parent) #endif connect(d->progressWidget, &ProgressView::testCancel, this, [ = ] { + qDebug() << "Installation cancelled by user"; setWindowFlags(windowFlags() | Qt::WindowCloseButtonHint); d->resultWidget->updateResult(BMHandler::SyscExecFailed, "title", "description"); slideWidget(d->progressWidget, d->resultWidget); d->wsib->setCurrentPage(2); }); connect(d->usbWidget, &UsbSelectView::finish, this, [ = ](quint32 error, const QString & title, const QString & description) { + qDebug() << "USB selection finished - Error:" << error << "Title:" << title; Qt::WindowFlags flags = Qt::WindowCloseButtonHint; flags |= Qt::WindowSystemMenuHint; flags |= Qt::WindowMinimizeButtonHint; @@ -215,14 +223,16 @@ BMWindow::BMWindow(QWidget *parent) emit d->progressWidget->finish(0, error, title, description); }); connect(d->usbWidget, &UsbSelectView::backToPrevUI, this, [=]{ + qDebug() << "User clicked back, returning to ISO selection"; slideWidget(d->usbWidget, d->isoWidget, 1); d->wsib->setCurrentPage(0); }); //diff mac,win,linux connect(d->progressWidget, &ProgressView::finish, this, [ = ](quint32 current, quint32 error, const QString & title, const QString & description) { - qDebug() << error << title << description << current; + qDebug() << "Progress finished - Current:" << current << "Error:" << error << "Title:" << title; if (error != BMHandler::NoError) { + qWarning() << "Operation failed with error:" << error; titlebar()->setQuitMenuDisabled(false); #ifdef Q_OS_WIN setWindowFlags(Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint); @@ -238,6 +248,7 @@ BMWindow::BMWindow(QWidget *parent) } #ifdef Q_OS_LINUX if (error == BMHandler::NoError && current == 101) { + qDebug() << "Operation completed successfully on Linux"; titlebar()->setMenuVisible(true); titlebar()->setQuitMenuDisabled(false); DWindowManagerHelper::instance()->setMotifFunctions(windowHandle(), DWindowManagerHelper::FUNC_CLOSE, true); @@ -248,6 +259,7 @@ BMWindow::BMWindow(QWidget *parent) #endif #ifndef Q_OS_LINUX #if defined Q_OS_Win + qDebug() << "Operation completed on Windows"; titlebar()->setQuitMenuDisabled(false); setWindowFlags(Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint); closeflags = true; @@ -261,15 +273,18 @@ BMWindow::BMWindow(QWidget *parent) #endif }); + qDebug() << "Starting BMInterface"; d->interface->start(); } void BMWindow :: slot_ThemeChange() { Q_D(BMWindow); + qDebug() << "Theme change detected"; DPalette pa; DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType(); if (themeType == DGuiApplicationHelper::LightType) { + qDebug() << "Applying light theme"; pa = d->wsib->palette(); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) pa.setColor(DPalette::Background, QColor(255, 255, 255)); @@ -281,6 +296,7 @@ void BMWindow :: slot_ThemeChange() // d->wsib->setSecondaryPointColor(QColor("#96ACBD")); d->wsib->setSecondaryPointColor(QColor(150, 172, 189, 51)); } else if (themeType == DGuiApplicationHelper::DarkType) { + qDebug() << "Applying dark theme"; pa = d->wsib->palette(); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) pa.setColor(DPalette::Background, QColor("#292929")); @@ -296,6 +312,7 @@ void BMWindow :: slot_ThemeChange() BMWindow::~BMWindow() { + qDebug() << "Destroying Boot Maker window"; m_pSAnimationGroup->deleteLater(); } @@ -306,12 +323,14 @@ QString rootCommand() void startBackend() { + qDebug() << "Starting backend process"; QProcess::startDetached(rootCommand()); } #if defined(Q_OS_WIN) void BMWindow::closeEvent(QCloseEvent *event) { + qDebug() << "Close event received, closeflags:" << closeflags; if (closeflags == false) { event->ignore(); } else { @@ -322,6 +341,7 @@ void BMWindow::closeEvent(QCloseEvent *event) void BMWindow::slideWidget(DWidget *left, DWidget *right, int iDirection) { + qDebug() << "Sliding widgets - Direction:" << iDirection; SlideAnimatoin* pSlideAnimation = new SlideAnimatoin; pSlideAnimation->initAnimation(left, right, iDirection); @@ -350,6 +370,7 @@ SlideAnimatoin::~SlideAnimatoin() void SlideAnimatoin::initAnimation(DWidget* pLeftWidget, DWidget* pRightWidget, int iDirection) { + qDebug() << "Initializing slide animation - Direction:" << iDirection; setLeftWidget(pLeftWidget); setRightWidget(pRightWidget); m_pLeftWidget->show(); @@ -387,6 +408,7 @@ void SlideAnimatoin::setRightWidget(DWidget* pWidget) void SlideAnimatoin::slot_AnimationGroupFinished() { + qDebug() << "Slide animation finished"; for (int i = 0; i < this->animationCount(); i++) { this->animationAt(i)->deleteLater(); } diff --git a/src/app/main.cpp b/src/app/main.cpp index 20375784..5e4cbe47 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -50,6 +50,7 @@ static bool switchToRoot(QApplication &app) int main(int argc, char **argv) { + qInfo() << "Starting Boot Maker application"; Utils::initResource(); #ifndef Q_OS_WIN #if defined(DTK_STATIC_LIB) @@ -58,7 +59,7 @@ int main(int argc, char **argv) #endif if (!QString(qgetenv("XDG_CURRENT_DESKTOP")).toLower().startsWith("deepin")) { - + qInfo() << "Setting XDG_CURRENT_DESKTOP to Deepin"; setenv("XDG_CURRENT_DESKTOP", "Deepin", 1); } @@ -73,7 +74,9 @@ int main(int argc, char **argv) // app.setTheme("light"); #ifdef Q_OS_MAC + qDebug() << "Checking root privileges on macOS"; if (switchToRoot(app)) { + qDebug() << "Switching to root user, exiting current instance"; exit(0); } #endif @@ -83,21 +86,25 @@ int main(int argc, char **argv) DLogManager::registerFileAppender(); #ifndef Q_OS_MAC + qDebug() << "Setting up single instance check"; qputenv("DTK_USE_SEMAPHORE_SINGLEINSTANCE", "1"); if (!DGuiApplicationHelper::instance()->setSingleInstance(app.applicationName(), DGuiApplicationHelper::UserScope)) { + qDebug() << "Another instance is already running, exiting"; exit(0); } #endif #ifdef Q_OS_WIN + qDebug() << "Loading fonts on Windows"; Utils::loadFonts(); app.setWindowIcon(QIcon(":/theme/light/image/deepin-boot-maker.svg")); #endif + qDebug() << "Loading translations"; app.loadTranslator(); Utils::loadTranslate(); app.setApplicationDisplayName(QObject::tr("Boot Maker")); - qDebug() << "Boot Maker UI started."; + qDebug() << "Boot Maker UI starting"; #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) DApplicationSettings savetheme; #endif @@ -107,10 +114,13 @@ int main(int argc, char **argv) // w.waitAuth(); auto ret = app.exec(); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + qInfo() << "Stopping BMInterface instance"; BMInterface::instance()->stop(); #else + qInfo() << "Stopping BMInterface reference"; BMInterface::ref().stop(); #endif + qDebug() << "Application exiting with code:" << ret; return ret; } @@ -118,6 +128,7 @@ int main(int argc, char **argv) namespace Utils { void loadFonts() { + qInfo() << "Loading preferred fonts on Windows"; QFontDatabase database; QStringList fontlist = database.families(); @@ -129,11 +140,13 @@ void loadFonts() foreach (QString font, preferList) { if (fontlist.contains(font)) { + qInfo() << "Setting application font to:" << font; QFont newFont = QFont(font); qApp->setFont(newFont); return; } } + qWarning() << "No preferred fonts found, using system default"; } } #endif diff --git a/src/app/view/deviceinfoitem.cpp b/src/app/view/deviceinfoitem.cpp index e0aeed6a..d6b2734e 100644 --- a/src/app/view/deviceinfoitem.cpp +++ b/src/app/view/deviceinfoitem.cpp @@ -32,6 +32,7 @@ DeviceInfoItem::DeviceInfoItem(const QString &name, const QString &device, const QString &cap, int percent, DWidget *parent) : DWidget(parent) { + qDebug() << "Creating DeviceInfoItem:" << name << "device:" << device << "capacity:" << cap << "percent:" << percent; s_removeDevice = WidgetUtil::getDpiPixmap(":/theme/light/image/drive.svg", this); auto mainLayout = new QHBoxLayout(this); @@ -107,6 +108,7 @@ DeviceInfoItem::DeviceInfoItem(const QString &name, const QString &device, connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, [ = ] { + qDebug() << "Theme changed for device:" << name; DPalette pa; DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType(); if (themeType == DGuiApplicationHelper::LightType) @@ -136,6 +138,7 @@ DeviceInfoItem::DeviceInfoItem(const QString &name, const QString &device, DeviceInfoItem::DeviceInfoItem(DWidget *parent) : DeviceInfoItem("Remove Device", "NULL", "0/0G", 0, parent) { + qDebug() << "Creating default DeviceInfoItem for device removal"; setProperty("needformat", false); } diff --git a/src/app/view/formatdialog.cpp b/src/app/view/formatdialog.cpp index 4ee825ea..d48ee683 100644 --- a/src/app/view/formatdialog.cpp +++ b/src/app/view/formatdialog.cpp @@ -13,6 +13,7 @@ NewStr autoCutText(const QString &text, DLabel *pDesLbl) { if (text.isEmpty() || nullptr == pDesLbl) { + qDebug() << "Invalid input for autoCutText: empty text or null label"; return NewStr(); } @@ -24,9 +25,11 @@ NewStr autoCutText(const QString &text, DLabel *pDesLbl) NewStr newstr; int width = pDesLbl->width(); if (titlewidth < width) { + qDebug() << "Text fits in one line:" << strText; newstr.strList.append(strText); newstr.resultStr += strText; } else { + qDebug() << "Text needs multiple lines, width:" << width << "text width:" << titlewidth; for (int i = 0; i < strText.count(); i++) { str += strText.at(i); @@ -49,6 +52,7 @@ NewStr autoCutText(const QString &text, DLabel *pDesLbl) FormatDialog::FormatDialog(QWidget *parent) : DDialog(parent) { + qDebug() << "Initializing FormatDialog"; setFixedWidth(380); // 设置对话框图标 setIcon(QMessageBox::standardIcon(QMessageBox::Icon::Warning)); @@ -61,6 +65,7 @@ FormatDialog::~FormatDialog() void FormatDialog::initDialog(const QString &titleText, const QString &strFormatText, const QString btnMsg1, DDialog::ButtonType btnType1, const QString btnMsg2, DDialog::ButtonType btnType2) { + qDebug() << "Initializing dialog with title:" << titleText; // 设置title if (!titleText.isEmpty()) setTitle(titleText); @@ -75,8 +80,10 @@ void FormatDialog::initDialog(const QString &titleText, const QString &strFormat // 按钮 if (btnMsg2.isEmpty()) { + qDebug() << "Adding single button:" << btnMsg1; addButton(btnMsg1, false, btnType1); } else { + qDebug() << "Adding two buttons:" << btnMsg1 << "and" << btnMsg2; addButton(btnMsg1, false, btnType1); addButton(btnMsg2, true, btnType2); } @@ -90,13 +97,16 @@ void FormatDialog::initDialog(const QString &titleText, const QString &strFormat void FormatDialog::autoFeed(DLabel *label) { + qDebug() << "Auto feeding text for label"; NewStr newstr = autoCutText(m_strFormatText, label); label->setText(newstr.resultStr); int height_lable = newstr.strList.size() * newstr.fontHeifht; label->setFixedHeight(height_lable); if (0 == m_iLabelOldHeight) { // 第一次exec自动调整 + qDebug() << "First time auto feed, adjusting size"; adjustSize(); } else { + qDebug() << "Adjusting height from" << m_iLabelOldHeight << "to" << height_lable; setFixedHeight(m_iDialogOldHeight - m_iLabelOldHeight + height_lable); //字号变化后自适应调整 } m_iLabelOldHeight = height_lable; @@ -106,6 +116,7 @@ void FormatDialog::autoFeed(DLabel *label) void FormatDialog::changeEvent(QEvent *event) { if (event->type() == QEvent::FontChange) { + qDebug() << "Font change event detected"; Dtk::Widget::DLabel *p = findChild("ContentLabel"); if (nullptr != p) { autoFeed(p); diff --git a/src/app/view/isoselectview.cpp b/src/app/view/isoselectview.cpp index 777321fb..69924115 100644 --- a/src/app/view/isoselectview.cpp +++ b/src/app/view/isoselectview.cpp @@ -49,23 +49,27 @@ void ThreadCheckFile::run() bool checkok = false; while (restart) { restart = false; + qDebug() << "Checking ISO file:" << m_file; checkok = BMInterface::instance()->checkfile(m_file); } + qInfo() << "ISO file check result:" << checkok << "for file:" << m_file; emit checkFileFinish(checkok); #else restart = true; bool checkok = false; while (restart) { restart = false; - //BMInterface::instance() 在dtk6中被屏蔽了 - checkok = BMInterface::ref().checkfile(m_file); + qDebug() << "Checking ISO file:" << m_file; + checkok = BMInterface::ref().checkfile(m_file); } + qInfo() << "ISO file check result:" << checkok << "for file:" << m_file; emit checkFileFinish(checkok); #endif } ISOSelectView::ISOSelectView(DWidget *parent) : DWidget(parent) { + qDebug() << "Initializing ISOSelectView"; setObjectName("ISOSelectView"); setAutoFillBackground(true); @@ -179,12 +183,16 @@ ISOSelectView::ISOSelectView(DWidget *parent) : DWidget(parent) slot_ThemeChange(); connect(&t_checkfile, &ThreadCheckFile::checkFileFinish, this, [ = ](bool result) { + qDebug() << "File check finished, result:" << result; m_checkFile->setText(""); QString stateText = ""; - if (!result) + if (!result) { + qWarning() << "Invalid ISO file detected"; stateText = tr("Illegal ISO image file"); + } m_nextSetp->setDisabled(false); if ("" != stateText) { + qDebug() << "Updating UI for invalid ISO file"; isoIcon->setPixmap(WidgetUtil::getDpiPixmap(":/theme/light/image/disc_dark.svg", this)); QString stateTemplateText = QString(s_stateTemplate).arg(stateText); m_hits->setText(stateTemplateText); @@ -199,6 +207,7 @@ ISOSelectView::ISOSelectView(DWidget *parent) : DWidget(parent) } } } else { + qDebug() << "Updating UI for valid ISO file"; isoIcon->setPixmap(WidgetUtil::getDpiPixmap(":/theme/light/image/media-optical-96px.svg", this)); int itemCount = isoPanelLayout->count(); for (int i = (itemCount - 1); i >= 0; --i) { @@ -249,6 +258,7 @@ ISOSelectView::ISOSelectView(DWidget *parent) : DWidget(parent) }); connect(m_fileSelect, &DLabel::linkActivated, this, [ = ](const QString & /*link*/) { + qDebug() << "Opening file dialog for ISO selection"; DFileDialog fileDlg(this); fileDlg.setViewMode(DFileDialog::Detail); fileDlg.setFileMode(DFileDialog::ExistingFile); @@ -257,10 +267,12 @@ ISOSelectView::ISOSelectView(DWidget *parent) : DWidget(parent) fileDlg.selectNameFilter("ISO (*.iso)"); if (DFileDialog::Accepted == fileDlg.exec()) { QString text = fileDlg.selectedFiles().first(); + qInfo() << "ISO file selected from dialog:" << text; onFileSelected(text); } }); connect(m_nextSetp, &DPushButton::clicked, this, [=]{ + qInfo() << "Next button clicked, selected ISO file:" << m_isoFilePath; emit isoFileSelected(m_isoFilePath); }); connect(isoPanel, &DropFrame::fileDrop, this, &ISOSelectView::onFileSelected); @@ -351,6 +363,7 @@ bool ISOSelectView::eventFilter(QObject *obj, QEvent *event) void ISOSelectView::onFileSelected(const QString &file) { + qDebug() << "File selected:" << file; QFileInfo info(file); QFontMetrics fontWidth(m_fileLabel->font()); QString elidedText = fontWidth.elidedText(info.fileName(), Qt::ElideMiddle, m_fileLabel->width() - 20); @@ -371,8 +384,10 @@ void ISOSelectView::onFileSelected(const QString &file) spliter->hide(); t_checkfile.setFile(file); if (t_checkfile.isRunning()) { + qDebug() << "Restarting file check for:" << file; t_checkfile.setRestart(); } else { + qDebug() << "Starting file check for:" << file; t_checkfile.start(); } } diff --git a/src/app/view/resultview.cpp b/src/app/view/resultview.cpp index ec34e539..92679591 100644 --- a/src/app/view/resultview.cpp +++ b/src/app/view/resultview.cpp @@ -154,47 +154,53 @@ ResultView::ResultView(DWidget *parent) : DWidget(parent) void ResultView::updateResult(quint32 error, const QString &/*title*/, const QString &/*description*/) { auto errorType = static_cast(error); + qInfo() << "Updating result view with error type:" << errorType; switch (errorType) { case BMHandler::NoError: + qInfo() << "Operation completed successfully"; m_rebootLater->disconnect(); connect(m_rebootLater, &DPushButton::clicked, this, [ = ]() { + qInfo() << "User clicked 'Done' button, exiting application"; qApp->exit(0); }); return; case BMHandler::SyscExecFailed: case BMHandler::ErrorType::InstallBootloaderFailed: + qWarning() << "Critical operation failed:" << errorType; if (DTK_NAMESPACE::DCORE_NAMESPACE::DSysInfo::uosEditionType() != DTK_NAMESPACE::DCORE_NAMESPACE::DSysInfo::UosProfessional) { + qInfo() << "Non-professional edition detected, showing feedback option"; m_logHits->setText(tr("The error log will be uploaded automatically with the feedback. We cannot improve without your feedback")); m_rebootLater->setText(tr("Submit Feedback")); m_logHits->adjustSize(); m_rebootLater->disconnect(); connect(m_rebootLater, &DPushButton::clicked, this, [ = ]() { + auto editionType = DTK_NAMESPACE::DCORE_NAMESPACE::DSysInfo::uosEditionType(); + qInfo() << "User clicked feedback button, edition type:" << editionType; // FIXME: call feedback 非专业版保持链接进社区 - if (DTK_NAMESPACE::DCORE_NAMESPACE::DSysInfo::uosEditionType() == DTK_NAMESPACE::DCORE_NAMESPACE::DSysInfo::UosCommunity) { + if (editionType == DTK_NAMESPACE::DCORE_NAMESPACE::DSysInfo::UosCommunity) { QDesktopServices::openUrl(QString("https://bbs.deepin.org/post/209286")); - } - else if(DTK_NAMESPACE::DCORE_NAMESPACE::DSysInfo::uosEditionType() == DTK_NAMESPACE::DCORE_NAMESPACE::DSysInfo::UosHome) { + } else if(editionType == DTK_NAMESPACE::DCORE_NAMESPACE::DSysInfo::UosHome) { QDesktopServices::openUrl(QString("https://bbs.chinauos.com/post/4838?id=4838&type_id=5&forum_name=%E6%A1%8C%E9%9D%A2%E4%B8%AA%E4%BA%BA%E7%89%88")); - } - else if((DTK_NAMESPACE::DCORE_NAMESPACE::DSysInfo::uosEditionType() == DTK_NAMESPACE::DCORE_NAMESPACE::DSysInfo::UosEnterprise) || - (DTK_NAMESPACE::DCORE_NAMESPACE::DSysInfo::uosEditionType() == DTK_NAMESPACE::DCORE_NAMESPACE::DSysInfo::UosEnterprise)) - { + } else if((editionType == DTK_NAMESPACE::DCORE_NAMESPACE::DSysInfo::UosEnterprise) || + (editionType == DTK_NAMESPACE::DCORE_NAMESPACE::DSysInfo::UosEnterprise)) { QDesktopServices::openUrl(QString("https://bbs.chinauos.com/zh/post/5609")); - } - else { + } else { + qInfo() << "Launching deepin-feedback"; QProcess::startDetached("deepin-feedback"); } }); } else { + qInfo() << "Professional edition detected, showing after-sales service option"; m_rebootLater->setText(tr("After-Sale Services")); m_logHits->adjustSize(); m_rebootLater->disconnect(); connect(m_rebootLater, &DPushButton::clicked, this, [ = ]() { + qInfo() << "User clicked after-sales service button"; // FIXME: call service-support fix bug 19711 专业版不再调用deepin-feedback链接进社区,而是调用服务与支持客户端 QDBusInterface syssupport("com.deepin.dde.ServiceAndSupport", "/com/deepin/dde/ServiceAndSupport", "com.deepin.dde.ServiceAndSupport"); syssupport.call("ServiceSession", 2); @@ -202,17 +208,18 @@ void ResultView::updateResult(quint32 error, const QString &/*title*/, const QSt } break; default: + qWarning() << "Operation failed with error:" << errorType << "-" << BMHandler::errorString(errorType); m_logHits->setText(BMHandler::errorString(errorType)); m_rebootLater->setText(tr("Close", "button")); m_rebootLater->disconnect(); connect(m_rebootLater, &DPushButton::clicked, this, [ = ]() { + qInfo() << "User clicked close button after error, exiting application"; qApp->exit(0); }); break; } m_hitsTitle->setText(tr("Sorry, process failed")); -// m_title->setText(tr("Process failed")); m_resultIcon->setPixmap(WidgetUtil::getDpiPixmap(":/theme/light/image/fail.svg", this)); m_logHits->show(); m_rebootNow->hide(); @@ -221,6 +228,7 @@ void ResultView::updateResult(quint32 error, const QString &/*title*/, const QSt void ResultView::onLogLinkActivated(const QString &link) { if (link == "#show_log") { + qInfo() << "User clicked to view log file:" << Dtk::Core::DLogManager::getlogFilePath(); QDesktopServices::openUrl(QUrl::fromLocalFile(Dtk::Core::DLogManager::getlogFilePath())); } } diff --git a/src/app/view/usbselectview.cpp b/src/app/view/usbselectview.cpp index 47907c25..4824b510 100644 --- a/src/app/view/usbselectview.cpp +++ b/src/app/view/usbselectview.cpp @@ -231,9 +231,11 @@ UsbSelectView::UsbSelectView(DWidget *parent) : DWidget(parent) connect(&BMInterface::ref(), &BMInterface::deviceListChanged, this, [ = ](const QList &addlist, const QList& dellist) { + qInfo() << "Device list changed - Added:" << addlist.size() << "devices, Removed:" << dellist.size() << "devices"; bool hasPartitionSelected = false; foreach (DeviceInfo info, dellist) { + qInfo() << "Device removed:" << info.path << "Label:" << info.label; for (int i = 0; i < this->m_mountDevs.count(); i++) { DeviceInfo refInfo = this->m_mountDevs.at(i); if (refInfo == info) { @@ -243,6 +245,7 @@ UsbSelectView::UsbSelectView(DWidget *parent) : DWidget(parent) //移除列表中包含选中项 if (info.path == this->property("last_path")&&!info.path.isEmpty()&&!addlist.contains(info)) { + qInfo() << "Selected device was removed:" << info.path; m_formatDiskCheck->setDisabled(true); m_formatDiskCheck->setChecked(false); setProperty("user_format", false); @@ -265,6 +268,7 @@ UsbSelectView::UsbSelectView(DWidget *parent) : DWidget(parent) QStringList strDevList; foreach (const DeviceInfo &partition, this->m_mountDevs) { + qInfo() << "Adding device to list:" << partition.path << "Label:" << partition.label << "Format needed:" << partition.needFormat; QListWidgetItem *listItem = new QListWidgetItem; DeviceInfoItem *infoItem = new DeviceInfoItem( partition.label, @@ -288,6 +292,7 @@ UsbSelectView::UsbSelectView(DWidget *parent) : DWidget(parent) infoItem->setEnabled(false); } if (partition.path == this->property("last_path").toString()) { + qInfo() << "Restoring previous selection:" << partition.path; infoItem->setCheck(true); m_deviceList->setCurrentItem(listItem); hasPartitionSelected = true; @@ -314,11 +319,11 @@ UsbSelectView::UsbSelectView(DWidget *parent) : DWidget(parent) connect(m_deviceList, &DeviceListWidget::itemClicked, this, [ = ](QListWidgetItem * current) { - if (current != nullptr) { bool bFirst = current->data(Qt::UserRole).toBool(); if (!bFirst) { - return ; + qInfo() << "Ignoring click on non-primary device"; + return; } } DeviceInfoItem *infoItem; @@ -329,16 +334,18 @@ UsbSelectView::UsbSelectView(DWidget *parent) : DWidget(parent) } } - infoItem = qobject_cast(m_deviceList->itemWidget(current)); if (infoItem) { + qInfo() << "Device selected:" << infoItem->property("path").toString() << "Format needed:" << infoItem->needFormat(); if (infoItem->needFormat()) { + qInfo() << "Device requires formatting"; m_formatDiskCheck->setChecked(true); m_formatDiskCheck->setDisabled(true); handleFormat(true); } else { auto format = this->property("user_format").toBool(); + qInfo() << "User format preference:" << format; m_formatDiskCheck->setChecked(format); m_formatDiskCheck->setDisabled(false); handleFormat(format); @@ -349,25 +356,30 @@ UsbSelectView::UsbSelectView(DWidget *parent) : DWidget(parent) this->setProperty("last_fstype", infoItem->property("fstype").toString()); m_start->setDisabled(false); } - m_previous = current; + m_previous = current; }); connect(m_start, &DPushButton::clicked, this, [ = ] { auto format = m_formatDiskCheck->isChecked(); + qInfo() << "Start button clicked, format option:" << format; QString usbMountPoint = XSys::DiskUtil::MountPoint(this->property("last_path").toString()); usbMountPoint += "/"; QString isoFilePath = this->property("isoFilePath").toString(); + qInfo() << "USB mount point:" << usbMountPoint << "ISO file path:" << isoFilePath; + int ret = 1; // 判断用户勾选格式化后选择的ISO镜像的位置是否就是用户制作启动盘的U盘里。 if (format && (usbMountPoint.length() > 1) && (usbMountPoint == isoFilePath.left(usbMountPoint.length()))) { + qWarning() << "ISO file is on the target USB drive - showing warning dialog"; FormatDialog formatDialogSceneB(this); formatDialogSceneB.initDialog(tr("Format Partition"),tr("You have selected the ISO image in this USB flash drive. Formatting it will erase all your files. Please reselect the image file or cancel the formatting."), tr("OK", "button"),DDialog::ButtonType::ButtonWarning); formatDialogSceneB.setContentsMargins(0, 0, 0, 0); ret = formatDialogSceneB.exec(); } else if (format) { + qInfo() << "Showing format confirmation dialog"; FormatDialog formatDialogSceneA(this); formatDialogSceneA.initDialog(tr("Format Partition"),tr("Formatting the partition will overwrite all data, please have a backup before proceeding."), tr("Cancel", "button"),DDialog::ButtonType::ButtonNormal,tr("OK", "button"),DDialog::ButtonType::ButtonWarning); @@ -375,6 +387,7 @@ UsbSelectView::UsbSelectView(DWidget *parent) : DWidget(parent) ret = formatDialogSceneA.exec(); } if (ret != 1) { + qInfo() << "Format operation cancelled by user"; if (this->property("last_fstype").toString() == "vfat") { m_formatDiskCheck->setChecked(false); this->setProperty("user_format", false); @@ -387,26 +400,30 @@ UsbSelectView::UsbSelectView(DWidget *parent) : DWidget(parent) #ifdef Q_OS_LINUX if (!m_formatDiskCheck->isChecked() && "vfat" != this->property("last_fstype").toString()) { + qWarning() << "Disk format error: Non-FAT32 partition selected without formatting"; emit finish(2, "install failed", tr("Disk Format Error: Please format the partition with FAT32")); return; } #endif QString path = this->property("last_path").toString(); - qDebug() << "Select usb device" << path; + qInfo() << "Starting installation with device:" << path << "Format:" << m_formatDiskCheck->isChecked(); emit this->deviceSelected(path, m_formatDiskCheck->isChecked()); }); connect(pBackBtn, &DPushButton::clicked, this, [=]{ + qInfo() << "Back button clicked"; emit this->backToPrevUI(); }); } void UsbSelectView::getIsoFileSelectedPath(QString isoPath) { + qInfo() << "ISO file path set:" << isoPath; this->setProperty("isoFilePath",isoPath); } void UsbSelectView::resetStartInstall() { + qInfo() << "Resetting start button state"; m_start->setEnabled(true); } diff --git a/src/libdbm/backend/bootmaker.cpp b/src/libdbm/backend/bootmaker.cpp index 60e9a7ef..de17c1cd 100644 --- a/src/libdbm/backend/bootmaker.cpp +++ b/src/libdbm/backend/bootmaker.cpp @@ -28,20 +28,22 @@ BootMaker::BootMaker(QObject *parent) : BMHandler(parent) ,m_pInstaller(nullptr) { + qDebug() << "Initializing BootMaker"; m_usbDeviceMonitor = new DeviceMonitor(); m_monitorWork = new QThread(); m_usbDeviceMonitor->moveToThread(m_monitorWork); -// connect(monitorWork, &QThread::started, -// m_usbDeviceMonitor, &DeviceMonitor::startMonitor); + qDebug() << "Device monitor moved to worker thread"; connect(m_monitorWork, &QThread::finished, m_usbDeviceMonitor, &DeviceMonitor::deleteLater); connect(m_usbDeviceMonitor, &DeviceMonitor::removablePartitionsChanged, this, &BootMaker::removablePartitionsChanged); m_monitorWork->start(); + qDebug() << "Device monitor thread started"; connect(this, &BootMaker::finished, this, [ = ](int errcode, const QString & description) { + qInfo() << "Installation finished - Error code:" << errcode << "Description:" << description; this->reportProgress(101, errcode, "install failed", description); }); } @@ -49,6 +51,7 @@ BootMaker::BootMaker(QObject *parent) : BMHandler(parent) void BootMaker::reboot() { #ifdef Q_OS_WIN32 + qInfo() << "Windows reboot sequence started"; HANDLE hToken; TOKEN_PRIVILEGES tkp; OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken); @@ -59,45 +62,54 @@ void BootMaker::reboot() // ExitWindowsEx(EWX_REBOOT, EWX_FORCE); #endif #ifdef Q_OS_LINUX + qInfo() << "Linux reboot sequence started"; sync(); ::reboot(RB_AUTOBOOT); #endif #ifdef Q_OS_MAC + qInfo() << "macOS reboot sequence started"; XSys::SynExec("shutdown", "-r now &"); #endif } void BootMaker::start() { - qInfo() << "BootMaker start"; + qInfo() << "Starting BootMaker service"; if (m_pInstaller == nullptr) { + qDebug() << "Creating new installer instance"; m_pInstaller = QtInstallerFactory::getInstance()->createInstaller(); if (m_pInstaller != nullptr) { + qDebug() << "Setting up installer connections"; connect(m_pInstaller, &QtBaseInstaller::progressfinished, this, [=](ProgressStatus status, BMHandler::ErrorType error) { Q_UNUSED(status); + qInfo() << "Installation progress finished - Error type:" << error; emit finished(error, errorString(BMHandler::ErrorType(error))); }); connect(m_pInstaller, &QtBaseInstaller::reportProgress, m_usbDeviceMonitor, [=](int current, const QString &title, const QString &description){ + qDebug() << "Progress update - Current:" << current << "Title:" << title; emit this->reportProgress(current, ErrorType::NoError, title, description); }); connect(m_pInstaller->m_sevenZipCheck.m_szpp, &SevenZipProcessParser::progressChanged, m_usbDeviceMonitor, [ = ](int current, int /*total*/, const QString & fileName) { + qDebug() << "SevenZip progress - Current:" << current << "File:" << fileName; emit this->reportProgress(current * 60 / 100 + 20, ErrorType::NoError, "extract", fileName); }, Qt::QueuedConnection); + } else { + qWarning() << "Failed to create installer instance"; } } if (m_pInstaller != nullptr) { if (m_pInstaller->isRunning()) { - qInfo() << "Installer is running"; + qInfo() << "Installer is already running, stopping current installation"; m_pInstaller->stopInstall(); } else { - qInfo() << "Start flush disk"; + qInfo() << "Starting disk flush and device monitoring"; emit m_usbDeviceMonitor->startMonitor(); } } @@ -105,17 +117,19 @@ void BootMaker::start() void BootMaker::stop() { + qInfo() << "Stopping BootMaker service"; emit m_usbDeviceMonitor->pauseMonitor(); } const QList BootMaker::deviceList() const { - qDebug() << "BootMaker deviceList"; + qDebug() << "Retrieving device list"; return m_usbDeviceMonitor->deviceList(); } + bool BootMaker::checkfile(const QString &filepath) { - qDebug() << "CheckFile:" << filepath; + qDebug() << "Checking file integrity:" << filepath; // //check iso integrity // SevenZip sevenZipCheck(filepath, ""); @@ -130,7 +144,7 @@ bool BootMaker::checkfile(const QString &filepath) bool BootMaker::install(const QString &image, const QString &unused_device, const QString &partition, bool formatDevice) { - qDebug() << "Begin install" << image << unused_device << partition << formatDevice; + qDebug() << "Starting installation - Image:" << image << "Partition:" << partition << "Format:" << formatDevice; if (m_pInstaller != nullptr) { emit m_usbDeviceMonitor->pauseMonitor(); @@ -139,6 +153,8 @@ bool BootMaker::install(const QString &image, const QString &unused_device, cons m_pInstaller->setformat(formatDevice); m_pInstaller->beginInstall(); emit m_usbDeviceMonitor->startMonitor(); + } else { + qWarning() << "Installation failed - Installer not initialized"; } return true; diff --git a/src/libdbm/bminterface.cpp b/src/libdbm/bminterface.cpp index f5838071..78a8195c 100644 --- a/src/libdbm/bminterface.cpp +++ b/src/libdbm/bminterface.cpp @@ -32,17 +32,23 @@ BMInterface::BMInterface(QObject *parent) : { Q_D(BMInterface); + qDebug() << "Initializing Boot Maker Interface"; qRegisterMetaType>(); #ifdef Q_OS_LINUX + qDebug() << "Creating D-Bus handler for Linux platform"; d->handler = new BMDbusHandler; #else + qDebug() << "Creating Boot Maker handler for non-Linux platform"; d->handler = new BootMaker; #endif + + qDebug() << "Moving handler to worker thread"; QThread *handlerwork = new QThread; d->handler->moveToThread(handlerwork); handlerwork->start(); + qDebug() << "Setting up signal connections"; connect(d->handler, &BMHandler::removablePartitionsChanged, this, &BMInterface::deviceListChanged); connect(d->handler, &BMHandler::finished, @@ -57,34 +63,38 @@ BMInterface::BMInterface(QObject *parent) : d->handler, &BMHandler::startInstall ); connect(d->handler, &BMHandler::startInstallRet, this, &BMInterface::startInstallRet); + qDebug() << "Boot Maker Interface initialization completed"; } BMInterface::~BMInterface() { - + qDebug() << "Destroying Boot Maker Interface"; } void BMInterface::start() { Q_D(BMInterface); + qInfo() << "Starting Boot Maker handler"; return d->handler->start(); } void BMInterface::stop() { Q_D(BMInterface); + qInfo() << "Stopping Boot Maker handler"; return d->handler->stop(); } void BMInterface::reboot() { Q_D(BMInterface); + qInfo() << "Initiating system reboot"; return d->handler->reboot(); } QList BMInterface::deviceList() { - qDebug() << "BMInterface deviceList"; + qDebug() << "Retrieving device list"; Q_D(BMInterface); return d->handler->deviceList(); } diff --git a/src/libdbm/installer/qtX86Installer.cpp b/src/libdbm/installer/qtX86Installer.cpp index 72c697e5..96ad50a2 100644 --- a/src/libdbm/installer/qtX86Installer.cpp +++ b/src/libdbm/installer/qtX86Installer.cpp @@ -9,36 +9,46 @@ QtX86Installer::QtX86Installer(QObject *parent) : QtBaseInstaller (parent) { - + qDebug() << "Initializing X86 installer"; } bool QtX86Installer::installBootload() { - qDebug() << "begin install bootloader on" << m_strPartionName; + qDebug() << "Starting bootloader installation on partition:" << m_strPartionName; m_progressStatus = INSTALLBOOTLOADER; QString strDisk = XSys::DiskUtil::GetPartitionDisk(m_strPartionName); if (strDisk.isEmpty()) { + qCritical() << "Failed to get partition disk information"; return false; } + qDebug() << "Installing bootloader on partition:" << m_strPartionName; XSys::Result result = XSys::Syslinux::InstallBootloader(m_strPartionName); if (!result.isSuccess()) { + qCritical() << "Failed to install bootloader:" << result.errmsg(); return false; } + qDebug() << "Installing MBR on disk:" << strDisk; result = XSys::Syslinux::InstallMbr(strDisk); if (!result.isSuccess()) { + qCritical() << "Failed to install MBR:" << result.errmsg(); return false; } + qDebug() << "Setting active partition:" << m_strPartionName << "on disk:" << strDisk; if (!XSys::DiskUtil::SetActivePartion(strDisk, m_strPartionName)) { + qCritical() << "Failed to set active partition"; return false; } + qDebug() << "Setting partition label for image:" << m_strImage; XSys::DiskUtil::SetPartionLabel(m_strPartionName, m_strImage); + + qInfo() << "Bootloader installation completed successfully"; return true; } diff --git a/src/libdbm/installer/qtbaseinstaller.cpp b/src/libdbm/installer/qtbaseinstaller.cpp index ed874395..fb79faef 100644 --- a/src/libdbm/installer/qtbaseinstaller.cpp +++ b/src/libdbm/installer/qtbaseinstaller.cpp @@ -16,39 +16,46 @@ QtBaseInstaller::QtBaseInstaller(QObject *parent) : QObject(parent) ,m_bRunning(false) ,m_bStop(false) { - + qDebug() << "Initializing QtBaseInstaller"; } void QtBaseInstaller::setformat(bool bFormat) { + qDebug() << "Setting format flag:" << bFormat; m_bFormat = bFormat; } void QtBaseInstaller::setPartionName(const QString& strPartionName) { + qDebug() << "Setting partition name:" << strPartionName; m_strPartionName = strPartionName; } void QtBaseInstaller::setImage(const QString& strImage) { + qDebug() << "Setting image path:" << strImage; m_strImage = strImage; } void QtBaseInstaller::beginInstall() { + qDebug() << "Starting installation process"; m_bRunning = true; m_bStop = false; bool bRet = hasEnoughSpace(); if (!bRet) { + qWarning() << "Insufficient space check failed"; checkError(); return; } else { + qDebug() << "USB space check completed successfully"; emit this->reportProgress(5, "check usb space finished", ""); } if (m_bStop) { + qDebug() << "Installation stopped by user"; m_bRunning = false; return; } @@ -56,14 +63,17 @@ void QtBaseInstaller::beginInstall() bRet = checkISOIntegrity(); if (!bRet) { + qWarning() << "ISO integrity check failed"; checkError(); return; } else { + qDebug() << "ISO integrity check completed successfully"; emit this->reportProgress(10, "check integrity finished", ""); } if (m_bStop) { + qDebug() << "Installation stopped by user"; m_bRunning = false; return; } @@ -71,14 +81,17 @@ void QtBaseInstaller::beginInstall() bRet = formatUsb(); if (!bRet) { + qWarning() << "USB formatting failed"; checkError(); return; } else { + qDebug() << "USB formatting completed successfully"; emit this->reportProgress(15, "format usb finished", ""); } if (m_bStop) { + qDebug() << "Installation stopped by user"; m_bRunning = false; return; } @@ -86,14 +99,17 @@ void QtBaseInstaller::beginInstall() bRet = installBootload(); if (!bRet) { + qWarning() << "Bootloader installation failed"; checkError(); return; } else { + qDebug() << "Bootloader installation completed successfully"; emit this->reportProgress(20, "install bootloader finished", ""); } if (m_bStop) { + qDebug() << "Installation stopped by user"; m_bRunning = false; return; } @@ -101,16 +117,20 @@ void QtBaseInstaller::beginInstall() bRet = extractISO(); if (!bRet) { + qWarning() << "ISO extraction failed"; checkError(); return; } else { + qDebug() << "ISO extraction completed successfully"; emit this->reportProgress(80, "extract ISO finished", ""); } + qDebug() << "Starting IO synchronization"; emit this->reportProgress(81, "begin sync IO", ""); if (m_bStop) { + qInfo() << "Installation stopped by user"; m_bRunning = false; return; } @@ -118,32 +138,38 @@ void QtBaseInstaller::beginInstall() bRet = syncIO(); if (!bRet) { + qWarning() << "IO synchronization failed"; checkError(); return; } else { + qDebug() << "IO synchronization completed successfully"; emit this->reportProgress(90, "sync IO finished", ""); } if (m_bStop) { + qDebug() << "Installation stopped by user"; m_bRunning = false; return; } + qInfo() << "Configuring syslinux"; configSyslinux(); //通过判断镜像中是否存在anaconda的文件夹来推测该镜像的安装器 if(needAddRepo()) { - qInfo() << "need add repo"; + qInfo() << "Repository configuration needed - modifying boot files"; modifyBootGrubFile("/EFI/BOOT/grub.cfg"); modifyBootGrubFile("/syslinux/syslinux.cfg"); } else { - qInfo() << "not need add repo"; + qInfo() << "No repository configuration needed"; } + qInfo() << "Installation process completed"; emit this->reportProgress(100, "finish", ""); if (m_bStop) { + qInfo() << "Installation stopped by user"; m_bRunning = false; return; } @@ -151,30 +177,34 @@ void QtBaseInstaller::beginInstall() bRet = ejectDisk(); if (!bRet) { + qWarning() << "Disk ejection failed"; checkError(); return; } else { + qInfo() << "Disk ejected successfully"; emit this->reportProgress(101, "finish", ""); } + qInfo() << "Installation process finished"; m_bRunning = false; } void QtBaseInstaller::checkError() { + qInfo() << "Checking installation error"; m_bRunning = false; if (m_bStop) { - qInfo() << "Stop Install"; + qInfo() << "Installation stopped by user"; return; } - qInfo() << "begin check error"; + qInfo() << "Beginning error check"; QString strDisk = XSys::DiskUtil::GetPartitionDisk(m_strPartionName); if (strDisk.isEmpty()) { - qCritical() << "Error::get(Error::USBMountFailed)"; + qCritical() << "Failed to get partition disk information"; emit progressfinished(m_progressStatus, BMHandler::ErrorType::USBMountFailed); return; } @@ -200,8 +230,8 @@ void QtBaseInstaller::checkError() } } - if (!bFind) { - qCritical() << "Error::get(Error::USBMountFailed)"; + if (!bFind) { + qCritical() << "Partition not found in disk partitions"; emit progressfinished(m_progressStatus, BMHandler::ErrorType::USBMountFailed); return; } @@ -250,93 +280,93 @@ bool QtBaseInstaller::isRunning() const void QtBaseInstaller::stopInstall() { + qInfo() << "Stopping installation process - Current status:" << m_progressStatus; m_bStop = true; - qInfo() << "m_progressStatus:" << m_progressStatus; - if(EXTRACTISO == m_progressStatus || CHECKINTEGRITY == m_progressStatus) { - qInfo() << "Installer stop install"; + if(EXTRACTISO == m_progressStatus || CHECKINTEGRITY == m_progressStatus) { + qInfo() << "Stopping SevenZip process"; m_sevenZipCheck.stopProcess(); } } bool QtBaseInstaller::hasEnoughSpace() { - bool bRet = false; - qInfo() << "begin check space"; + qInfo() << "Checking available space"; m_progressStatus = CHECKSPACE; QFileInfo isoInfo(m_strImage); //分区没有挂载时是获取不到正确的可用空间和分区大小的,因些需要先进行挂载。 QString strMountPt = XSys::DiskUtil::MountPoint(m_strPartionName); if (strMountPt.isEmpty()) { + qInfo() << "Mounting partition for space check"; XSys::DiskUtil::Mount(m_strPartionName); } strMountPt = XSys::DiskUtil::MountPoint(m_strPartionName); if (strMountPt.isEmpty()) { - qCritical() << "Can't get correct partition space."; + qCritical() << "Failed to get mount point for space check"; return false; } #define KByt 1024 if (m_bFormat) { if (isoInfo.size() / KByt > XSys::DiskUtil::GetPartitionTotalSpace(m_strPartionName)) { - qCritical() << "Error::get(Error::USBSizeError)"; - bRet = false; + qCritical() << "Insufficient total space on partition"; + return false; } else { - bRet = true; + qInfo() << "Sufficient total space available"; + return true; } } else { if (isoInfo.size() / KByt > XSys::DiskUtil::GetPartitionFreeSpace(m_strPartionName)) { - qCritical() << "Error::get(Error::USBSizeError)"; - bRet = false; + qCritical() << "Insufficient free space on partition"; + return false; } else { - bRet = true; + qInfo() << "Sufficient free space available"; + return true; } } - - return bRet; } bool QtBaseInstaller::checkISOIntegrity() { - bool bRet = false; - qInfo() << "check iso integrity."; + qInfo() << "Checking ISO integrity"; m_progressStatus = CHECKINTEGRITY; - //check iso integrity m_sevenZipCheck.setArchiveFile(m_strImage); m_sevenZipCheck.setOutputDirectory(""); if (!m_sevenZipCheck.check()) { - qCritical() << "Error::get(Error::ExtractImgeFailed)"; - bRet = false; + qCritical() << "ISO integrity check failed"; + return false; } else { - bRet = true; + qInfo() << "ISO integrity check passed"; + return true; } - - return bRet; } bool QtBaseInstaller::umountPartion() { + qInfo() << "Unmounting partition:" << m_strPartionName; return XSys::DiskUtil::UmountPartion(m_strPartionName); } bool QtBaseInstaller::umountDisk() { + qInfo() << "Unmounting disk"; bool bRet = false; QString device = XSys::DiskUtil::GetPartitionDisk(m_strPartionName); if (!XSys::DiskUtil::UmountDisk(device)) { - qCritical() << "umount partition failed: "; + qCritical() << "Failed to unmount disk:" << device; bRet = false; } else { + qInfo() << "Disk unmounted successfully"; bRet = true; } @@ -345,15 +375,16 @@ bool QtBaseInstaller::umountDisk() QString QtBaseInstaller::getMountPoint() { - return XSys::DiskUtil::MountPoint(m_strPartionName); + return XSys::DiskUtil::MountPoint(m_strPartionName); } bool QtBaseInstaller::ejectDisk() { - qInfo() << "begin eject disk"; + qInfo() << "Ejecting disk"; m_progressStatus = EJECTDISK; if (!(umountDisk())) { + qCritical() << "Failed to unmount disk before ejection"; return false; } @@ -364,17 +395,20 @@ bool QtBaseInstaller::ejectDisk() bool QtBaseInstaller::formatUsb() { - qInfo() << "begin format usb."; + qInfo() << "Formatting USB device"; m_progressStatus = FORMATUSB; if (!umountPartion()) { + qCritical() << "Failed to unmount partition before formatting"; return false; } if (m_bFormat) { if (!XSys::DiskUtil::FormatPartion(m_strPartionName)) { + qCritical() << "Failed to format partition"; return false; } + qInfo() << "Partition formatted successfully"; } return true; @@ -382,12 +416,13 @@ bool QtBaseInstaller::formatUsb() bool QtBaseInstaller::installBootload() { + qInfo() << "Installing bootloader"; return false; } bool QtBaseInstaller::extractISO() { - qInfo() << "begin extract ISO to" << m_strPartionName; + qInfo() << "Extracting ISO to partition:" << m_strPartionName; XSys::SynExec("partprobe", m_strPartionName); m_progressStatus = GETINSTALLDIR; //由于前面的命令中会自动挂载系统,而导致如果操作过快会获取挂载点为空,然后在后面再次进行挂载时又挂载失败。因此加一个延时,让系统内核状态同步完成。 @@ -406,20 +441,22 @@ bool QtBaseInstaller::extractISO() } while(iTestCount > 0); if (installDir.isEmpty()) { + qInfo() << "Mounting partition for extraction"; XSys::DiskUtil::Mount(m_strPartionName); installDir = XSys::DiskUtil::MountPoint(m_strPartionName); } if (installDir.isEmpty()) { - qCritical() << "Error::get(Error::USBMountFailed)"; + qCritical() << "Failed to get mount point for extraction"; return false; } if (m_bStop) { - return true; + qInfo() << "Extraction stopped by user"; + return true; } - qInfo() << "begin clear target device files"; + qInfo() << "Clearing target device files"; m_progressStatus = EXTRACTISO; Utils::ClearTargetDev(installDir); m_sevenZipCheck.setArchiveFile(m_strImage); @@ -429,28 +466,35 @@ bool QtBaseInstaller::extractISO() bool QtBaseInstaller::syncIO() { - qInfo() << "begin sysc IO"; + qInfo() << "Synchronizing IO"; m_progressStatus = SYNCIO; return XSys::SynExec("sync", "").isSuccess(); } bool QtBaseInstaller::configSyslinux() { - qInfo() << "begin configure syslinux"; + qInfo() << "Configuring syslinux"; XSys::SynExec("sync", ""); QString installDir = XSys::DiskUtil::MountPoint(m_strPartionName); - qDebug() << "configure syslinux, installDir:" << installDir; - return XSys::Syslinux::ConfigSyslinx(installDir).isSuccess(); + qDebug() << "Configuring syslinux in directory:" << installDir; + bool result = XSys::Syslinux::ConfigSyslinx(installDir).isSuccess(); + if (result) { + qInfo() << "Syslinux configuration completed successfully"; + } else { + qCritical() << "Syslinux configuration failed"; + } + return result; } bool QtBaseInstaller::needAddRepo() { + qInfo() << "Checking if repository configuration is needed"; QStringList args; args << "-f" << "-i" << m_strImage; XSys::Result ret = XSys::SynExec("isoinfo", args); if (!ret.isSuccess()) { - qWarning() << "call isoinfo failed" << ret.result(); + qWarning() << "Failed to execute isoinfo:" << ret.result(); return false; } @@ -466,6 +510,7 @@ bool QtBaseInstaller::needAddRepo() void QtBaseInstaller::modifyBootGrubFile(QString grub_file_name) { + qInfo() << "Modifying boot grub file:" << grub_file_name; QString strMountPt = XSys::DiskUtil::MountPoint(m_strPartionName); QString strFullFileName = strMountPt + grub_file_name; @@ -473,7 +518,7 @@ void QtBaseInstaller::modifyBootGrubFile(QString grub_file_name) QFile readFile(strFullFileName); if (!readFile.open(QIODevice::ReadOnly)) { - qCritical() << readFile.errorString(); + qCritical() << "Failed to open grub file for reading:" << readFile.errorString(); return; } @@ -482,7 +527,7 @@ void QtBaseInstaller::modifyBootGrubFile(QString grub_file_name) QFile writeFile(strTempFileName); if (!writeFile.open(QIODevice::ReadWrite|QIODevice::Truncate)) { - qCritical() << writeFile.errorString(); + qCritical() << "Failed to open temporary file for writing:" << writeFile.errorString(); return; } @@ -504,5 +549,8 @@ void QtBaseInstaller::modifyBootGrubFile(QString grub_file_name) writeFile.close(); QFile::remove(strFullFileName); QFile::rename(strTempFileName, strFullFileName); + qInfo() << "Grub file modified successfully"; + } else { + qWarning() << "Grub file not found:" << strFullFileName; } } diff --git a/src/libdbm/installer/qtinstallerfactory.cpp b/src/libdbm/installer/qtinstallerfactory.cpp index 5b75d7ad..b18520b2 100644 --- a/src/libdbm/installer/qtinstallerfactory.cpp +++ b/src/libdbm/installer/qtinstallerfactory.cpp @@ -23,6 +23,7 @@ QtInstallerFactory* QtInstallerFactory::m_pSelf = nullptr; QtInstallerFactory* QtInstallerFactory::getInstance() { if (nullptr == m_pSelf) { + qDebug() << "Creating new QtInstallerFactory instance"; m_pSelf = new QtInstallerFactory; } @@ -31,22 +32,23 @@ QtInstallerFactory* QtInstallerFactory::getInstance() QtBaseInstaller* QtInstallerFactory::createInstaller() { + qDebug() << "Creating platform-specific installer"; QtBaseInstaller* pInstaller = nullptr; #if defined(Q_PROCESSOR_X86) - qDebug() << "Architecture:X86_64"; + qDebug() << "Detected X86_64 architecture, creating X86 installer"; pInstaller = new QtX86Installer(); #elif defined(Q_PROCESSOR_MIPS) - qDebug() << "Architecture:MIPS"; + qDebug() << "Detected MIPS architecture, creating MIPS installer"; pInstaller = new QtMipsInstaller; #elif defined(Q_PROCESSOR_ARM) - qDebug() << "Architecture:ARM"; + qDebug() << "Detected ARM architecture, creating ARM installer"; pInstaller = new QtArmInstaller; #elif defined(__sw_64__) - qDebug() << "Architecture:SW"; + qDebug() << "Detected SW architecture, creating SW installer"; pInstaller = new QtSwInstaller; #else - qDebug() << "Architecture:Other"; + qDebug() << "Detected unknown architecture, creating generic installer"; pInstaller = new QtOtherInstaller; #endif @@ -55,5 +57,5 @@ QtBaseInstaller* QtInstallerFactory::createInstaller() QtInstallerFactory::QtInstallerFactory(QObject *parent) : QObject(parent) { - + qDebug() << "Initializing QtInstallerFactory"; } diff --git a/src/libdbm/installer/qtmipsinstaller.cpp b/src/libdbm/installer/qtmipsinstaller.cpp index bffc5379..80b43a09 100644 --- a/src/libdbm/installer/qtmipsinstaller.cpp +++ b/src/libdbm/installer/qtmipsinstaller.cpp @@ -9,24 +9,30 @@ QtMipsInstaller::QtMipsInstaller(QObject *parent) : QtBaseInstaller (parent) { - + qDebug() << "Initializing MIPS installer"; } bool QtMipsInstaller::installBootload() { - qInfo() << "begin install bootloader on" << m_strPartionName; + qInfo() << "Starting bootloader installation on partition:" << m_strPartionName; m_progressStatus = INSTALLBOOTLOADER; QString strDisk = XSys::DiskUtil::GetPartitionDisk(m_strPartionName); if (strDisk.isEmpty()) { + qCritical() << "Failed to get partition disk information"; return false; } + qDebug() << "Setting active partition:" << m_strPartionName << "on disk:" << strDisk; if (!XSys::DiskUtil::SetActivePartion(strDisk, m_strPartionName)) { + qCritical() << "Failed to set active partition"; return false; } + qDebug() << "Setting partition label for image:" << m_strImage; XSys::DiskUtil::SetPartionLabel(m_strPartionName, m_strImage); + + qInfo() << "Bootloader installation completed successfully"; return true; } diff --git a/src/libdbm/util/devicemonitor.cpp b/src/libdbm/util/devicemonitor.cpp index 8399be3c..528888a8 100644 --- a/src/libdbm/util/devicemonitor.cpp +++ b/src/libdbm/util/devicemonitor.cpp @@ -18,27 +18,31 @@ DeviceMonitor::DeviceMonitor(QObject *parent) : QObject(parent) { + qDebug() << "Initializing device monitor"; qRegisterMetaType>(); m_timer = new QTimer(this); m_timer->setInterval(2000); connect(m_timer, &QTimer::timeout, this, [ = ] { QList list = Utils::ListUsbDrives(); - qDebug() << "list length:" << list.length(); + qDebug() << "Detected" << list.length() << "USB devices"; for (int i = 0; i < list.size(); i++) { - qDebug() << "list i:" << i << " path:" << list.at(i).path << " label:" << list.at(i).label; + qDebug() << "Device" << i << "- Path:" << list.at(i).path + << "Label:" << list.at(i).label + << "Type:" << list.at(i).fstype + << "Format needed:" << list.at(i).needFormat; } QList intersectList = this->getIntersectDevice(list); - qDebug() << "intersectlist count:" << intersectList.size(); + qDebug() << "Found" << intersectList.size() << "unchanged devices"; QList addList = this->getNorDevice(list, intersectList); QList delList = this->getNorDevice(m_deviceList, intersectList); if ((!addList.isEmpty()) || !delList.isEmpty()) { + qInfo() << "Device changes detected - Added:" << addList.count() + << "Removed:" << delList.count(); emit this->removablePartitionsChanged(addList, delList); - qDebug() << "addlist count = " << addList.count(); - qDebug() << "reducelist count =" << delList.count(); } this->m_deviceList = list; @@ -46,6 +50,7 @@ DeviceMonitor::DeviceMonitor(QObject *parent) : QObject(parent) connect(this, &DeviceMonitor::pauseMonitor, m_timer, &QTimer::stop); connect(this, &DeviceMonitor::startMonitor, this, [ = ]() { + qInfo() << "Starting device monitoring"; this->m_deviceList.clear(); m_timer->start(); }); @@ -58,6 +63,8 @@ QList DeviceMonitor::getIntersectDevice(const QList& lis foreach (DeviceInfo info, list) { foreach (DeviceInfo tempInfo, m_deviceList) { if ((tempInfo == info)&&(tempInfo.total == info.total)&&(tempInfo.used == info.used)) { + qDebug() << "Found unchanged device - Path:" << info.path + << "Label:" << info.label; intersectList.push_back(info); } } @@ -81,6 +88,8 @@ QList DeviceMonitor::getNorDevice(const QList& calcuList } if (bInsert) { + qDebug() << "Found new device - Path:" << info.path + << "Label:" << info.label; XorList.push_back(info); } } @@ -90,11 +99,13 @@ QList DeviceMonitor::getNorDevice(const QList& calcuList const QList DeviceMonitor::deviceList() const { + qDebug() << "Retrieving current device list"; return Utils::ListUsbDrives(); } QString deviceListToJson(QList deviceList) { + qDebug() << "Converting device list to JSON format"; QJsonArray array; for (auto device : deviceList) { QJsonObject obj; @@ -106,17 +117,10 @@ QString deviceListToJson(QList deviceList) obj.insert("needformat", device.needFormat); obj.insert("strDev", device.strDev); obj.insert("isDisk", device.isDisk); - qDebug() << device.needFormat; + qDebug() << "Device format needed:" << device.needFormat; array.push_back(obj); } -// QJsonObject obj; -// obj.insert("path", "Utest"); -// obj.insert("label", "U盘test"); -// obj.insert("used", 10000); -// obj.insert("total", 100000); -// obj.insert("needformat", false); -// array.push_back(obj); QJsonDocument doc; doc.setArray(array); return QString::fromUtf8(doc.toJson()); @@ -124,6 +128,7 @@ QString deviceListToJson(QList deviceList) QList deviceListFromJson(QString json) { + qDebug() << "Parsing device list from JSON"; QList list; QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8()); for (auto jsonObj : doc.array()) { @@ -137,6 +142,8 @@ QList deviceListFromJson(QString json) device.needFormat = obj.value("needformat").toBool(); device.isDisk = obj.value("isDisk").toBool(); device.strDev = obj.value("strDev").toString(); + qDebug() << "Parsed device - Path:" << device.path + << "Label:" << device.label; list.push_back(device); } return list; diff --git a/src/libdbm/util/sevenzip.cpp b/src/libdbm/util/sevenzip.cpp index bc9dc03a..c5355fc5 100644 --- a/src/libdbm/util/sevenzip.cpp +++ b/src/libdbm/util/sevenzip.cpp @@ -19,6 +19,7 @@ SevenZip::SevenZip(const QString &image, const QString &target, QObject *parent) ,m_bExit(true) ,m_sevenz(this) { + qDebug() << "Initializing SevenZip with image:" << image << "target:" << target; #ifdef Q_OS_LINUX QString sevnz = "7z"; @@ -31,7 +32,6 @@ SevenZip::SevenZip(const QString &image, const QString &target, QObject *parent) m_sevenZip = sevnz; m_archiveFile = image; m_outputDir = "-o" + target; - // connect(&m_szpp, &SevenZipProcessParser::progressChanged, this, &SevenZip::progressChanged); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) connect(&m_sevenz, static_cast(&QProcess::finished), this, &SevenZip::handleFinished); @@ -43,23 +43,26 @@ SevenZip::SevenZip(const QString &image, const QString &target, QObject *parent) void SevenZip::setArchiveFile(const QString &archiveFile) { + qDebug() << "Setting archive file:" << archiveFile; m_archiveFile = archiveFile; } void SevenZip::setOutputDirectory(const QString &outputDir) { + qDebug() << "Setting output directory:" << outputDir; m_outputDir = "-o" + outputDir; } void SevenZip::stopProcess() { QString strCmd = QString("kill 9 %1").arg(m_sevenz.processId()); - qDebug() << strCmd; + qDebug() << "Stopping 7-Zip process with command:" << strCmd; QProcess::execute(strCmd); } bool SevenZip::extract() { + qDebug() << "Starting extraction of archive:" << m_archiveFile; m_sevenz.setProgram(m_sevenZip); QTemporaryFile progress; @@ -81,7 +84,7 @@ bool SevenZip::extract() m_sevenz.setArguments(args); m_sevenz.setStandardErrorFile(progress.fileName()); - qDebug() << m_sevenz.program() << m_sevenz.arguments().join(" "); + qDebug() << "Executing 7-Zip command:" << m_sevenz.program() << m_sevenz.arguments().join(" "); m_sevenz.start(); m_sevenz.waitForStarted(-1); @@ -97,7 +100,8 @@ bool SevenZip::extract() progress.close(); progress.remove(); - qInfo() << m_sevenz.exitStatus() << m_sevenz.exitCode(); + qInfo() << "Extraction completed - Exit status:" << m_sevenz.exitStatus() + << "Exit code:" << m_sevenz.exitCode(); return (m_sevenz.exitStatus() == QProcess::NormalExit) && (0 == m_sevenz.exitCode()); @@ -105,6 +109,7 @@ bool SevenZip::extract() bool SevenZip::check() { + qDebug() << "Starting archive verification:" << m_archiveFile; m_sevenz.setProgram(m_sevenZip); QStringList args; @@ -118,33 +123,34 @@ bool SevenZip::check() #endif m_eventLoop.exec(); } - qInfo() << "check iso result" << m_sevenz.exitStatus() << m_sevenz.exitCode(); + qInfo() << "Archive verification completed - Exit status:" << m_sevenz.exitStatus() + << "Exit code:" << m_sevenz.exitCode(); return (m_sevenz.exitStatus() == QProcess::NormalExit) && (0 == m_sevenz.exitCode()); } void SevenZip::handleFinished() { - qDebug() <<"Zip Event Exit"; + qDebug() << "7-Zip process finished"; m_eventLoop.quit(); } SevenZipProcessParser::SevenZipProcessParser(const QString &file, QProcess *process, QObject *parent): QThread(parent) { + qDebug() << "Initializing SevenZip process parser"; m_progressFilename = file; m_sevenZip = process; } void SevenZipProcessParser::run() { - qDebug() << "Start Parse"; + qDebug() << "Starting progress parsing"; QFile progress(m_progressFilename); -// qDebug() << "progressFilename:" << m_progressFilename; progress.open(QIODevice::ReadOnly); while (QProcess::NotRunning != m_sevenZip->state()) { - QByteArray readed = progress.readLine(); + QByteArray readed = progress.readLine(); QString progressStr = QString::fromUtf8(readed).split("\b").last(); - QStringList prgressInfoList = progressStr.split(" - "); + QStringList prgressInfoList = progressStr.split(" - "); if (1 <= prgressInfoList.size()) { int pencent = prgressInfoList.first().split("% ").first().remove(" ").toInt(); m_lastPencent = (pencent >= m_lastPencent) ? pencent : m_lastPencent; @@ -152,10 +158,10 @@ void SevenZipProcessParser::run() if (2 <= prgressInfoList.size()) { m_lastFilename = prgressInfoList.last().isEmpty() ? m_lastFilename : prgressInfoList.last(); } - qInfo() << "send SevenZip progress" << m_lastPencent << m_lastFilename; + qDebug() << "Extraction progress:" << m_lastPencent << "% - Current file:" << m_lastFilename; emit progressChanged(m_lastPencent, 100, m_lastFilename); QThread::sleep(1); } - qInfo() << "End Parse" << m_sevenZip->state(); + qInfo() << "Progress parsing completed - Process state:" << m_sevenZip->state(); progress.close(); } diff --git a/src/libdbm/util/utils.cpp b/src/libdbm/util/utils.cpp index c24cec82..c01a0a05 100644 --- a/src/libdbm/util/utils.cpp +++ b/src/libdbm/util/utils.cpp @@ -25,6 +25,7 @@ static void initQRC() { + qDebug() << "Initializing resource files"; #ifdef Q_OS_LINUX //Q_INIT_RESOURCE(blob_linux); #else @@ -36,6 +37,7 @@ namespace Utils { bool isUft8(const QByteArray& byArr) { + qDebug() << "Checking UTF-8 encoding"; unsigned int nBytes = 0;//UFT8可用1-6个字节编码,ASCII用一个字节 bool bAllAscii = true; @@ -66,6 +68,7 @@ bool isUft8(const QByteArray& byArr) nBytes = 2; } else { + qDebug() << "Invalid UTF-8 sequence detected"; return false; } @@ -74,6 +77,7 @@ bool isUft8(const QByteArray& byArr) } else { if ((chr & 0xC0) != 0x80) { + qDebug() << "Invalid UTF-8 continuation byte"; return false; } @@ -82,6 +86,7 @@ bool isUft8(const QByteArray& byArr) } if (nBytes != 0) { + qDebug() << "Incomplete UTF-8 sequence"; return false; } @@ -94,6 +99,7 @@ bool isUft8(const QByteArray& byArr) bool isGBK(const QByteArray& byArr) { + qDebug() << "Checking GBK encoding"; unsigned int nBytes = 0; bool bAllAscii = true; @@ -111,6 +117,7 @@ bool isGBK(const QByteArray& byArr) nBytes = +2; } else { + qDebug() << "Invalid GBK sequence"; return false; } @@ -119,6 +126,7 @@ bool isGBK(const QByteArray& byArr) } else { if (chr < 0x40 || chr>0xFE) { + qDebug() << "Invalid GBK continuation byte"; return false; } @@ -127,6 +135,7 @@ bool isGBK(const QByteArray& byArr) } if (nBytes != 0) {//违返规则 + qDebug() << "Incomplete GBK sequence"; return false; } @@ -139,6 +148,7 @@ bool isGBK(const QByteArray& byArr) void loadTranslate() { + qDebug() << "Loading translations"; QTranslator *qtTranslator = new QTranslator; qtTranslator->load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); qApp->installTranslator(qtTranslator); @@ -190,26 +200,30 @@ void loadTranslate() tranlateUrl = QString(":/translations/deepin-boot-maker_%1.qm").arg(tnapplang); } - if (!QFile::exists(tranlateUrl)) { tranlateUrl = ":/translations/deepin-boot-maker.qm"; } - qDebug() << "locate:" << clangcode; - qDebug() << "load:" << tranlateUrl; + qDebug() << "System locale:" << clangcode; + qDebug() << "Loading translation file:" << tranlateUrl; if (translator->load(tranlateUrl)) { qApp->installTranslator(translator); + qDebug() << "Translation loaded successfully"; + } else { + qWarning() << "Failed to load translation file:" << tranlateUrl; } #endif } QString UsbShowText(const QString &dev) { + qDebug() << "Getting USB device display text for:" << dev; QString showText; if (!dev.isEmpty()) { QString label = XSys::DiskUtil::GetPartitionLabel(dev); if (label.isEmpty()) { + qDebug() << "No label found, using default label"; label = QObject::tr("Removable disk"); } #ifdef Q_OS_UNIX @@ -219,12 +233,14 @@ QString UsbShowText(const QString &dev) #ifdef Q_OS_WIN32 showText = QString("(%1:) %2").arg(dev.at(0)).arg(label); #endif + qDebug() << "Device display text:" << showText; } return showText; } void ClearTargetDev(const QString &targetPath) { + qInfo() << "Clearing target device at:" << targetPath; QStringList dirlist; dirlist.append("/boot/"); dirlist.append("/EFI/"); @@ -239,10 +255,12 @@ void ClearTargetDev(const QString &targetPath) foreach (QString dirname, dirlist) { QString fullDir = targetPath + dirname; + qDebug() << "Removing directory:" << fullDir; XSys::FS::RmDir(fullDir); } #ifdef Q_OS_UNIX + qDebug() << "Syncing filesystem"; XSys::SynExec("sync", ""); #endif } @@ -400,18 +418,18 @@ QMap CommandLsblkParse() bool CheckInstallDisk(const QString &targetDev) { - qDebug() << "CheckInstallDisk"; + qDebug() << "Checking installation disk:" << targetDev; if (XSys::DiskUtil::PF_FAT32 != XSys::DiskUtil::GetPartitionFormat(targetDev)) { - qDebug() << "disk format error " << targetDev; + qWarning() << "Invalid disk format for:" << targetDev; return false; } QString targetPath = XSys::DiskUtil::MountPoint(targetDev); - qDebug() << "targetPath: " << targetPath; + qDebug() << "Target mount point:" << targetPath; QFile test(QDir::toNativeSeparators(targetPath + "/" + "UOS")); if (!test.open(QIODevice::ReadWrite)) { - qDebug() << "erro open file: " << test.fileName(); + qWarning() << "Failed to open test file:" << test.fileName(); return false; } @@ -420,18 +438,20 @@ bool CheckInstallDisk(const QString &targetDev) QByteArray data = UOS.readAll(); if (data.length() != test.write(data)) { - qDebug() << "erro write file: " << UOS.fileName(); + qWarning() << "Failed to write test file:" << UOS.fileName(); return false; } test.close(); UOS.close(); test.remove(); + qInfo() << "Installation disk check passed"; return true; } bool isUsbDisk(const QString &dev) { + qDebug() << "Checking if device is USB:" << dev; QString out = XSys::FS::TmpFilePath("diskutil_isusb_out"); XSys::SynExec("bash", QString("-c \" diskutil info %1 > \"%2\" \" ").arg(dev).arg(out)); QFile outfile(out); @@ -439,12 +459,14 @@ bool isUsbDisk(const QString &dev) QString info = outfile.readAll(); outfile.close(); outfile.remove(); - return info.contains(QRegularExpression("Protocol:\\s+USB")); + bool isUsb = info.contains(QRegularExpression("Protocol:\\s+USB")); + qDebug() << "Device" << dev << "is USB:" << isUsb; + return isUsb; } QList ListUsbDrives() { - qDebug() << "ListUsbDrives"; + qDebug() << "Listing USB drives"; QList deviceList; #ifdef Q_OS_WIN32 QFileInfoList extdrivesList = QDir::drives(); @@ -455,7 +477,7 @@ QList ListUsbDrives() .contains("A:") && !QDir::toNativeSeparators(deviceLetter) .contains("B:")) { if (GetDriveType(LPWSTR(deviceLetter.utf16())) == 2) { - + qDebug() << "Found removable drive:" << deviceLetter; DeviceInfo info; info.path = QDir::toNativeSeparators(deviceLetter); deviceList.push_back(info); @@ -479,6 +501,7 @@ QList ListUsbDrives() if (usbfileinfoL.at(i).fileName().contains(QRegularExpression("^usb-\\S{1,}$")) || usbfileinfoL.at(i).fileName().contains(QRegularExpression("^mmc-\\S{1,}$"))) { #endif QString path = usbfileinfoL.at(i).canonicalFilePath(); + qDebug() << "Found USB/MMC device:" << path; removeDevice.insert(path, usbfileinfoL.at(i).fileName()); } } @@ -513,7 +536,11 @@ QList ListUsbDrives() partitionInfo.target = dfinfo.target; partitionInfo.needFormat = needformat; deviceList.push_back(partitionInfo); - qDebug() << partitionInfo.path << partitionInfo.used << partitionInfo.total << partitionInfo.target << partitionInfo.needFormat; + qDebug() << "Partition info - Path:" << partitionInfo.path + << "Used:" << partitionInfo.used + << "Total:" << partitionInfo.total + << "Target:" << partitionInfo.target + << "Need format:" << partitionInfo.needFormat; } } #endif @@ -531,6 +558,7 @@ QList ListUsbDrives() for (int i = 0; i < usbdevsL.size(); ++i) { if (isUsbDisk("/dev/" + usbdevsL.at(i))) { auto path = "/dev/" + usbdevsL.at(i); + qDebug() << "Found USB device:" << path; fulldrivelist.append(path); DeviceInfo info; @@ -539,15 +567,17 @@ QList ListUsbDrives() } } - qDebug() << fulldrivelist; + qDebug() << "Found USB devices:" << fulldrivelist; outfile.close(); outfile.remove(); #endif + qInfo() << "Found" << deviceList.size() << "USB devices"; return deviceList; } void initResource() { + qDebug() << "Initializing application resources"; initQRC(); } } diff --git a/src/service/bootmakerservice.cpp b/src/service/bootmakerservice.cpp index 15392de2..050ef1e7 100644 --- a/src/service/bootmakerservice.cpp +++ b/src/service/bootmakerservice.cpp @@ -50,18 +50,21 @@ const QString s_PolkitActionReboot = "com.deepin.bootmaker.reboot"; bool checkAuthorization(qint64 pid, const QString &action) { #if defined (Q_OS_LINUX) || defined (Q_OS_UNIX) || defined (Q_OS_MAC) + qDebug() << "Checking authorization for action:" << action << "PID:" << pid; PolkitQt1::Authority::Result ret = PolkitQt1::Authority::instance()->checkAuthorizationSync( action, PolkitQt1::UnixProcessSubject(pid), PolkitQt1::Authority::AllowUserInteraction); if (PolkitQt1::Authority::Yes == ret) { + qDebug() << "Authorization check passed for action:" << action; return true; } else { - qWarning() << qPrintable("Policy authorization check failed!"); + qWarning() << "Policy authorization check failed for action:" << action; return false; } #else + qDebug() << "Authorization check skipped on non-Linux/Unix/Mac platform"; return true; #endif } @@ -101,12 +104,14 @@ int getProcIdByExeName(std::string execName) static QString getProcIdExe(qint64 id) { + qDebug() << "Getting executable path for process ID:" << id; QString execName; if (id > 0) { // Read contents of virtual /proc/{pid}/cmdline file QString exeSymlinkPath = QString("/proc/%1/exe").arg(id); char *actualpath = realpath(exeSymlinkPath.toStdString().c_str(), NULL); execName = QString(actualpath); + qDebug() << "Process executable path:" << execName; } return execName; } @@ -115,66 +120,78 @@ BootMakerService::BootMakerService(QObject *parent) : QObject(parent), d_ptr(new BootMakerServicePrivate(this)) { Q_D(BootMakerService); + qDebug() << "Initializing Boot Maker Service"; + d->bm = new BootMaker(); QThread *bmThread = new QThread(); d->bm->moveToThread(bmThread); bmThread->start(); + qDebug() << "Boot Maker handler moved to worker thread"; connect(d->bm, &BootMaker::removablePartitionsChanged, this, [ = ](const QList &addlist, const QList& dellist) { + qDebug() << "Device list changed - Added:" << addlist.size() << "Removed:" << dellist.size(); emit DeviceListChanged(deviceListToJson(addlist), deviceListToJson(dellist)); }); connect(d->bm, &BootMaker::finished, this, &BootMakerService::Finished); -// connect(d->bm, &BootMaker::checkFileResult, -// this, &BootMakerService::CheckFileResult); connect(d->bm, &BootMaker::reportProgress, this, &BootMakerService::ReportProgress); connect(d->bm, &BootMaker::reportProgress1, this, &BootMakerService::ReportProgress1); -// connect(this, &BootMakerService::startInstall, -// d->bm, &BootMaker::install); connect(d->bm, &BootMaker::finished, this, [ = ](int errcode, const QString &) { + qDebug() << "Boot Maker finished with error code:" << errcode; QThread::msleep(1000); qApp->exit(errcode); }); connect(this, &BootMakerService::s_StartBootMarker, d->bm, &BootMaker::start); + qDebug() << "Boot Maker Service initialization completed"; } BootMakerService::~BootMakerService() { - + qDebug() << "Destroying Boot Maker Service"; } void BootMakerService::Reboot() { Q_D(BootMakerService); - if (checkAuthorization(d->dbusCallerPid(), s_PolkitActionReboot)) + qInfo() << "Reboot requested"; + if (checkAuthorization(d->dbusCallerPid(), s_PolkitActionReboot)) { + qDebug() << "Reboot authorized, proceeding"; d->bm->reboot(); + } else { + qWarning() << "Reboot request denied - Authorization failed"; + } } void BootMakerService::Start() { Q_D(BootMakerService); + qInfo() << "Start requested"; if (!d->checkCaller()) { + qWarning() << "Start request denied - Invalid caller"; return; } + qDebug() << "Starting Boot Maker"; emit s_StartBootMarker(); } void BootMakerService::Stop() { Q_D(BootMakerService); + qInfo() << "Stop requested"; if (!d->checkCaller()) { + qWarning() << "Stop request denied - Invalid caller"; return; } - qDebug() << "service exit by call Stop"; + qDebug() << "Stopping Boot Maker Service"; qApp->exit(0); } @@ -184,26 +201,31 @@ void BootMakerService::Stop() //! return json of devicelist QString BootMakerService::DeviceList() { - qDebug() << "BootMakerService DeviceList"; Q_D(BootMakerService); + qDebug() << "Device list requested"; if (!d->checkCaller()) { + qWarning() << "Device list request denied - Invalid caller"; return ""; } return deviceListToJson(d->bm->deviceList()); } -bool BootMakerService::Install(const QString &image, const QString &device, const QString &partition, bool formatDevice) +bool BootMakerService::Install(const QString &image, const QString &device, const QString &partition, bool formatDevice) { Q_D(BootMakerService); + qInfo() << "Install requested - Image:" << image << "Device:" << device << "Partition:" << partition; + if (!d->checkCaller()) { + qWarning() << "Install request denied - Invalid caller"; return false; } if (!d->disableCheck && !checkAuthorization(d->dbusCallerPid(), s_PolkitActionCreate)) { + qWarning() << "Install request denied - Authorization failed"; return false; } - qDebug() << "install image:" << image << " device:" << device << " partition:" << partition; + qDebug() << "Starting installation process"; emit d->bm->startInstall(image, device, partition, formatDevice); return true; } @@ -211,23 +233,20 @@ bool BootMakerService::Install(const QString &image, const QString &device, cons bool BootMakerService::CheckFile(const QString &filepath) { Q_D(BootMakerService); - - // if (!d->checkCaller()) { - // return false; - // } + qDebug() << "File check requested:" << filepath; return d->bm->checkfile(filepath); -// emit d->bm->startCheckfile(filepath); -// return true; } bool BootMakerServicePrivate::checkCaller() { if (disableCheck) { + qDebug() << "Caller check disabled"; return true; } Q_Q(BootMakerService); if (!q->calledFromDBus()) { + qWarning() << "Caller check failed - Not called from DBus"; return false; } @@ -235,14 +254,13 @@ bool BootMakerServicePrivate::checkCaller() QString callerExe = getProcIdExe(callerPid); QString dbmExe = QStandardPaths::findExecutable("deepin-boot-maker", {"/usr/bin"}); - qDebug() << "callerPid is: " << callerPid << "callerExe is:" << callerExe; + qDebug() << "Caller check - PID:" << callerPid << "Executable:" << callerExe; if (callerExe != dbmExe) { - qDebug() << QString("caller not authorized") ; + qWarning() << "Caller not authorized - Invalid executable"; return false; } - qDebug() << QString("caller authorized"); - + qDebug() << "Caller authorized"; return true; } @@ -254,6 +272,7 @@ qint64 BootMakerServicePrivate::dbusCallerPid() { Q_Q(BootMakerService); if (!q->calledFromDBus()) { + qDebug() << "Not called from DBus, returning 0"; return 0; } @@ -262,5 +281,6 @@ qint64 BootMakerServicePrivate::dbusCallerPid() return static_cast(interface->servicePid(q->message().service()).value()); } + qDebug() << "Failed to get DBus caller PID"; return 0; } diff --git a/src/service/main.cpp b/src/service/main.cpp index a467fd3a..16f6d969 100644 --- a/src/service/main.cpp +++ b/src/service/main.cpp @@ -17,19 +17,26 @@ const QString BootMakerPath = "/com/deepin/bootmaker"; int main(int argc, char *argv[]) { + qInfo() << "Starting Boot Maker Service"; + QString PATH = qgetenv("PATH"); + qDebug() << "Initial PATH:" << PATH; if (PATH.isEmpty()) { + qDebug() << "PATH is empty, setting default to /usr/bin"; PATH = "/usr/bin"; } PATH += ":/usr/sbin"; PATH += ":/sbin"; qputenv("PATH", PATH.toLatin1()); + qDebug() << "Updated PATH:" << PATH; QString strDebug = qgetenv("QT_LOGGING_RULES"); + qDebug() << "Initial QT_LOGGING_RULES:" << strDebug; if (strDebug.isEmpty()) { + qDebug() << "Setting default QT_LOGGING_RULES to *.debug=false"; strDebug = "*.debug=false"; } @@ -43,6 +50,8 @@ int main(int argc, char *argv[]) QCoreApplication a(argc, argv); a.setOrganizationName("deepin"); a.setApplicationName("deepin-boot-maker-service"); + qDebug() << "Application initialized with name:" << a.applicationName(); + BootMakerService service; const QString m_format = "%{time}{yyyyMMdd.HH:mm:ss.zzz}[%{type:1}][%{function:-35} %{line:-4} %{threadid} ] %{message}\n"; @@ -51,22 +60,27 @@ int main(int argc, char *argv[]) DBMLogManager::registerFileAppender(); DBMLogManager::registerConsoleAppender(); - qDebug() << "write log to" << DBMLogManager::getlogFilePath(); - qDebug() << PATH; + qInfo() << "Log file path:" << DBMLogManager::getlogFilePath(); + qDebug() << "Environment PATH:" << PATH; + qDebug() << "Registering D-Bus service:" << BootMakerServiceName; auto systemBus = QDBusConnection::systemBus(); if (!systemBus.registerService(BootMakerServiceName)) { - qCritical() << "registerService failed:" << systemBus.lastError(); + qCritical() << "Failed to register D-Bus service:" << systemBus.lastError().message(); exit(0x0001); } + qInfo() << "D-Bus service registered successfully"; + qDebug() << "Registering D-Bus object at path:" << BootMakerPath; if (!systemBus.registerObject(BootMakerPath, &service, QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals)) { - qCritical() << "registerObject failed:" << systemBus.lastError(); + qCritical() << "Failed to register D-Bus object:" << systemBus.lastError().message(); exit(0x0002); } + qInfo() << "D-Bus object registered successfully"; + qInfo() << "Boot Maker Service started successfully"; return a.exec(); }