stages/rpm: option to prevent dracut from running
Add the ability to prevent `dracut` from running via the post install scripts. This is done by installing symlinks named like the dracut scripts in `/usr/lib/kernel/install.d/` in `/etc/kernel/install.d`. They symlinks point to `/dev/null` and since the ones in `/etc` takes precedent over the system ones they effectively disable dracut from running. After the run is completed the symlinks are removed and the original files thus unmasked.
This commit is contained in:
parent
755c07a142
commit
1cca184ccd
1 changed files with 37 additions and 0 deletions
|
|
@ -44,6 +44,10 @@ from osbuild import api
|
|||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"disable_dracut": {
|
||||
"description": "Prevent dracut from running",
|
||||
"type": "boolean"
|
||||
},
|
||||
"exclude": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
|
|
@ -102,6 +106,10 @@ SCHEMA_2 = """
|
|||
"type": "array",
|
||||
"items": { "type": "string" }
|
||||
},
|
||||
"disable_dracut": {
|
||||
"description": "Prevent dracut from running",
|
||||
"type": "boolean"
|
||||
},
|
||||
"exclude": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
|
|
@ -157,6 +165,25 @@ def generate_package_metadata(tree):
|
|||
return json.loads(jsdata)
|
||||
|
||||
|
||||
def disable_dracut(tree):
|
||||
kernel_install_d = f"{tree}/etc/kernel/install.d"
|
||||
files = []
|
||||
|
||||
os.makedirs(kernel_install_d, exist_ok=True)
|
||||
|
||||
for path in ["50-dracut.install", "51-dracut-rescue.install"]:
|
||||
target = os.path.join(kernel_install_d, path)
|
||||
os.symlink("/dev/null", target)
|
||||
files.append(target)
|
||||
|
||||
return files
|
||||
|
||||
|
||||
def enable_dracut(masked_files):
|
||||
for path in masked_files:
|
||||
os.unlink(path)
|
||||
|
||||
|
||||
def parse_input(inputs):
|
||||
packages = inputs["packages"]
|
||||
path = packages["path"]
|
||||
|
|
@ -208,11 +235,17 @@ def main(tree, inputs, options):
|
|||
|
||||
subprocess.run(["/bin/sh", "-c", script], check=True)
|
||||
|
||||
|
||||
extra_args = []
|
||||
|
||||
if options.get("exclude", {}).get("docs"):
|
||||
extra_args += ["--excludedocs"]
|
||||
|
||||
# prevent dracut from running, if enabled
|
||||
no_dracut = options.get("disable_dracut", False)
|
||||
if no_dracut:
|
||||
masked_files = disable_dracut(tree)
|
||||
|
||||
with tempfile.NamedTemporaryFile(prefix="manifest.", mode='w') as manifest:
|
||||
manifest.writelines(c+'\n' for c in packages)
|
||||
manifest.flush()
|
||||
|
|
@ -227,6 +260,10 @@ def main(tree, inputs, options):
|
|||
"--install", manifest.name
|
||||
], cwd=pkgpath, check=True)
|
||||
|
||||
# re-enabled dracut
|
||||
if no_dracut:
|
||||
enable_dracut(masked_files)
|
||||
|
||||
# remove temporary machine ID if it was created by us
|
||||
if not machine_id_set_previously:
|
||||
print("deleting the fake machine id")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue