update helper scripts and more

This commit is contained in:
Dengke Tang
2023-02-27 15:37:22 -08:00
parent 908f6c4dba
commit 1500c855e9
6 changed files with 81 additions and 87 deletions
+12 -23
View File
@@ -1,8 +1,6 @@
import argparse
import os
import subprocess
import xml.dom.minidom
import sys
parser = argparse.ArgumentParser(description='PECL Package generator')
@@ -27,32 +25,23 @@ NOTES = args.notes
TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
WORK_DIR = os.path.join(TOOLS_DIR, '..')
def run(args):
print(f"$ {subprocess.list2cmdline(args)}")
subprocess.check_call(args)
run(['python3', f'{TOOLS_DIR}/cleanup_build.py'])
subprocess.run(['python3', f'{TOOLS_DIR}/cleanup_build.py'], check=True)
os.chdir(WORK_DIR)
run(['git', 'submodule', 'update', '--init', '--recursive'])
subprocess.run(['git', 'submodule', 'update',
'--init', '--recursive'], check=True)
subprocess.run(['python3', f'{TOOLS_DIR}/prepare_pecl_package_xml.py', '--name', NAME, '--user', USER,
'--email', EMAIL, '--version', VERSION, '--notes', NOTES], check=True)
try:
run(['python3', f'{TOOLS_DIR}/prepare_pecl_package_xml.py', '--name', NAME, '--user', USER,
'--email', EMAIL, '--version', VERSION, '--notes', NOTES])
with open('package.xml', 'r') as f:
package_xml = f.read()
subprocess.run(['tidy', '-xml', '-m', '-i', 'package.xml'], check=True)
subprocess.run(['pear', 'package-validate'], check=True)
subprocess.run(['pear', 'package'], check=True)
except subprocess.CalledProcessError as e:
sys.exit(f'ERROR PROCESSING review package.xml: {e}')
with open('package.xml', 'r') as f:
package_xml = f.read()
doc = xml.dom.minidom.parse('package.xml')
doc.encoding = 'UTF-8'
xml_str = doc.toprettyxml(indent=' ', newl='')
with open('package.xml', 'w') as f:
f.write(xml_str)
run(['pear', 'package-validate'])
run(['pear', 'package'])
print(f'ERROR PROCESSING review package.xml: {e}')
exit(1)
print(f'Size of {PACKAGE}-{VERSION}.tgz: {os.path.getsize(f"{PACKAGE}-{VERSION}.tgz") / 1024 / 1024:.2f} MB')