2018-05-07 09:55:38 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# code: utf-8
|
|
|
|
|
|
|
|
'''
|
|
|
|
A wrapper script to generate zip files for GitHub releases.
|
|
|
|
|
|
|
|
This script tends to be compatible with both Python 2 and Python 3.
|
|
|
|
'''
|
|
|
|
|
|
|
|
from __future__ import print_function
|
|
|
|
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
|
|
|
|
|
2020-02-16 10:12:25 +00:00
|
|
|
DEDRM_SRC_DIR = 'DeDRM_Plugin'
|
|
|
|
DEDRM_README= 'DeDRM_Plugin_ReadMe.txt'
|
|
|
|
OBOK_SRC_DIR = 'Obok_plugin'
|
|
|
|
OBOK_README = 'Obok_plugin_ReadMe.txt'
|
|
|
|
RELEASE_DIR = 'release'
|
2018-05-07 09:55:38 +00:00
|
|
|
|
|
|
|
def make_calibre_plugin():
|
|
|
|
|
2018-12-02 11:51:51 +00:00
|
|
|
shutil.make_archive(core_dir, 'zip', core_dir)
|
|
|
|
shutil.rmtree(core_dir)
|
2018-05-07 09:55:38 +00:00
|
|
|
|
|
|
|
|
2018-12-02 11:51:51 +00:00
|
|
|
def make_obok_plugin():
|
|
|
|
obok_plugin_dir = os.path.join(SHELLS_BASE, 'Obok_calibre_plugin')
|
|
|
|
core_dir = os.path.join(obok_plugin_dir, 'obok_plugin')
|
2018-05-07 09:55:38 +00:00
|
|
|
|
2018-12-02 11:51:51 +00:00
|
|
|
shutil.copytree(OBOK_SRC_DIR, core_dir)
|
2020-02-16 10:12:25 +00:00
|
|
|
shutil.make_archive(core_dir, 'zip')
|
2018-05-07 09:55:38 +00:00
|
|
|
shutil.rmtree(core_dir)
|
|
|
|
|
2020-02-16 10:12:25 +00:00
|
|
|
def make_release(version):
|
2018-12-02 11:51:51 +00:00
|
|
|
try:
|
2020-02-16 10:12:25 +00:00
|
|
|
shutil.rmtree(RELEASE_DIR)
|
|
|
|
except:
|
2018-12-02 11:51:51 +00:00
|
|
|
pass
|
2020-02-16 10:12:25 +00:00
|
|
|
os.mkdir(RELEASE_DIR)
|
|
|
|
shutil.make_archive(DEDRM_SRC_DIR, 'zip', DEDRM_SRC_DIR)
|
|
|
|
shutil.make_archive(OBOK_SRC_DIR, 'zip', OBOK_SRC_DIR)
|
|
|
|
shutil.move(DEDRM_SRC_DIR+'.zip', RELEASE_DIR)
|
|
|
|
shutil.move(OBOK_SRC_DIR+'.zip', RELEASE_DIR)
|
|
|
|
shutil.copy(DEDRM_README, RELEASE_DIR)
|
|
|
|
shutil.copy(OBOK_README, RELEASE_DIR)
|
|
|
|
shutil.copy("ReadMe_Overview.txt", RELEASE_DIR)
|
2018-05-07 10:27:05 +00:00
|
|
|
|
|
|
|
release_name = 'DeDRM_tools_{}'.format(version)
|
2020-02-16 10:12:25 +00:00
|
|
|
result = shutil.make_archive(release_name, 'zip', RELEASE_DIR)
|
|
|
|
try:
|
|
|
|
shutil.rmtree(RELEASE_DIR)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
return result
|
2018-05-07 09:55:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2018-05-07 10:27:05 +00:00
|
|
|
import sys
|
|
|
|
try:
|
|
|
|
version = sys.argv[1]
|
|
|
|
except IndexError:
|
|
|
|
raise SystemExit('Usage: {} version'.format(__file__))
|
|
|
|
|
|
|
|
print(make_release(version))
|