mirror of https://github.com/linuxdeepin/linglong
Compare commits
No commits in common. "76f93d96f9ca87ef0a040b80fffded0fed85836f" and "b1fb90e7bc331e795c68d820da53b758cb8da403" have entirely different histories.
76f93d96f9
...
b1fb90e7bc
|
|
@ -746,7 +746,7 @@ int main(int argc, char **argv)
|
|||
Q_INIT_RESOURCE(builder_releases);
|
||||
// 初始化应用,builder在非tty环境也输出日志
|
||||
linglong::utils::global::applicationInitialize(true);
|
||||
linglong::utils::global::initLinyapsLogSystem(linglong::utils::log::LogBackend::Console);
|
||||
linglong::utils::global::initLinyapsLogSystem(argv[0]);
|
||||
|
||||
CLI::App commandParser{ _("linyaps builder CLI \n"
|
||||
"A CLI program to build linyaps application\n") };
|
||||
|
|
|
|||
|
|
@ -930,7 +930,7 @@ int main(int argc, char **argv)
|
|||
QCoreApplication app(argc, argv);
|
||||
// application initialize
|
||||
applicationInitialize();
|
||||
initLinyapsLogSystem(linglong::utils::log::LogBackend::Journal);
|
||||
initLinyapsLogSystem(argv[0]);
|
||||
|
||||
// invoke method
|
||||
auto ret = QMetaObject::invokeMethod(
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ auto main(int argc, char *argv[]) -> int
|
|||
QCoreApplication app(argc, argv);
|
||||
|
||||
applicationInitialize();
|
||||
initLinyapsLogSystem(linglong::utils::log::LogBackend::Journal);
|
||||
initLinyapsLogSystem(argv[0]);
|
||||
|
||||
auto ociRuntimeCLI = qgetenv("LINGLONG_OCI_RUNTIME");
|
||||
if (ociRuntimeCLI.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -280,8 +280,14 @@ utils::error::Result<void> UABPackager::packIcon() noexcept
|
|||
{
|
||||
LINGLONG_TRACE("add icon to uab")
|
||||
|
||||
auto iconAchieve = this->uab.parentDir().absoluteFilePath("icon.a");
|
||||
if (auto ret = utils::command::Cmd("ar").exec({ "q", iconAchieve, icon->absoluteFilePath() });
|
||||
!ret) {
|
||||
return LINGLONG_ERR(ret);
|
||||
}
|
||||
|
||||
QByteArray iconSection{ "linglong.icon" };
|
||||
if (auto ret = this->uab.addNewSection(iconSection, icon.value()); !ret) {
|
||||
if (auto ret = this->uab.addNewSection(iconSection, QFileInfo{ iconAchieve }); !ret) {
|
||||
return LINGLONG_ERR(ret);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -724,19 +724,13 @@ QVariantMap PackageManager::installFromLayer(const QDBusUnixFileDescriptor &fd,
|
|||
return;
|
||||
}
|
||||
|
||||
auto newRef = package::Reference::fromPackageInfo(*info);
|
||||
if (!newRef) {
|
||||
taskRef.reportError(std::move(newRef).error());
|
||||
return;
|
||||
}
|
||||
|
||||
auto ret = executePostInstallHooks(*newRef);
|
||||
if (!ret) {
|
||||
taskRef.reportError(std::move(ret).error());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!localRef) {
|
||||
auto newRef = package::Reference::fromPackageInfo(*info);
|
||||
if (!newRef) {
|
||||
taskRef.reportError(std::move(newRef).error());
|
||||
return;
|
||||
}
|
||||
|
||||
auto generateCacheRet = this->tryGenerateCache(*newRef);
|
||||
if (!generateCacheRet) {
|
||||
taskRef.reportError(std::move(generateCacheRet).error());
|
||||
|
|
@ -752,18 +746,30 @@ QVariantMap PackageManager::installFromLayer(const QDBusUnixFileDescriptor &fd,
|
|||
return;
|
||||
}
|
||||
|
||||
auto newRef = package::Reference::fromPackageInfo(*info);
|
||||
if (!newRef) {
|
||||
taskRef.reportError(std::move(newRef).error());
|
||||
return;
|
||||
}
|
||||
|
||||
auto generateCacheRet = this->tryGenerateCache(*newRef);
|
||||
if (!generateCacheRet) {
|
||||
taskRef.reportError(std::move(generateCacheRet).error());
|
||||
return;
|
||||
}
|
||||
|
||||
ret = removeAfterInstall(*localRef, *newRef, std::vector{ module });
|
||||
auto ret = removeAfterInstall(*localRef, *newRef, std::vector{ module });
|
||||
if (!ret) {
|
||||
qCritical() << "failed to remove old reference" << localRef->toString()
|
||||
<< "after install" << packageRef.toString() << ":"
|
||||
<< ret.error().message();
|
||||
}
|
||||
|
||||
ret = executePostInstallHooks(*newRef);
|
||||
if (!ret) {
|
||||
taskRef.reportError(std::move(ret).error());
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
auto refSpec =
|
||||
|
|
@ -1084,19 +1090,7 @@ QVariantMap PackageManager::installFromUAB(const QDBusUnixFileDescriptor &fd,
|
|||
if (!ret) {
|
||||
qCritical() << "rollback importLayerDir failed:" << ret.error().message();
|
||||
}
|
||||
|
||||
ret = executePostUninstallHooks(layerRef);
|
||||
if (!ret) {
|
||||
LogE("failed to rollback execute uninstall hooks: {}", ret.error());
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
});
|
||||
|
||||
auto result = executePostInstallHooks(ref);
|
||||
if (!result) {
|
||||
taskRef.reportError(std::move(result).error());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (oldAppRef) {
|
||||
|
|
@ -1122,6 +1116,12 @@ QVariantMap PackageManager::installFromUAB(const QDBusUnixFileDescriptor &fd,
|
|||
}
|
||||
}
|
||||
|
||||
auto ret = executePostInstallHooks(newAppRef);
|
||||
if (!ret) {
|
||||
taskRef.reportError(std::move(ret).error());
|
||||
return;
|
||||
}
|
||||
|
||||
transaction.commit();
|
||||
taskRef.updateState(linglong::api::types::v1::State::Succeed, "install uab successfully");
|
||||
};
|
||||
|
|
@ -1436,7 +1436,6 @@ void PackageManager::Install(PackageTask &taskContext,
|
|||
utils::error::ErrorCode::AppInstallModuleNotFound));
|
||||
return;
|
||||
}
|
||||
|
||||
InstallRef(taskContext,
|
||||
newRef,
|
||||
installModules->second,
|
||||
|
|
@ -1451,20 +1450,8 @@ void PackageManager::Install(PackageTask &taskContext,
|
|||
if (tmp.state() != linglong::api::types::v1::State::Succeed) {
|
||||
LogE("failed to rollback install {}", newRef.toString());
|
||||
}
|
||||
|
||||
auto ret = executePostUninstallHooks(newRef);
|
||||
if (!ret) {
|
||||
LogE("failed to rollback execute uninstall hooks: {}", ret.error());
|
||||
}
|
||||
});
|
||||
|
||||
auto ret = executePostInstallHooks(newRef);
|
||||
if (!ret) {
|
||||
taskContext.updateState(linglong::api::types::v1::State::Failed,
|
||||
"Failed to execute postInstall hooks.\n" + ret.error().message());
|
||||
return;
|
||||
}
|
||||
|
||||
taskContext.updateSubState(linglong::api::types::v1::SubState::PostAction,
|
||||
"processing after install");
|
||||
|
||||
|
|
@ -1503,6 +1490,13 @@ void PackageManager::Install(PackageTask &taskContext,
|
|||
}
|
||||
}
|
||||
|
||||
auto ret = executePostInstallHooks(newRef);
|
||||
if (!ret) {
|
||||
taskContext.updateState(linglong::api::types::v1::State::Failed,
|
||||
"Failed to execute postInstall hooks.\n" + ret.error().message());
|
||||
return;
|
||||
}
|
||||
|
||||
transaction.commit();
|
||||
taskContext.updateState(linglong::api::types::v1::State::Succeed,
|
||||
"Install " + newRef.toString() + " (from repo: "
|
||||
|
|
@ -1953,21 +1947,8 @@ void PackageManager::Update(PackageTask &taskContext,
|
|||
if (tmp.state() != linglong::api::types::v1::State::Succeed) {
|
||||
LogE("failed to rollback install {}", newRef.toString());
|
||||
}
|
||||
|
||||
auto ret = executePostUninstallHooks(newRef);
|
||||
if (!ret) {
|
||||
LogE("failed to rollback execute uninstall hooks: {}", ret.error());
|
||||
}
|
||||
});
|
||||
|
||||
auto result = executePostInstallHooks(newRef);
|
||||
if (!result) {
|
||||
taskContext.updateState(linglong::api::types::v1::State::Failed,
|
||||
"Failed to execute postInstall hooks.\n"
|
||||
+ result.error().message());
|
||||
return;
|
||||
}
|
||||
|
||||
auto oldRefLayerItem = this->repo.getLayerItem(oldRef);
|
||||
|
||||
taskContext.updateState(
|
||||
|
|
@ -2002,6 +1983,12 @@ void PackageManager::Update(PackageTask &taskContext,
|
|||
return;
|
||||
}
|
||||
|
||||
ret = executePostInstallHooks(newRef);
|
||||
if (!ret) {
|
||||
qCritical() << "failed to execute post install hooks" << ret.error().message();
|
||||
return;
|
||||
}
|
||||
|
||||
auto result = this->tryGenerateCache(newRef);
|
||||
if (!result) {
|
||||
taskContext.reportError(
|
||||
|
|
@ -2155,14 +2142,14 @@ void PackageManager::pullDependency(PackageTask &taskContext,
|
|||
transaction.addRollBack([this, runtimeRef = *runtime, module]() noexcept {
|
||||
auto result = this->repo.remove(runtimeRef.reference, module);
|
||||
if (!result) {
|
||||
LogE("failed to remove remote reference: {} : {}",
|
||||
runtimeRef.reference.toString(),
|
||||
result.error().message());
|
||||
qCritical() << result.error();
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
||||
result = executePostUninstallHooks(runtimeRef.reference);
|
||||
if (!result) {
|
||||
LogE("failed to rollback execute uninstall hooks: {}", result.error());
|
||||
qCritical() << result.error();
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -2223,14 +2210,13 @@ void PackageManager::pullDependency(PackageTask &taskContext,
|
|||
transaction.addRollBack([this, baseRef = *base, module]() noexcept {
|
||||
auto result = this->repo.remove(baseRef.reference, module);
|
||||
if (!result) {
|
||||
LogE("failed to remove remote reference: {} : {}",
|
||||
baseRef.reference.toString(),
|
||||
result.error().message());
|
||||
qCritical() << result.error();
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
||||
result = executePostUninstallHooks(baseRef.reference);
|
||||
if (!result) {
|
||||
LogE("failed to rollback execute uninstall hooks: {}", result.error());
|
||||
qCritical() << result.error();
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -100,9 +100,6 @@ public
|
|||
// Nothing to do here, Permissions() will be rejected in org.deepin.linglong.PackageManager.conf
|
||||
void Permissions() { }
|
||||
|
||||
utils::error::Result<void> executePostInstallHooks(const package::Reference &ref) noexcept;
|
||||
utils::error::Result<void> executePostUninstallHooks(const package::Reference &ref) noexcept;
|
||||
|
||||
Q_SIGNALS:
|
||||
void TaskAdded(QDBusObjectPath object_path);
|
||||
void TaskRemoved(QDBusObjectPath object_path,
|
||||
|
|
@ -159,6 +156,8 @@ private:
|
|||
utils::error::Result<void> generateCache(const package::Reference &ref) noexcept;
|
||||
utils::error::Result<void> tryGenerateCache(const package::Reference &ref) noexcept;
|
||||
utils::error::Result<void> removeCache(const package::Reference &ref) noexcept;
|
||||
utils::error::Result<void> executePostInstallHooks(const package::Reference &ref) noexcept;
|
||||
utils::error::Result<void> executePostUninstallHooks(const package::Reference &ref) noexcept;
|
||||
linglong::repo::OSTreeRepo &repo; // NOLINT
|
||||
PackageTaskQueue tasks;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ int main(int argc, char **argv)
|
|||
{
|
||||
qputenv("QT_FORCE_STDERR_LOGGING", QByteArray("1"));
|
||||
linglong::utils::global::installMessageHandler();
|
||||
linglong::utils::global::initLinyapsLogSystem(linglong::utils::log::LogBackend::Console);
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ LogBackend parseLogBackend(const char *backends)
|
|||
|
||||
} // namespace
|
||||
|
||||
void initLinyapsLogSystem(linglong::utils::log::LogBackend backend)
|
||||
void initLinyapsLogSystem(const char *command)
|
||||
{
|
||||
LogLevel logLevel = LogLevel::Info;
|
||||
LogBackend logBackend = LogBackend::None;
|
||||
|
|
@ -165,7 +165,13 @@ void initLinyapsLogSystem(linglong::utils::log::LogBackend backend)
|
|||
if (logBackendEnv) {
|
||||
logBackend = parseLogBackend(logBackendEnv);
|
||||
} else {
|
||||
logBackend = backend;
|
||||
if (command == std::string("ll-builder")) {
|
||||
logBackend = LogBackend::Console;
|
||||
} else if (command == std::string("ll-cli")) {
|
||||
logBackend = LogBackend::Journal;
|
||||
} else if (command == std::string("ll-package-manager")) {
|
||||
logBackend = LogBackend::Journal;
|
||||
}
|
||||
|
||||
if (isatty(STDERR_FILENO)) {
|
||||
logBackend = logBackend | LogBackend::Console;
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "linglong/utils/log/log.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <atomic>
|
||||
|
|
@ -18,7 +16,7 @@ void applicationInitialize(bool appForceStderrLogging = false);
|
|||
void installMessageHandler();
|
||||
bool linglongInstalled();
|
||||
void cancelAllTask() noexcept;
|
||||
void initLinyapsLogSystem(linglong::utils::log::LogBackend backend);
|
||||
void initLinyapsLogSystem(const char *command);
|
||||
|
||||
class GlobalTaskControl : public QObject
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue