Exemplo n.º 1
0
def main():
    # Start reactor
    thr = _start_reactor()
    
    # stop all
    util.shutdownall()
    
    # Establish libvirt connections and start reactor
    clone.init()
    
    # Remove everything in delete list
    for to_delete in conf_domains.to_delete_domains(): 
        clone.delete(to_delete)
    
    # Get domain specs to clone
    to_clone_domains = conf_domains.to_clone_domains()
    
    # Schedule all clone entries
    index = 0
    for to_clone in to_clone_domains:
        exitHere = to_clone == to_clone_domains[-1]
        if exitHere: 
            exitHere = lambda: reactor.stop()
        else:
            exitHere = None
            
        clone.clone(to_clone.clone_source, to_clone.name, index, exitHere, False)
        index += 1
    
    # Wait for exit
    print 'Waiting for clone process...'
    thr.join()
    print 'Exiting'
Exemplo n.º 2
0
def handle_depends_include(depends, extra_includes):
    for depend in depends:
        is_root_repo = True
        if sp_pak_type:
            if depend in sp_pak_type:
                dep = sp_pak_type[depend]
                dep_path = get_dep_path(depend)
                is_root_repo = False
                url = dep["url"]
                branch = "master"
                if "branch" in dep:
                    branch = dep["branch"]
                if "git" in url:
                    if not args.nc:
                        clone.clone(url, dep_path, branch)
                    if "path_map" in dep:
                        path_map = dep["path_map"]
                        if "addons/sourcemod/scripting/include" in path_map:
                            extra_includes += [
                                os.path.join(
                                    dep_path, path_map[
                                        "addons/sourcemod/scripting/include"])
                            ]
                else:
                    clone.handle_wget(url, dep_path)
                    extra_includes += [dep_path]
        if is_root_repo:
            extra_includes += [
                os.path.join(cwd, depend, "addons/sourcemod/scripting/include")
            ]
Exemplo n.º 3
0
def main():
    """
        The main function of the program if an argument is given it will recognize it and execute the proper function.\n

        If no argument is provided it will show a menu with all the available options to the user.
    """
    arguments = len(sys.argv) - 1

    if arguments == 0:
        os.system('clear')
        print(
            'What you want to do?\n'
            '\n1) Generate XML // 2) Start server // 3) Clone // 4) Help // 5) List devices options // 6) Exit\n'
        )
        choose = input("Selection: ")
        os.system('clear')
        if choose == "1":
            genxml()
        elif choose == "2":
            server()
        elif choose == "3":
            clone()
        elif choose == "4":
            show_help()
        elif choose == "5":
            show_devices()
        else:
            BYE()
    else:
        try:
            # Checks the arguments provided to see if are valid.
            arguments, _ = getopt.getopt(argument_list, short_options,
                                         long_options)
        except getopt.error:
            exit()

        # Loop through the arguments checking for matches if the argument received is not
        # listed it will return an eror and exit the program
        for current_argument, _ in arguments:
            if current_argument in ("-h", "--help"):
                show_help()
            if current_argument in ("-g", "--genxml"):
                genxml()
            if current_argument in ("-s", "--server"):
                server()
            if current_argument in ("-c", "--clone"):
                clone()
            if current_argument in ("-l", "--list"):
                show_devices()
Exemplo n.º 4
0
def clone_repo(repo):
    url = repo[0]
    name = os.path.splitext(os.path.basename(url))[0]
    branch = "master"
    recursive = True
    if len(repo) >= 4:
        recursive = repo[3]
    if len(repo) >= 3:
        name = repo[2]
    if len(repo) >= 2:
        branch = repo[1]
    path = ""
    if "SVB-" in name:
        path = os.path.join(cwd, name)
    else:
        path = os.path.join(sources, name)
    clone.clone(url, path, branch, recursive)
Exemplo n.º 5
0
from logging import setLogRecordFactory
from kivy.app import App
from numpy.lib.function_base import select
from pitch import pitch
from clone import clone
from threading import Lock,Thread
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.core.window import Window
Window.size = (320, 240)
pitchObj = pitch()
cloneObj = clone()

class MainWindow(Screen):   
    pass


