QuasarAppCI/BuildBotLib/asssetsinstaller.py

116 lines
2.5 KiB
Python
Raw Normal View History

2019-12-13 16:09:43 +03:00
# This Python file uses the following encoding: utf-8
import BuildBotLib.basemodule as base
from buildbot.plugins import util, steps
import os
import shutil
2019-12-13 17:46:43 +03:00
import subprocess
2019-12-13 16:09:43 +03:00
2019-12-13 17:05:49 +03:00
LAST_FORMAT = [""]
2019-12-13 16:09:43 +03:00
@util.renderer
def NDKDownloadCMD(props):
2019-12-13 17:46:43 +03:00
link = props.getProperty("link")
2019-12-13 16:09:43 +03:00
module = props.getProperty("module")
2019-12-16 15:16:55 +03:00
dirpath = props.getProperty("builddir")
2019-12-13 16:09:43 +03:00
2019-12-16 15:36:39 +03:00
if os.path.exists(dirpath + "/" + module):
2019-12-16 15:16:55 +03:00
shutil.rmtree(dirpath + "/" + module)
2019-12-13 16:09:43 +03:00
res = []
2019-12-13 17:00:59 +03:00
format = link[link.rfind('.'):].lower()
2019-12-13 17:05:49 +03:00
LAST_FORMAT[0] = format
2019-12-13 16:09:43 +03:00
if module == "AndroidNDK":
2019-12-16 15:36:39 +03:00
if os.path.exists(dirpath + "/temp" + format):
2019-12-16 15:16:55 +03:00
os.remove(dirpath + "/temp" + format)
2019-12-13 16:42:47 +03:00
res = ["curl", link, "--output", "temp" + format]
2019-12-13 16:37:22 +03:00
2019-12-13 16:09:43 +03:00
return res
@util.renderer
def ExtractCMD(props):
2019-12-13 17:05:49 +03:00
format = LAST_FORMAT[0]
2019-12-13 16:09:43 +03:00
module = props.getProperty("module")
2019-12-13 16:39:15 +03:00
res = ["echo", "format '" + format + "' not supported"]
2019-12-13 16:09:43 +03:00
2019-12-13 16:48:52 +03:00
if format == ".zip":
2019-12-13 17:15:39 +03:00
res = ["unzip", "temp" + format, "-d", module]
2019-12-13 16:39:15 +03:00
2019-12-16 15:11:58 +03:00
return res
@util.renderer
def ConfigureCMD(props):
format = LAST_FORMAT[0]
module = props.getProperty("module")
res = ["echo", "Configure " + module + " failed"]
if format == ".zip":
2019-12-16 14:49:30 +03:00
dirpath = props.getProperty("builddir")
all_subdirs = base.allSubdirsOf(dirpath + "/" + module)
2019-12-13 18:08:57 +03:00
latest_subdir = max(all_subdirs, key=os.path.getmtime)
2019-12-16 14:49:30 +03:00
subprocess.getoutput(["ln -sf " + latest_subdir + " " +
dirpath + "/current"])
2019-12-13 17:46:43 +03:00
2019-12-16 15:11:58 +03:00
res = ["echo", "Configure " + module]
2019-12-13 16:09:43 +03:00
return res
def getFactory():
2019-12-13 17:46:43 +03:00
factory = base.getFactory()
2019-12-13 16:09:43 +03:00
factory.addStep(
2019-12-13 17:46:43 +03:00
steps.ShellCommand(
command=NDKDownloadCMD,
name='download new item',
description='download new item',
2019-12-13 16:09:43 +03:00
)
2019-12-13 17:46:43 +03:00
)
2019-12-13 16:09:43 +03:00
factory.addStep(
2019-12-13 17:46:43 +03:00
steps.ShellCommand(
command=ExtractCMD,
name='extract new item',
description='extract new item',
2019-12-13 16:09:43 +03:00
)
2019-12-13 17:46:43 +03:00
)
2019-12-13 16:09:43 +03:00
2019-12-16 15:11:58 +03:00
factory.addStep(
steps.ShellCommand(
command=ConfigureCMD,
name='configure new item',
description='configure new item',
)
)
2019-12-13 16:09:43 +03:00
return factory
def getRepo():
2019-12-13 17:46:43 +03:00
return ""
2019-12-13 16:09:43 +03:00
def getPropertyes():
return [
util.ChoiceStringParameter(
2019-12-13 17:46:43 +03:00
name='module',
2019-12-13 16:09:43 +03:00
choices=["AndroidNDK", "AndroidSDK"],
2019-12-13 17:46:43 +03:00
default="AndroidNDK"
),
util.StringParameter(
name='link',
label="url to download item",
default=""
2019-12-13 16:09:43 +03:00
),
]