`UseHostRepositories=`, `--use-host-repositories`
-: This option is only applicable for dnf-based distributions:
+: This option is only applicable for RPM-based distributions:
*CentOS*, *Fedora Linux*, *Mageia*, *Photon*, *Rocky Linux*, *Alma Linux*
and *OpenMandriva*.
- Allows use of the host's existing dnf repositories.
- By default, a hardcoded set of default dnf repositories is generated and used.
+ Allows use of the host's existing RPM repositories.
+ By default, a hardcoded set of default RPM repositories is generated and used.
Use `--repositories=` to identify a custom set of repositories to be enabled
and used for the build.
+`RepositoryDirectory`, `--repository-directory`
+
+: This option can (for now) only be used with RPM-based istributions and Arch
+ Linux. It identifies a directory containing extra repository definitions that
+ will be used when installing packages. The files are passed directly to the
+ corresponding package manager and should be written in the format expected by
+ the package manager of the image's distro.
+
`Architecture=`, `--architecture=`
: The architecture to build the image for. Note that this currently
build result of a preceding run might be copied into a build image
as part of the source tree (see above).
+* The **`mkosi.reposdir/`** directory, if it exists, is automatically
+ used as the repository directory for extra repository files. See
+ the `RepositoryDirectory` option for more information.
+
All these files are optional.
Note that the location of all these files may also be configured
Verb,
die,
install_grub,
+ is_rpm_distribution,
nspawn_params_for_blockdev_access,
nspawn_rlimit_params,
patch_file,
if args.use_host_repositories:
default_repos = ""
else:
- default_repos = f"{'repodir' if args.distribution == Distribution.photon else 'reposdir'}={workspace(root)}"
+ option = "repodir" if args.distribution == Distribution.photon else "reposdir"
+ default_repos = f"{option}={workspace(root)} {args.repos_dir if args.repos_dir else ''}"
config_file = workspace(root) / "dnf.conf"
config_file.write_text(
[community]
{server}
+
+ {f"Include = {args.repos_dir}/*" if args.repos_dir else ""}
"""
)
)
action=BooleanAction,
help="Use host's existing software repositories (only for dnf-based distributions)",
)
+ group.add_argument("--repository-directory", metavar="PATH", dest="repos_dir",
+ help="Directory container extra distribution specific repository files")
group.add_argument("--architecture", help="Override the architecture of installation")
group = parser.add_argument_group("Output")
args_find_path(args, "output_dir", "mkosi.output/")
args_find_path(args, "workspace_dir", "mkosi.workspace/")
args_find_path(args, "mksquashfs_tool", "mkosi.mksquashfs-tool", as_list=True)
+ args_find_path(args, "repos_dir", "mkosi.reposdir/")
find_extra(args)
find_skeleton(args)
if args.ssh_port <= 0:
die("--ssh-port must be > 0")
+ if args.repos_dir and not (is_rpm_distribution(args.distribution) or args.distribution == Distribution.arch):
+ die("--repository-directory is only supported on RPM based distributions and Arch")
+
# We set a reasonable umask so that files that are created in the image
# will have reasonable permissions. We don't want those permissions to be
# influenced by the caller's umask which will be used only for output files.
def __str__(self) -> str:
return self.name
+def is_rpm_distribution(d: Distribution) -> bool:
+ return d in (
+ Distribution.fedora,
+ Distribution.mageia,
+ Distribution.centos,
+ Distribution.centos_epel,
+ Distribution.photon,
+ Distribution.openmandriva,
+ Distribution.rocky,
+ Distribution.rocky_epel,
+ Distribution.alma,
+ Distribution.alma_epel
+ )
+
class SourceFileTransfer(enum.Enum):
copy_all = "copy-all"
mirror: Optional[str]
repositories: List[str]
use_host_repositories: bool
+ repos_dir: Optional[str]
architecture: Optional[str]
output_format: OutputFormat
manifest_format: List[ManifestFormat]
"release": None,
"repositories": [],
"use_host_repositories": False,
+ "repos_dir": None,
"base_image": None,
"root_size": None,
"secure_boot": False,