Add auto-unshare super smartness

This commit is contained in:
jpic 2020-02-12 21:35:02 +01:00
parent 3413fd8981
commit 40335a88a7
2 changed files with 8 additions and 0 deletions

View File

@ -15,6 +15,7 @@ class Build(Script):
The build script iterates over visitors and runs the build functions, it The build script iterates over visitors and runs the build functions, it
also provides wrappers around the buildah command. also provides wrappers around the buildah command.
""" """
unshare = True
def __init__(self): def __init__(self):
super().__init__() super().__init__()

View File

@ -1,6 +1,7 @@
import asyncio import asyncio
import copy import copy
import cli2 import cli2
import os
import textwrap import textwrap
from .proc import Proc from .proc import Proc
@ -19,6 +20,7 @@ class Script:
immediate=True, immediate=True,
), ),
] ]
unshare = False
def __init__(self, name=None, doc=None): def __init__(self, name=None, doc=None):
self.name = name or type(self).__name__.lower() self.name = name or type(self).__name__.lower()
@ -79,6 +81,11 @@ class Script:
raise raise
async def run(self, *args, **kwargs): async def run(self, *args, **kwargs):
if self.unshare and os.getuid() != 0:
import sys
# restart under buildah unshare environment !
os.execvp('buildah', ['buildah', 'unshare'] + sys.argv)
for key, value in kwargs.items(): for key, value in kwargs.items():
setattr(self, key, value) setattr(self, key, value)