Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/libdbm/installer/qtX86Installer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2020 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2020 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-only

Expand Down Expand Up @@ -47,7 +47,10 @@ bool QtX86Installer::installBootload()
}

qDebug() << "Setting partition label for image:" << m_strImage;
XSys::DiskUtil::SetPartionLabel(m_strPartionName, m_strImage);
if (!XSys::DiskUtil::SetPartionLabel(m_strPartionName, m_strImage)) {
qCritical() << "Failed to set partition label";
return false;
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
}

qInfo() << "Bootloader installation completed successfully";
return true;
Expand Down
7 changes: 5 additions & 2 deletions src/libdbm/installer/qtmipsinstaller.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2020 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2020 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-only

Expand Down Expand Up @@ -31,7 +31,10 @@ bool QtMipsInstaller::installBootload()
}

qDebug() << "Setting partition label for image:" << m_strImage;
XSys::DiskUtil::SetPartionLabel(m_strPartionName, m_strImage);
if (!XSys::DiskUtil::SetPartionLabel(m_strPartionName, m_strImage)) {
qCritical() << "Failed to set partition label";
return false;
}

qInfo() << "Bootloader installation completed successfully";
return true;
Expand Down
6 changes: 5 additions & 1 deletion src/vendor/src/libxsys/Cmd/Cmd.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2015 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-only

Expand Down Expand Up @@ -63,6 +63,10 @@ Result SynExec(const QString &exec, const QString &param, const QString &execPip
Result ret = runApp(exec, param, execPipeIn);
qInfo() << "call:" << exec + " " + param << "with:" << execPipeIn ;
qInfo() << "resut:" << ret.isSuccess();
if (!ret.isSuccess()) {
qInfo() << "stdout:" << ret.result();
qInfo() << "stderr:" << ret.errmsg();
}
return ret;
}

Expand Down
45 changes: 25 additions & 20 deletions src/vendor/src/libxsys/DiskUtil/DiskUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,36 +745,41 @@
return ret.isSuccess();
}

void SetPartionLabel(const QString& strPartion, const QString& strImage)
bool SetPartionLabel(const QString& strPartion, const QString& strImage)

Check warning on line 748 in src/vendor/src/libxsys/DiskUtil/DiskUtil.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'SetPartionLabel' is never used.

Check warning on line 748 in src/vendor/src/libxsys/DiskUtil/DiskUtil.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

The function 'SetPartionLabel' is never used.
{
/*QProcess cannot handle Chinese paths*/
XSys::SynExec(XSys::FS::SearchBin("fsck"), QString("-y %1").arg(strPartion));
QStringList args;
args << "-i" << strImage << "-d";
XSys::Result ret3 = XSys::SynExec("isoinfo", args);
if (!XSys::SynExec(XSys::FS::SearchBin("fsck"), QStringList{"-y", strPartion}).isSuccess()) {
qWarning() << "fsck failed on" << strPartion << ", continuing anyway";
}

if (!ret3.isSuccess()) {
qWarning() << "call isoinfo failed" << ret3.result();
return;
XSys::Result isoResult = XSys::SynExec("isoinfo", QStringList{"-i", strImage, "-d"});
if (!isoResult.isSuccess()) {
qWarning() << "call isoinfo failed:" << isoResult.result();
return false;
}

QStringList volume = ret3.result().split("\n").filter("Volume id");
QString tem = volume.takeAt(0);
QStringList strValues = tem.split(":");
QString strName = QString("UNKNOWN");
QString strTemp;
// Volume id 格式: "Volume id: DEEPIN" 或 "Volume id: UOS"
QString volumeId;
for (const QString &line : isoResult.result().split("\n")) {
if (line.startsWith("Volume id:")) {

Check warning on line 763 in src/vendor/src/libxsys/DiskUtil/DiskUtil.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Consider using std::find_if algorithm instead of a raw loop.

Check warning on line 763 in src/vendor/src/libxsys/DiskUtil/DiskUtil.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Consider using std::find_if algorithm instead of a raw loop.
volumeId = line.split(":").last().trimmed();
break;
}
}

if (2 <= strValues.size()) {
strTemp = strValues.at(1);
strTemp = strTemp.trimmed();
if (volumeId.isEmpty()) {
qWarning() << "No volume id found in isoinfo output";
return false;
}

//标签名最长长度为十一位
strName = strTemp.isEmpty()?strName:(strTemp.length() > 11)?strTemp.left(11):strTemp;
XSys::SynExec(XSys::FS::SearchBin("fatlabel"), QString(" %1 \"%2\"").arg(strPartion).arg(strName));
// FAT32 卷标最长 11 字符
QString label = volumeId.left(11);
if (volumeId.length() > 11) {
qWarning() << "Volume id truncated:" << volumeId << "->" << label;
}
return XSys::SynExec(XSys::FS::SearchBin("fatlabel"), QStringList{strPartion, label}).isSuccess();
}

QString getPartitionUUID(const QString& strPartition)

Check warning on line 782 in src/vendor/src/libxsys/DiskUtil/DiskUtil.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'getPartitionUUID' is never used.

Check warning on line 782 in src/vendor/src/libxsys/DiskUtil/DiskUtil.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

The function 'getPartitionUUID' is never used.
{
XSys::Result ret = XSys::SynExec("lsblk", "-p -l --fs -o name,uuid");

Expand Down
4 changes: 2 additions & 2 deletions src/vendor/src/libxsys/DiskUtil/DiskUtil.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2015 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-only

Expand Down Expand Up @@ -34,7 +34,7 @@ bool FormatPartion(const QString& targetDev);
bool CreatePartition(const QString& diskDev);
QStringList GetPartionOfDisk(const QString& strDisk);
bool SetActivePartion(const QString& strDisk, const QString& strPartion);
void SetPartionLabel(const QString& strPartion, const QString& strImage);
bool SetPartionLabel(const QString& strPartion, const QString& strImage);
QString getPartitionUUID(const QString& strPartition);
}

Expand Down
Loading