# -*- coding: utf-8 -*-
from setuphelpers import *

app_dir="/opt/tea"

def install():
    # Declare local variables
    binary = glob.glob(rf"tea*-linux*")[0]

    # Delete older version
    if isdir(app_dir):
        remove_tree(app_dir)

    mkdirs(app_dir)
    filecopyto(rf"{basedir}/{binary}",rf"{app_dir}/{binary}")

    print(f"Creating {binary} alias in path")
    os.symlink(rf"{app_dir}/{binary}", rf"/usr/local/bin/{binary}")

def uninstall():
    # Removing of symlink
    bin_path = glob.glob(rf"/usr/local/bin/tea*-linux*")[0]
    if isfile(bin_path) or os.path.islink(bin_path):
        remove_file(bin_path)
        
    # Removing of the software 
    if isdir(app_dir):
        remove_tree(app_dir)