ostbuild: More work on deploy commands
This commit is contained in:
parent
3a365521a8
commit
0597a3f71c
|
|
@ -29,6 +29,7 @@ pyostbuild_PYTHON = \
|
||||||
src/ostbuild/pyostbuild/builtin_compose.py \
|
src/ostbuild/pyostbuild/builtin_compose.py \
|
||||||
src/ostbuild/pyostbuild/builtin_chroot_compile_one.py \
|
src/ostbuild/pyostbuild/builtin_chroot_compile_one.py \
|
||||||
src/ostbuild/pyostbuild/builtin_compile_one.py \
|
src/ostbuild/pyostbuild/builtin_compile_one.py \
|
||||||
|
src/ostbuild/pyostbuild/builtin_deploy_root.py \
|
||||||
src/ostbuild/pyostbuild/builtin_pull_components.py \
|
src/ostbuild/pyostbuild/builtin_pull_components.py \
|
||||||
src/ostbuild/pyostbuild/builtin_git_mirror.py \
|
src/ostbuild/pyostbuild/builtin_git_mirror.py \
|
||||||
src/ostbuild/pyostbuild/builtin_prefix.py \
|
src/ostbuild/pyostbuild/builtin_prefix.py \
|
||||||
|
|
@ -48,6 +49,7 @@ pyostbuild_PYTHON = \
|
||||||
src/ostbuild/pyostbuild/odict.py \
|
src/ostbuild/pyostbuild/odict.py \
|
||||||
src/ostbuild/pyostbuild/ostbuildlog.py \
|
src/ostbuild/pyostbuild/ostbuildlog.py \
|
||||||
src/ostbuild/pyostbuild/ostbuildrc.py \
|
src/ostbuild/pyostbuild/ostbuildrc.py \
|
||||||
|
src/ostbuild/pyostbuild/privileged_subproc.py \
|
||||||
src/ostbuild/pyostbuild/warningfilter.py \
|
src/ostbuild/pyostbuild/warningfilter.py \
|
||||||
src/ostbuild/pyostbuild/subprocess_helpers.py \
|
src/ostbuild/pyostbuild/subprocess_helpers.py \
|
||||||
src/ostbuild/pyostbuild/vcs.py \
|
src/ostbuild/pyostbuild/vcs.py \
|
||||||
|
|
|
||||||
|
|
@ -101,9 +101,14 @@ class OstbuildBuildComponents(builtins.Builtin):
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
current_vcs_version = component['revision']
|
current_vcs_version = component['revision']
|
||||||
previous_vcs_version = json.loads(previous_metadata_text)['revision']
|
previous_metadata = json.loads(previous_metadata_text)
|
||||||
if current_vcs_version != previous_vcs_version:
|
previous_vcs_version = previous_metadata['revision']
|
||||||
|
if current_vcs_version == previous_vcs_version:
|
||||||
log("Metadata differs; VCS version unchanged")
|
log("Metadata differs; VCS version unchanged")
|
||||||
|
for k,v in meta_copy.iteritems():
|
||||||
|
previous_v = previous_metadata.get(k)
|
||||||
|
if v != previous_v:
|
||||||
|
log("Key %r differs: old: %r new: %r" % (k, previous_v, v))
|
||||||
else:
|
else:
|
||||||
log("Metadata differs; note vcs version is now '%s', was '%s'" % (current_vcs_version, previous_vcs_version))
|
log("Metadata differs; note vcs version is now '%s', was '%s'" % (current_vcs_version, previous_vcs_version))
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
# Copyright (C) 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,subprocess,tempfile,re,shutil
|
||||||
|
import argparse
|
||||||
|
import time
|
||||||
|
import urlparse
|
||||||
|
import json
|
||||||
|
from StringIO import StringIO
|
||||||
|
|
||||||
|
from . import builtins
|
||||||
|
from .ostbuildlog import log, fatal
|
||||||
|
from . import ostbuildrc
|
||||||
|
from . import privileged_subproc
|
||||||
|
|
||||||
|
class OstbuildDeployQemu(builtins.Builtin):
|
||||||
|
name = "deploy-qemu"
|
||||||
|
short_description = "Extract data from shadow repository to qemu"
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
builtins.Builtin.__init__(self)
|
||||||
|
|
||||||
|
def execute(self, argv):
|
||||||
|
parser = argparse.ArgumentParser(description=self.short_description)
|
||||||
|
parser.add_argument('--prefix')
|
||||||
|
parser.add_argument('--bin-snapshot')
|
||||||
|
|
||||||
|
args = parser.parse_args(argv)
|
||||||
|
self.args = args
|
||||||
|
|
||||||
|
self.parse_config()
|
||||||
|
self.parse_bin_snapshot(args.prefix, args.bin_snapshot)
|
||||||
|
|
||||||
|
target_names = []
|
||||||
|
for target in self.bin_snapshot['targets']:
|
||||||
|
target_names.append(target['name'])
|
||||||
|
|
||||||
|
helper = privileged_subproc.PrivilegedSubprocess()
|
||||||
|
sys_repo = os.path.join(self.ostree_dir, 'repo')
|
||||||
|
shadow_path = os.path.join(self.workdir, 'shadow-repo')
|
||||||
|
helper.spawn_sync(['ostree', '--repo=' + sys_repo,
|
||||||
|
'pull-local', shadow_path])
|
||||||
|
|
||||||
|
builtins.register(OstbuildDeployRoot)
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
# Copyright (C) 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,subprocess,tempfile,re,shutil
|
||||||
|
import argparse
|
||||||
|
import time
|
||||||
|
import urlparse
|
||||||
|
import json
|
||||||
|
from StringIO import StringIO
|
||||||
|
|
||||||
|
from . import builtins
|
||||||
|
from .ostbuildlog import log, fatal
|
||||||
|
from . import ostbuildrc
|
||||||
|
from . import privileged_subproc
|
||||||
|
|
||||||
|
class OstbuildDeployRoot(builtins.Builtin):
|
||||||
|
name = "deploy-root"
|
||||||
|
short_description = "Extract data from shadow repository to system repository"
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
builtins.Builtin.__init__(self)
|
||||||
|
|
||||||
|
def execute(self, argv):
|
||||||
|
parser = argparse.ArgumentParser(description=self.short_description)
|
||||||
|
parser.add_argument('--prefix')
|
||||||
|
parser.add_argument('--bin-snapshot')
|
||||||
|
|
||||||
|
args = parser.parse_args(argv)
|
||||||
|
self.args = args
|
||||||
|
|
||||||
|
self.parse_config()
|
||||||
|
self.parse_bin_snapshot(args.prefix, args.bin_snapshot)
|
||||||
|
|
||||||
|
target_names = []
|
||||||
|
for target in self.bin_snapshot['targets']:
|
||||||
|
target_names.append(target['name'])
|
||||||
|
|
||||||
|
helper = privileged_subproc.PrivilegedSubprocess()
|
||||||
|
sys_repo = os.path.join(self.ostree_dir, 'repo')
|
||||||
|
shadow_path = os.path.join(self.workdir, 'shadow-repo')
|
||||||
|
helper.spawn_sync(['ostree', '--repo=' + sys_repo,
|
||||||
|
'pull-local', shadow_path])
|
||||||
|
|
||||||
|
builtins.register(OstbuildDeployRoot)
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
# Copyright (C) 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,subprocess,tempfile,re,shutil
|
||||||
|
import argparse
|
||||||
|
import time
|
||||||
|
import urlparse
|
||||||
|
import json
|
||||||
|
from StringIO import StringIO
|
||||||
|
|
||||||
|
from . import builtins
|
||||||
|
from .ostbuildlog import log, fatal
|
||||||
|
from . import ostbuildrc
|
||||||
|
from . import privileged_subproc
|
||||||
|
|
||||||
|
class OstbuildPrivhelperDeployQemu(builtins.Builtin):
|
||||||
|
name = "privhelper-deploy-qemu"
|
||||||
|
short_description = "Helper for deploy-qemu"
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
builtins.Builtin.__init__(self)
|
||||||
|
|
||||||
|
def execute(self, argv):
|
||||||
|
parser = argparse.ArgumentParser(description=self.short_description)
|
||||||
|
|
||||||
|
args = parser.parse_args(argv)
|
||||||
|
self.args = args
|
||||||
|
|
||||||
|
self.parse_config()
|
||||||
|
self.parse_bin_snapshot(args.prefix, args.bin_snapshot)
|
||||||
|
|
||||||
|
target_names = []
|
||||||
|
for target in self.bin_snapshot['targets']:
|
||||||
|
target_names.append(target['name'])
|
||||||
|
|
||||||
|
helper = privileged_subproc.PrivilegedSubprocess()
|
||||||
|
sys_repo = os.path.join(self.ostree_dir, 'repo')
|
||||||
|
shadow_path = os.path.join(self.workdir, 'shadow-repo')
|
||||||
|
helper.spawn_sync(['ostree', '--repo=' + sys_repo,
|
||||||
|
'pull-local', shadow_path])
|
||||||
|
|
||||||
|
builtins.register(OstbuildDeployRoot)
|
||||||
|
|
@ -42,12 +42,12 @@ class Builtin(object):
|
||||||
self.snapshot = None
|
self.snapshot = None
|
||||||
self.bin_snapshot = None
|
self.bin_snapshot = None
|
||||||
self.repo = None
|
self.repo = None
|
||||||
self.ostree_dir = self._find_ostree_dir()
|
self.ostree_dir = self.find_ostree_dir()
|
||||||
(self.active_branch, self.active_branch_checksum) = self._find_active_branch()
|
(self.active_branch, self.active_branch_checksum) = self._find_active_branch()
|
||||||
self._src_snapshots = None
|
self._src_snapshots = None
|
||||||
self._bin_snapshots = None
|
self._bin_snapshots = None
|
||||||
|
|
||||||
def _find_ostree_dir(self):
|
def find_ostree_dir(self):
|
||||||
for path in ['/ostree', '/sysroot/ostree']:
|
for path in ['/ostree', '/sysroot/ostree']:
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
return path
|
return path
|
||||||
|
|
@ -180,9 +180,12 @@ class Builtin(object):
|
||||||
else:
|
else:
|
||||||
fatal("No repository configured, and shadow-repo not found. Use \"ostbuild shadow-repo-init\" to make one")
|
fatal("No repository configured, and shadow-repo not found. Use \"ostbuild shadow-repo-init\" to make one")
|
||||||
|
|
||||||
def parse_snapshot(self, prefix, path):
|
def parse_prefix(self, prefix):
|
||||||
if prefix is not None:
|
if prefix is not None:
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
|
|
||||||
|
def parse_snapshot(self, prefix, path):
|
||||||
|
self.parse_prefix(prefix)
|
||||||
self._init_repo()
|
self._init_repo()
|
||||||
if path is None:
|
if path is None:
|
||||||
latest_path = self.get_src_snapshot_db().get_latest_path()
|
latest_path = self.get_src_snapshot_db().get_latest_path()
|
||||||
|
|
@ -197,8 +200,7 @@ class Builtin(object):
|
||||||
fatal("Unhandled 00ostree-src-snapshot-version \"%d\", expected 0" % (src_ver, ))
|
fatal("Unhandled 00ostree-src-snapshot-version \"%d\", expected 0" % (src_ver, ))
|
||||||
|
|
||||||
def parse_bin_snapshot(self, prefix, path):
|
def parse_bin_snapshot(self, prefix, path):
|
||||||
if prefix is not None:
|
self.parse_prefix(prefix)
|
||||||
self.prefix = prefix
|
|
||||||
self._init_repo()
|
self._init_repo()
|
||||||
if path is None:
|
if path is None:
|
||||||
latest_path = self.get_bin_snapshot_db().get_latest_path()
|
latest_path = self.get_bin_snapshot_db().get_latest_path()
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ from . import builtin_checkout
|
||||||
from . import builtin_chroot_compile_one
|
from . import builtin_chroot_compile_one
|
||||||
from . import builtin_compose
|
from . import builtin_compose
|
||||||
from . import builtin_compile_one
|
from . import builtin_compile_one
|
||||||
|
from . import builtin_deploy_root
|
||||||
from . import builtin_git_mirror
|
from . import builtin_git_mirror
|
||||||
from . import builtin_pull_components
|
from . import builtin_pull_components
|
||||||
from . import builtin_prefix
|
from . import builtin_prefix
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
# Copyright (C) 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,subprocess
|
||||||
|
|
||||||
|
from .ostbuildlog import log, fatal
|
||||||
|
from . import ostbuildrc
|
||||||
|
|
||||||
|
class PrivilegedSubprocess(object):
|
||||||
|
|
||||||
|
def spawn_sync(self, argv):
|
||||||
|
helper = ostbuildrc.get_key('privileged_exec', default='pkexec')
|
||||||
|
|
||||||
|
handlers = {'pkexec': self._pkexec_spawn_sync}
|
||||||
|
|
||||||
|
handler = handlers.get(helper)
|
||||||
|
if handler is None:
|
||||||
|
fatal("Unrecognized privileged_exec; valid values=%r" % (handlers.keys(),))
|
||||||
|
else:
|
||||||
|
handler(argv)
|
||||||
|
|
||||||
|
def _pkexec_spawn_sync(self, argv):
|
||||||
|
pkexec_argv = ['pkexec'] + argv
|
||||||
|
log("Running: %s" % (subprocess.list2cmdline(pkexec_argv), ))
|
||||||
|
subprocess.check_call(pkexec_argv)
|
||||||
Loading…
Reference in New Issue