added developer and verbose flags to poetry install
This commit is contained in:
parent
d4ac9e618f
commit
8357cddbab
2 changed files with 55 additions and 30 deletions
24
install2.sh
24
install2.sh
|
@ -10,6 +10,28 @@ if [[ -f /etc/os-release ]]; then
|
||||||
os=${ID}
|
os=${ID}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# parse arguments
|
||||||
|
dev=""
|
||||||
|
verbose=""
|
||||||
|
while getopts "drv:" opt; do
|
||||||
|
case ${opt} in
|
||||||
|
d)
|
||||||
|
dev="-d"
|
||||||
|
;;
|
||||||
|
v)
|
||||||
|
verbose="-v"
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
echo "script usage: $(basename $0) [-d] [-v]" >&2
|
||||||
|
echo "" >&2
|
||||||
|
echo "-v enable verbose install" >&2
|
||||||
|
echo "-d enable developer install" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
echo "installing CORE for ${os}"
|
echo "installing CORE for ${os}"
|
||||||
case ${os} in
|
case ${os} in
|
||||||
"ubuntu")
|
"ubuntu")
|
||||||
|
@ -27,4 +49,4 @@ python3 -m pip install --user pipx
|
||||||
python3 -m pipx ensurepath
|
python3 -m pipx ensurepath
|
||||||
export PATH=$PATH:~/.local/bin
|
export PATH=$PATH:~/.local/bin
|
||||||
pipx install invoke
|
pipx install invoke
|
||||||
inv install
|
inv install $(dev) $(verbose)
|
||||||
|
|
61
tasks.py
61
tasks.py
|
@ -56,80 +56,83 @@ def get_os() -> OsInfo:
|
||||||
return OsInfo(name, like, version)
|
return OsInfo(name, like, version)
|
||||||
|
|
||||||
|
|
||||||
def install_system(c: Context, os_info: OsInfo) -> None:
|
def install_system(c: Context, os_info: OsInfo, hide: bool) -> None:
|
||||||
print("installing system dependencies...")
|
print("installing system dependencies...")
|
||||||
if os_info.like == OsLike.DEBIAN:
|
if os_info.like == OsLike.DEBIAN:
|
||||||
c.run(
|
c.run(
|
||||||
"sudo apt install -y automake pkg-config gcc libev-dev ebtables iproute2 "
|
"sudo apt install -y automake pkg-config gcc libev-dev ebtables iproute2 "
|
||||||
"ethtool tk python3-tk", hide=True
|
"ethtool tk python3-tk", hide=hide
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def install_grpcio(c: Context) -> None:
|
def install_grpcio(c: Context, hide: bool) -> None:
|
||||||
print("installing grpcio-tools...")
|
print("installing grpcio-tools...")
|
||||||
c.run("python3 -m pip install --user grpcio-tools", hide=True)
|
c.run("python3 -m pip install --user grpcio-tools", hide=hide)
|
||||||
|
|
||||||
|
|
||||||
def build(c: Context) -> None:
|
def build(c: Context, hide: bool) -> None:
|
||||||
print("building core...")
|
print("building core...")
|
||||||
c.run("./bootstrap.sh", hide=True)
|
c.run("./bootstrap.sh", hide=hide)
|
||||||
c.run("./configure", hide=True)
|
c.run("./configure", hide=hide)
|
||||||
c.run("make -j", hide=True)
|
c.run("make -j", hide=hide)
|
||||||
|
|
||||||
|
|
||||||
def install_core(c: Context) -> None:
|
def install_core(c: Context, hide: bool) -> None:
|
||||||
print("installing vcmd...")
|
print("installing vcmd...")
|
||||||
with c.cd(VCMD_DIR):
|
with c.cd(VCMD_DIR):
|
||||||
c.run("sudo make install", hide=True)
|
c.run("sudo make install", hide=hide)
|
||||||
print("installing gui...")
|
print("installing gui...")
|
||||||
with c.cd(GUI_DIR):
|
with c.cd(GUI_DIR):
|
||||||
c.run("sudo make install", hide=True)
|
c.run("sudo make install", hide=hide)
|
||||||
|
|
||||||
|
|
||||||
def install_poetry(c: Context, dev: bool) -> None:
|
def install_poetry(c: Context, dev: bool, hide: bool) -> None:
|
||||||
print("installing poetry...")
|
print("installing poetry...")
|
||||||
c.run("pipx install poetry", hide=True)
|
c.run("pipx install poetry", hide=hide)
|
||||||
args = "" if dev else "--no-dev"
|
args = "" if dev else "--no-dev"
|
||||||
with c.cd(DAEMON_DIR):
|
with c.cd(DAEMON_DIR):
|
||||||
print("installing core environment using poetry...")
|
print("installing core environment using poetry...")
|
||||||
c.run(f"poetry install {args}", hide=True)
|
c.run(f"poetry install {args}", hide=hide)
|
||||||
if dev:
|
if dev:
|
||||||
c.run("poetry run pre-commit install")
|
c.run("poetry run pre-commit install")
|
||||||
|
|
||||||
|
|
||||||
def install_ospf_mdr(c: Context, os_info: OsInfo) -> None:
|
def install_ospf_mdr(c: Context, os_info: OsInfo, hide: bool) -> None:
|
||||||
if c.run("which zebra"):
|
if c.run("which zebra", warn=True, hide=hide):
|
||||||
print("quagga already installed, skipping ospf mdr")
|
print("quagga already installed, skipping ospf mdr")
|
||||||
return
|
return
|
||||||
if os_info.like == OsLike.DEBIAN:
|
if os_info.like == OsLike.DEBIAN:
|
||||||
c.run("sudo apt install -y libtool gawk libreadline-dev")
|
c.run("sudo apt install -y libtool gawk libreadline-dev", hide=hide)
|
||||||
clone_dir = "/tmp/ospf-mdr"
|
clone_dir = "/tmp/ospf-mdr"
|
||||||
c.run(
|
c.run(
|
||||||
f"git clone https://github.com/USNavalResearchLaboratory/ospf-mdr {clone_dir}"
|
f"git clone https://github.com/USNavalResearchLaboratory/ospf-mdr {clone_dir}",
|
||||||
|
hide=hide
|
||||||
)
|
)
|
||||||
with c.cd(clone_dir):
|
with c.cd(clone_dir):
|
||||||
c.run("./bootstrap.sh")
|
c.run("./bootstrap.sh", hide=hide)
|
||||||
c.run(
|
c.run(
|
||||||
"./configure --disable-doc --enable-user=root --enable-group=root "
|
"./configure --disable-doc --enable-user=root --enable-group=root "
|
||||||
"--with-cflags=-ggdb --sysconfdir=/usr/local/etc/quagga --enable-vtysh "
|
"--with-cflags=-ggdb --sysconfdir=/usr/local/etc/quagga --enable-vtysh "
|
||||||
"--localstatedir=/var/run/quagga"
|
"--localstatedir=/var/run/quagga",
|
||||||
|
hide=hide
|
||||||
)
|
)
|
||||||
c.run("make -j")
|
c.run("make -j", hide=hide)
|
||||||
c.run("sudo make install")
|
c.run("sudo make install", hide=hide)
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def install(c, dev=False):
|
def install(c, dev=False, verbose=False):
|
||||||
"""
|
"""
|
||||||
install core
|
install core
|
||||||
"""
|
"""
|
||||||
|
hide = not verbose
|
||||||
os_info = get_os()
|
os_info = get_os()
|
||||||
install_system(c, os_info)
|
install_system(c, os_info, hide)
|
||||||
install_grpcio(c)
|
install_grpcio(c, hide)
|
||||||
build(c)
|
build(c, hide)
|
||||||
install_core(c)
|
install_core(c, hide)
|
||||||
install_poetry(c, dev)
|
install_poetry(c, dev, hide)
|
||||||
install_ospf_mdr(c, os_info)
|
install_ospf_mdr(c, os_info, hide)
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
|
|
Loading…
Reference in a new issue