Skip to content

Repository files navigation

Linglong Packaging Tool

A standalone tool to generate Linglong (linyaps) .uab packages from CMake, Meson, Autotools, or qmake projects.

Principle

The tool generates a linglong.yaml configuration file for your project, then calls ll-builder build and ll-builder export to build the Linglong package.

The tool automatically detects the build system in your project directory:

  • CMakeCMakeLists.txt found
  • Mesonmeson.build found
  • Autotoolsconfigure.ac, configure.in, or autogen.sh found
  • qmake.pro file found

It generates appropriate default build commands for each build system.

Dependencies

  • ll-builder (from linglong-builder package)
  • libyaml-cpp0.7 (YAML generation and parsing)
  • libcli11-dev (command-line argument parsing)
  • nlohmann-json3-dev (JSON parsing)
  • CMake 3.16+, C++17 compiler
sudo apt install libyaml-cpp-dev libcli11-dev nlohmann-json3-dev cmake linglong-builder

Build from Source

cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
sudo cmake --build build --target install

Quick Start

cd /path/to/your/project

# 1. Interactive configuration (default): you will be prompted for each setting
#    Detected build tool, default build commands, and existing config (if any)
#    will be shown. Press Enter to accept defaults.
linglong-build-tool init

# 2. Build the linglong package
linglong-build-tool pack

Non-interactive mode (default values)

# Generate linglong.yaml with default settings (no prompts)
linglong-build-tool init --default

Load configuration from JSON file

# Initialize from a JSON configuration file
linglong-build-tool init --config myconfig.json

Build Tool Detection

The tool scans your project directory for build system files and generates appropriate default build commands:

Build System Detection File Default Build Commands
CMake CMakeLists.txt rm -rf build, cmake -B build, cmake --build build -j$(nproc), cmake --build build --target install
Meson meson.build meson setup build, meson compile -C build, meson install -C build
Autotools configure.ac / configure.in / autogen.sh ./autogen.sh --prefix=$PREFIX, make -j$(nproc), make install
qmake *.pro qmake -r .., make -j$(nproc), make install
Unknown None of the above Prompts user to enter custom build commands

When the detected build tool is Meson, the tool automatically adds meson to build_depends in the generated linglong.yaml, since Meson is not pre-installed in the build container.

Build Only or Export Only

linglong-build-tool pack --build-only   # build only, skip export
linglong-build-tool pack --export-only  # export only, skip build

Custom Output Path

linglong-build-tool pack -o /path/to/output.uab

Architecture Override

linglong-build-tool pack --architecture loongarch64

CLI Options Reference

init Subcommand

Option Description Default
--default Initialize with default values without interactive prompts. Off
--config <path> Load configuration from a JSON file. Off

When run without options, the tool enters interactive mode. It displays all configurable parameters with their current values (loaded from an existing linglong.yaml if present, otherwise from defaults). Press Enter to accept a value, or type a new value. For fields like runtime, you will be asked whether to configure it first.

deps Subcommand

Parse and resolve build dependencies from CMakeLists.txt or meson.build files.

Subcommand Description
check Parse dependencies and display APT package resolution results
apply Resolve dependencies and write to linglong.yaml buildext section
Option Description Default
--build-file <path> Path to build file (CMakeLists.txt or meson.build). Auto-detects if not specified. Auto
--format json|table Output format (for check subcommand). table
--dry-run Preview changes without writing (for apply subcommand). Off

Resolution Layers

  1. rosdep base.yaml — Community-maintained mapping of 1000+ packages (bundled snapshot)
  2. libapt-pkg-dev — APT cache C++ API fallback (read-only, no root required)
  3. Heuristiclib<name>-dev guess for unknown packages

Usage Examples

# Check dependencies from CMakeLists.txt
linglong-build-tool deps check --build-file CMakeLists.txt

# Check dependencies in JSON format
linglong-build-tool deps check --build-file CMakeLists.txt --format json

# Auto-detect build file and check dependencies
linglong-build-tool deps check

# Resolve and write to linglong.yaml
linglong-build-tool deps apply --build-file CMakeLists.txt

# Preview resolution without writing
linglong-build-tool deps apply --build-file CMakeLists.txt --dry-run

pack Subcommand

