support: move info about support pkg from python script to deps.cmake

This is a variable info about RetDec dependency, so move it to other deps.
This commit is contained in:
Matula Peter 2020-01-29 15:17:51 +01:00
parent 6e1ddea7aa
commit 415bf17005
3 changed files with 15 additions and 21 deletions

View File

@ -42,3 +42,10 @@ set(YARAMOD_URL
CACHE STRING "URL of YaraMod archive to use."
)
set(YARAMOD_ARCHIVE_SHA256 "f40c168996e9a137cfd4d83181b05bb92d8b1c4615aad923b48ab13f2aca1129")
set(SUPPORT_PKG_URL
"https://github.com/avast/retdec-support/releases/download/2019-03-08/retdec-support_2019-03-08.tar.xz"
CACHE STRING "URL of RetDec support package to use."
)
set(SUPPORT_PKG_SHA256 "629351609bca0f4b8edbd4e53789192305256aeb908e953f5546e121a911d54e")
set(SUPPORT_PKG_VERSION "2019-03-08")

View File

@ -22,7 +22,7 @@ endif()
install(CODE "
execute_process(
# -u = unbuffered -> print debug messages right away.
COMMAND \"${PYTHON_EXECUTABLE}\" -u \"${CMAKE_SOURCE_DIR}/support/install-share.py\" \"${CMAKE_INSTALL_PREFIX}\"
COMMAND \"${PYTHON_EXECUTABLE}\" -u \"${CMAKE_SOURCE_DIR}/support/install-share.py\" \"${CMAKE_INSTALL_PREFIX}\" \"${SUPPORT_PKG_URL}\" \"${SUPPORT_PKG_SHA256}\" \"${SUPPORT_PKG_VERSION}\"
RESULT_VARIABLE INSTALL_SHARE_RES
)
if(INSTALL_SHARE_RES)

View File

@ -11,38 +11,27 @@ import shutil
import tarfile
import urllib.request
###############################################################################
version_filename = 'version.txt'
arch_suffix = 'tar.xz'
sha256hash_ref = '629351609bca0f4b8edbd4e53789192305256aeb908e953f5546e121a911d54e'
version = '2019-03-08'
arch_name = 'retdec-support' + '_' + version + '.' + arch_suffix
###############################################################################
def cleanup(support_dir):
shutil.rmtree(support_dir, ignore_errors=True)
def get_install_path(argv):
if len(argv) != 2:
def get_args(argv):
if len(argv) != 5:
print('ERROR: Unexpected number of arguments.')
print(' Expecting tuple: (install path, URL, SHA256, version).')
sys.exit(1)
else:
return argv[1]
return (argv[1], argv[2], argv[3], argv[4])
def main():
install_path = get_install_path(sys.argv)
install_path, arch_url, sha256hash_ref, version = get_args(sys.argv)
support_dir = os.path.join(install_path, 'share', 'retdec', 'support')
arch_path = os.path.join(support_dir, arch_name)
arch_path = os.path.join(support_dir, 'retdec-support.tar.xz')
# Share directory exists.
if os.path.exists(support_dir):
version_path = os.path.join(support_dir, version_filename)
version_path = os.path.join(support_dir, 'version.txt')
if os.path.isfile(version_path):
with open(version_path) as version_file:
version_from_file = version_file.read().split('\n')[0]
@ -58,8 +47,6 @@ def main():
os.makedirs(support_dir, exist_ok=True)
# Download archive
arch_url = 'https://github.com/avast/retdec-support/releases/download/%s/%s' % (version, arch_name)
print('Downloading archive from %s ...' % arch_url)
try:
urllib.request.urlretrieve(arch_url, arch_path)
except (urllib.request.HTTPError, urllib.request.URLError) as ex: