Skip to content

Commit

Permalink
fix: get uab meta info failed
Browse files Browse the repository at this point in the history
Require uab file executable,
to get the meta info via --print-meta.

Log: Fix get uab meta info failed.
Bug: https://pms.uniontech.com/bug-view-292129.html
Influence: uab-package
  • Loading branch information
rb-union committed Dec 5, 2024
1 parent 6463a06 commit f2a501f
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/deb-installer/uab/uab_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ UabPkgInfo::Ptr UabBackend::packageFromMetaData(const QString &uabPath, QString
return {};
}

const QByteArray output = uabExecuteOutput(uabPath);
const QByteArray output = uabExecuteOutput(uabPath, errorString);
if (output.isEmpty()) {
return {};
}
Expand Down Expand Up @@ -383,12 +383,32 @@ UabPkgInfo::Ptr UabBackend::packageFromMetaJson(const QByteArray &json, QString

QByteArray UabBackend::uabExecuteOutput(const QString &uabPath, QString *errorString)
{
QFile uabFile(uabPath);
if (!uabFile.exists()) {
return {};
}

// temporarily set uab file executable to get meta info.
static const QFile::Permissions kExecutable = QFile::ExeOwner | QFile::ExeUser | QFile::ExeGroup;
QFile::Permissions savePermission = uabFile.permissions();
bool needExecutable = !(savePermission & kExecutable);
if (needExecutable && (!uabFile.setPermissions(savePermission | kExecutable))) {
if (errorString) {
*errorString = QString("set uab file executable failed: %1").arg(uabFile.errorString());
}
return {};
}

QProcess proc;
proc.setProgram(uabPath);
proc.setArguments({kUabPkgCmdPrintMeta});
proc.start();
proc.waitForFinished();

if (needExecutable) {
uabFile.setPermissions(savePermission);
}

if (0 != proc.exitCode() || QProcess::NormalExit != proc.exitStatus()) {
if (errorString) {
*errorString = QString("exec uab package failed: %1").arg(proc.errorString());
Expand Down

0 comments on commit f2a501f

Please sign in to comment.