Option Description Default
--build-only Only run ll-builder build, skip export. Use for debugging the build process. Off
--export-only Only run ll-builder export, skip build. Requires a previous successful build. Off
-o, --output <path> Output .uab file path. Defaults to {id}_{version}_{arch}.uab in the project directory. Auto
--architecture <arch> Override architecture detection. Auto-detected

Global Options

Option Description Default
-C, --directory <path> Working directory (project root). Defaults to the current directory. .
-v, --verbose Verbose output. Prints more debug information. Off
-h, --help Print help and exit. -
--version Print version and exit. -

Configuration

The tool generates linglong.yaml directly in the project directory. The configuration is obtained through:

  1. Interactive mode (default) — prompts for each field, with defaults pre-filled from an existing linglong.yaml (if present) or from built-in defaults.
  2. --default mode — generates linglong.yaml with built-in defaults, no interaction.
  3. --config <file> mode — reads configuration from a JSON file, then generates linglong.yaml.

JSON Configuration File Format

When using --config <path>, the JSON file should follow this structure:

{
  "package_id": "org.example.app",
  "package_version": "1.0.0.0",
  "package_name": "app",
  "package_description": "A demo app",
  "base": "org.deepin.base/25.2.2",
  "command": "app",
  "runtime": "",
  "build_depends": [],
  "depends": [],
  "build_commands": [
    "rm -rf build || true",
    "cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${PREFIX}",
    "cmake --build build -j$(nproc)",
    "cmake --build build --target install"
  ],
  "architecture": "x86_64",
  "channel": "main"
}

Configuration Fields

Field Required Description
package_id Yes Package ID, reverse domain notation (e.g. org.example.app)
package_version Yes Version string, auto-padded to 4 parts (e.g. 1.0 -> 1.0.0.0)
base Yes Base environment, e.g. org.deepin.base/25.2.2
command app kind Startup command for the application
package_name No Package name (defaults to package_id)
package_kind No Package kind, currently only app
package_description No Description text (defaults to package_name)
runtime No Runtime environment (optional, user chooses whether to configure)
build_depends No Build dependencies list (auto-populated for Meson)
depends No Runtime dependencies list
build_commands No Custom build commands (auto-detected based on build tool)
architecture No Target architecture (auto-detected via uname())
channel No Distribution channel (defaults to main)

Project Structure

linglong_build_tool/
├── CMakeLists.txt                          # Build file
├── LICENSE -> LICENSES/LGPL-3.0-or-later.txt
├── LICENSES/
│   └── LGPL-3.0-or-later.txt              # LGPL-3.0 license
├── debian/                                 # Debian packaging
│   ├── changelog
│   ├── control
│   ├── copyright
│   ├── rules
│   ├── watch
│   └── source/
├── data/
│   └── rosdep-base.yaml                     # Rosdep dependency mapping snapshot
├── src/                                    # C++ source code
│   ├── main.cpp                            # Entry point, CLI parsing
│   ├── config.h                            # LinglongConfig struct
│   ├── config_reader.cpp/.h                # JSON config reader/writer
│   ├── utils.h/.cpp                        # Utility functions (architecture detection,
│   │                                       #   version normalization, build tool detection,
│   │                                       #   default build commands/depends)
│   ├── yaml_generator.cpp/.h               # linglong.yaml generator
│   ├── ll_builder.cpp/.h                   # ll-builder wrapper
│   ├── deps_parser.cpp/.h                  # CMake/Meson dependency parser
│   ├── deps_resolver.cpp/.h                # Three-layer dependency resolver
│   ├── deps_command.cpp/.h                 # --deps command
│   ├── init_command.cpp/.h                 # --init command
│   └── pack_command.cpp/.h                 # --pack command
├── scripts/
│   ├── linglong-build-tool-completion.bash # Bash completion
│   ├── _linglong-build-tool                # Zsh completion
│   ├── linglong-build-tool.fish            # Fish completion
│   └── linglong-pack.sh                    # Fallback shell script
└── tests/                                  # Unit tests
    ├── CMakeLists.txt
    ├── test_config_reader.cpp
    ├── test_yaml_generator.cpp
    └── test_ll_builder.cpp

Testing

cd build && ctest

References

About

CMake packaging tool for Linglong (linyaps) .uab format

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages