- Go 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
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. |
||
| .gitignore | ||
| COPYING | ||
| go.mod | ||
| main.go | ||
| main_test.go | ||
| put.go | ||
| put_test.go | ||
| README.md | ||
| resolve.go | ||
| utils.go | ||
| utils_test.go | ||
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