| 1 |
#!/usr/bin/env python |
| 2 |
|
| 3 |
|
| 4 |
# SPDX-FileCopyrightText: 2018 Klaralvdalens Datakonsult AB a KDAB Group company [email protected] |
| 5 |
# SPDX-License-Identifier: LGPL-2.0-or-later |
| 6 |
|
| 7 |
|
| 8 |
# This is my quick and dirty script to generate clazy app images on each release |
| 9 |
# Requires iamsergio/clazy-centos68 docker image to work |
| 10 |
|
| 11 |
import sys, os |
| 12 |
|
| 13 |
CLAZY_SHA1 = '' |
| 14 |
WORK_FOLDER = '/tmp/clazy_work/' |
| 15 |
DOCKER_IMAGE = 'iamsergio/clazy-centos68' |
| 16 |
DEST_FILE = WORK_FOLDER + '/Clazy-x86_64.AppImage' |
| 17 |
|
| 18 |
def print_usage(): |
| 19 |
print(sys.argv[0] + ' <clazy sha1>') |
| 20 |
|
| 21 |
def run_command(cmd, abort_on_error = True): |
| 22 |
print(cmd) |
| 23 |
success = (os.system(cmd) == 0) |
| 24 |
if abort_on_error and not success: |
| 25 |
sys.exit(1) |
| 26 |
|
| 27 |
return success |
| 28 |
|
| 29 |
def prepare_folder(): |
| 30 |
run_command('rm -rf ' + WORK_FOLDER) |
| 31 |
os.mkdir(WORK_FOLDER) |
| 32 |
|
| 33 |
def make_appimage_in_docker(): |
| 34 |
cmd = 'docker run -i -t -v %s:%s %s %s' % (WORK_FOLDER, WORK_FOLDER, DOCKER_IMAGE, 'bash -c "cd /clazy/ && git pull && /clazy/dev-scripts/docker/make_appimage.sh %s %s"' % (CLAZY_SHA1, str(os.getuid()))) |
| 35 |
if not run_command(cmd): |
| 36 |
print('Error running docker. Make sure docker is running and that you have ' + DOCKER_IMAGE) |
| 37 |
|
| 38 |
os.environ['ARCH'] = 'x86_64' |
| 39 |
if not run_command('appimagetool-x86_64.AppImage %s/clazy.AppDir/ %s' % (WORK_FOLDER, DEST_FILE)): |
| 40 |
return False |
| 41 |
|
| 42 |
return True |
| 43 |
|
| 44 |
|
| 45 |
def clazy_source_directory(): |
| 46 |
return os.path.dirname(os.path.realpath(__file__)) + '/../' |
| 47 |
|
| 48 |
def run_tests(): |
| 49 |
os.chdir(clazy_source_directory() + '/tests/') |
| 50 |
os.environ['CLAZY_CXX'] = '/tmp/clazy_work//Clazy-x86_64.AppImage' |
| 51 |
os.environ['CLAZYSTANDALONE_CXX'] = '/tmp/clazy_work//Clazy-x86_64.AppImage --standalone' |
| 52 |
return run_command("./run_tests.py --verbose") |
| 53 |
|
| 54 |
|
| 55 |
if len(sys.argv) != 2: |
| 56 |
print_usage(); |
| 57 |
sys.exit(1) |
| 58 |
|
| 59 |
|
| 60 |
CLAZY_SHA1 = sys.argv[1] |
| 61 |
|
| 62 |
prepare_folder() |
| 63 |
|
| 64 |
if not make_appimage_in_docker(): |
| 65 |
sys.exit(1) |
| 66 |
|
| 67 |
if not run_tests(): |
| 68 |
sys.exit(1) |
| 69 |
|
| 70 |
print('') |
| 71 |
run_command('sha1sum ' + DEST_FILE) |
| 72 |
run_command('sha256sum ' + DEST_FILE) |
| 73 |
|
| 74 |
sign_script = os.getenv('CLAZY_SIGN_SCRIPT', '') |
| 75 |
|
| 76 |
if sign_script: |
| 77 |
os.chdir(WORK_FOLDER) |
| 78 |
if not run_command(sign_script + ' ' + DEST_FILE): |
| 79 |
print('Error signing file') |
| 80 |
sys.exit(1) |
| 81 |
|
| 82 |
print('') |
| 83 |
print('Success: ' + DEST_FILE) |