[ostree/wip/ostbuild-v2: 4/4] ostbuild: lots more wip
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree/wip/ostbuild-v2: 4/4] ostbuild: lots more wip
- Date: Thu, 19 Apr 2012 03:15:29 +0000 (UTC)
commit bb19072255e79446dd799c7225dd313e77b38909
Author: Colin Walters <walters verbum org>
Date: Wed Apr 18 23:05:43 2012 -0400
ostbuild: lots more wip
Makefile-ostbuild.am | 2 +-
src/ostbuild/pyostbuild/buildutil.py | 2 +-
src/ostbuild/pyostbuild/builtin_checkout.py | 16 ++++++---
.../pyostbuild/builtin_chroot_compile_one.py | 5 +--
src/ostbuild/pyostbuild/builtin_compose.py | 11 ++----
src/ostbuild/pyostbuild/builtin_modify_snapshot.py | 36 +++++++++----------
src/ostbuild/pyostbuild/builtins.py | 6 +++
src/ostbuild/pyostbuild/main.py | 2 +-
src/ostbuild/pyostbuild/vcs.py | 2 +-
9 files changed, 42 insertions(+), 40 deletions(-)
---
diff --git a/Makefile-ostbuild.am b/Makefile-ostbuild.am
index 63e4127..95441c2 100644
--- a/Makefile-ostbuild.am
+++ b/Makefile-ostbuild.am
@@ -30,7 +30,7 @@ pyostbuild_PYTHON = \
src/ostbuild/pyostbuild/builtin_compile_one.py \
src/ostbuild/pyostbuild/builtin_pull_components.py \
src/ostbuild/pyostbuild/builtin_resolve.py \
- src/ostbuild/pyostbuild/builtin_replace_component.py \
+ src/ostbuild/pyostbuild/builtin_modify_snapshot.py \
src/ostbuild/pyostbuild/builtin_status.py \
src/ostbuild/pyostbuild/builtins.py \
src/ostbuild/pyostbuild/filemonitor.py \
diff --git a/src/ostbuild/pyostbuild/buildutil.py b/src/ostbuild/pyostbuild/buildutil.py
index 96e0e40..386a35c 100755
--- a/src/ostbuild/pyostbuild/buildutil.py
+++ b/src/ostbuild/pyostbuild/buildutil.py
@@ -40,7 +40,7 @@ def parse_src_key(srckey):
if idx < 0:
raise ValueError("Invalid SRC uri=%s" % (srckey, ))
keytype = srckey[:idx]
- if keytype not in ['git']:
+ if keytype not in ['git', 'dirty-git']:
raise ValueError("Unsupported SRC uri=%s" % (srckey, ))
uri = srckey[idx+1:]
return (keytype, uri)
diff --git a/src/ostbuild/pyostbuild/builtin_checkout.py b/src/ostbuild/pyostbuild/builtin_checkout.py
index e604dbc..a4e2613 100755
--- a/src/ostbuild/pyostbuild/builtin_checkout.py
+++ b/src/ostbuild/pyostbuild/builtin_checkout.py
@@ -70,10 +70,16 @@ class OstbuildCheckout(builtins.Builtin):
checkoutdir = os.path.join(os.getcwd(), component_name)
fileutil.ensure_parent_dir(checkoutdir)
- component_src = vcs.get_vcs_checkout(self.mirrordir, keytype, uri, checkoutdir,
- component['revision'],
- overwrite=args.overwrite)
-
+ if keytype == 'dirty-git':
+ # Kind of a hack, but...
+ if os.path.lexists(checkoutdir):
+ os.unlink(checkoutdir)
+ os.symlink(uri, checkoutdir)
+ else:
+ vcs.get_vcs_checkout(self.mirrordir, keytype, uri, checkoutdir,
+ component['revision'],
+ overwrite=args.overwrite)
+
if args.clean:
vcs.clean(keytype, checkoutdir)
@@ -99,6 +105,6 @@ class OstbuildCheckout(builtins.Builtin):
json.dump(component, f, indent=4, sort_keys=True)
f.close()
- log("Checked out: %r" % (component_src, ))
+ log("Checked out: %r" % (checkoutdir, ))
builtins.register(OstbuildCheckout)
diff --git a/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py b/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py
index b9f4344..e3560b9 100755
--- a/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py
+++ b/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py
@@ -90,10 +90,7 @@ class OstbuildChrootCompileOne(builtins.Builtin):
if args.name:
component_name = args.name
else:
- cwd = os.getcwd()
- parent = os.path.dirname(cwd)
- parentparent = os.path.dirname(parent)
- component_name = '%s/%s/%s' % tuple(map(os.path.basename, [parentparent, parent, cwd]))
+ component_name = self.get_component_from_cwd()
components = self.snapshot['components']
component = components.get(component_name)
diff --git a/src/ostbuild/pyostbuild/builtin_compose.py b/src/ostbuild/pyostbuild/builtin_compose.py
index b8d6c1e..a3d6424 100755
--- a/src/ostbuild/pyostbuild/builtin_compose.py
+++ b/src/ostbuild/pyostbuild/builtin_compose.py
@@ -78,14 +78,9 @@ class OstbuildCompose(builtins.Builtin):
stdin=open(tmppath))
os.unlink(tmppath)
- contents = {}
- for k,v in bin_snapshot.iteritems():
- if k not in ('components', 'targets'):
- contents[k] = v
-
- components_path = os.path.join(compose_rootdir, 'contents.json')
- f = open(components_path, 'w')
- json.dump(contents, f, indent=4, sort_keys=True)
+ contents_path = os.path.join(compose_rootdir, 'contents.json')
+ f = open(contents_path, 'w')
+ json.dump(bin_snapshot, f, indent=4, sort_keys=True)
f.close()
run_sync(['ostree', '--repo=' + self.repo,
diff --git a/src/ostbuild/pyostbuild/builtin_modify_snapshot.py b/src/ostbuild/pyostbuild/builtin_modify_snapshot.py
index 35a10fc..eafe410 100755
--- a/src/ostbuild/pyostbuild/builtin_modify_snapshot.py
+++ b/src/ostbuild/pyostbuild/builtin_modify_snapshot.py
@@ -37,31 +37,29 @@ class OstbuildModifySnapshot(builtins.Builtin):
def execute(self, argv):
parser = argparse.ArgumentParser(description=self.short_description)
- parser.add_argument('component')
- parser.add_argument('new-contents')
+ parser.add_argument('--src-snapshot')
args = parser.parse_args(argv)
self.parse_config()
- self.parse_active_branch()
+ self.parse_snapshot(args.src_snapshot)
- snapshot = self.get_component_snapshot(args.component)
+ component_name = self.get_component_from_cwd()
+ current_meta = self.get_component_meta(component_name)
+
+ new_snapshot = dict(self.snapshot)
+ new_meta = dict(current_meta)
+ if 'patches' in new_meta:
+ del new_meta['patches']
+ new_meta['src'] = "dirty-git:%s" % (os.getcwd(), )
+ new_meta['revision'] = run_sync_get_output(['git', 'rev-parse', 'HEAD'])
- replacing_trees = snapshot['trees']
- previous_contents = set()
- new_contents = set()
- for tree in replacing_trees:
- previous_contents_string = run_sync_get_output(['ostree', '--repo=' + self.repo,
- 'ls', '--nul-filenames-only',
- '-R', snapshot['ostree-revision'],
- '/'])
- for filename in previous_contents.split('\0'):
- previous_contents.add(filename)
- new_contents = run_sync_get_output(['find', '-print0'],
- cwd=parser.new_contents)
- for filename in new_contents.split('\0'):
- new_contents.add(filename)
+ new_snapshot['components'][component_name] = new_meta
- print "%r %r" % (previous_contents, new_contents)
+ db = self.get_src_snapshot_db()
+ path = db.store(new_snapshot)
+ log("Replaced %s with %s %s" % (component_name, new_meta['src'],
+ new_meta['revision']))
+ log("New source snapshot: %s" % (path, ))
builtins.register(OstbuildModifySnapshot)
diff --git a/src/ostbuild/pyostbuild/builtins.py b/src/ostbuild/pyostbuild/builtins.py
index 6dd24a1..673512a 100755
--- a/src/ostbuild/pyostbuild/builtins.py
+++ b/src/ostbuild/pyostbuild/builtins.py
@@ -72,6 +72,12 @@ class Builtin(object):
else:
return (None, None)
+ def get_component_from_cwd(self):
+ cwd = os.getcwd()
+ parent = os.path.dirname(cwd)
+ parentparent = os.path.dirname(parent)
+ return '%s/%s/%s' % tuple(map(os.path.basename, [parentparent, parent, cwd]))
+
def parse_config(self):
self.ostbuildrc = ostbuildrc
diff --git a/src/ostbuild/pyostbuild/main.py b/src/ostbuild/pyostbuild/main.py
index 2b92e41..1ca2d95 100755
--- a/src/ostbuild/pyostbuild/main.py
+++ b/src/ostbuild/pyostbuild/main.py
@@ -30,7 +30,7 @@ from . import builtin_compose
from . import builtin_compile_one
from . import builtin_pull_components
from . import builtin_resolve
-from . import builtin_replace_component
+from . import builtin_modify_snapshot
from . import builtin_status
def usage(ecode):
diff --git a/src/ostbuild/pyostbuild/vcs.py b/src/ostbuild/pyostbuild/vcs.py
index 10c7e39..0716122 100755
--- a/src/ostbuild/pyostbuild/vcs.py
+++ b/src/ostbuild/pyostbuild/vcs.py
@@ -71,5 +71,5 @@ def get_vcs_checkout(mirrordir, keytype, uri, dest, branch, overwrite=True):
return dest
def clean(keytype, checkoutdir):
- assert keytype == 'git'
+ assert keytype in ('git', 'dirty-git')
run_sync(['git', 'clean', '-d', '-f', '-x'], cwd=checkoutdir)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]