summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2012-05-01 16:45:34 -0400
committerColin Walters <walters@verbum.org>2012-05-04 16:16:16 -0400
commit938f4eaf442827e6ee243ec3b0ae1a02cf838a53 (patch)
tree1e601700aa704b27c7bb31039701ab34ad3c05df
parentb845e0a2bb79fb8fee3f6e0d6375d648c44195b1 (diff)
downloadostree-938f4eaf442827e6ee243ec3b0ae1a02cf838a53.tar.gz
ostbuild: Lots more
-rw-r--r--Makefile-ostbuild.am1
-rwxr-xr-xsrc/ostbuild/pyostbuild/builtin_branch_prefix.py4
-rwxr-xr-xsrc/ostbuild/pyostbuild/builtin_build_components.py2
-rwxr-xr-xsrc/ostbuild/pyostbuild/builtin_checkout.py4
-rwxr-xr-xsrc/ostbuild/pyostbuild/builtin_resolve.py1
-rwxr-xr-xsrc/ostbuild/pyostbuild/builtin_shadow_repo_init.py52
-rwxr-xr-xsrc/ostbuild/pyostbuild/builtins.py19
-rw-r--r--src/ostbuild/pyostbuild/jsondb.py1
-rwxr-xr-xsrc/ostbuild/pyostbuild/main.py1
-rwxr-xr-xsrc/ostbuild/pyostbuild/vcs.py5
10 files changed, 81 insertions, 9 deletions
diff --git a/Makefile-ostbuild.am b/Makefile-ostbuild.am
index 21ec7b46..15b53c93 100644
--- a/Makefile-ostbuild.am
+++ b/Makefile-ostbuild.am
@@ -34,6 +34,7 @@ pyostbuild_PYTHON = \
src/ostbuild/pyostbuild/builtin_resolve.py \
src/ostbuild/pyostbuild/builtin_modify_snapshot.py \
src/ostbuild/pyostbuild/builtin_tree_to_bin.py \
+ src/ostbuild/pyostbuild/builtin_shadow_repo_init.py \
src/ostbuild/pyostbuild/builtin_status.py \
src/ostbuild/pyostbuild/builtins.py \
src/ostbuild/pyostbuild/filemonitor.py \
diff --git a/src/ostbuild/pyostbuild/builtin_branch_prefix.py b/src/ostbuild/pyostbuild/builtin_branch_prefix.py
index 5aaf9399..81dcd07a 100755
--- a/src/ostbuild/pyostbuild/builtin_branch_prefix.py
+++ b/src/ostbuild/pyostbuild/builtin_branch_prefix.py
@@ -63,7 +63,9 @@ class OstbuildBranchPrefix(builtins.Builtin):
fatal("Mismatched name %r in snapshot" % (name, ))
target['name'] = name.replace(orig_prefix, args.newprefix)
- db.store(forked_snapshot)
+ path = db.store(forked_snapshot)
+
+ log("Saved %r" % (path, ))
run_sync(['ostbuild', 'prefix', args.newprefix],
log_initiation=False, log_success=False)
diff --git a/src/ostbuild/pyostbuild/builtin_build_components.py b/src/ostbuild/pyostbuild/builtin_build_components.py
index 5e35c0f0..af1ba7c4 100755
--- a/src/ostbuild/pyostbuild/builtin_build_components.py
+++ b/src/ostbuild/pyostbuild/builtin_build_components.py
@@ -95,7 +95,7 @@ class OstbuildBuildComponents(builtins.Builtin):
else:
log("No previous build for '%s' found" % (name, ))
- checkoutdir = os.path.join(self.workdir, 'src')
+ checkoutdir = os.path.join(self.workdir, 'checkouts')
component_src = os.path.join(checkoutdir, basename)
run_sync(['ostbuild', 'checkout', '--snapshot=' + self.snapshot_path,
'--clean', '--overwrite', basename], cwd=checkoutdir)
diff --git a/src/ostbuild/pyostbuild/builtin_checkout.py b/src/ostbuild/pyostbuild/builtin_checkout.py
index 27281bea..f9cba416 100755
--- a/src/ostbuild/pyostbuild/builtin_checkout.py
+++ b/src/ostbuild/pyostbuild/builtin_checkout.py
@@ -72,8 +72,10 @@ class OstbuildCheckout(builtins.Builtin):
if is_dirty:
# Kind of a hack, but...
- if os.path.lexists(checkoutdir):
+ if os.path.islink(checkoutdir):
os.unlink(checkoutdir)
+ if args.overwrite and os.path.isdir(checkoutdir):
+ shutil.rmtree(checkoutdir)
os.symlink(uri, checkoutdir)
else:
vcs.get_vcs_checkout(self.mirrordir, keytype, uri, checkoutdir,
diff --git a/src/ostbuild/pyostbuild/builtin_resolve.py b/src/ostbuild/pyostbuild/builtin_resolve.py
index fc7ca624..2c39b051 100755
--- a/src/ostbuild/pyostbuild/builtin_resolve.py
+++ b/src/ostbuild/pyostbuild/builtin_resolve.py
@@ -139,7 +139,6 @@ class OstbuildResolve(builtins.Builtin):
self.args = args
self.parse_config()
- self.repo = ostbuildrc.get_key('repo')
self.manifest = json.load(open(args.manifest))
self.prefix = self.manifest['prefix']
diff --git a/src/ostbuild/pyostbuild/builtin_shadow_repo_init.py b/src/ostbuild/pyostbuild/builtin_shadow_repo_init.py
new file mode 100755
index 00000000..03211d2f
--- /dev/null
+++ b/src/ostbuild/pyostbuild/builtin_shadow_repo_init.py
@@ -0,0 +1,52 @@
+# 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,stat,subprocess,tempfile,re,shutil
+from StringIO import StringIO
+import json
+import select,time
+import argparse
+
+from . import builtins
+from .ostbuildlog import log, fatal
+from . import fileutil
+from .subprocess_helpers import run_sync, run_sync_get_output
+
+class OstbuildShadowRepoInit(builtins.Builtin):
+ name = "shadow-repo-init"
+ short_description = "Initialize a user-mode shadow repository for /ostree/repo"
+
+ def __init__(self):
+ builtins.Builtin.__init__(self)
+
+ def execute(self, argv):
+ parser = argparse.ArgumentParser(description=self.short_description)
+
+ args = parser.parse_args(argv)
+
+ self.parse_config()
+
+ path = os.path.join(self.workdir, 'shadow-repo')
+ fileutil.ensure_dir(path)
+ if os.path.isdir(os.path.join(path, 'objects')):
+ log("Shadow repository '%s' appears to already exist" % (path, ))
+ else:
+ run_sync(['ostree', '--repo=' + path, 'init', '--archive'])
+ run_sync(['ostree', '--repo=' + path, 'config', 'set', 'core.parent', '/ostree/repo'])
+ log("Created shadow repository: %s" % (path, ))
+
+builtins.register(OstbuildShadowRepoInit)
diff --git a/src/ostbuild/pyostbuild/builtins.py b/src/ostbuild/pyostbuild/builtins.py
index 4c3f5021..949f5321 100755
--- a/src/ostbuild/pyostbuild/builtins.py
+++ b/src/ostbuild/pyostbuild/builtins.py
@@ -169,10 +169,21 @@ class Builtin(object):
self._bin_snapshots = self.create_db('bin-snapshot')
return self._bin_snapshots
+ def _init_repo(self):
+ repo = ostbuildrc.get_key('repo', default=None)
+ if repo is not None:
+ self.repo = repo
+ else:
+ shadow_path = os.path.join(self.workdir, 'shadow-repo')
+ if os.path.isdir(shadow_path):
+ self.repo = shadow_path
+ else:
+ fatal("No repository configured, and shadow-repo not found. Use \"ostbuild shadow-repo-init\" to make one")
+
def parse_snapshot(self, prefix, path):
if prefix is not None:
self.prefix = prefix
- self.repo = ostbuildrc.get_key('repo')
+ self._init_repo()
if path is None:
latest_path = self.get_src_snapshot_db().get_latest_path()
if latest_path is None:
@@ -183,12 +194,12 @@ class Builtin(object):
self.snapshot = json.load(open(self.snapshot_path))
src_ver = self.snapshot['00ostree-src-snapshot-version']
if src_ver != 0:
- 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):
if prefix is not None:
self.prefix = prefix
- self.repo = ostbuildrc.get_key('repo')
+ self._init_repo()
if path is None:
latest_path = self.get_bin_snapshot_db().get_latest_path()
if latest_path is None:
@@ -199,7 +210,7 @@ class Builtin(object):
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)
+ fatal("Unhandled 00ostree-bin-snapshot-version \"%d\", expected 0" % (bin_ver, ))
def execute(self, args):
raise NotImplementedError()
diff --git a/src/ostbuild/pyostbuild/jsondb.py b/src/ostbuild/pyostbuild/jsondb.py
index 6d7906e4..810103df 100644
--- a/src/ostbuild/pyostbuild/jsondb.py
+++ b/src/ostbuild/pyostbuild/jsondb.py
@@ -97,6 +97,7 @@ class JsonDB(object):
if latest is not None:
if digest == latest[2]:
+ os.unlink(tmppath)
return latest[3]
latest_version = (latest[0], latest[1])
else:
diff --git a/src/ostbuild/pyostbuild/main.py b/src/ostbuild/pyostbuild/main.py
index 2a60f85d..507cb1ef 100755
--- a/src/ostbuild/pyostbuild/main.py
+++ b/src/ostbuild/pyostbuild/main.py
@@ -34,6 +34,7 @@ from . import builtin_prefix
from . import builtin_resolve
from . import builtin_modify_snapshot
from . import builtin_tree_to_bin
+from . import builtin_shadow_repo_init
from . import builtin_status
def usage(ecode):
diff --git a/src/ostbuild/pyostbuild/vcs.py b/src/ostbuild/pyostbuild/vcs.py
index 07161224..7811f5ee 100755
--- a/src/ostbuild/pyostbuild/vcs.py
+++ b/src/ostbuild/pyostbuild/vcs.py
@@ -51,17 +51,20 @@ def get_vcs_checkout(mirrordir, keytype, uri, dest, branch, overwrite=True):
tmp_dest = dest + '.tmp'
if os.path.isdir(tmp_dest):
shutil.rmtree(tmp_dest)
+ if os.path.islink(dest):
+ os.unlink(dest)
if os.path.isdir(dest):
if overwrite:
shutil.rmtree(dest)
else:
tmp_dest = dest
if not os.path.isdir(tmp_dest):
- run_sync(['git', 'clone', '-q',
+ run_sync(['git', 'clone', '-q', '--origin', 'localmirror',
'--no-checkout', module_mirror, tmp_dest])
else:
run_sync(['git', 'fetch'], cwd=tmp_dest)
run_sync(['git', 'checkout', '-q', branch], cwd=tmp_dest)
+ run_sync(['git', 'remote', 'add', 'upstream', uri], cwd=tmp_dest)
run_sync(['git', 'submodule', 'init'], cwd=tmp_dest)
have_submodules = _fixup_submodule_references(mirrordir, tmp_dest)
if have_submodules: