-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_addon.py
executable file
·54 lines (44 loc) · 1.66 KB
/
build_addon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, you can obtain one at http://mozilla.org/MPL/2.0/.
#
import os
import shutil
import subprocess
from zipfile import ZipFile, ZIP_DEFLATED
def main():
cwd = os.getcwd()
os.chdir(os.path.dirname(os.path.abspath(__file__)))
productName = 'collaboraonline'
workDir = 'workdir'
if os.path.exists(workDir):
shutil.rmtree(workDir)
os.makedirs(workDir)
destDir = 'dest'
if os.path.exists(destDir):
shutil.rmtree(destDir)
os.makedirs(destDir)
packageName = productName + '-nuxeo-wopi'
jarBundleName = packageName + '.jar'
jarBundlePath = os.path.join(workDir, jarBundleName)
zipBundleName = packageName + '.zip'
zipBundlePath = os.path.join(destDir, zipBundleName)
# 1. Build JAR
subprocess.run(['jar', 'cf', jarBundlePath, 'web', 'OSGI-INF']).check_returncode()
# 2. Create ZIP
with ZipFile(zipBundlePath, 'w') as myzip:
myzip.write('package.xml', 'package.xml', ZIP_DEFLATED)
myzip.write('install.xml', 'install.xml', ZIP_DEFLATED)
for f in os.listdir('config'):
myzip.write(os.path.join('config', f), 'install/config/' + f, ZIP_DEFLATED)
for f in os.listdir('images'):
myzip.write(os.path.join('images', f), 'install/images/' + f, ZIP_DEFLATED)
myzip.write(jarBundlePath, 'install/bundles/' + jarBundleName, ZIP_DEFLATED)
# Cleanup
shutil.rmtree(workDir)
os.chdir(cwd)
if __name__ == "__main__":
main()
# vim:set shiftwidth=4 softtabstop=4 expandtab: