Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ll-builder supports import directory #935

Merged
merged 1 commit into from
Dec 24, 2024
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
20 changes: 20 additions & 0 deletions apps/ll-builder/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,16 @@ You can report bugs to the linyaps team under this project: https://github.com/O
->required()
->check(CLI::ExistingFile);

// add build importDir
std::string layerDir;
auto buildImportDir =
commandParser.add_subcommand("import-dir", _("Import linyaps layer dir to build repo"))
->group(hiddenGroup);
buildImportDir->usage(_("Usage: ll-builder import-dir PATH"));
buildImportDir->add_option("PATH", layerDir, _("layer dir path"))
->type_name("PATH")
->required();

// add build extract
std::string dir;
auto buildExtract = commandParser.add_subcommand("extract", _("Extract linyaps layer to dir"));
Expand Down Expand Up @@ -782,6 +792,16 @@ You can report bugs to the linyaps team under this project: https://github.com/O
return 0;
}

if (buildImportDir->parsed()) {
auto result =
linglong::builder::Builder::importLayer(repo, QString::fromStdString(layerDir));
if (!result) {
qCritical() << result.error();
return -1;
}
return 0;
}

if (buildPush->parsed()) {
auto project =
parseProjectConfig(QDir().absoluteFilePath(QString::fromStdString(filePath)));
Expand Down
13 changes: 12 additions & 1 deletion libs/linglong/src/linglong/builder/linglong_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,18 @@ linglong::utils::error::Result<void> Builder::push(const std::string &module,
utils::error::Result<void> Builder::importLayer(repo::OSTreeRepo &ostree, const QString &path)
{
LINGLONG_TRACE("import layer");

if (std::filesystem::is_directory(path.toStdString())) {
auto layerDir = package::LayerDir(path);
auto info = layerDir.info();
if (!info) {
return LINGLONG_ERR(info);
}
auto result = ostree.importLayerDir(layerDir);
if (!result) {
return LINGLONG_ERR(result);
}
return LINGLONG_OK;
}
auto layerFile = package::LayerFile::New(path);
if (!layerFile) {
return LINGLONG_ERR(layerFile);
Expand Down
Loading