mirror of
https://github.com/ostreedev/ostree.git
synced 2025-03-19 22:50:35 +03:00
ostbuild: Add preserve_net config option
This is going to be necessary for the builder.
This commit is contained in:
parent
5bf65be10b
commit
277843f3a2
@ -14,7 +14,7 @@ dependency problems.
|
||||
At the end, the Yocto build process generates two tarballs: one for a
|
||||
base "runtime", and one "devel" with all of the development tools like
|
||||
gcc. We then import that into an OSTree branch
|
||||
e.g. "bases/gnomeos-3.4-yocto-i686-devel".
|
||||
e.g. "bases/yocto/gnomeos-3.4-i686-devel".
|
||||
|
||||
We also have a Yocto recipe "ostree-native" which generates (as you
|
||||
might guess) a native binary of ostree. That binary is used to import
|
||||
|
@ -21,6 +21,7 @@ import urlparse
|
||||
import tempfile
|
||||
import StringIO
|
||||
|
||||
from . import ostbuildrc
|
||||
from .subprocess_helpers import run_sync_get_output
|
||||
|
||||
BUILD_ENV = {
|
||||
@ -141,3 +142,12 @@ def compose(repo, target, artifacts):
|
||||
revision = run_sync_get_output(child_args, log_initiation=True).strip()
|
||||
os.unlink(path)
|
||||
return revision
|
||||
|
||||
def get_base_user_chroot_args():
|
||||
path = find_user_chroot_path()
|
||||
args = [path, '--unshare-pid', '--unshare-ipc']
|
||||
if not ostbuildrc.get_key('preserve_net', default=False):
|
||||
args.append('--unshare-net')
|
||||
return args
|
||||
|
||||
|
||||
|
@ -208,6 +208,7 @@ class OstbuildBuild(builtins.Builtin):
|
||||
parser = argparse.ArgumentParser(description=self.short_description)
|
||||
parser.add_argument('--skip-built', action='store_true')
|
||||
parser.add_argument('--recompose', action='store_true')
|
||||
parser.add_argument('--skip-compose', action='store_true')
|
||||
parser.add_argument('--start-at')
|
||||
parser.add_argument('--shell-on-failure', action='store_true')
|
||||
parser.add_argument('--debug-shell', action='store_true')
|
||||
@ -255,7 +256,8 @@ class OstbuildBuild(builtins.Builtin):
|
||||
component = self.snapshot['components'].get(component_name)
|
||||
self._build_one_component(component_name, component)
|
||||
|
||||
for target in self.snapshot['targets']:
|
||||
self._compose(target)
|
||||
if not args.skip_compose:
|
||||
for target in self.snapshot['targets']:
|
||||
self._compose(target)
|
||||
|
||||
builtins.register(OstbuildBuild)
|
||||
|
@ -23,6 +23,7 @@ import json
|
||||
from . import builtins
|
||||
from . import buildutil
|
||||
from . import fileutil
|
||||
from . import ostbuildrc
|
||||
from .ostbuildlog import log, fatal
|
||||
from .subprocess_helpers import run_sync, run_sync_get_output
|
||||
|
||||
@ -128,16 +129,15 @@ class OstbuildChrootCompileOne(builtins.Builtin):
|
||||
|
||||
chroot_sourcedir = os.path.join('/ostbuild', 'source', component_name)
|
||||
|
||||
ostbuild_user_chroot_path = buildutil.find_user_chroot_path()
|
||||
|
||||
child_args = [ostbuild_user_chroot_path, '--unshare-pid', '--unshare-net', '--unshare-ipc',
|
||||
'--mount-readonly', '/',
|
||||
'--mount-proc', '/proc',
|
||||
'--mount-bind', '/dev', '/dev',
|
||||
'--mount-bind', child_tmpdir, '/tmp',
|
||||
'--mount-bind', os.getcwd(), chroot_sourcedir,
|
||||
'--mount-bind', resultdir, '/ostbuild/results',
|
||||
'--chdir', chroot_sourcedir]
|
||||
child_args = buildutil.get_base_user_chroot_args()
|
||||
child_args.extend([
|
||||
'--mount-readonly', '/',
|
||||
'--mount-proc', '/proc',
|
||||
'--mount-bind', '/dev', '/dev',
|
||||
'--mount-bind', child_tmpdir, '/tmp',
|
||||
'--mount-bind', os.getcwd(), chroot_sourcedir,
|
||||
'--mount-bind', resultdir, '/ostbuild/results',
|
||||
'--chdir', chroot_sourcedir])
|
||||
if args.debug_shell:
|
||||
child_args.extend([rootdir, '/bin/sh'])
|
||||
else:
|
||||
|
@ -35,15 +35,11 @@ class OstbuildChrootRunTriggers(builtins.Builtin):
|
||||
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
ostbuild_user_chroot_path = buildutil.find_user_chroot_path()
|
||||
|
||||
child_args = [ostbuild_user_chroot_path,
|
||||
'--unshare-pid', '--unshare-net', '--unshare-ipc',
|
||||
'--mount-proc', '/proc',
|
||||
'--mount-bind', '/dev', '/dev',
|
||||
args.root,
|
||||
'/usr/bin/ostree-run-triggers']
|
||||
print "%r" % (child_args,)
|
||||
child_args = buildutil.get_base_user_chroot_args()
|
||||
child_args.extend(['--mount-proc', '/proc',
|
||||
'--mount-bind', '/dev', '/dev',
|
||||
args.root,
|
||||
'/usr/bin/ostree-run-triggers'])
|
||||
env_copy = dict(buildutil.BUILD_ENV)
|
||||
env_copy['PWD'] = '/'
|
||||
run_sync(child_args, env=env_copy)
|
||||
|
@ -31,11 +31,22 @@ def get():
|
||||
_config[k.strip()] = v.strip()
|
||||
return _config
|
||||
|
||||
def get_key(name, provided_args=None):
|
||||
# This hack is because we want people to be able to pass None
|
||||
# for "default", but still distinguish default=None from default
|
||||
# not passed.
|
||||
_default_not_supplied = object()
|
||||
def get_key(name, provided_args=None, default=_default_not_supplied):
|
||||
global _default_not_supplied
|
||||
config = get()
|
||||
if provided_args:
|
||||
v = provided_args.get(name)
|
||||
if v is not None:
|
||||
return v
|
||||
return config[name]
|
||||
if default is _default_not_supplied:
|
||||
# Possibly throw a KeyError
|
||||
return config[name]
|
||||
value = config.get(name, _default_not_supplied)
|
||||
if value is _default_not_supplied:
|
||||
return default
|
||||
return value
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user