class PitchWindow(Screen):
    prevSlider = 0
    pitchThread = None
        

    def on_enter(self):  
        self.pitchThread = Thread(target=pitch.modulate, args=(pitchObj,self))
        self.pitchThread.start()

    def on_pre_leave(self): 
        pitchObj.stop()
    
    def pitchChange(self, slider):
        if slider!=self.prevSlider:
Exemplo n.º 6
0
 def clone(self):
     """Builds a new local working copy by cloning a folder from an already inited
        remote folder in a container."""
     
     clone(self)
Exemplo n.º 7
0
    def clone(self):
        """Builds a new local working copy by cloning a folder from an already inited
           remote folder in a container."""

        clone(self)
Exemplo n.º 8
0
def build(srcpkg, outdir, package, jobid, logfile, arch):
    logging.info('building %s to %s' % (os.path.basename(srcpkg), outdir))

    steptimer.start()
    vmid = 'buildvm_%d' % jobid

    # open a libvirt connection to hypervisor
    libvirt.virInitialize()
    libvirt.virEventRegisterDefaultImpl()
    conn = libvirt.open('qemu:///system')
    if conn == None:
        logging.error('Failed to open connection to the hypervisor')
        return False

    # create VM
    clone_storage = clone(conn, BASE_VMID[arch], vmid)
    steptimer.mark('clone vm')

    domain = conn.lookupByName(vmid)

    # start vm, automatically clean up when we are done, unless debugging
    domain.createWithFlags(libvirt.VIR_DOMAIN_START_AUTODESTROY if not debug else 0)

    # wait for vm to boot up
    wait_for_guest_agent(conn, domain, 5*60)
    guestPing(domain)

    steptimer.mark('boot')

    # ensure directory exists and is empty
    guestExec(domain, 'cmd', ['/C', 'rmdir', '/S', '/Q', r'C:\\vm_in\\'])
    guestExec(domain, 'cmd', ['/C', 'mkdir', r'C:\\vm_in\\'])

    # install build instructions and source
    for f in ['build.sh', 'wrapper.sh', srcpkg]:
        guestFileCopyTo(domain, f, r'C:\\vm_in\\' + os.path.basename(f))

    if package.depends:
        guestFileWrite(domain, r'C:\\vm_in\\depends', bytes(package.depends, 'ascii'))

    steptimer.mark('put')

    # attempt the build
    success = guestExec(domain, bash_path[arch], ['-l','/cygdrive/c/vm_in/wrapper.sh', os.path.basename(srcpkg), r'C:\\vm_out', package.script, package.kind])
    steptimer.mark('build')

    # XXX: guest-agent doesn't seem to be capable of capturing output of cygwin
    # process (for some strange reason), so we arrange to redirect it to a file
    # and collect it here...
    guestFileCopyFrom(domain, r'C:\\vm_in\\output', logfile)
    logging.info('build logfile is %s' % (logfile))

    # if the build was successful, fetch build products from VM
    if success:
        os.makedirs(outdir, exist_ok=True)
        manifest = os.path.join(outdir, 'manifest')
        guestFileCopyFrom(domain, r'C:\\vm_out\\manifest', manifest)

        with open(manifest) as f:
            for l in f:
                l = l.strip()
                fn = os.path.join(outdir, l)
                os.makedirs(os.path.dirname(fn), exist_ok=True)
                winpath = l.replace('/',r'\\')
                guestFileCopyFrom(domain, r'C:\\vm_out\\' + winpath, fn)

    steptimer.mark('fetch')

    if not debug:
        # terminate the VM.  Don't bother giving it a chance to shut down
        # cleanly since we won't be using it again
        domain.destroy()

        # clean up VM
        domain.undefineFlags(libvirt.VIR_DOMAIN_UNDEFINE_MANAGED_SAVE |
                             libvirt.VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA |
                             libvirt.VIR_DOMAIN_UNDEFINE_NVRAM)
        os.remove(clone_storage)
        steptimer.mark('destroy vm')

    status = 'succeeded' if success else 'failed'
    logging.info('build %s, %s' % (status, steptimer.report()))

    return success
