taler-deployment

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

commit a976769c5aba89444a162c18f940fc49f57321d2
parent fd6e915be9885ad7b4e5b09af5f898fe8d149e15
Author: Florian Dold <florian.dold@gmail.com>
Date:   Fri, 11 Oct 2019 15:48:31 +0530

WIP: build system

Diffstat:
Mbin/taler-deployment | 144++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 129 insertions(+), 15 deletions(-)

diff --git a/bin/taler-deployment b/bin/taler-deployment @@ -1,5 +1,20 @@ #!/usr/bin/env python3 +# This file is part of GNU Taler. +# +# GNU Taler is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Taler 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Taler. If not, see <https://www.gnu.org/licenses/>. + import click import types import os @@ -44,6 +59,7 @@ class Repo: name: str url: str deps: List[str] + builder: Callable @click.group() @@ -54,19 +70,117 @@ def cli(): # map from environment name to currenct currmap = {"test": "TESTKUDOS", "demo": "KUDOS", "int": "INTKUDOS"} + +def update_checkout(p: Path): + """Clean the repository's working directory and + update it to the match the latest version of the upstream branch + that we are tracking.""" + subprocess.run(["git", "-C", p.as_posix(), "clean", "-fdx"], check=True) + subprocess.run(["git", "-C", p.as_posix(), "fetch"], check=True) + subprocess.run(["git", "-C", p.as_posix(), "reset"], check=True) + res = subprocess.run( + [ + "git", + "-C", + p.as_posix(), + "rev-parse", + "--abbrev-ref", + "--symbolic-full-name", + "@{u}", + ], + stderr=subprocess.DEVNULL, + stdout=subprocess.PIPE, + encoding="utf-8", + ) + if res.returncode != 0: + ref = "HEAD" + else: + ref = res.stdout.strip("\n ") + print(f"resetting to ref {ref}") + subprocess.run(["git", "-C", p.as_posix(), "reset", "--hard", ref], check=True) + + +def default_configure(*extra): + pfx = Path.home() / "local" + subprocess.run(["./configure", f"--prefix={pfx.as_posix}"] + extra, check=True) + + +def build_libmicrohttpd(p): + update_checkout(p) + subprocess.run(["./bootstrap"], check=True) + # Debian gnutls packages are too old ... + default_configure("--with-gnutls=/usr/local") + subprocess.run(["make"], check=True) + subprocess.run(["make", "install"], check=True) + + +def build_gnunet(p): + update_checkout(p) + + +def build_exchange(p): + update_checkout(p) + + +def build_twister(p): + update_checkout(p) + + +def build_merchant(p): + update_checkout(p) + + +def build_bank(p): + update_checkout(p) + + +def build_landing(p): + update_checkout(p) + + +def build_donations(p): + update_checkout(p) + + +def build_blog(p): + update_checkout(p) + + +def build_survey(p): + update_checkout(p) + + +def build_backoffice(p): + update_checkout(p) + + # 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", []), + Repo( + "libmicrohttpd", "git://gnunet.org/libmicrohttpd.git", [], build_libmicrohttpd + ), + Repo("gnunet", "git://gnunet.org/gnunet.git", [], build_gnunet), + Repo( + "exchange", + "git://git.taler.net/exchange", + ["gnunet", "libmicrohttpd"], + build_exchange, + ), + Repo( + "twister", "git://git.taler.net/twister", ["gnunet", "exchange"], build_twister + ), + Repo( + "merchant", + "git://git.taler.net/merchant", + ["exchange", "libmicrohttpd"], + build_merchant, + ), + Repo("bank", "git://git.taler.net/bank", [], build_bank), + Repo("landing", "git://git.taler.net/landing", [], build_landing), + Repo("donations", "git://git.taler.net/donations", [], build_donations), + Repo("blog", "git://git.taler.net/blog", [], build_blog), + Repo("survey", "git://git.taler.net/survey", [], build_survey), + Repo("backoffice", "git://git.taler.net/backoffice", [], build_backoffice), ] @@ -90,10 +204,6 @@ 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 @@ -136,6 +246,10 @@ def build(): update_repos() stale = get_stale_repos() print(f"found stale repos: {stale}") + for r in stale: + p = Path.home() / "sources" / r.name + p.chdir() + r.builder(p) @cli.command()