From 06e9a04357984777ec40bd56dcc30c5a42e96868 Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Fri, 11 Sep 2020 16:33:21 -0700 Subject: [PATCH] install: update reinstall to account for local installs as well --- tasks.py | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/tasks.py b/tasks.py index 4b858465..43ba186c 100644 --- a/tasks.py +++ b/tasks.py @@ -397,10 +397,11 @@ def install_emane(c, verbose=False, local=False): help={ "dev": "uninstall development mode", "verbose": "enable verbose", + "local": "determines if core was installed local to system, default is False", "prefix": f"prefix where scripts are installed, default is {DEFAULT_PREFIX}" }, ) -def uninstall(c, dev=False, verbose=False, prefix=DEFAULT_PREFIX): +def uninstall(c, dev=False, verbose=False, local=False, prefix=DEFAULT_PREFIX): """ uninstall core, scripts, service, virtual environment, and clean build directory """ @@ -415,14 +416,18 @@ def uninstall(c, dev=False, verbose=False, prefix=DEFAULT_PREFIX): c.run("make clean", hide=hide) c.run("./bootstrap.sh clean", hide=hide) - python = get_python(c, warn=True) - if python: - with c.cd(DAEMON_DIR): - if dev: - with p.start("uninstalling pre-commit"): - c.run("poetry run pre-commit uninstall", hide=hide) - with p.start("uninstalling poetry virtual environment"): - c.run(f"poetry env remove {python}", hide=hide) + if local: + with p.start("uninstalling core"): + c.run("sudo python3 -m pip uninstall -y core") + else: + python = get_python(c, warn=True) + if python: + with c.cd(DAEMON_DIR): + if dev: + with p.start("uninstalling pre-commit"): + c.run("poetry run pre-commit uninstall", hide=hide) + with p.start("uninstalling poetry virtual environment"): + c.run(f"poetry env remove {python}", hide=hide) # remove installed files bin_dir = Path(prefix).joinpath("bin") @@ -432,10 +437,11 @@ def uninstall(c, dev=False, verbose=False, prefix=DEFAULT_PREFIX): c.run(f"sudo rm -f {dest}", hide=hide) # remove core-python symlink - core_python = bin_dir.joinpath("core-python") - c.run(f"sudo rm -f {core_python}", hide=hide) + if not local: + core_python = bin_dir.joinpath("core-python") + c.run(f"sudo rm -f {core_python}", hide=hide) - # install service + # remove service systemd_dir = Path("/lib/systemd/system/") service_name = "core-daemon.service" service_file = systemd_dir.joinpath(service_name) @@ -460,7 +466,7 @@ def reinstall( """ run the uninstall task, get latest from specified branch, and run install task """ - uninstall(c, dev, verbose, prefix) + uninstall(c, dev, verbose, local, prefix) hide = not verbose p = Progress(verbose) with p.start("pulling latest code"):