taler-deployment

Deployment scripts and configuration files
Log | Files | Refs | README

commit e08b838b0eeadfcc9f1a9f348715b281c04e97d1
parent 8f809cfd8592a7b406ef9cdb6bfb42380ac8621f
Author: Florian Dold <florian.dold@gmail.com>
Date:   Fri, 11 Oct 2019 15:09:41 +0530

wip: build deployment via python

Diffstat:
Mbin/taler-deployment | 80++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------
1 file changed, 59 insertions(+), 21 deletions(-)

diff --git a/bin/taler-deployment b/bin/taler-deployment @@ -54,6 +54,21 @@ def cli(): # map from environment name to currenct currmap = {"test": "TESTKUDOS", "demo": "KUDOS", "int": "INTKUDOS"} +# Our repositories, *must* be topologically sorted +repos = [ + Repo("libmicrohttpd", "git://gnunet.org/libmicrohttpd.git", []), + Repo("gnunet", "git://gnunet.org/gnunet.git", []), + Repo("exchange", "git://git.taler.net/exchange", ["gnunet", "libmicrohttpd"]), + Repo("twister", "git://git.taler.net/twister", ["gnunet", "exchange"]), + Repo("merchant", "git://git.taler.net/merchant", ["exchange", "libmicrohttpd"]), + Repo("bank", "git://git.taler.net/bank", []), + Repo("landing", "git://git.taler.net/landing", []), + Repo("donations", "git://git.taler.net/donations", []), + Repo("blog", "git://git.taler.net/blog", []), + Repo("survey", "git://git.taler.net/survey", []), + Repo("backoffice", "git://git.taler.net/backoffice", []), +] + def ensure_activated(): """Make sure that the environment variables have been @@ -64,7 +79,7 @@ def ensure_activated(): sys.exit(1) out = subprocess.check_output( ["bash", "-c", "source ~/activate; echo $TALER_BOOTSTRAP_TIMESTAMP"], - encoding="utf-8" + encoding="utf-8", ) out = out.strip(" \n") if out != ts: @@ -75,21 +90,58 @@ def ensure_activated(): sys.exit(1) +def build_repo(r): + pass + + +def update_repos(): + for r in repos: + r_dir = Path.home() / "sources" / r.name + subprocess.run(["git", "-C", r_dir.as_posix(), "fetch"], check=True) + res = subprocess.run( + ["git", "-C", r_dir.as_posix(), "status", "-sb"], + check=True, + stdout=subprocess.PIPE, + encoding="utf-8", + ) + if "behind" in res.stdout: + print(f"new commits in {r}") + s = r_dir / "taler-buildstamp" + if s.exists(): + s.unlink() + + +def get_stale_repos(): + timestamps = {} + stale = [] + for r in repos: + r_dir = Path.home() / "sources" / r.name + s = r_dir / "taler-buildstamp" + if not s.exists(): + timestamp[r.name] = time.now() + stale.append(r) + break + timestamp[r.name] = s.stat().st_mtime + for dep in r.deps: + if timestamp[dep] > ts: + stale.append(r) + break + return stale + + @cli.command() def build(): """Build the deployment from source.""" ensure_activated() - os.chdir((Path.home() / "deployment" / "taler-build").as_posix()) - subprocess.run(["./invalidate.sh"], check=True) - subenv = os.environ.copy() - subenv["GNUNET_FORCE_LOG"] = "util;;;;WARNING/taler;;;;DEBUG/twister;;;;DEBUG/test;;;;DEBUG" - subprocess.run(["make"], check=True, env=subenv) + update_repos() + stale = get_stale_repos() + print(f"found stale repos: stale") @cli.command() @click.argument("envname", type=click.Choice(["test", "int", "demo"])) def bootstrap(envname): - """Bootstrap a GNU Taler deployment from the deploymen.git repository""" + """Bootstrap a GNU Taler deployment.""" home = Path.home() @@ -98,20 +150,6 @@ def bootstrap(envname): cfgtext = (home / "envcfg.py").read_text() exec(cfgtext, cfg.__dict__) - repos = [ - Repo("gnunet", "git://gnunet.org/gnunet.git", []), - Repo("libmicrohttpd", "git://gnunet.org/libmicrohttpd.git", []), - Repo("twister", "git://git.taler.net/twister", ["gnunet", "exchange"]), - Repo("bank", "git://git.taler.net/bank", []), - Repo("merchant", "git://git.taler.net/merchant", ["exchange", "libmicrohttpd"]), - Repo("landing", "git://git.taler.net/landing", []), - Repo("exchange", "git://git.taler.net/exchange", ["gnunet", "libmicrohttpd"]), - Repo("donations", "git://git.taler.net/donations", []), - Repo("blog", "git://git.taler.net/blog", []), - Repo("survey", "git://git.taler.net/survey", []), - Repo("backoffice", "git://git.taler.net/backoffice", []), - ] - sources = home / "sources" for r in repos: