# joseccnet/chroot-distros2 architecture

> Architecture diagram of the GitHub repository joseccnet/chroot-distros2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joseccnet/chroot-distros2
- Repository: https://github.com/joseccnet/chroot-distros2

## Overview

#### Purpose and execution model
This is a Bash-based Linux administration toolkit that creates and operates filesystem-isolated `chroot` environments under a configured jail root. It is not a service or web application: privileged users invoke scripts directly. Primary entry points are per-distribution builders, mount lifecycle management, cloning, deletion, and repository update scripts.

Paths: `build-chroot-Debian.sh`, `mount_umount-chroot.sh`, `chroot.conf`

#### Distribution build layer
Eight build entry points provision a named target filesystem for Debian-family and RPM-family distributions, accepting release and architecture selection. They encapsulate distribution-specific bootstrap/package-manager behavior, supported-release handling, optional custom mirrors, and cross-architecture targets.

Paths: `build-chroot-Debian.sh`, `build-chroot-Ubuntu.sh`, `build-chroot-Centos.sh`

#### Shared bootstrap contract
Builders share common shell behavior through the library and central configuration. `chroot.conf` defines the installation/jail policy consumed by scripts; `lib/chroot-lib.sh` is the likely common boundary for validation, logging, path handling, and reusable chroot operations. Environment variables are the main runtime override interface (for mirror, EOL, GPG, minimum space, and interactive behavior).

Paths: `chroot.conf`, `lib/chroot-lib.sh`, `build-chroot-Fedora.sh`

#### Repository and release metadata
RPM-family builds depend on checked-in repository definitions and yum/dnf configuration rather than only host defaults. This makes repository selection and legacy-release support part of the repository’s provisioning architecture. Linux Mint builds similarly carry per-release APT source and preference material.

Paths: `centos/yumcentos.conf`, `fedora/fedora.repo`, `openSuse/repo-oss.repo`

#### Mount lifecycle and runtime boundary
A created chroot becomes usable only after the mount manager attaches required host-backed filesystems. This stage supports individual and bulk mount/unmount, status inspection, dry-run behavior, idempotence, and logging. Its security boundary is hardened mount configuration, including restricted mount flags, slave propagation, and read-only `/sys`; it does not turn chroot into a security sandbox.

Paths: `mount_umount-chroot.sh`, `chroot.conf`, `lib/chroot-lib.sh`

#### Chroot lifecycle operations
Cloning duplicates an existing jail without repeat provisioning. Safe removal is deliberately separate from raw filesystem deletion: it validates targets, requires unmounting and explicit confirmation, and can enumerate available jails. Repository self-update is also an explicit administrative operation.

Paths: `clone-chroot-Distro.sh`, `removeVM-chroot.sh`, `update_chroot-distros.sh`

#### External dependencies and operational environment
The runtime is Linux with Bash 4.3+ and root privileges. Builders interact with distribution package ecosystems and remote mirrors—APT/debootstrap-style Debian-family sources and yum/dnf/zypper-style RPM-family repositories—while runtime uses kernel mount namespaces/filesystem mounts and the `chroot` command. Optional SSH use relies on generated chroot-compatible filesystem layout/configuration; process and resource limits remain inherited from the host.

Paths: `ubuntu/trusty_etc_init.d_udev`, `centos/CentOS-Vault.repo`, `openSuse/repo-update.repo`

