mirror of
https://github.com/ostreedev/ostree.git
synced 2024-12-26 03:22:08 +03:00
ostbuild: Run triggers after constructing build root
This commit is contained in:
parent
ebe35dbefe
commit
ef7f12f31b
@ -25,6 +25,7 @@ pyostbuild_PYTHON = \
|
||||
src/ostbuild/pyostbuild/builtin_autodiscover_meta.py \
|
||||
src/ostbuild/pyostbuild/builtin_build.py \
|
||||
src/ostbuild/pyostbuild/builtin_chroot_compile_one.py \
|
||||
src/ostbuild/pyostbuild/builtin_chroot_run_triggers.py \
|
||||
src/ostbuild/pyostbuild/builtin_commit_artifacts.py \
|
||||
src/ostbuild/pyostbuild/builtin_compile_one.py \
|
||||
src/ostbuild/pyostbuild/builtin_resolve.py \
|
||||
|
@ -15,11 +15,35 @@
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
from .subprocess_helpers import run_sync_get_output
|
||||
|
||||
ARTIFACT_RE = re.compile(r'^artifact-([^,]+),([^,]+),([^,]+),([^,]+),(.+)-((?:runtime)|(?:devel))\.tar$')
|
||||
BUILD_ENV = {
|
||||
'HOME' : '/',
|
||||
'HOSTNAME' : 'ostbuild',
|
||||
'LANG': 'C',
|
||||
'PATH' : '/usr/bin:/bin:/usr/sbin:/sbin',
|
||||
'SHELL' : '/bin/bash',
|
||||
'TERM' : 'vt100',
|
||||
'TMPDIR' : '/tmp',
|
||||
'TZ': 'EST5EDT'
|
||||
}
|
||||
|
||||
def find_user_chroot_path():
|
||||
# We need to search PATH here manually so we correctly pick up an
|
||||
# ostree install in e.g. ~/bin even though we're going to set PATH
|
||||
# below for our children inside the chroot.
|
||||
ostbuild_user_chroot_path = None
|
||||
for dirname in os.environ['PATH'].split(':'):
|
||||
path = os.path.join(dirname, 'linux-user-chroot')
|
||||
if os.access(path, os.X_OK):
|
||||
ostbuild_user_chroot_path = path
|
||||
break
|
||||
if ostbuild_user_chroot_path is None:
|
||||
ostbuild_user_chroot_path = 'linux-user-chroot'
|
||||
return ostbuild_user_chroot_path
|
||||
|
||||
def branch_name_for_artifact(a):
|
||||
return 'artifacts/%s/%s/%s' % (a['buildroot'],
|
||||
|
@ -21,20 +21,10 @@ import argparse
|
||||
import json
|
||||
|
||||
from . import builtins
|
||||
from . import buildutil
|
||||
from .ostbuildlog import log, fatal
|
||||
from .subprocess_helpers import run_sync
|
||||
|
||||
BUILD_ENV = {
|
||||
'HOME' : '/',
|
||||
'HOSTNAME' : 'ostbuild',
|
||||
'LANG': 'C',
|
||||
'PATH' : '/usr/bin:/bin:/usr/sbin:/sbin',
|
||||
'SHELL' : '/bin/bash',
|
||||
'TERM' : 'vt100',
|
||||
'TMPDIR' : '/tmp',
|
||||
'TZ': 'EST5EDT'
|
||||
}
|
||||
|
||||
class OstbuildChrootCompileOne(builtins.Builtin):
|
||||
name = "chroot-compile-one"
|
||||
short_description = "Build artifacts from the current source directory in a chroot"
|
||||
@ -95,6 +85,8 @@ class OstbuildChrootCompileOne(builtins.Builtin):
|
||||
shutil.rmtree(rootdir_tmp)
|
||||
child_args = ['ostree', '--repo=' + args.repo, 'checkout', '-U', rev, rootdir_tmp]
|
||||
run_sync(child_args)
|
||||
child_args = ['ostbuild', 'chroot-run-triggers', rootdir_tmp]
|
||||
run_sync(child_args)
|
||||
builddir_tmp = os.path.join(rootdir_tmp, 'ostbuild')
|
||||
os.mkdir(builddir_tmp)
|
||||
os.mkdir(os.path.join(builddir_tmp, 'source'))
|
||||
@ -114,17 +106,7 @@ class OstbuildChrootCompileOne(builtins.Builtin):
|
||||
|
||||
chroot_sourcedir = os.path.join('/ostbuild', 'source', self.metadata['name'])
|
||||
|
||||
# We need to search PATH here manually so we correctly pick up an
|
||||
# ostree install in e.g. ~/bin even though we're going to set PATH
|
||||
# below for our children inside the chroot.
|
||||
ostbuild_user_chroot_path = None
|
||||
for dirname in os.environ['PATH'].split(':'):
|
||||
path = os.path.join(dirname, 'linux-user-chroot')
|
||||
if os.access(path, os.X_OK):
|
||||
ostbuild_user_chroot_path = path
|
||||
break
|
||||
if ostbuild_user_chroot_path is None:
|
||||
ostbuild_user_chroot_path = 'linux-user-chroot'
|
||||
ostbuild_user_chroot_path = buildutil.find_user_chroot_path()
|
||||
|
||||
child_args = [ostbuild_user_chroot_path, '--unshare-pid', '--unshare-net', '--unshare-ipc',
|
||||
'--mount-readonly', '/',
|
||||
@ -143,7 +125,7 @@ class OstbuildChrootCompileOne(builtins.Builtin):
|
||||
'--ostbuild-resultdir=/ostbuild/results',
|
||||
'--ostbuild-meta=_ostbuild-meta'])
|
||||
child_args.extend(rest_args)
|
||||
env_copy = dict(BUILD_ENV)
|
||||
env_copy = dict(buildutil.BUILD_ENV)
|
||||
env_copy['PWD'] = chroot_sourcedir
|
||||
run_sync(child_args, env=env_copy, keep_stdin=args.debug_shell)
|
||||
|
||||
|
51
src/ostbuild/pyostbuild/builtin_chroot_run_triggers.py
Executable file
51
src/ostbuild/pyostbuild/builtin_chroot_run_triggers.py
Executable file
@ -0,0 +1,51 @@
|
||||
# Copyright (C) 2011,2012 Colin Walters <walters@verbum.org>
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
import os,sys,re,subprocess,tempfile,shutil
|
||||
from StringIO import StringIO
|
||||
import argparse
|
||||
import json
|
||||
|
||||
from . import builtins
|
||||
from . import buildutil
|
||||
from .ostbuildlog import log, fatal
|
||||
from .subprocess_helpers import run_sync
|
||||
|
||||
class OstbuildChrootRunTriggers(builtins.Builtin):
|
||||
name = "chroot-run-triggers"
|
||||
short_description = "Run ostree-run-triggers inside a chroot"
|
||||
|
||||
def execute(self, argv):
|
||||
parser = argparse.ArgumentParser(description=self.short_description)
|
||||
parser.add_argument('root')
|
||||
|
||||
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,)
|
||||
env_copy = dict(buildutil.BUILD_ENV)
|
||||
env_copy['PWD'] = '/'
|
||||
run_sync(child_args, env=env_copy)
|
||||
|
||||
builtins.register(OstbuildChrootRunTriggers)
|
@ -25,6 +25,7 @@ from . import builtins
|
||||
from . import builtin_autodiscover_meta
|
||||
from . import builtin_build
|
||||
from . import builtin_chroot_compile_one
|
||||
from . import builtin_chroot_run_triggers
|
||||
from . import builtin_commit_artifacts
|
||||
from . import builtin_compile_one
|
||||
from . import builtin_resolve
|
||||
|
Loading…
Reference in New Issue
Block a user