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:
Lars Karlitski 2019-08-14 04:52:51 +03:00
parent 29c396584f
commit f54fbe2912
2 changed files with 36 additions and 0 deletions

View file

@ -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
View 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)