Main entry points: [`lib/chroot-lib.sh`](https://github.com/joseccnet/chroot-distros2/blob/main/lib/chroot-lib.sh) (Shared shell library), [`build-chroot-Debian.sh`](https://github.com/joseccnet/chroot-distros2/blob/main/build-chroot-Debian.sh) (Debian builder), [`build-chroot-Ubuntu.sh`](https://github.com/joseccnet/chroot-distros2/blob/main/build-chroot-Ubuntu.sh) (Ubuntu builder), [`build-chroot-Centos.sh`](https://github.com/joseccnet/chroot-distros2/blob/main/build-chroot-Centos.sh) (RPM-family builders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_admin["Administrative entry points"]
  node_operator(("Root Bash operator<br/>execution environment"))
  node_config["Jail policy<br/>configuration contract<br/>[chroot.conf]"]
  node_library["Shared shell library<br/>[chroot-lib.sh]"]
  node_clone["Clone chroot<br/>lifecycle entry point"]
  node_remove["Safe removal<br/>lifecycle entry point<br/>[removeVM-chroot.sh]"]
  node_self_update["Toolkit self-update<br/>maintenance entry point"]
end

subgraph group_provisioning["Provisioning"]
  node_debian_builder["Debian builder<br/>build entry point"]
  node_ubuntu_builder["Ubuntu builder<br/>build entry point"]
  node_rpm_builders["RPM-family builders<br/>build entry points"]
  node_rpm_metadata["RPM repository definitions<br/>repository metadata<br/>[yumcentos.conf]"]
  node_apt_metadata["Debian-family mirrors<br/>package repositories"]
end

subgraph group_runtime["Mounted chroot runtime"]
  node_target_fs[("Provisioned jail filesystem<br/>chroot target")]
  node_mount_manager["Mount lifecycle manager<br/>mount entry point"]
  node_host_mounts["Host-backed mounts<br/>kernel mount boundary"]
  node_active_chroot{{"Usable mounted chroot<br/>runtime environment"}}
end

node_remote_repos[("Remote package mirrors<br/>external package ecosystems")]
node_kernel["Linux kernel and chroot<br/>host runtime dependency"]

node_operator -->|"invokes"| node_debian_builder
node_operator -->|"invokes"| node_ubuntu_builder
node_operator -->|"invokes"| node_rpm_builders
node_operator -->|"operates"| node_mount_manager
node_operator -->|"invokes"| node_clone
node_operator -->|"invokes"| node_remove
node_config -->|"defines policy for"| node_library
node_library -->|"shared by"| node_debian_builder
node_library -->|"shared by"| node_ubuntu_builder
node_library -->|"shared by"| node_rpm_builders
node_library -->|"shared by"| node_mount_manager
node_debian_builder -->|"selects"| node_apt_metadata
node_ubuntu_builder -->|"selects"| node_apt_metadata
node_rpm_builders -->|"uses"| node_rpm_metadata
node_apt_metadata -->|"resolves"| node_remote_repos
node_rpm_metadata -->|"resolves"| node_remote_repos
node_debian_builder -->|"bootstraps"| node_target_fs
node_ubuntu_builder -->|"bootstraps"| node_target_fs
node_rpm_builders -->|"provisions"| node_target_fs
node_mount_manager -->|"attaches and detaches"| node_host_mounts
node_host_mounts -->|"makes usable"| node_active_chroot
node_target_fs -->|"root filesystem for"| node_active_chroot
node_kernel -->|"provides"| node_host_mounts
node_kernel -->|"executes"| node_active_chroot
node_clone -->|"duplicates"| node_target_fs
node_remove -->|"deletes after unmount"| node_target_fs
node_self_update -.->|"updates toolkit sources"| node_debian_builder

click node_config "https://github.com/joseccnet/chroot-distros2/blob/main/chroot.conf"
click node_library "https://github.com/joseccnet/chroot-distros2/blob/main/lib/chroot-lib.sh"
click node_debian_builder "https://github.com/joseccnet/chroot-distros2/blob/main/build-chroot-Debian.sh"
click node_ubuntu_builder "https://github.com/joseccnet/chroot-distros2/blob/main/build-chroot-Ubuntu.sh"
click node_rpm_builders "https://github.com/joseccnet/chroot-distros2/blob/main/build-chroot-Centos.sh"
click node_rpm_metadata "https://github.com/joseccnet/chroot-distros2/blob/main/centos/yumcentos.conf"
click node_mount_manager "https://github.com/joseccnet/chroot-distros2/blob/main/mount_umount-chroot.sh"
click node_clone "https://github.com/joseccnet/chroot-distros2/blob/main/clone-chroot-Distro.sh"
click node_remove "https://github.com/joseccnet/chroot-distros2/blob/main/removeVM-chroot.sh"
click node_self_update "https://github.com/joseccnet/chroot-distros2/blob/main/update_chroot-distros.sh"

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_operator,node_config,node_library,node_clone,node_remove,node_self_update toneBlue
class node_debian_builder,node_ubuntu_builder,node_rpm_builders,node_rpm_metadata,node_apt_metadata toneAmber
class node_target_fs,node_mount_manager,node_host_mounts,node_active_chroot toneMint
class node_remote_repos,node_kernel toneNeutral
```

## Components

### Administrative entry points

- **Root Bash operator**: execution environment · Linux root user invokes toolkit scripts directly.
- [Jail policy](https://github.com/joseccnet/chroot-distros2/blob/main/chroot.conf): configuration contract · Defines jail-root installation and mount policy. · `chroot.conf`
- [Shared shell library](https://github.com/joseccnet/chroot-distros2/blob/main/lib/chroot-lib.sh): shell library · Common validation, logging, paths, and chroot operations. · `lib/chroot-lib.sh`
- [Clone chroot](https://github.com/joseccnet/chroot-distros2/blob/main/clone-chroot-Distro.sh): lifecycle entry point · Duplicates an existing jail without provisioning again. · `clone-chroot-Distro.sh`
- [Safe removal](https://github.com/joseccnet/chroot-distros2/blob/main/removeVM-chroot.sh): lifecycle entry point · Requires an unmounted validated target and explicit confirmation. · `removeVM-chroot.sh`
- [Toolkit self-update](https://github.com/joseccnet/chroot-distros2/blob/main/update_chroot-distros.sh): maintenance entry point · `update_chroot-distros.sh`

### Provisioning

- [Debian builder](https://github.com/joseccnet/chroot-distros2/blob/main/build-chroot-Debian.sh): build entry point · `build-chroot-Debian.sh`
- [Ubuntu builder](https://github.com/joseccnet/chroot-distros2/blob/main/build-chroot-Ubuntu.sh): build entry point · `build-chroot-Ubuntu.sh`
- [RPM-family builders](https://github.com/joseccnet/chroot-distros2/blob/main/build-chroot-Centos.sh): build entry points · Provision CentOS, Fedora, and related RPM targets. · `build-chroot-Centos.sh`
- [RPM repository definitions](https://github.com/joseccnet/chroot-distros2/blob/main/centos/yumcentos.conf): repository metadata · Checked-in yum, dnf, and zypper repository selection supports legacy releases. · `centos/yumcentos.conf`
- **Debian-family mirrors**: package repositories · Remote APT/debootstrap sources selected by builder options and environment overrides.

### Mounted chroot runtime

- **Provisioned jail filesystem**: chroot target · Named distribution root created beneath the configured jail root.
- [Mount lifecycle manager](https://github.com/joseccnet/chroot-distros2/blob/main/mount_umount-chroot.sh): mount entry point · Mounts, unmounts, inspects, and bulk-manages host-backed chroot filesystems. · `mount_umount-chroot.sh`
- **Host-backed mounts**: kernel mount boundary · Restricted flags, slave propagation, and read-only /sys support usable jails.
- **Usable mounted chroot**: runtime environment · Runs via chroot with host-inherited process and resource limits.

### Other components

- **Remote package mirrors**: external package ecosystems · APT, yum/dnf, and zypper repositories supply target packages.
- **Linux kernel and chroot**: host runtime dependency · Provides mounts, namespaces, and the chroot command.

## Connections

- Root Bash operator → Debian builder: invokes
- Root Bash operator → Ubuntu builder: invokes
- Root Bash operator → RPM-family builders: invokes
- Root Bash operator → Mount lifecycle manager: operates
- Root Bash operator → Clone chroot: invokes
- Root Bash operator → Safe removal: invokes
- Jail policy → Shared shell library: defines policy for
- Shared shell library → Debian builder: shared by
- Shared shell library → Ubuntu builder: shared by
- Shared shell library → RPM-family builders: shared by
- Shared shell library → Mount lifecycle manager: shared by
- Debian builder → Debian-family mirrors: selects
- Ubuntu builder → Debian-family mirrors: selects
- RPM-family builders → RPM repository definitions: uses
- Debian-family mirrors → Remote package mirrors: resolves
- RPM repository definitions → Remote package mirrors: resolves
- Debian builder → Provisioned jail filesystem: bootstraps
- Ubuntu builder → Provisioned jail filesystem: bootstraps
- RPM-family builders → Provisioned jail filesystem: provisions
- Mount lifecycle manager → Host-backed mounts: attaches and detaches
- Host-backed mounts → Usable mounted chroot: makes usable
- Provisioned jail filesystem → Usable mounted chroot: root filesystem for
- Linux kernel and chroot → Host-backed mounts: provides
- Linux kernel and chroot → Usable mounted chroot: executes
- Clone chroot → Provisioned jail filesystem: duplicates
- Safe removal → Provisioned jail filesystem: deletes after unmount
- Toolkit self-update → Debian builder: updates toolkit sources
