[Native][Tools] Add input directory in the bundles repack script
This commit is contained in:
@@ -5,36 +5,39 @@ import os
|
|||||||
import os.path
|
import os.path
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 3:
|
||||||
print('Usage: ' + sys.argv[0] + ' <kotlin_version>')
|
print('Usage: ' + sys.argv[0] + ' <kotlin_version> <input_dir>')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
kotlinVersion = sys.argv[1]
|
kotlinVersion = sys.argv[1]
|
||||||
print('Repacking bundles for Kotlin/Native version ' + kotlinVersion)
|
inputDir = sys.argv[2]
|
||||||
|
print('Repacking bundles for Kotlin/Native version ' + kotlinVersion + ' from ' + inputDir)
|
||||||
|
os.chdir(inputDir)
|
||||||
|
|
||||||
bundles = [f for f in os.listdir('.') if f.startswith('kotlin-native-prebuilt-') and (f.endswith('.tar.gz') or f.endswith('.zip')) and os.path.isfile(f)]
|
bundles = [f for f in os.listdir('.')
|
||||||
|
if f.startswith('kotlin-native-prebuilt-') and (f.endswith('.tar.gz') or f.endswith('.zip')) and os.path.isfile(f)]
|
||||||
print('Found ' + str(len(bundles)) + ' bundle files to repack: ' + ', '.join(bundles))
|
print('Found ' + str(len(bundles)) + ' bundle files to repack: ' + ', '.join(bundles))
|
||||||
|
|
||||||
for bundle in bundles:
|
for bundle in bundles:
|
||||||
print('')
|
print('')
|
||||||
print('Unpacking ' + bundle)
|
print('Unpacking ' + bundle)
|
||||||
unpackCommand = 'unzip -qq' if bundle.endswith('.zip') else 'tar -xzf'
|
unpackCommand = 'unzip -qq' if bundle.endswith('.zip') else 'tar -xzf'
|
||||||
os.system(unpackCommand + ' ' + bundle)
|
os.system(unpackCommand + ' ' + bundle)
|
||||||
|
|
||||||
extractedDir = bundle.rstrip('.tar.gz').rstrip('.zip')
|
extractedDir = bundle.rstrip('.tar.gz').rstrip('.zip')
|
||||||
renamedDir = extractedDir.replace('-prebuilt-', '-')
|
renamedDir = extractedDir.replace('-prebuilt-', '-')
|
||||||
print('Renaming ' + extractedDir + ' to ' + renamedDir)
|
print('Renaming ' + extractedDir + ' to ' + renamedDir)
|
||||||
os.rename(extractedDir, renamedDir)
|
os.rename(extractedDir, renamedDir)
|
||||||
|
|
||||||
repackedBundle = renamedDir + ('.zip' if bundle.endswith('.zip') else '.tar.gz')
|
repackedBundle = renamedDir + ('.zip' if bundle.endswith('.zip') else '.tar.gz')
|
||||||
print('Packing ' + repackedBundle)
|
print('Packing ' + repackedBundle)
|
||||||
packCommand = 'zip -qq -r' if bundle.endswith('.zip') else 'COPYFILE_DISABLE=true tar -czf'
|
packCommand = 'zip -qq -r' if bundle.endswith('.zip') else 'COPYFILE_DISABLE=true tar -czf'
|
||||||
os.system(packCommand + ' ' + repackedBundle + ' ' + renamedDir)
|
os.system(packCommand + ' ' + repackedBundle + ' ' + renamedDir)
|
||||||
shutil.rmtree(renamedDir)
|
shutil.rmtree(renamedDir)
|
||||||
|
|
||||||
print('Calculating SHA256')
|
print('Calculating SHA256')
|
||||||
shaCommand = 'shasum -a 256'
|
shaCommand = 'shasum -a 256'
|
||||||
os.system(shaCommand + ' ' + repackedBundle + ' > ' + repackedBundle + '.sha256')
|
os.system(shaCommand + ' ' + repackedBundle + ' > ' + repackedBundle + '.sha256')
|
||||||
|
|
||||||
print('')
|
print('')
|
||||||
print('Done.')
|
print('Done.')
|
||||||
|
|||||||
Reference in New Issue
Block a user