Exemplo n.º 9
0
def handle_ext(ext):
    repo = None
    steamworks_dir = os.path.join(sources, "steamworks_sdk")
    if ext == "SteamWorks":
        if not os.path.exists(os.path.join(steamworks_dir, "sdk")):
            #url="https://partner.steamgames.com/downloads/steamworks_sdk.zip"
            #clone.handle_wget(url, steamworks_dir)
            #name = os.path.basename(url)
            name = "steamworks_sdk_148a.zip"
            zip = os.path.join(steamworks_dir, name)
            if not os.path.exists(zip):
                print("tem q baixar o sdk separado no url acima")
                exit(1)
            os.chdir(steamworks_dir)
            subprocess.run("unzip -q \"" + zip + "\"",
                           shell=True,
                           cwd=os.getcwd())

        repo = ("https://github.com/KyleSanderson/SteamWorks.git", )
    elif ext == "metamod-source":
        repo = ("https://github.com/alliedmodders/metamod-source.git", )
    elif ext == "sourcemod":
        repo = ("https://github.com/alliedmodders/sourcemod.git", "master",
                "sourcemod", False)
    elif ext == "sendproxy":
        repo = ("https://github.com/TheByKotik/sendproxy.git", )
    elif ext == "sm-ripext":
        repo = ("https://github.com/ErikMinekus/sm-ripext.git", )
    elif ext == "TF2Items":
        repo = ("https://github.com/asherkin/TF2Items.git", )
    elif ext == "DHooks2":
        repo = (
            "https://github.com/peace-maker/DHooks2.git",
            "dynhooks",
        )
    elif ext == "SVB-RandomMap":
        repo = ("https://github.com/ServerDosBrothers/SVB-RandomMap.git", )
    elif ext == "SVB-Telephone":
        repo = ("https://github.com/ServerDosBrothers/SVB-Telephone.git", )
    elif ext == "FileNetMessages":
        repo = ("https://github.com/Accelerator74/FileNetMessages.git", )
    elif ext == "latedl":
        repo = ("https://github.com/jonatan1024/latedl.git", )
    elif ext == "SVB-Vtflib":
        repo = ("https://github.com/ServerDosBrothers/SVB-Vtflib.git", )
    elif ext == "System2":
        repo = ("https://github.com/dordnung/System2.git", )
    elif ext == "l4dtoolz":
        repo = ("https://github.com/ivailosp/l4dtoolz.git", )
    elif ext == "Left4Downtown2":
        repo = ("https://github.com/Attano/Left4Downtown2.git", )
    elif ext == "SMJansson":
        repo = ("https://github.com/thraaawn/SMJansson.git", )

    if repo is None:
        return

    clone_repo(repo)

    sourcemod_src_dir = os.path.join(sources, "sourcemod")

    if ext == "sourcemod":
        sourcepawn_src_dir = os.path.join(sourcemod_src_dir, "sourcepawn")
        #shutil.rmtree(sourcepawn_src_dir,ignore_errors=True)
        clone.clone("https://github.com/alliedmodders/sourcepawn.git",
                    sourcepawn_src_dir,
                    recursive=False)
        amtl_src_dir = os.path.join(sourcepawn_src_dir, "third_party/amtl")
        #shutil.rmtree(amtl_src_dir,ignore_errors=True)
        clone.clone("https://github.com/alliedmodders/amtl.git",
                    amtl_src_dir,
                    recursive=False)
        amtl_src_dir = os.path.join(sourcemod_src_dir, "public/amtl")
        #shutil.rmtree(amtl_src_dir,ignore_errors=True)
        clone.clone("https://github.com/alliedmodders/amtl.git",
                    amtl_src_dir,
                    recursive=False)

    mmsource_src_dir = os.path.join(sources, "metamod-source")
    if args.L4D2:
        hl2sdk_dir = os.path.join(sources, "hl2sdk-l4d2")
    else:
        hl2sdk_dir = os.path.join(sources, "hl2sdk-tf2")

    sourcemod_bin_dir = os.path.join(game, "addons/sourcemod")

    os.environ["SRCDS_BASE"] = str(pathlib.Path(game).parent)

    os.environ["SOURCEMOD14"] = sourcemod_src_dir
    os.environ["SOURCEMOD16"] = sourcemod_src_dir
    os.environ["SOURCEMOD"] = sourcemod_src_dir
    os.environ["SMCENTRAL"] = sourcemod_src_dir
    os.environ["SMSDK"] = sourcemod_src_dir

    os.environ["SOURCEMOD_BINS"] = sourcemod_bin_dir

    os.environ["MMSOURCE19"] = mmsource_src_dir
    os.environ["MMSOURCE18"] = mmsource_src_dir
    os.environ["MMSOURCE10"] = mmsource_src_dir
    os.environ["MMSOURCE110"] = mmsource_src_dir
    os.environ["MMSOURCE_DEV"] = mmsource_src_dir
    os.environ["MMSOURCE"] = mmsource_src_dir

    os.environ["HL2SDK"] = hl2sdk_dir
    os.environ["HL2SDK_ORIG"] = hl2sdk_dir
    os.environ["HL2SDKOB"] = hl2sdk_dir
    os.environ["HL2SDK_OB"] = hl2sdk_dir
    os.environ["HL2SDKOBVALVE"] = hl2sdk_dir
    os.environ["HL2SDK_OB_VALVE"] = hl2sdk_dir
    os.environ["HL2SDK2013"] = hl2sdk_dir

    if args.L4D2:
        os.environ["ENGINE"] = "left4dead2"
        os.environ["HL2SDKL4D2"] = hl2sdk_dir
        os.environ["HL2SDK_L4D2"] = hl2sdk_dir
    else:
        os.environ["ENGINE"] = "orangeboxvalve"
        os.environ["HL2SDKTF2"] = hl2sdk_dir
        os.environ["HL2SDK_TF2"] = hl2sdk_dir

    os.environ["STEAMWORKS"] = os.path.join(steamworks_dir, "sdk")

    os.environ["CC"] = "gcc"
    os.environ["CXX"] = "g++"
    os.environ[
        "CFLAGS"] = "-w -Wno-error -Wno-format-truncation -Wno-stringop-overflow -Wno-stringop-truncation -Wno-expansion-to-defined -Wno-address-of-packed-member "
    os.environ["CXXFLAGS"] = "-fpermissive -Wno-class-memaccess "

    os.chdir(os.path.join(sources, "ambuild"))
    #subprocess.run("sudo python setup.py install",shell=True,cwd=os.getcwd(),env=os.environ)
    #subprocess.run("pip install .",shell=True,cwd=os.getcwd(),env=os.environ)

    optimize_flag = "--enable-debug" if debug else "--enable-optimize"

    if args.L4D2:
        base_args = "--sdks=l4d2 "
    else:
        base_args = "--sdks=tf2 "

    base_args += optimize_flag + " --hl2sdk-root=\"" + sources + "\" "
    base_args_ext = base_args + "--mms-path=\"" + mmsource_src_dir + "\" --sm-path=\"" + sourcemod_src_dir + "\" "
    base_args_ext_nogame = optimize_flag + " --mms-path=\"" + mmsource_src_dir + "\" --sm-path=\"" + sourcemod_src_dir + "\" "
    base_args_ext_nogame_nometa = optimize_flag + " --sm-path=\"" + sourcemod_src_dir + "\""

    if ext == "sourcemod":
        os.chdir(sourcemod_src_dir)
        build_ambuild2(base_args + "--mms-path=\"" + mmsource_src_dir +
                       "\" --no-mysql --disable-auto-versioning")
        package.copy_folder(os.path.join(sourcemod_src_dir, "build/package"),
                            game)
    elif ext == "metamod-source":
        os.chdir(mmsource_src_dir)
        build_ambuild2(base_args)
        package.copy_folder(os.path.join(mmsource_src_dir, "build/package"),
                            game)
    elif ext == "sendproxy":
        sendproxy_src_dir = os.path.join(sources, "sendproxy")
        os.chdir(os.path.join(sendproxy_src_dir, "extension"))
        build_ambuild2(base_args_ext)
        package.copy_folder(
            os.path.join(sendproxy_src_dir, "addons/sourcemod/gamedata"),
            os.path.join(game, "addons/sourcemod/gamedata"))
        package.copy_folder(
            os.path.join(sendproxy_src_dir, "extension/build/package"), game)
    elif ext == "sm-ripext":
        sm_ripext_src_dir = os.path.join(sources, "sm-ripext")
        os.chdir(sm_ripext_src_dir)
        build_ambuild2(base_args_ext)
        package.copy_folder(os.path.join(sm_ripext_src_dir, "build/package"),
                            game)
    elif ext == "TF2Items":
        tf2items_src_dir = os.path.join(sources, "TF2Items")
        os.chdir(tf2items_src_dir)
        build_ambuild1(optimize_flag)
        package.copy_folder(os.path.join(tf2items_src_dir, "build/package"),
                            game)
    elif ext == "SteamWorks":
        steamworks_src_dir = os.path.join(sources, "SteamWorks")
        os.chdir(steamworks_src_dir)
        if args.L4D2:
            build_ambuild2(
                base_args_ext.replace("--sdks=l4d2", "--sdks=sdk2013"))
        else:
            build_ambuild2(
                base_args_ext.replace("--sdks=tf2", "--sdks=sdk2013"))
        package.copy_folder(os.path.join(steamworks_src_dir, "build/package"),
                            game)
    elif ext == "DHooks2":
        dhooks_src_dir = os.path.join(sources, "DHooks2")
        os.chdir(dhooks_src_dir)
        build_ambuild2(base_args_ext_nogame)
        package.copy_folder(os.path.join(dhooks_src_dir, "build/package"),
                            game)
    elif ext == "SVB-RandomMap":
        random_src_dir = os.path.join(cwd, "SVB-RandomMap")
        os.chdir(random_src_dir)
        build_ambuild2(base_args)
        package.copy_folder(os.path.join(random_src_dir, "build/package"),
                            game)
    elif ext == "SVB-Telephone":
        telephone_src_dir = os.path.join(cwd, "SVB-Telephone")
        os.chdir(telephone_src_dir)
        build_ambuild2(base_args_ext_nogame_nometa)
        package.copy_folder(os.path.join(telephone_src_dir, "build/package"),
                            game)
    elif ext == "FileNetMessages":
        filenet_src_dir = os.path.join(sources, "FileNetMessages")
        os.chdir(filenet_src_dir)
        subprocess.run("make -j4", shell=True, cwd=os.getcwd())
        if args.L4D2:
            package.copy_folder(
                os.path.join(
                    filenet_src_dir,
                    "Release.left4dead2/filenetmessages.ext.2.l4d2.so"),
                os.path.join(game, "addons/sourcemod/extensions"))
        else:
            package.copy_folder(
                os.path.join(
                    filenet_src_dir,
                    "Release.orangeboxvalve/filenetmessages.ext.2.ep2v.so"),
                os.path.join(game, "addons/sourcemod/extensions"))
    elif ext == "latedl":
        latedl_src_dir = os.path.join(sources, "latedl")
        os.chdir(latedl_src_dir)
        build_ambuild2(base_args_ext)
        package.copy_folder(os.path.join(latedl_src_dir, "build/package"),
                            game)
    elif ext == "SVB-Vtflib":
        vtflib_src_dir = os.path.join(cwd, "SVB-Vtflib")
        os.chdir(vtflib_src_dir)
        build_ambuild2(base_args_ext)
        package.copy_folder(os.path.join(vtflib_src_dir, "build/package"),
                            game)
    elif ext == "System2":
        print(
            "eu esqueci pq desisti de faze o system2 compila vc tem q baixa manual"
        )
    elif ext == "l4dtoolz":
        l4dz_src_dir = os.path.join(sources, "l4dtoolz")
        os.chdir(l4dz_src_dir)
        subprocess.run("make -j4", shell=True, cwd=os.getcwd())
        package.copy_folder(
            os.path.join(l4dz_src_dir,
                         "Release.left4dead2/l4dtoolz_mm_i486.so"),
            os.path.join(game, "addons"))
        package.copy_folder(os.path.join(l4dz_src_dir, "l4dtoolz.vdf"),
                            os.path.join(game, "addons/metamod"))
    elif ext == "Left4Downtown2":
        os.environ["USE_PLAYERSLOTS"] = "false"
        l4dr_src_dir = os.path.join(sources, "Left4Downtown2")
        os.chdir(l4dr_src_dir)
        subprocess.run("make -j4", shell=True, cwd=os.getcwd())
        package.copy_folder(
            os.path.join(l4dr_src_dir, "Release/left4downtown.ext.2.l4d2.so"),
            os.path.join(game, "addons/sourcemod/extensions"))
        package.copy_folder(os.path.join(l4dr_src_dir, "scripting"),
                            os.path.join(game, "addons/sourcemod/scripting"))
        package.copy_folder(os.path.join(l4dr_src_dir, "gamedata"),
                            os.path.join(game, "addons/sourcemod/gamedata"))
    elif ext == "SMJansson":
        print(
            "eu esqueci pq eu nunca fiz o smjansson compila se vira pra acha")
        pass