mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Update build scripts
This commit is contained in:
parent
98bbf0db87
commit
8d4963a159
@ -190,6 +190,36 @@ def copy_profiles_from_directory(source_path, destination_path, team_id, bundle_
|
||||
print('Warning: skipping provisioning profile at {} with bundle_id {} (base_name {})'.format(file_path, profile_name, profile_base_name))
|
||||
|
||||
|
||||
def resolve_aps_environment_from_directory(source_path, team_id, bundle_id):
|
||||
for file_name in os.listdir(source_path):
|
||||
file_path = source_path + '/' + file_name
|
||||
if os.path.isfile(file_path):
|
||||
if not file_path.endswith('.mobileprovision'):
|
||||
continue
|
||||
|
||||
profile_data = run_executable_with_output('openssl', arguments=[
|
||||
'smime',
|
||||
'-inform',
|
||||
'der',
|
||||
'-verify',
|
||||
'-noverify',
|
||||
'-in',
|
||||
file_path
|
||||
], decode=False, stderr_to_stdout=False, check_result=True)
|
||||
|
||||
profile_dict = plistlib.loads(profile_data)
|
||||
profile_name = profile_dict['Entitlements']['application-identifier']
|
||||
|
||||
if profile_name.startswith(team_id + '.' + bundle_id):
|
||||
profile_base_name = profile_name[len(team_id + '.' + bundle_id):]
|
||||
if profile_base_name == '':
|
||||
if 'aps-environment' not in profile_dict['Entitlements']:
|
||||
print('Provisioning profile at {} does not include an aps-environment entitlement'.format(file_path))
|
||||
sys.exit(1)
|
||||
return profile_dict['Entitlements']['aps-environment']
|
||||
return None
|
||||
|
||||
|
||||
def copy_certificates_from_directory(source_path, destination_path):
|
||||
for file_name in os.listdir(source_path):
|
||||
file_path = source_path + '/' + file_name
|
||||
@ -208,6 +238,9 @@ class CodesigningSource:
|
||||
def copy_profiles_to_destination(self, destination_path):
|
||||
raise Exception('Not implemented')
|
||||
|
||||
def resolve_aps_environment(self):
|
||||
raise Exception('Not implemented')
|
||||
|
||||
def copy_certificates_to_destination(self, destination_path):
|
||||
raise Exception('Not implemented')
|
||||
|
||||
@ -242,6 +275,10 @@ class GitCodesigningSource(CodesigningSource):
|
||||
source_path = self.working_dir + '/decrypted/profiles/{}'.format(self.codesigning_type)
|
||||
copy_profiles_from_directory(source_path=source_path, destination_path=destination_path, team_id=self.team_id, bundle_id=self.bundle_id)
|
||||
|
||||
def resolve_aps_environment(self):
|
||||
source_path = self.working_dir + '/decrypted/profiles/{}'.format(self.codesigning_type)
|
||||
return resolve_aps_environment_from_directory(source_path=source_path, team_id=self.team_id, bundle_id=self.bundle_id)
|
||||
|
||||
def copy_certificates_to_destination(self, destination_path):
|
||||
source_path = None
|
||||
if self.codesigning_type in ['adhoc', 'appstore']:
|
||||
@ -267,5 +304,8 @@ class DirectoryCodesigningSource(CodesigningSource):
|
||||
def copy_profiles_to_destination(self, destination_path):
|
||||
copy_profiles_from_directory(source_path=self.directory_path + '/profiles', destination_path=destination_path, team_id=self.team_id, bundle_id=self.bundle_id)
|
||||
|
||||
def resolve_aps_environment(self):
|
||||
return resolve_aps_environment_from_directory(source_path=self.directory_path + '/profiles', team_id=self.team_id, bundle_id=self.bundle_id)
|
||||
|
||||
def copy_certificates_to_destination(self, destination_path):
|
||||
copy_certificates_from_directory(source_path=self.directory_path + '/certs', destination_path=destination_path)
|
||||
|
@ -15,6 +15,12 @@ from BazelLocation import locate_bazel
|
||||
from BuildConfiguration import CodesigningSource, GitCodesigningSource, DirectoryCodesigningSource, BuildConfiguration, build_configuration_from_json
|
||||
import RemoteBuild
|
||||
|
||||
|
||||
class ResolvedCodesigningData:
|
||||
def __init__(self, aps_environment):
|
||||
self.aps_environment = aps_environment
|
||||
|
||||
|
||||
class BazelCommandLine:
|
||||
def __init__(self, bazel, override_bazel_version, override_xcode_version, bazel_user_root):
|
||||
self.build_environment = BuildEnvironment(
|
||||
@ -384,7 +390,7 @@ def clean(bazel, arguments):
|
||||
bazel_command_line.invoke_clean()
|
||||
|
||||
|
||||
def resolve_codesigning(arguments, base_path, build_configuration, provisioning_profiles_path, additional_codesigning_output_path):
|
||||
def resolve_codesigning(arguments, base_path, build_configuration, provisioning_profiles_path, additional_codesigning_output_path) -> ResolvedCodesigningData:
|
||||
profile_source = None
|
||||
if arguments.gitCodesigningRepository is not None:
|
||||
password = os.getenv('TELEGRAM_CODESIGNING_GIT_PASSWORD')
|
||||
@ -427,8 +433,10 @@ def resolve_codesigning(arguments, base_path, build_configuration, provisioning_
|
||||
profile_source.copy_profiles_to_destination(destination_path=additional_codesigning_output_path + '/profiles')
|
||||
profile_source.copy_certificates_to_destination(destination_path=additional_codesigning_output_path + '/certs')
|
||||
|
||||
return ResolvedCodesigningData(aps_environment=profile_source.resolve_aps_environment())
|
||||
|
||||
def resolve_configuration(base_path, bazel_command_line: BazelCommandLine, arguments, aps_environment, additional_codesigning_output_path):
|
||||
|
||||
def resolve_configuration(base_path, bazel_command_line: BazelCommandLine, arguments, additional_codesigning_output_path):
|
||||
configuration_repository_path = '{}/build-input/configuration-repository'.format(base_path)
|
||||
os.makedirs(configuration_repository_path, exist_ok=True)
|
||||
|
||||
@ -440,20 +448,23 @@ def resolve_configuration(base_path, bazel_command_line: BazelCommandLine, argum
|
||||
with open(configuration_repository_path + '/BUILD', 'w+') as file:
|
||||
pass
|
||||
|
||||
build_configuration.write_to_variables_file(aps_environment=aps_environment, path=configuration_repository_path + '/variables.bzl')
|
||||
|
||||
provisioning_path = '{}/provisioning'.format(configuration_repository_path)
|
||||
if os.path.exists(provisioning_path):
|
||||
shutil.rmtree(provisioning_path)
|
||||
os.makedirs(provisioning_path, exist_ok=True)
|
||||
|
||||
resolve_codesigning(
|
||||
codesigning_data = resolve_codesigning(
|
||||
arguments=arguments,
|
||||
base_path=base_path,
|
||||
build_configuration=build_configuration,
|
||||
provisioning_profiles_path=provisioning_path,
|
||||
additional_codesigning_output_path=additional_codesigning_output_path
|
||||
)
|
||||
if codesigning_data.aps_environment is None:
|
||||
print('Could not find a valid aps-environment entitlement in the provided provisioning profiles')
|
||||
sys.exit(1)
|
||||
|
||||
build_configuration.write_to_variables_file(aps_environment=codesigning_data.aps_environment, path=configuration_repository_path + '/variables.bzl')
|
||||
|
||||
provisioning_profile_files = []
|
||||
for file_name in os.listdir(provisioning_path):
|
||||
@ -489,7 +500,6 @@ def generate_project(bazel, arguments):
|
||||
base_path=os.getcwd(),
|
||||
bazel_command_line=bazel_command_line,
|
||||
arguments=arguments,
|
||||
aps_environment=arguments.apsEnvironment,
|
||||
additional_codesigning_output_path=None
|
||||
)
|
||||
|
||||
@ -539,7 +549,6 @@ def build(bazel, arguments):
|
||||
base_path=os.getcwd(),
|
||||
bazel_command_line=bazel_command_line,
|
||||
arguments=arguments,
|
||||
aps_environment=arguments.apsEnvironment,
|
||||
additional_codesigning_output_path=None
|
||||
)
|
||||
|
||||
@ -603,7 +612,6 @@ def test(bazel, arguments):
|
||||
base_path=os.getcwd(),
|
||||
bazel_command_line=bazel_command_line,
|
||||
arguments=arguments,
|
||||
aps_environment=arguments.apsEnvironment,
|
||||
additional_codesigning_output_path=None
|
||||
)
|
||||
|
||||
@ -669,16 +677,6 @@ def add_codesigning_common_arguments(current_parser: argparse.ArgumentParser):
|
||||
|
||||
|
||||
def add_project_and_build_common_arguments(current_parser: argparse.ArgumentParser):
|
||||
current_parser.add_argument(
|
||||
'--apsEnvironment',
|
||||
choices=[
|
||||
'development',
|
||||
'production'
|
||||
],
|
||||
required=True,
|
||||
help='APNS environment',
|
||||
)
|
||||
|
||||
add_codesigning_common_arguments(current_parser=current_parser)
|
||||
|
||||
|
||||
@ -928,7 +926,6 @@ if __name__ == '__main__':
|
||||
base_path=os.getcwd(),
|
||||
bazel_command_line=None,
|
||||
arguments=args,
|
||||
aps_environment='production',
|
||||
additional_codesigning_output_path=remote_input_path
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user