
import os


def install():
    print(("git submodule init"))
    print(os.system("git submodule init"))
    print(("git submodule update"))
    print(os.system("git submodule update"))
    print(("mkdir ./MP-SPDZ/Player-Data"))
    print(os.system("mkdir ./MP-SPDZ/Player-Data"))
    print(("apt-get install automake build-essential git libboost-dev libboost-thread-dev libsodium-dev libssl-dev libtool m4 python texinfo yasm"))
    print(os.system("apt-get install automake build-essential git libboost-dev libboost-thread-dev libsodium-dev libssl-dev libtool m4 python texinfo yasm"))
    print(("./MP-SPDZ/Scripts/tldr.sh"))
    print(os.system("./MP-SPDZ/Scripts/tldr.sh"))
    print(("cd MP-SPDZ && ls && make -j8 tldr"))
    print(os.system("cd MP-SPDZ && ls && make -j8 tldr"))
    print(("create Link from Player"))
    print(os.system("ln -s MP-SPDZ/Player-Data/ ."))
    print(("create Link from local"))
    print(os.system("ln -s MP-SPDZ/local/ ."))
    print(("create Link from Programs"))
    print(os.system("ln -s MP-SPDZ/Programs/ ."))
    print(("./MP-SPDZ/compile.py tutorial"))
    print(os.system("./MP-SPDZ/compile.py tutorial"))
    print(("cd MP-SPDZ && ls && make -j8 mascot-party"))
    print(os.system("cd MP-SPDZ && ls && make -j8 mascot"))
    print(("echo 1 2 3 4 > ./Player-Data/Input-P0-0"))
    print(os.system("echo 1 2 3 4 > ./Player-Data/Input-P0-0"))
    print(("echo 1 2 3 4 > ./Player-Data/Input-P1-0"))
    print(os.system("echo 1 2 3 4 > ./Player-Data/Input-P1-0"))
    print(("./MP-SPDZ/Scripts/mascot.sh tutorial"))
    print(os.system("./MP-SPDZ/Scripts/mascot.sh tutorial"))

    
    print(("\n"))
    os.system("cd tls/pycryptoMod && python setup.py install")
    a = os.popen('cd ./tls/pycryptoMod/build && ls').read()
    b = a.split("\n")
    if b[1].startswith("lib"):
        os.system("mv tls/pycryptoMod/build/"+b[1]+"/Crypto tls/")


def comp(a):
    print(("cp to Programs"))
    print(os.system("cp ./mpc/"+a+".mpc ./Programs/Source/"))
    print(("compile"))
    print(os.system("./MP-SPDZ/compile.py "+a))

def compCrypto(a):

    os.system("rm -rf tls/Crypto")
    os.system("cd tls/pycryptoMod && python setup.py install")
    a = os.popen('cd ./tls/pycryptoMod/build && ls').read()
    b = a.split("\n")
    if b[1].startswith("lib"):
        os.system("mv tls/pycryptoMod/build/"+b[1]+"/Crypto tls/")