# fluent/fluent-package-builder architecture

> Architecture diagram of the GitHub repository fluent/fluent-package-builder, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fluent/fluent-package-builder
- Repository: https://github.com/fluent/fluent-package-builder

## Overview

1. **What this repository is**
   - `fluent-package-builder` is a packaging factory, not an application runtime.
   - Its job is to produce installable artifacts for Fluentd-based products across Linux, Windows, and macOS, plus the repository metadata packages that let users install those artifacts from apt/yum.

2. **Top-level control plane**
   - The root `Rakefile` is the main entry point.
   - Ruby/Bundler code in `lib/` defines the shared build tasks and helpers, while platform-specific subtrees provide inputs and packaging recipes.
   - The root also contains CI, versioning, changelog, and release automation metadata.

3. **Core build abstractions**
   - `lib/package-task.rb` and the family-specific builders in `lib/apt/` and `lib/yum/` are the central orchestration layer.
   - These tasks read version/config data from `fluent-package/config.rb` and package dependency state from the Gemfiles/lockfiles.
   - Their output is a set of distro-specific package build jobs, not a single monolithic build.

4. **Product families / output boundaries**
   - `fluent-package/` is the main product: the actual Fluent package installed under `/opt/fluent`.
   - `fluent-apt-source/` and `fluent-lts-apt-source/` are helper Debian packages that install apt repo configuration and signing keys.
   - `fluent-release/` and `fluent-lts-release/` are yum repo packages for the RPM ecosystem, again focused on repo setup and trust material rather than the application payload.
   - This separation is important: application artifacts and repository-bootstrap artifacts are built and versioned independently.

5. **Main Linux packaging pipeline**
   - `fluent-package/apt/` and `fluent-package/yum/` hold distro-specific container build roots.
   - Each target directory contains a `Dockerfile`, base-image wiring, and sometimes `qemu-dummy-static`/`from` markers for cross-architecture builds.
   - The build flow is: Ruby/Rake task chooses a target matrix, Docker builds the package in an isolated OS environment, and the resulting `.deb` or `.rpm` is published into repository layout directories.

6. **Template-driven package contents**
   - `fluent-package/templates/` contains the filesystem payload and service integration templates that become part of the package.
   - These templates define config files, systemd units, tmpfiles rules, logrotate integration, shell wrappers, and macOS plist content.
   - This is where the package’s install-time behavior is shaped: paths, service names, defaults, and command shims.

7. **OS integration and service model**
   - The Linux package installs into standard system locations via templates under `etc/`, `usr/`, and service-management hooks.
   - systemd integration is a first-class boundary: service units, tmpfiles, needrestart, and logrotate are all explicitly packaged.
   - For macOS, the build produces a `.dmg` with `.plist`/package resources.
   - For Windows, the `msi/` subtree defines the installer layout, UI assets, post-install scripts, and WiX source.

8. **Cross-platform packaging implementations**
   - `fluent-package/msi/` is the Windows installer pipeline, driven by batch/PowerShell assets and a WiX source file.
   - `fluent-package/dmg/` is the macOS installer pipeline, with packaged resources and postinstall logic.
   - These are separate from the Linux package builders, but they share versioning and some artifact content decisions through the Ruby build system.

9. **Release repository mechanics**
   - `fluent-package/manage-fluent-repositories.sh`, `convert-artifacts-layout.sh`, and similar scripts indicate a second-stage artifact layout transformation.
   - Repository packages and generated artifacts are arranged for consumption by apt/yum clients, with signing keys checked in under the relevant release/source subtrees.
   - The repo therefore has both “build a package” and “package the package repository” concerns.

10. **Testing and validation**
   - `serverspec/` contains install/runtime verification for Linux, Windows, and Kafka/confluent-related scenarios.
   - The `apt/` and `yum/` subtrees include install tests, systemd upgrade/downgrade tests, package-size checks, and service-specific validation scripts.
   - Tests are containerized and target real package behavior after installation, which is critical because the architecture is packaging-centric rather than application-centric.

11. **Architecture matrix and cross-build support**
   - GitHub Actions workflows in `.github/workflows/` run matrix builds for apt/yum, macOS, Windows, bundle auditing, and release maintenance.
   - AArch64 and ppc64le support is handled via target-specific directories and qemu-static injection when the host cannot natively execute the target architecture.
   - This means build topology is intentionally multi-architecture and matrix-driven.

