mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-02-02 10:35:08 -05:00
image: update mkosi and use package directory feature
This commit is contained in:
parent
5ef12895fa
commit
889677c795
@ -1,6 +1,5 @@
|
||||
""" Bazel rule for building mkosi images. """
|
||||
|
||||
load("@aspect_bazel_lib//lib:paths.bzl", "relative_file")
|
||||
load("@bazel_skylib//lib:paths.bzl", "paths")
|
||||
|
||||
def _mkosi_image_impl(ctx):
|
||||
@ -9,7 +8,6 @@ def _mkosi_image_impl(ctx):
|
||||
outputs = []
|
||||
tools = []
|
||||
workdir = ctx.file.mkosi_conf.dirname
|
||||
config_rel = lambda target: relative_file(target, ctx.file.mkosi_conf.path)
|
||||
env = {}
|
||||
args.add("-C", workdir)
|
||||
if ctx.attr.distribution:
|
||||
@ -19,24 +17,24 @@ def _mkosi_image_impl(ctx):
|
||||
if ctx.attr.output:
|
||||
args.add("--output", ctx.attr.output)
|
||||
args.add_all(ctx.attr.packages, before_each = "--package")
|
||||
for package_file in ctx.files.package_files:
|
||||
args.add("--package", config_rel(package_file.path))
|
||||
for package_dir in ctx.files.package_directories:
|
||||
args.add("--package-directory", package_dir.path)
|
||||
if len(ctx.files.local_mirror) > 0:
|
||||
env["LOCAL_MIRROR"] = config_rel(ctx.files.local_mirror[0].dirname)
|
||||
env["LOCAL_MIRROR"] = ctx.files.local_mirror[0].dirname
|
||||
for tree in ctx.files.base_trees:
|
||||
args.add("--base-tree", config_rel(tree.path))
|
||||
args.add("--base-tree", tree.path)
|
||||
for tree in ctx.files.skeleton_trees:
|
||||
args.add("--skeleton-tree", config_rel(tree.path))
|
||||
args.add("--skeleton-tree", tree.path)
|
||||
for tree in ctx.files.package_manager_trees:
|
||||
args.add("--package-manager_tree", config_rel(tree.path))
|
||||
args.add("--package-manager-tree", tree.path)
|
||||
for tree in ctx.files.extra_trees:
|
||||
args.add("--extra-tree", config_rel(tree.path))
|
||||
args.add("--extra-tree", tree.path)
|
||||
for initrd in ctx.files.initrds:
|
||||
inputs.append(initrd)
|
||||
args.add("--initrd", config_rel(initrd.path))
|
||||
args.add("--initrd", initrd.path)
|
||||
inputs.extend(ctx.files.mkosi_conf)
|
||||
inputs.extend(ctx.files.srcs[:])
|
||||
inputs.extend(ctx.files.package_files[:])
|
||||
inputs.extend(ctx.files.package_directories[:])
|
||||
inputs.extend(ctx.files.base_trees[:])
|
||||
inputs.extend(ctx.files.skeleton_trees[:])
|
||||
inputs.extend(ctx.files.package_manager_trees[:])
|
||||
@ -59,9 +57,9 @@ def _mkosi_image_impl(ctx):
|
||||
if output.is_directory and out_dir.path.startswith(output.path + "/"):
|
||||
fail("output directory {} is nested within output directory {}; outputs cannot be nested within each other!".format(out_dir.path, output.path))
|
||||
outputs.append(out_dir)
|
||||
args.add("--output-dir", config_rel(out_dir.path))
|
||||
args.add("--output-dir", out_dir.path)
|
||||
else:
|
||||
args.add("--output-dir", config_rel(paths.join(ctx.bin_dir.path, ctx.label.package)))
|
||||
args.add("--output-dir", paths.join(ctx.bin_dir.path, ctx.label.package))
|
||||
args.add_all(ctx.attr.extra_args)
|
||||
for key, value in ctx.attr.env.items():
|
||||
args.add("--environment", "{}={}".format(key, value))
|
||||
@ -126,7 +124,7 @@ mkosi_image = rule(
|
||||
"out_dir": attr.string(),
|
||||
"output": attr.string(),
|
||||
"outs": attr.output_list(),
|
||||
"package_files": attr.label_list(allow_files = True),
|
||||
"package_directories": attr.label_list(allow_files = True),
|
||||
"package_manager_trees": attr.label_list(allow_files = True),
|
||||
"packages": attr.string_list(),
|
||||
"seed": attr.string(),
|
||||
|
@ -4,7 +4,24 @@ shopt -s inherit_errexit
|
||||
|
||||
export PATH=/run/wrappers/bin:/run/current-system/sw/bin:/bin:/usr/bin:/usr/local/bin
|
||||
VERSION_ARG=""
|
||||
args=("$@")
|
||||
args=()
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
key="$1"
|
||||
case $key in
|
||||
--*-tree | --initrd | --package-directory | --output-dir)
|
||||
# absolutize any file paths
|
||||
shift # past the key and to the value
|
||||
value="$1"
|
||||
args+=("${key}" "$(realpath "${value}")")
|
||||
shift # past the value
|
||||
;;
|
||||
*)
|
||||
args+=("$1")
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -n ${VERSION_FILE+x} ]]; then
|
||||
VERSION_ARG="--environment=IMAGE_VERSION=$(cat "${VERSION_FILE}")"
|
||||
@ -14,14 +31,12 @@ fi
|
||||
if [[ -n ${LOCAL_MIRROR+x} ]]; then
|
||||
LOCAL_MIRROR=$(realpath "${LOCAL_MIRROR}")
|
||||
reposdir=$(mktemp -d)
|
||||
cat > "${reposdir}/mkosi.repo" << EOF
|
||||
[local-mirror]
|
||||
name=local-mirror
|
||||
baseurl=file://${LOCAL_MIRROR}
|
||||
enabled=1
|
||||
gpgcheck=0
|
||||
EOF
|
||||
# putting an empty repo file under /etc/yum.repos.d/mkosi.repo
|
||||
# will make mkosi use only package directories
|
||||
# and not try to fetch packages from the network
|
||||
touch "${reposdir}/mkosi.repo"
|
||||
args+=("--package-manager-tree=${reposdir}:/etc/yum.repos.d")
|
||||
args+=("--package-directory" "${LOCAL_MIRROR}")
|
||||
fi
|
||||
|
||||
exec @@MKOSI@@ "${args[@]}" build
|
||||
|
12
flake.nix
12
flake.nix
@ -28,17 +28,11 @@
|
||||
callPackage = pkgsUnstable.callPackage;
|
||||
|
||||
mkosiDev = (pkgsUnstable.mkosi.overrideAttrs (oldAttrs: rec {
|
||||
# TODO(malt3): remove patch once merged and released upstream (systemd/mkosi#2163)
|
||||
src = pkgsUnstable.fetchFromGitHub {
|
||||
owner = "systemd";
|
||||
repo = "mkosi";
|
||||
rev = "abf22cdc6ccb13f2cd84679ede77231455ec6813";
|
||||
hash = "sha256-njtYWSXSLMcn6AtGfAeL/ncZQ6g+Vgpe7EaKLkzAOl4=";
|
||||
};
|
||||
propagatedBuildInputs = oldAttrs.propagatedBuildInputs ++ (with pkgsUnstable; [
|
||||
# package management
|
||||
dnf5
|
||||
rpm
|
||||
createrepo_c
|
||||
|
||||
# filesystem tools
|
||||
squashfsTools # mksquashfs
|
||||
@ -50,6 +44,10 @@
|
||||
cpio # cpio
|
||||
zstd # zstd
|
||||
xz # xz
|
||||
|
||||
# utils
|
||||
gnused # sed
|
||||
gnugrep # grep
|
||||
]);
|
||||
}));
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file")
|
||||
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
|
||||
load("@rules_pkg//:pkg.bzl", "pkg_tar")
|
||||
load("//bazel/mkosi:mkosi_image.bzl", "mkosi_image")
|
||||
@ -27,25 +26,6 @@ copy_to_directory(
|
||||
replace_prefixes = {"file": ""},
|
||||
)
|
||||
|
||||
[
|
||||
copy_file(
|
||||
name = name,
|
||||
src = "@" + name + "//file",
|
||||
out = name + ".rpm",
|
||||
allow_symlink = True,
|
||||
)
|
||||
for name in [
|
||||
"kernel_lts",
|
||||
"kernel_core_lts",
|
||||
"kernel_modules_lts",
|
||||
"kernel_modules_core_lts",
|
||||
"kernel_mainline",
|
||||
"kernel_core_mainline",
|
||||
"kernel_modules_mainline",
|
||||
"kernel_modules_core_mainline",
|
||||
]
|
||||
]
|
||||
|
||||
[
|
||||
mkosi_image(
|
||||
name = "base_" + kernel_variant,
|
||||
@ -71,11 +51,8 @@ copy_to_directory(
|
||||
local_mirror = ["@mkosi_rpms//:repo"],
|
||||
mkosi_conf = "mkosi.conf",
|
||||
output = kernel_variant,
|
||||
package_files = [
|
||||
":kernel_" + kernel_variant,
|
||||
":kernel_core_" + kernel_variant,
|
||||
":kernel_modules_" + kernel_variant,
|
||||
":kernel_modules_core_" + kernel_variant,
|
||||
package_directories = [
|
||||
":rpms_" + kernel_variant,
|
||||
],
|
||||
tags = [
|
||||
"manual",
|
||||
|
@ -15,6 +15,9 @@ Packages=systemd
|
||||
dbus
|
||||
udev
|
||||
util-linux
|
||||
kernel
|
||||
kernel-core
|
||||
kernel-modules
|
||||
|
||||
# nvme / disk / udev tools
|
||||
Packages=nvme-cli
|
||||
|
Loading…
x
Reference in New Issue
Block a user