diff --git a/src/linglong/builder/depend_fetcher.cpp b/src/linglong/builder/depend_fetcher.cpp index acd0a23be..f22efc5a2 100644 --- a/src/linglong/builder/depend_fetcher.cpp +++ b/src/linglong/builder/depend_fetcher.cpp @@ -53,12 +53,13 @@ DependFetcher::~DependFetcher() = default; void DependFetcher::printProgress(const uint &progress, const QString &speed) { printer.printReplacedText(QString("%1%2%3%4 (%5\% %6/s)") - .arg(ref.appId, -20) - .arg(ref.version, -15) - .arg(ref.module, -15) - .arg("downloading") - .arg(progress) - .arg(speed)); + .arg(ref.appId, -20) + .arg(ref.version, -15) + .arg(ref.module, -15) + .arg("downloading") + .arg(progress) + .arg(speed), + 2); } linglong::util::Error DependFetcher::fetch(const QString &subPath, const QString &targetPath) @@ -79,7 +80,8 @@ linglong::util::Error DependFetcher::fetch(const QString &subPath, const QString .arg(ref.appId, -20) .arg(ref.version, -15) .arg(ref.module, -15) - .arg("...")); + .arg("..."), + 2); auto ret = ostree.pull(ref, true); if (!ret.has_value()) { return WrapError(NewError(ret.error().code(), ret.error().message()), @@ -95,7 +97,8 @@ linglong::util::Error DependFetcher::fetch(const QString &subPath, const QString .arg(ref.appId, -20) .arg(ref.version, -15) .arg(ref.module, -15) - .arg("checkout")); + .arg("checkout"), + 2); auto ret = ostree.checkout(ref, subPath, targetPath); if (!ret.has_value()) { return WrapError(NewError(ret.error().code(), ret.error().message()), @@ -106,7 +109,8 @@ linglong::util::Error DependFetcher::fetch(const QString &subPath, const QString .arg(ref.appId, -20) .arg(ref.version, -15) .arg(ref.module, -15) - .arg("complete\n")); + .arg("complete\n"), + 2); } // for app,lib. if the dependType match runtime, should be submitted together. if (dd_ptr->dependType == DependTypeRuntime) { diff --git a/src/linglong/builder/linglong_builder.cpp b/src/linglong/builder/linglong_builder.cpp index b0b710942..96040ca0e 100644 --- a/src/linglong/builder/linglong_builder.cpp +++ b/src/linglong/builder/linglong_builder.cpp @@ -504,16 +504,27 @@ linglong::util::Error LinglongBuilder::build() project->generateBuildScript(); project->configFilePath = projectConfigPath; - linglong::builder::BuilderConfig::instance()->setProjectName(project->package->id); + printer.printMessage("[Build Target]"); + printer.printMessage(project->package->id, 2); + printer.printMessage("[Project Info]"); + printer.printMessage(QString("Packge Name: %1").arg(project->package->name), 2); + printer.printMessage(QString("Version: %1").arg(project->package->version), 2); + printer.printMessage(QString("Packge Type: %1").arg(project->package->kind), 2); + printer.printMessage(QString("Build Arch: %1").arg(project->config().targetArch()), 2); + + printer.printMessage("[Current Repo]"); + printer.printMessage(QString("Name: %1").arg(BuilderConfig::instance()->remoteRepoName), 2); + printer.printMessage(QString("Url: %1").arg(BuilderConfig::instance()->remoteRepoEndpoint), 2); + if (!project->package || project->package->kind.isEmpty()) { return NewError(-1, "unknown package kind"); } SourceFetcher sf(project->source, printer, project.get()); if (project->source) { - printer.printMessage(QString("fetching source code from: %1").arg(project->source->url)); + printer.printMessage("[Processing Source]"); auto err = sf.fetch(); if (err) { return NewError(-1, "fetch source failed"); @@ -529,6 +540,10 @@ linglong::util::Error LinglongBuilder::build() util::ensureDir(project->config().cacheAbsoluteFilePath( { "overlayfs", "up", project->config().targetInstallPath("") })); + printer.printMessage("[Processing Dependency]"); + printer.printMessage( + QString("%1%2%3%4").arg("Package", -20).arg("Version", -15).arg("Module", -15).arg("Status"), + 2); package::Ref baseRef(""); QString hostBasePath; @@ -705,16 +720,17 @@ linglong::util::Error LinglongBuilder::build() r->hooks = r->hooks.value_or(ocppi::runtime::config::types::Hooks{}); r->hooks->prestart = { { std::nullopt, std::nullopt, "/usr/sbin/ldconfig", std::nullopt } }; + printer.printMessage("[Start Build]"); if (startContainer(container, *r)) { return NewError(-1, "build task failed in container"); } - + printer.printMessage("[Commit Content]"); auto result = commitBuildOutput(project.get(), anno["overlayfs"]); if (!result.has_value()) { return NewError(result.error().code(), result.error().message()); } - printer.printMessage(QString("build %1 success").arg(project->package->id)); + printer.printMessage(QString("Build %1 success").arg(project->package->id)); return Success(); } diff --git a/src/linglong/builder/source_fetcher.cpp b/src/linglong/builder/source_fetcher.cpp index bc2f868ea..3445e9eae 100644 --- a/src/linglong/builder/source_fetcher.cpp +++ b/src/linglong/builder/source_fetcher.cpp @@ -171,9 +171,11 @@ util::Error SourceFetcherPrivate::fetchGitRepo() if (!QDir::setCurrent(sourceTargetPath())) { return NewError(-1, QString("change to %1 failed").arg(sourceTargetPath())); } - + QSharedPointer output = QSharedPointer::create(); - q->printer.printMessage(QString("git clone --recurse-submodules %1 %2").arg(source->url).arg(sourceTargetPath())); + q->printer.printMessage( + QString("git clone --recurse-submodules %1 %2").arg(source->url).arg(sourceTargetPath()), + 2); auto err = util::Exec("git", { "clone", @@ -194,7 +196,9 @@ util::Error SourceFetcherPrivate::fetchGitRepo() QDir::setCurrent(sourceTargetPath()); - q->printer.printMessage(QString("git checkout -b %1 %2").arg(source->version).arg(source->commit)); + q->printer.printMessage( + QString("git checkout -b %1 %2").arg(source->version).arg(source->commit), + 2); err = util::Exec("git", { "checkout", @@ -204,17 +208,17 @@ util::Error SourceFetcherPrivate::fetchGitRepo() }, -1, output); - + if (!output->isEmpty()) { q->printer.printMessage(QString(output->constData())); } if (err) { - q->printer.printMessage("git checkout failed. " + err.message()); + q->printer.printMessage("git checkout failed. " + err.message(), 2); output->clear(); } - q->printer.printMessage(QString("git reset --hard %1").arg(source->commit)); + q->printer.printMessage(QString("git reset --hard %1").arg(source->commit), 2); err = util::Exec("git", { "reset", @@ -225,7 +229,7 @@ util::Error SourceFetcherPrivate::fetchGitRepo() output); if (!output->isEmpty()) { - q->printer.printMessage(QString(output->constData())); + q->printer.printMessage(QString(output->constData()), 2); } return WrapError(err, "git reset failed"); @@ -235,9 +239,9 @@ util::Error SourceFetcherPrivate::handleLocalPatch() { Q_Q(SourceFetcher); // apply local patch - q->printer.printMessage("finding local patch"); + q->printer.printReplacedText("Finding local patch ...", 2); if (source->patch.isEmpty()) { - q->printer.printMessage("nothing to patch"); + q->printer.printReplacedText("Nothing to patch\n", 2); return Success(); } @@ -246,12 +250,13 @@ util::Error SourceFetcherPrivate::handleLocalPatch() qWarning() << QString("this patch is empty, check it"); continue; } - q->printer.printMessage(QString("applying patch: %1").arg(localPatch)); + q->printer.printReplacedText(QString("Applying %1 ...").arg(localPatch), 2); if (auto err = util::Exec("patch", { "-p1", "-i", project->config().absoluteFilePath({ localPatch }) })) { return NewError(err, "patch failed"); } + q->printer.printReplacedText(QString("Applying %1 done\n").arg(localPatch), 2); } return Success(); @@ -288,8 +293,10 @@ linglong::util::Error SourceFetcher::fetch() util::Error err; if (d->source->kind == "git") { + printer.printMessage(QString("Source: %1").arg(d->source->url), 2); err = d->fetchGitRepo(); } else if (d->source->kind == "archive") { + printer.printMessage(QString("Source: %1").arg(d->source->url), 2); QString s; std::tie(s, err) = d->fetchArchiveFile(); if (err) { @@ -298,7 +305,9 @@ linglong::util::Error SourceFetcher::fetch() err = d->extractFile(s, d->sourceTargetPath()); } else if (d->source->kind == "local") { err = d->handleLocalSource(); + printer.printMessage(QString("Source: %1").arg(sourceRoot()), 2); } else if (d->source->kind == "file") { + printer.printMessage(QString("Source: %1").arg(d->source->url), 2); QString s; std::tie(s, err) = d->fetchArchiveFile(); if (err) {