[ostree] ostbuild: Add preserve_net config option
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] ostbuild: Add preserve_net config option
- Date: Tue, 13 Mar 2012 21:07:34 +0000 (UTC)
commit 277843f3a23f1f20e664cedf4ae5f84115e955f7
Author: Colin Walters <walters verbum org>
Date: Tue Mar 13 17:06:06 2012 -0400
ostbuild: Add preserve_net config option
This is going to be necessary for the builder.
gnomeos/README-build.md | 2 +-
src/ostbuild/pyostbuild/buildutil.py | 10 ++++++++++
src/ostbuild/pyostbuild/builtin_build.py | 6 ++++--
.../pyostbuild/builtin_chroot_compile_one.py | 20 ++++++++++----------
.../pyostbuild/builtin_chroot_run_triggers.py | 14 +++++---------
src/ostbuild/pyostbuild/ostbuildrc.py | 15 +++++++++++++--
6 files changed, 43 insertions(+), 24 deletions(-)
---
diff --git a/gnomeos/README-build.md b/gnomeos/README-build.md
index 3a86b60..b432276 100644
--- a/gnomeos/README-build.md
+++ b/gnomeos/README-build.md
@@ -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
diff --git a/src/ostbuild/pyostbuild/buildutil.py b/src/ostbuild/pyostbuild/buildutil.py
index 814e5e5..96e0e40 100755
--- a/src/ostbuild/pyostbuild/buildutil.py
+++ b/src/ostbuild/pyostbuild/buildutil.py
@@ -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
+
+
diff --git a/src/ostbuild/pyostbuild/builtin_build.py b/src/ostbuild/pyostbuild/builtin_build.py
index 3603932..772aaca 100755
--- a/src/ostbuild/pyostbuild/builtin_build.py
+++ b/src/ostbuild/pyostbuild/builtin_build.py
@@ -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)
diff --git a/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py b/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py
index 40d4665..fa29be9 100755
--- a/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py
+++ b/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py
@@ -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:
diff --git a/src/ostbuild/pyostbuild/builtin_chroot_run_triggers.py b/src/ostbuild/pyostbuild/builtin_chroot_run_triggers.py
index bdee64c..b945599 100755
--- a/src/ostbuild/pyostbuild/builtin_chroot_run_triggers.py
+++ b/src/ostbuild/pyostbuild/builtin_chroot_run_triggers.py
@@ -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)
diff --git a/src/ostbuild/pyostbuild/ostbuildrc.py b/src/ostbuild/pyostbuild/ostbuildrc.py
index 413f7f1..a36febb 100755
--- a/src/ostbuild/pyostbuild/ostbuildrc.py
+++ b/src/ostbuild/pyostbuild/ostbuildrc.py
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]