• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# Copyright (c) 2023 Huawei Device Co., Ltd.
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
17import subprocess
18import argparse
19import os
20import sys
21
22
23def parse_args(args):
24    parser = argparse.ArgumentParser()
25    parser.add_argument('--sdk-out-dir')
26    options = parser.parse_args(args)
27    return options
28
29
30def sign_sdk(zipfile, sign_list):
31    if zipfile.endswith('.zip'):
32        sign = os.getenv('SIGN')
33        dir_name = zipfile.split('-')[0]
34        cmd1 = ['unzip', zipfile]
35        subprocess.call(cmd1)
36        for root, dirs, files in os.walk(dir_name):
37            for file in files:
38                file = os.path.join(root, file)
39                if file.split('/')[-1] in sign_list or file.endswith('.so') or file.endswith('.dylib') or file.split('/')[-2] == 'bin':
40                    cmd2 = ['codesign', '--sign', sign, '--timestamp', '--options=runtime', file]
41                    subprocess.call(cmd2)
42        cmd3 = ['rm', zipfile]
43        subprocess.call(cmd3)
44        cmd4 = ['zip', '-r', zipfile, dir_name]
45        subprocess.call(cmd4)
46        cmd5 = ['rm', '-rf', dir_name]
47        subprocess.call(cmd5)
48        cmd6 = ['xcrun', 'notarytool', 'submit', zipfile, '--keychain-profile', '"ohos-sdk"', '--wait']
49        subprocess.call(cmd6)
50
51
52def main(args):
53    options = parse_args(args)
54    darwin_sdk_dir = os.path.join(options.sdk_out_dir, 'darwin')
55    os.chdir(darwin_sdk_dir)
56    sign_list = ['lldb-argdumper', 'fsevents.node', 'idl', 'restool', 'diff', 'ark_asm', 'ark_disasm', 'hdc', 'syscap_tool']
57    for file in os.listdir('.'):
58        sign_sdk(file, sign_list)
59
60
61if __name__ == '__main__':
62    sys.exit(main(sys.argv[1:]))
63