stages/fix-bls: add workaround for grub2-mkrelpath
grub2-mkrelpath uses /proc/self/mountinfo to find the source of the file system it is installed to. This breaks in a container. Add org.osbuild.fix-bls which goes through /boot/loader/entries and fixes paths by removing anything before /boot.
This commit is contained in:
parent
29c396584f
commit
f54fbe2912
2 changed files with 36 additions and 0 deletions
|
|
@ -36,6 +36,9 @@
|
|||
"options": {
|
||||
"root_fs_uuid": "76a22bf4-f153-4541-b6c7-0332c0dfaeac"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "org.osbuild.fix-bls"
|
||||
}
|
||||
],
|
||||
"assembler":
|
||||
|
|
|
|||
33
stages/org.osbuild.fix-bls
Executable file
33
stages/org.osbuild.fix-bls
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import glob
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
def main(tree, _options):
|
||||
"""Fix broken paths in /boot/loader/entries.
|
||||
|
||||
grub2-mkrelpath uses /proc/self/mountinfo to find the source of the file
|
||||
system it is installed to. This breaks in a container, because we
|
||||
bind-mount the tree from the host.
|
||||
"""
|
||||
|
||||
path_re = re.compile(r"(/.*)+/boot")
|
||||
|
||||
for name in glob.glob(f"{tree}/boot/loader/entries/*.conf"):
|
||||
with open(name) as f:
|
||||
entry = f.read().splitlines(keepends=True)
|
||||
|
||||
with open(name, "w") as f:
|
||||
for line in entry:
|
||||
f.write(path_re.sub("/boot", line))
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
Loading…
Add table
Add a link
Reference in a new issue