ostbuild: Add tree-to-bin and bin-to-src
This commit is contained in:
parent
0e266d3f92
commit
a6a8e00edf
|
|
@ -33,6 +33,7 @@ pyostbuild_PYTHON = \
|
||||||
src/ostbuild/pyostbuild/builtin_prefix.py \
|
src/ostbuild/pyostbuild/builtin_prefix.py \
|
||||||
src/ostbuild/pyostbuild/builtin_resolve.py \
|
src/ostbuild/pyostbuild/builtin_resolve.py \
|
||||||
src/ostbuild/pyostbuild/builtin_modify_snapshot.py \
|
src/ostbuild/pyostbuild/builtin_modify_snapshot.py \
|
||||||
|
src/ostbuild/pyostbuild/builtin_tree_to_bin.py \
|
||||||
src/ostbuild/pyostbuild/builtin_status.py \
|
src/ostbuild/pyostbuild/builtin_status.py \
|
||||||
src/ostbuild/pyostbuild/builtins.py \
|
src/ostbuild/pyostbuild/builtins.py \
|
||||||
src/ostbuild/pyostbuild/filemonitor.py \
|
src/ostbuild/pyostbuild/filemonitor.py \
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,8 @@ class OstbuildBinToSrc(builtins.Builtin):
|
||||||
self.parse_bin_snapshot(args.prefix, args.bin_snapshot)
|
self.parse_bin_snapshot(args.prefix, args.bin_snapshot)
|
||||||
|
|
||||||
snapshot = self.bin_snapshot_to_src(self.bin_snapshot)
|
snapshot = self.bin_snapshot_to_src(self.bin_snapshot)
|
||||||
json.dump(snapshot, sys.stdout, indent=4, sort_keys=True)
|
db = self.get_src_snapshot_db()
|
||||||
|
path = db.store(snapshot)
|
||||||
|
log("Source snapshot: %s" % (path, ))
|
||||||
|
|
||||||
builtins.register(OstbuildBinToSrc)
|
builtins.register(OstbuildBinToSrc)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
# ostbuild-compile-one-make wraps systems that implement the GNOME build API:
|
||||||
|
# http://people.gnome.org/~walters/docs/build-api.txt
|
||||||
|
|
||||||
|
import os,sys,stat,subprocess,tempfile,re,shutil
|
||||||
|
import argparse
|
||||||
|
from StringIO import StringIO
|
||||||
|
import json
|
||||||
|
|
||||||
|
from . import builtins
|
||||||
|
from .ostbuildlog import log, fatal
|
||||||
|
from .subprocess_helpers import run_sync, run_sync_get_output
|
||||||
|
from . import buildutil
|
||||||
|
|
||||||
|
class OstbuildTreeToBin(builtins.Builtin):
|
||||||
|
name = "tree-to-bin"
|
||||||
|
short_description = "Turn a tree into a binary snapshot"
|
||||||
|
|
||||||
|
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('--tree')
|
||||||
|
|
||||||
|
args = parser.parse_args(argv)
|
||||||
|
self.parse_config()
|
||||||
|
if args.prefix:
|
||||||
|
self.prefix = args.prefix
|
||||||
|
|
||||||
|
if args.tree:
|
||||||
|
self.load_bin_snapshot_from_path(args.tree)
|
||||||
|
else:
|
||||||
|
self.load_bin_snapshot_from_current()
|
||||||
|
|
||||||
|
db = self.get_bin_snapshot_db()
|
||||||
|
path = db.store(self.bin_snapshot)
|
||||||
|
log("Binary snapshot: %s" % (path, ))
|
||||||
|
|
||||||
|
builtins.register(OstbuildTreeToBin)
|
||||||
|
|
@ -92,7 +92,14 @@ class Builtin(object):
|
||||||
self.snapshot_dir = os.path.join(self.workdir, 'snapshots')
|
self.snapshot_dir = os.path.join(self.workdir, 'snapshots')
|
||||||
self.patchdir = os.path.join(self.workdir, 'patches')
|
self.patchdir = os.path.join(self.workdir, 'patches')
|
||||||
|
|
||||||
def parse_active_branch(self):
|
def load_bin_snapshot_from_path(self, path):
|
||||||
|
self.bin_snapshot_path = os.path.join(path, 'contents.json')
|
||||||
|
self.bin_snapshot = json.load(open(self.bin_snapshot_path))
|
||||||
|
bin_ver = self.bin_snapshot['00ostree-bin-snapshot-version']
|
||||||
|
if bin_ver != 0:
|
||||||
|
fatal("Unhandled 00ostree-bin-snapshot-version \"%d\", expected 0", bin_ver)
|
||||||
|
|
||||||
|
def load_bin_snapshot_from_current(self):
|
||||||
if self.ostree_dir is None:
|
if self.ostree_dir is None:
|
||||||
fatal("/ostree directory not found")
|
fatal("/ostree directory not found")
|
||||||
repo_path = os.path.join(self.ostree_dir, 'repo')
|
repo_path = os.path.join(self.ostree_dir, 'repo')
|
||||||
|
|
@ -101,11 +108,8 @@ class Builtin(object):
|
||||||
self.repo = repo_path
|
self.repo = repo_path
|
||||||
if self.active_branch is None:
|
if self.active_branch is None:
|
||||||
fatal("No \"current\" link found")
|
fatal("No \"current\" link found")
|
||||||
branch_path = os.path.join(self.ostree_dir, self.active_branch)
|
tree_path = os.path.join(self.ostree_dir, self.active_branch)
|
||||||
contents_path = os.path.join(branch_path, 'contents.json')
|
self.load_bin_snapshot_from_path(tree_path)
|
||||||
f = open(contents_path)
|
|
||||||
self.active_branch_contents = json.load(f)
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
def get_component_snapshot(self, name):
|
def get_component_snapshot(self, name):
|
||||||
found = False
|
found = False
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ from . import builtin_pull_components
|
||||||
from . import builtin_prefix
|
from . import builtin_prefix
|
||||||
from . import builtin_resolve
|
from . import builtin_resolve
|
||||||
from . import builtin_modify_snapshot
|
from . import builtin_modify_snapshot
|
||||||
|
from . import builtin_tree_to_bin
|
||||||
from . import builtin_status
|
from . import builtin_status
|
||||||
|
|
||||||
def usage(ecode):
|
def usage(ecode):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue