aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2022-02-10 15:24:41 +0100
committerMartin Ridgers <[email protected]>2022-02-11 10:46:06 +0100
commitd7ea2c537784910dd41d6b2ef97efe511d1eaf04 (patch)
treea567a8c80febe2953690fdc4c83173d097ab2ca3 /scripts
parentremote_build: better handling of git-daemon processes (diff)
downloadzen-d7ea2c537784910dd41d6b2ef97efe511d1eaf04.tar.xz
zen-d7ea2c537784910dd41d6b2ef97efe511d1eaf04.zip
remote_build: allow clone/fetch from external git daemons
Diffstat (limited to 'scripts')
-rw-r--r--scripts/remote_build.py53
1 files changed, 31 insertions, 22 deletions
diff --git a/scripts/remote_build.py b/scripts/remote_build.py
index 7acad2870..b2fcc85cf 100644
--- a/scripts/remote_build.py
+++ b/scripts/remote_build.py
@@ -72,6 +72,7 @@ def _local(args):
parser.add_argument("action", default="build", nargs="?", help="")
parser.add_argument("--commit", default=None, help="Commit to act on")
parser.add_argument("--keyfile", default=None, help="SSH key file")
+ parser.add_argument("--gitport", default=None, help="Use an exist git daemon at the given port")
args = parser.parse_args(args)
# Find the binaries we'll need
@@ -133,30 +134,38 @@ def _local(args):
print(f"Using host '{host}'")
# Start a git daemon to use as a transfer mechanism
- _header("Starting a git daemon")
- print("Port: 4493")
- print("Base-path: ", zen_dir)
- print("Host: ", _get_ip())
- daemon = subprocess.Popen(
- ( git_bin,
- "daemon",
- "--port=4493",
- "--export-all",
- "--reuseaddr",
- "--verbose",
- "--informative-errors",
- "--base-path=" + str(zen_dir) ),
- #stdout = daemon_log,
- stderr = subprocess.STDOUT
- )
- daemon_killer = _DaemonAutoKill()
+ _header("Git daemon")
+ daemon_port = args.gitport
+ if not daemon_port:
+ daemon_port = 4493
+
+ print("Starting out own one up")
+ print("Port:", daemon_port)
+ print("Base-path: ", zen_dir)
+ print("Host: ", _get_ip())
+ daemon = subprocess.Popen(
+ ( git_bin,
+ "daemon",
+ "--port=" + str(daemon_port),
+ "--export-all",
+ "--reuseaddr",
+ "--verbose",
+ "--informative-errors",
+ "--base-path=" + str(zen_dir) ),
+ #stdout = daemon_log,
+ stderr = subprocess.STDOUT
+ )
+ daemon_killer = _DaemonAutoKill()
+ else:
+ print("Using existing instance")
+ print("Port:", daemon_port)
# Run this script on the remote machine
_header("Running SSH")
commit = args.commit if args.commit else "origin/main"
- remote_zen_dir = "%s_%s" % (os.getlogin(), _get_ip())
+ remote_zen_dir = "%s_%s_%s" % (os.getlogin(), _get_ip(), str(daemon_port))
print(f"Using zen '~/{remote_zen_dir}'")
print(f"Running {__file__} remotely")
@@ -166,7 +175,7 @@ def _local(args):
*identity,
"-tA",
host,
- f"python3 -u - !remote {_get_ip()} '{remote_zen_dir}' {commit} '{args.action}'",
+ f"python3 -u - !remote {_get_ip()}:{daemon_port} '{remote_zen_dir}' {commit} '{args.action}'",
stdin=self_file)
# If we're bundling, collect zip files from the remote machine
@@ -185,7 +194,7 @@ def _remote(args):
# Parse arguments
desc = "Build Zen on a remote host"
parser = argparse.ArgumentParser(description=desc)
- parser.add_argument("ip", help="Host's IP address")
+ parser.add_argument("gitaddr", help="Host's Git daemon address")
parser.add_argument("reponame", help="Repository name clone into and work in")
parser.add_argument("commit", help="Zen commit to operate on")
parser.add_argument("action", help="The action to do")
@@ -203,10 +212,10 @@ def _remote(args):
"""
# Check for a clone, create it, chdir to it
- _header("REMOTE:", f"Clone/pull from {args.ip}")
+ _header("REMOTE:", f"Clone/pull from {args.gitaddr}")
clone_dir = zen_dir / args.reponame
if not clone_dir.is_dir():
- _run_checked("git", "clone", f"git://{args.ip}:4493/", clone_dir)
+ _run_checked("git", "clone", f"git://{args.gitaddr}/", clone_dir)
os.chdir(clone_dir)
_run_checked("git", "clean", "-fd")