File indexing completed on 2024-05-12 04:22:35
0001 #!/bin/python3 0002 0003 import requests 0004 import tarfile 0005 import shutil 0006 import os 0007 import json 0008 import sys 0009 import subprocess 0010 0011 # Converts a path to a relative one, to allow for it to be passed to os.path.join 0012 # This is primarily relevant on Windows, where full paths have the drive letter, and thus can be simply joined together as you can on Unix systems 0013 def makePathRelative(path): 0014 # If we're on Windows, chop the drive letter off... 0015 if sys.platform == "win32": 0016 return path[3:] 0017 0018 # Otherwise we just drop the starting slash off 0019 return path[1:] 0020 0021 packagingPath = os.path.abspath('_packaging') 0022 appdirPath = os.path.join(packagingPath, 'krita.appdir') 0023 downloadsPath = os.path.join(packagingPath, 'download') 0024 buildPath = os.path.abspath('_build') 0025 depsPath = os.path.abspath('_install') 0026 stagingRoot = os.path.join('_staging', makePathRelative(depsPath)) 0027 0028 if os.path.isdir(appdirPath): 0029 shutil.rmtree(appdirPath) 0030 0031 os.makedirs(os.path.join(appdirPath, 'usr')) 0032 0033 if not os.path.isdir(downloadsPath): 0034 os.makedirs(downloadsPath) 0035 0036 filesToMove = os.listdir(stagingRoot) 0037 for file in filesToMove: 0038 shutil.move(os.path.join(stagingRoot, file), os.path.join(appdirPath, 'usr')) 0039 0040 os.environ.putenv('KRITA_APPDIR_PATH', appdirPath) 0041 os.environ.putenv('KRITA_DOWNLOADS_PATH', downloadsPath) 0042 os.environ.putenv('KRITA_BUILD_PATH', buildPath) 0043 os.environ.putenv('KRITA_DEPS_PATH', depsPath) 0044 0045 commandToRun = ' '.join(['./packaging/linux/appimage/build-image.sh', packagingPath, os.path.abspath('.')]) 0046 0047 # Run the command 0048 try: 0049 print( "## RUNNING: " + commandToRun ) 0050 subprocess.check_call( commandToRun, stdout=sys.stdout, stderr=sys.stderr, shell=True ) 0051 except Exception: 0052 print("## Failed to build the appimage") 0053 sys.exit(1)