12. **Data flow summary**
   - Source inputs: Ruby config, Gem dependencies, distro templates, signing keys, and package metadata.
   - Build engine: Rake + Ruby helpers.
   - Build isolation: Docker containers for Linux, Windows container tooling for MSI, local macOS tooling for DMG.
   - Outputs: installable packages, repository bootstrap packages, and published repository layouts under family-specific output trees.
   - Verification: Serverspec and install/systemd tests run against the generated artifacts before release.

13. **How to draw the diagram**
   - Put `Rake/Bundler/lib/` at the center as the orchestrator.
   - Branch to four artifact families: Linux package build, repo-bootstrap packages, Windows MSI, and macOS DMG.
   - Show Dockerized distro-specific build roots behind Linux packaging.
   - Show signing/repository packages as a separate boundary from the main Fluent package payload.
   - Show tests and GitHub Actions as surrounding validation/automation layers, not part of the runtime product.

Main entry points: [`lib/package-task.rb`](https://github.com/fluent/fluent-package-builder/blob/master/lib/package-task.rb) (Package tasks), [`fluent-package`](https://github.com/fluent/fluent-package-builder/tree/master/fluent-package) (Fluent package), [`fluent-package/convert-artifacts-layout.sh`](https://github.com/fluent/fluent-package-builder/blob/master/fluent-package/convert-artifacts-layout.sh) (Repo layout), [`.github/workflows`](https://github.com/fluent/fluent-package-builder/blob/master/.github/workflows) (GitHub Actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Build orchestration"]
  node_rakefile["Rakefile<br/>entrypoint"]
  node_package_task["Package tasks<br/>orchestrator<br/>[package-task.rb]"]
  node_apt_lib["APT builder"]
  node_yum_lib["YUM builder"]
  node_config_rb["Config<br/>versioning<br/>[config.rb]"]
  node_gemfiles["Gem deps<br/>dependency-state"]
end

subgraph group_linux["Linux packaging"]
  node_fluent_package["Fluent package<br/>linux payload"]
  node_apt_roots["APT roots<br/>distro roots"]
  node_yum_roots["YUM roots<br/>distro roots"]
  node_templates["Templates"]
  node_repo_layout["Repo layout<br/>artifact layout"]
end

subgraph group_bootstrap["Repo bootstrap"]
  node_apt_source["APT source pkg<br/>repo bootstrap"]
  node_apt_source_lts["LTS source pkg<br/>repo bootstrap"]
  node_yum_release["YUM release pkg<br/>repo bootstrap"]
  node_yum_release_lts["LTS release pkg<br/>repo bootstrap"]
end

subgraph group_native["Native installers"]
  node_windows_msi["Windows MSI<br/>installer"]
  node_macos_dmg["macOS DMG<br/>installer"]
end

subgraph group_validation["Validation"]
  node_serverspec["Serverspec<br/>validation"]
  node_pkg_tests["Package tests<br/>validation"]
end

subgraph group_automation["Automation"]
  node_github_actions["GitHub Actions<br/>ci matrix<br/>[workflows]"]
end

node_rakefile -->|"drives"| node_package_task
node_package_task -->|"orchestrates"| node_apt_lib
node_package_task -->|"orchestrates"| node_yum_lib
node_package_task -->|"reads"| node_config_rb
node_package_task -->|"resolves"| node_gemfiles
node_apt_lib -->|"builds"| node_fluent_package
node_yum_lib -->|"builds"| node_fluent_package
node_fluent_package -->|"packages"| node_templates
node_fluent_package -->|"uses"| node_apt_roots
node_fluent_package -->|"uses"| node_yum_roots
node_fluent_package -->|"reformats"| node_repo_layout
node_apt_source -->|"publishes"| node_repo_layout
node_apt_source_lts -->|"publishes"| node_repo_layout
node_yum_release -->|"publishes"| node_repo_layout
node_yum_release_lts -->|"publishes"| node_repo_layout
node_windows_msi -.->|"shares config"| node_package_task
node_macos_dmg -.->|"shares config"| node_package_task
node_serverspec -->|"verifies"| node_pkg_tests
node_github_actions -->|"runs"| node_package_task
node_github_actions -->|"runs"| node_serverspec

click node_rakefile "https://github.com/fluent/fluent-package-builder/tree/master/Rakefile"
click node_package_task "https://github.com/fluent/fluent-package-builder/blob/master/lib/package-task.rb"
click node_apt_lib "https://github.com/fluent/fluent-package-builder/tree/master/lib/apt"
click node_yum_lib "https://github.com/fluent/fluent-package-builder/tree/master/lib/yum"
click node_config_rb "https://github.com/fluent/fluent-package-builder/blob/master/fluent-package/config.rb"
click node_gemfiles "https://github.com/fluent/fluent-package-builder/tree/master/fluent-package/Gemfile"
click node_fluent_package "https://github.com/fluent/fluent-package-builder/tree/master/fluent-package"
click node_apt_roots "https://github.com/fluent/fluent-package-builder/tree/master/fluent-package/apt"
click node_yum_roots "https://github.com/fluent/fluent-package-builder/tree/master/fluent-package/yum"
click node_templates "https://github.com/fluent/fluent-package-builder/tree/master/fluent-package/templates"
click node_repo_layout "https://github.com/fluent/fluent-package-builder/blob/master/fluent-package/convert-artifacts-layout.sh"
click node_apt_source "https://github.com/fluent/fluent-package-builder/tree/master/fluent-apt-source"
click node_apt_source_lts "https://github.com/fluent/fluent-package-builder/tree/master/fluent-lts-apt-source"
click node_yum_release "https://github.com/fluent/fluent-package-builder/tree/master/fluent-release"
click node_yum_release_lts "https://github.com/fluent/fluent-package-builder/tree/master/fluent-lts-release"
click node_windows_msi "https://github.com/fluent/fluent-package-builder/tree/master/fluent-package/msi"
click node_macos_dmg "https://github.com/fluent/fluent-package-builder/tree/master/fluent-package/dmg"
click node_serverspec "https://github.com/fluent/fluent-package-builder/tree/master/serverspec"
click node_pkg_tests "https://github.com/fluent/fluent-package-builder/tree/master/fluent-package/apt"
click node_github_actions "https://github.com/fluent/fluent-package-builder/blob/master/.github/workflows"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_rakefile,node_package_task,node_apt_lib,node_yum_lib,node_config_rb,node_gemfiles toneBlue
class node_fluent_package,node_apt_roots,node_yum_roots,node_templates,node_repo_layout toneAmber
class node_apt_source,node_apt_source_lts,node_yum_release,node_yum_release_lts toneMint
class node_windows_msi,node_macos_dmg toneRose
class node_serverspec,node_pkg_tests toneIndigo
class node_github_actions toneTeal
```

## Components

### Build orchestration

Shared Ruby/Rake build engine and configuration.

- [Rakefile](https://github.com/fluent/fluent-package-builder/tree/master/Rakefile): entrypoint · Top-level build entry point. · `Rakefile`
- [Package tasks](https://github.com/fluent/fluent-package-builder/blob/master/lib/package-task.rb): orchestrator · Shared packaging task layer and helpers. · `lib/package-task.rb`
- [APT builder](https://github.com/fluent/fluent-package-builder/tree/master/lib/apt): builder · Debian and Ubuntu package build logic. · `lib/apt`
- [YUM builder](https://github.com/fluent/fluent-package-builder/tree/master/lib/yum): builder · RPM package build logic. · `lib/yum`
- [Config](https://github.com/fluent/fluent-package-builder/blob/master/fluent-package/config.rb): versioning · Shared package version and build configuration. · `fluent-package/config.rb`
- [Gem deps](https://github.com/fluent/fluent-package-builder/tree/master/fluent-package/Gemfile): dependency-state · Bundler and Gem dependency inputs for reproducible builds. · `fluent-package/Gemfile`

### Linux packaging

Deb and RPM package build roots plus distro-specific pipelines.

- [Fluent package](https://github.com/fluent/fluent-package-builder/tree/master/fluent-package): linux payload · Main Fluent package payload and distro packaging root. · `fluent-package`
- [APT roots](https://github.com/fluent/fluent-package-builder/tree/master/fluent-package/apt): distro roots · Containerized Debian and Ubuntu build environments. · `fluent-package/apt`
- [YUM roots](https://github.com/fluent/fluent-package-builder/tree/master/fluent-package/yum): distro roots · Containerized RPM build environments. · `fluent-package/yum`
- [Templates](https://github.com/fluent/fluent-package-builder/tree/master/fluent-package/templates): payload templates · Filesystem payload, service units, wrappers, and defaults. · `fluent-package/templates`
- [Repo layout](https://github.com/fluent/fluent-package-builder/blob/master/fluent-package/convert-artifacts-layout.sh): artifact layout · Artifact rearrangement for repository consumption. · `fluent-package/convert-artifacts-layout.sh`

### Repo bootstrap

Packages that configure apt/yum repositories and trust.

- [APT source pkg](https://github.com/fluent/fluent-package-builder/tree/master/fluent-apt-source): repo bootstrap · Deb package that installs repo config and signing keys. · `fluent-apt-source`
- [LTS source pkg](https://github.com/fluent/fluent-package-builder/tree/master/fluent-lts-apt-source): repo bootstrap · LTS variant of the apt repository bootstrap package. · `fluent-lts-apt-source`
- [YUM release pkg](https://github.com/fluent/fluent-package-builder/tree/master/fluent-release): repo bootstrap · RPM repository package for the current release line. · `fluent-release`
- [LTS release pkg](https://github.com/fluent/fluent-package-builder/tree/master/fluent-lts-release): repo bootstrap · RPM repository package for the LTS release line. · `fluent-lts-release`

### Native installers

Windows MSI and macOS DMG packaging pipelines.

- [Windows MSI](https://github.com/fluent/fluent-package-builder/tree/master/fluent-package/msi): installer · WiX-based Windows installer pipeline. · `fluent-package/msi`
- [macOS DMG](https://github.com/fluent/fluent-package-builder/tree/master/fluent-package/dmg): installer · macOS disk image and package resources. · `fluent-package/dmg`

### Validation

Install and service behavior checks for generated artifacts.

- [Serverspec](https://github.com/fluent/fluent-package-builder/tree/master/serverspec): validation · Cross-platform install and runtime verification. · `serverspec`
- [Package tests](https://github.com/fluent/fluent-package-builder/tree/master/fluent-package/apt): validation · Distro-specific install, systemd, size, and upgrade tests. · `fluent-package/apt`

### Automation

CI workflows and release maintenance.

- [GitHub Actions](https://github.com/fluent/fluent-package-builder/blob/master/.github/workflows): ci matrix · Matrix CI for apt, yum, macOS, Windows, and maintenance. · `.github/workflows`

## Connections

- Rakefile → Package tasks: drives · Top-level build entry point delegates to shared packaging tasks.
- Package tasks → APT builder: orchestrates · Creates Debian and Ubuntu package build jobs.
- Package tasks → YUM builder: orchestrates · Creates RPM package build jobs.
- Package tasks → Config: reads · Uses shared version and package configuration.
- Package tasks → Gem deps: resolves · Uses bundled dependency state for reproducible builds.
- APT builder → Fluent package: builds · Builds the main Debian and Ubuntu package artifacts.
- YUM builder → Fluent package: builds · Builds the main RPM package artifacts.
- Fluent package → Templates: packages · Embeds filesystem payload and service integration templates.
- Fluent package → APT roots: uses · Distro build roots supply Debian and Ubuntu container environments.
- Fluent package → YUM roots: uses · Distro build roots supply RPM container environments.
- Fluent package → Repo layout: reformats · Transforms outputs into repository-friendly layouts.
- APT source pkg → Repo layout: publishes · Produces repository-facing apt bootstrap artifacts.
- LTS source pkg → Repo layout: publishes · Produces LTS repository-facing apt bootstrap artifacts.
- YUM release pkg → Repo layout: publishes · Produces repository-facing yum layout and metadata.
- LTS release pkg → Repo layout: publishes · Produces LTS repository-facing yum layout and metadata.
- Windows MSI → Package tasks: shares config · Windows installer shares versioning and build decisions.
- macOS DMG → Package tasks: shares config · macOS packaging shares versioning and build decisions.
- Serverspec → Package tests: verifies · Install and runtime checks exercise generated packages.
- GitHub Actions → Package tasks: runs · CI executes the packaging matrix and maintenance jobs.
- GitHub Actions → Serverspec: runs · CI runs validation suites against built artifacts.
