File indexing completed on 2024-04-28 16:57:38
0001 #!/usr/bin/env python 0002 0003 0004 # This file is part of the clazy static checker. 0005 0006 # Copyright (C) 2018 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com 0007 0008 # This library is free software; you can redistribute it and/or 0009 # modify it under the terms of the GNU Library General Public 0010 # License as published by the Free Software Foundation; either 0011 # version 2 of the License, or (at your option) any later version. 0012 0013 # This library is distributed in the hope that it will be useful, 0014 # but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 # Library General Public License for more details. 0017 0018 # You should have received a copy of the GNU Library General Public License 0019 # along with this library; see the file COPYING.LIB. If not, write to 0020 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0021 # Boston, MA 02110-1301, USA. 0022 0023 0024 # This is my quick and dirty script to generate clazy app images on each release 0025 # Requires iamsergio/clazy-centos68 docker image to work 0026 0027 import sys, os 0028 0029 CLAZY_SHA1 = '' 0030 WORK_FOLDER = '/tmp/clazy_work/' 0031 DOCKER_IMAGE = 'iamsergio/clazy-centos68' 0032 DEST_FILE = WORK_FOLDER + '/Clazy-x86_64.AppImage' 0033 0034 def print_usage(): 0035 print(sys.argv[0] + ' <clazy sha1>') 0036 0037 def run_command(cmd, abort_on_error = True): 0038 print(cmd) 0039 success = (os.system(cmd) == 0) 0040 if abort_on_error and not success: 0041 sys.exit(1) 0042 0043 return success 0044 0045 def prepare_folder(): 0046 run_command('rm -rf ' + WORK_FOLDER) 0047 os.mkdir(WORK_FOLDER) 0048 0049 def make_appimage_in_docker(): 0050 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()))) 0051 if not run_command(cmd): 0052 print('Error running docker. Make sure docker is running and that you have ' + DOCKER_IMAGE) 0053 0054 os.environ['ARCH'] = 'x86_64' 0055 if not run_command('appimagetool-x86_64.AppImage %s/clazy.AppDir/ %s' % (WORK_FOLDER, DEST_FILE)): 0056 return False 0057 0058 return True 0059 0060 0061 def clazy_source_directory(): 0062 return os.path.dirname(os.path.realpath(__file__)) + '/../' 0063 0064 def run_tests(): 0065 os.chdir(clazy_source_directory() + '/tests/') 0066 os.environ['CLAZY_CXX'] = '/tmp/clazy_work//Clazy-x86_64.AppImage' 0067 os.environ['CLAZYSTANDALONE_CXX'] = '/tmp/clazy_work//Clazy-x86_64.AppImage --standalone' 0068 return run_command("./run_tests.py --verbose") 0069 0070 0071 if len(sys.argv) != 2: 0072 print_usage(); 0073 sys.exit(1) 0074 0075 0076 CLAZY_SHA1 = sys.argv[1] 0077 0078 prepare_folder() 0079 0080 if not make_appimage_in_docker(): 0081 sys.exit(1) 0082 0083 if not run_tests(): 0084 sys.exit(1) 0085 0086 print('') 0087 run_command('sha1sum ' + DEST_FILE) 0088 run_command('sha256sum ' + DEST_FILE) 0089 0090 sign_script = os.getenv('CLAZY_SIGN_SCRIPT', '') 0091 0092 if sign_script: 0093 os.chdir(WORK_FOLDER) 0094 if not run_command(sign_script + ' ' + DEST_FILE): 0095 print('Error signing file') 0096 sys.exit(1) 0097 0098 print('') 0099 print('Success: ' + DEST_FILE)