Skip to content

Commit

Permalink
feat: ll-builder supports import directory
Browse files Browse the repository at this point in the history
ll-builder import命令支持传递目录, 这便于制作base和手动修改app
  • Loading branch information
myml committed Dec 23, 2024
1 parent f58cd1f commit 99a02c5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
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

0 comments on commit 99a02c5

Please sign in to comment.