util/chroot: add run() method to context class
Rename the ChrootProcDevSys class to just Chroot and add a run() method.
Calls now can be made using:
with Chroot(root) as chroot:
chroot.run(command)
This commit is contained in:
parent
931e832944
commit
3dbf389ebf
3 changed files with 13 additions and 16 deletions
|
|
@ -1,9 +1,8 @@
|
|||
#!/usr/bin/python3
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
from osbuild.util.chroot import ChrootProcDevSys
|
||||
from osbuild.util.chroot import Chroot
|
||||
|
||||
|
||||
def yesno(name: str, value: bool) -> str:
|
||||
|
|
@ -83,12 +82,8 @@ def main(tree, options):
|
|||
if initoverlayfs:
|
||||
initfs_bin = "/usr/bin/initoverlayfs-install"
|
||||
|
||||
with ChrootProcDevSys(tree):
|
||||
subprocess.run(["/usr/sbin/chroot", tree, initfs_bin,
|
||||
"--no-hostonly",
|
||||
"--kver", kver]
|
||||
+ opts,
|
||||
check=True)
|
||||
with Chroot(tree) as chroot:
|
||||
chroot.run([initfs_bin, "--no-hostonly", "--kver", kver] + opts, check=True)
|
||||
|
||||
return 0
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +1,20 @@
|
|||
#!/usr/bin/python3
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from osbuild import api
|
||||
from osbuild.util.chroot import ChrootProcDevSys
|
||||
from osbuild.util.chroot import Chroot
|
||||
|
||||
|
||||
def main(tree, options):
|
||||
policy = options["policy"]
|
||||
|
||||
with ChrootProcDevSys(tree):
|
||||
with Chroot(tree) as chroot:
|
||||
# update-crypto-polciies uses /proc/self/mountinfo to find and verify that fips paths have been mounted to their
|
||||
# expected locations by searching for the following path suffixes:
|
||||
# /crypto-policies/default-fips-config
|
||||
# /crypto-policies/back-ends/FIPS
|
||||
cmd = ["/usr/sbin/chroot", tree,
|
||||
"/usr/bin/update-crypto-policies", "--set", policy]
|
||||
|
||||
subprocess.run(cmd, check=True)
|
||||
cmd = ["/usr/bin/update-crypto-policies", "--set", policy]
|
||||
chroot.run(cmd, check=True)
|
||||
|
||||
return 0
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue