rootfs-put is a tool for copying files and their dependencies to a specified filesystem (rootfs)
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Alexey Shabalin 7624afabf0 Look up package owners with batched rpm -qf calls
record() ran rpm -qf once per copied file, about 10 ms per call natively
and much more under qemu-user. /usr/bin/python3 with its stdlib (2345
files) took 26 s. record() now queues the path, and saveRootfs() looks
up all queued paths with one rpm -qf per chunk of up to 1000 paths or
64 KiB of arguments. The same run takes 1.8 s and writes identical
metadata and files.

rpm -qf exits with the number of files it failed on. A file that no
package owns is expected and only prints "file ... is not owned by any
package" (rpm runs with LC_ALL=C to match it). Any other stderr line,
a missing rpm, or rpm killed by a signal is now an error. Before, such
failures went to the debug log, and rootfs-put exited 0 with packages
missing from the metadata, e.g. when the rpm database cannot be opened.

A path is now marked as put when it is queued, not when its owner is
found, so a path that no package owns is copied once instead of every
time it is reached.
2026-09-25 18:57:56 +03:00
.gitignore init 2025-12-30 13:22:17 +03:00
COPYING init 2025-12-30 13:22:17 +03:00
go.mod init 2025-12-30 13:22:17 +03:00
main.go Look up package owners with batched rpm -qf calls 2026-09-25 18:57:56 +03:00
main_test.go Record epoch, arch and source package in metadata 2026-09-25 17:50:56 +03:00
put.go Look up package owners with batched rpm -qf calls 2026-09-25 18:57:56 +03:00
put_test.go Look up package owners with batched rpm -qf calls 2026-09-25 18:57:56 +03:00
README.md Record epoch, arch and source package in metadata 2026-09-25 17:50:56 +03:00
resolve.go init 2025-12-30 13:22:17 +03:00
utils.go Look up package owners with batched rpm -qf calls 2026-09-25 18:57:56 +03:00
utils_test.go Look up package owners with batched rpm -qf calls 2026-09-25 18:57:56 +03:00

rootfs-put

rootfs-put is a tool for copying files and their dependencies to a specified filesystem (rootfs). It automatically resolves ELF file dependencies and copies all necessary libraries.

This tool is similar to initrd-put but also save package metadata to .rootfs.metadata.json.

Metadata

The metadata is saved to .rootfs.metadata.json in the rootfs. It contains the following information:

{
  "packages": {
    "bash5": "5.2.37-alt1",
    "glibc-core": "2.43.0.35.fe0ccc-alt1",
    ...
  },
  "rpms": {
    "bash5": {
      "epoch": 0,
      "version": "5.2.37",
      "release": "alt1",
      "arch": "x86_64",
      "sourcerpm": "bash5-5.2.37-alt1.src.rpm"
    },
    "glibc-core": {
      "epoch": 6,
      "version": "2.43.0.35.fe0ccc",
      "release": "alt1",
      "arch": "x86_64",
      "sourcerpm": "glibc-2.43.0.35.fe0ccc-alt1.src.rpm"
    },
    ...
  }
}

packages maps a package name to version-release. rpms holds the full identity of each package: the epoch (0 if the package has none) is needed to compare versions, sourcerpm to find the packages built from a source package.

Every package that owns a copied file is recorded, including packages that own it only as %ghost (e.g. alternatives links).

An entry in rpms is optional: packages recorded by an earlier version of rootfs-put have none, and an earlier version run over this file rewrites it without rpms. Consumers should fall back to packages.

Usage

export ROOTFS_PUT_ROOT=/path/to/rootfs # default /rootfs
export ROOTFS_PUT_DEBUG=true # for debug

rootfs-put \
    /usr/bin/bash \
    /lib64/iptables

License

GPL-3.0-or-later