mirror of https://github.com/linuxdeepin/linglong
Compare commits
4 Commits
b1fb90e7bc
...
76f93d96f9
| Author | SHA1 | Date |
|---|---|---|
|
|
76f93d96f9 | |
|
|
c94a0dc829 | |
|
|
9b302b55dd | |
|
|
cdc9420a48 |
|
|
@ -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(argv[0]);
|
||||
linglong::utils::global::initLinyapsLogSystem(linglong::utils::log::LogBackend::Console);
|
||||
|
||||
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(argv[0]);
|
||||
initLinyapsLogSystem(linglong::utils::log::LogBackend::Journal);
|
||||
|
||||
// invoke method
|
||||
auto ret = QMetaObject::invokeMethod(
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ auto main(int argc, char *argv[]) -> int
|
|||
QCoreApplication app(argc, argv);
|
||||
|
||||
applicationInitialize();
|
||||
initLinyapsLogSystem(argv[0]);
|
||||
initLinyapsLogSystem(linglong::utils::log::LogBackend::Journal);
|
||||
|
||||
auto ociRuntimeCLI = qgetenv("LINGLONG_OCI_RUNTIME");
|
||||
if (ociRuntimeCLI.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -280,14 +280,8 @@ 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, QFileInfo{ iconAchieve }); !ret) {
|
||||
if (auto ret = this->uab.addNewSection(iconSection, icon.value()); !ret) {
|
||||
return LINGLONG_ERR(ret);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -724,13 +724,19 @@ QVariantMap PackageManager::installFromLayer(const QDBusUnixFileDescriptor &fd,
|
|||
return;
|
||||
}
|
||||
|
||||
if (!localRef) {
|
||||
auto newRef = package::Reference::fromPackageInfo(*info);
|
||||
if (!newRef) {
|
||||
taskRef.reportError(std::move(newRef).error());
|
||||
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 generateCacheRet = this->tryGenerateCache(*newRef);
|
||||
if (!generateCacheRet) {
|
||||
taskRef.reportError(std::move(generateCacheRet).error());
|
||||
|
|
@ -746,30 +752,18 @@ 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;
|
||||
}
|
||||
|
||||
auto ret = removeAfterInstall(*localRef, *newRef, std::vector{ module });
|
||||
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 =
|
||||
|
|
@ -1090,7 +1084,19 @@ 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) {
|
||||
|
|
@ -1116,12 +1122,6 @@ 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,6 +1436,7 @@ void PackageManager::Install(PackageTask &taskContext,
|
|||
utils::error::ErrorCode::AppInstallModuleNotFound));
|
||||
return;
|
||||
}
|
||||
|
||||
InstallRef(taskContext,
|
||||
newRef,
|
||||
installModules->second,
|
||||
|
|
@ -1450,8 +1451,20 @@ 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");
|
||||
|
||||
|
|
@ -1490,13 +1503,6 @@ 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: "
|
||||
|
|
@ -1947,8 +1953,21 @@ 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(
|
||||
|
|
@ -1983,12 +2002,6 @@ 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(
|
||||
|
|
@ -2142,14 +2155,14 @@ void PackageManager::pullDependency(PackageTask &taskContext,
|
|||
transaction.addRollBack([this, runtimeRef = *runtime, module]() noexcept {
|
||||
auto result = this->repo.remove(runtimeRef.reference, module);
|
||||
if (!result) {
|
||||
qCritical() << result.error();
|
||||
Q_ASSERT(false);
|
||||
LogE("failed to remove remote reference: {} : {}",
|
||||
runtimeRef.reference.toString(),
|
||||
result.error().message());
|
||||
}
|
||||
|
||||
result = executePostUninstallHooks(runtimeRef.reference);
|
||||
if (!result) {
|
||||
qCritical() << result.error();
|
||||
Q_ASSERT(false);
|
||||
LogE("failed to rollback execute uninstall hooks: {}", result.error());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -2210,13 +2223,14 @@ void PackageManager::pullDependency(PackageTask &taskContext,
|
|||
transaction.addRollBack([this, baseRef = *base, module]() noexcept {
|
||||
auto result = this->repo.remove(baseRef.reference, module);
|
||||
if (!result) {
|
||||
qCritical() << result.error();
|
||||
Q_ASSERT(false);
|
||||
LogE("failed to remove remote reference: {} : {}",
|
||||
baseRef.reference.toString(),
|
||||
result.error().message());
|
||||
}
|
||||
|
||||
result = executePostUninstallHooks(baseRef.reference);
|
||||
if (!result) {
|
||||
qCritical() << result.error();
|
||||
LogE("failed to rollback execute uninstall hooks: {}", result.error());
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -100,6 +100,9 @@ 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,
|
||||
|
|
@ -156,8 +159,6 @@ 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,6 +14,7 @@ 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(const char *command)
|
||||
void initLinyapsLogSystem(linglong::utils::log::LogBackend backend)
|
||||
{
|
||||
LogLevel logLevel = LogLevel::Info;
|
||||
LogBackend logBackend = LogBackend::None;
|
||||
|
|
@ -165,13 +165,7 @@ void initLinyapsLogSystem(const char *command)
|
|||
if (logBackendEnv) {
|
||||
logBackend = parseLogBackend(logBackendEnv);
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
logBackend = backend;
|
||||
|
||||
if (isatty(STDERR_FILENO)) {
|
||||
logBackend = logBackend | LogBackend::Console;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "linglong/utils/log/log.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <atomic>
|
||||
|
|
@ -16,7 +18,7 @@ void applicationInitialize(bool appForceStderrLogging = false);
|
|||
void installMessageHandler();
|
||||
bool linglongInstalled();
|
||||
void cancelAllTask() noexcept;
|
||||
void initLinyapsLogSystem(const char *command);
|
||||
void initLinyapsLogSystem(linglong::utils::log::LogBackend backend);
|
||||
|
||||
class GlobalTaskControl : public QObject
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue