summaryrefslogtreecommitdiffstats
path: root/bin/update
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-09-06 04:48:44 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-05-19 03:43:22 +0200
commit7f52e3848e8b153f8a0b6bb7eef4f40afabe7e69 (patch)
treea19fad240fe462bb0b4f1ab05cf5c15ecdcf5793 /bin/update
parentuse my own server for now for the new update check (diff)
downloadcore-7f52e3848e8b153f8a0b6bb7eef4f40afabe7e69.tar.gz
core-7f52e3848e8b153f8a0b6bb7eef4f40afabe7e69.zip
move most of the updater settings to ini file
Also finally add the initial version of the upload scripts. Change-Id: I3ad5bcbeba60f0cf9700e5fe5001a24f162a3244
Diffstat (limited to 'bin/update')
-rwxr-xr-xbin/update/create_build_config.py25
-rwxr-xr-xbin/update/create_full_mar.py15
-rwxr-xr-xbin/update/create_full_mar_for_languages.py16
-rw-r--r--bin/update/tools.py7
-rwxr-xr-xbin/update/upload_build_config.py40
-rwxr-xr-xbin/update/upload_builds.py29
6 files changed, 105 insertions, 27 deletions
diff --git a/bin/update/create_build_config.py b/bin/update/create_build_config.py
index 1342746dee0a..8d0cf0e07cbe 100755
--- a/bin/update/create_build_config.py
+++ b/bin/update/create_build_config.py
@@ -4,40 +4,39 @@ import json
import sys
import os
-def update_url(old_url, **kwargs):
- new_url = old_url
- for key, val in kwargs.items():
- new_url = new_url.replace(key, val)
+from config import parse_config
- return new_url
+from tools import replace_variables_in_string
def update_all_url_entries(data, **kwargs):
- data['complete']['url'] = update_url(data['complete']['url'], **kwargs)
+ data['complete']['url'] = replace_variables_in_string(data['complete']['url'], **kwargs)
for language in data['languages']:
- language['complete']['url'] = update_url(language['complete']['url'], **kwargs)
+ language['complete']['url'] = replace_variables_in_string(language['complete']['url'], **kwargs)
def main(argv):
if len(argv) < 7:
- print("Usage: create_build_config.py $PRODUCTNAME $VERSION $BUILDID $UPDATECHANNEL $PLATFORM $TARGETDIR")
+ print("Usage: create_build_config.py $PRODUCTNAME $VERSION $BUILDID $PLATFORM $TARGETDIR $UPDATE_CONFIG")
+
+ config = parse_config(argv[6])
data = { 'productName' : argv[1],
'version' : argv[2],
'buildNumber' : argv[3],
- 'updateChannel' : argv[4],
- 'platform' : argv[5]
+ 'updateChannel' : config.channel,
+ 'platform' : argv[4]
}
extra_data_files = ['complete_info.json', 'complete_lang_info.json']
for extra_file in extra_data_files:
- extra_file_path = os.path.join(argv[6], extra_file)
+ extra_file_path = os.path.join(argv[5], extra_file)
with open(extra_file_path, "r") as f:
extra_data = json.load(f)
data.update(extra_data)
- update_all_url_entries(data, channel=argv[4], platform=argv[5], buildid=argv[3], version=argv[2])
+ update_all_url_entries(data, channel=config.channel, platform=argv[4], buildid=argv[3], version=argv[2])
- with open(os.path.join(argv[6], "build_config.json"), "w") as f:
+ with open(os.path.join(argv[5], "build_config.json"), "w") as f:
json.dump(data, f, indent=4)
if __name__ == "__main__":
diff --git a/bin/update/create_full_mar.py b/bin/update/create_full_mar.py
index 02870b35a63c..2362f2c9850d 100755
--- a/bin/update/create_full_mar.py
+++ b/bin/update/create_full_mar.py
@@ -6,6 +6,7 @@ import subprocess
import json
from tools import uncompress_file_to_dir, get_file_info
+from config import parse_config
current_dir_path = os.path.dirname(os.path.realpath(__file__))
@@ -15,19 +16,19 @@ def make_mar_name(target_dir, filename_prefix):
def main():
print(sys.argv)
- if len(sys.argv) < 9:
- print("Usage: create_full_mar_for_languages.py $PRODUCTNAME $WORKDIR $TARGETDIR $TEMPDIR $FILENAMEPREFIX $BASE_URL")
+ if len(sys.argv) < 7:
+ print("Usage: create_full_mar_for_languages.py $PRODUCTNAME $WORKDIR $TARGETDIR $TEMPDIR $FILENAMEPREFIX $UPDATE_CONFIG")
sys.exit(1)
- url = sys.argv[8]
- certificate_path = sys.argv[7]
- certificate_name = sys.argv[6]
+ update_config = sys.argv[6]
filename_prefix = sys.argv[5]
temp_dir = sys.argv[4]
target_dir = sys.argv[3]
workdir = sys.argv[2]
product_name = sys.argv[1]
+ config = parse_config(update_config)
+
tar_dir = os.path.join(workdir, "installation", product_name, "archive", "install", "en-US")
tar_file = os.path.join(tar_dir, os.listdir(tar_dir)[0])
@@ -42,11 +43,11 @@ def main():
subprocess.call([os.path.join(current_dir_path, 'make_full_update.sh'), mar_file, uncompress_dir])
signed_mar_file = make_mar_name(target_dir, filename_prefix + '_signed')
- subprocess.call([mar_executable, '-C', target_dir, '-d', certificate_path, '-n', certificate_name, '-s', mar_file, signed_mar_file])
+ subprocess.call([mar_executable, '-C', target_dir, '-d', config.certificate_path, '-n', config.certificate_name, '-s', mar_file, signed_mar_file])
os.rename(signed_mar_file, mar_file)
- file_info = { 'complete' : get_file_info(mar_file, url) }
+ file_info = { 'complete' : get_file_info(mar_file, config.base_url) }
with open(os.path.join(target_dir, 'complete_info.json'), "w") as complete_info_file:
json.dump(file_info, complete_info_file, indent = 4)
diff --git a/bin/update/create_full_mar_for_languages.py b/bin/update/create_full_mar_for_languages.py
index 7e79ac897f05..7daf5fe6034e 100755
--- a/bin/update/create_full_mar_for_languages.py
+++ b/bin/update/create_full_mar_for_languages.py
@@ -7,6 +7,8 @@ import json
from tools import uncompress_file_to_dir, get_file_info
+from config import parse_config
+
current_dir_path = os.path.dirname(os.path.realpath(__file__))
def make_complete_mar_name(target_dir, filename_prefix, language):
@@ -21,19 +23,19 @@ def create_lang_infos(mar_file_name, language, url):
def main():
print(sys.argv)
- if len(sys.argv) < 9:
- print("Usage: create_full_mar_for_languages.py $PRODUCTNAME $WORKDIR $TARGETDIR $TEMPDIR $FILENAMEPREFIX $BASE_URL")
+ if len(sys.argv) < 7:
+ print("Usage: create_full_mar_for_languages.py $PRODUCTNAME $WORKDIR $TARGETDIR $TEMPDIR $FILENAMEPREFIX $UPDATE_CONFIG")
sys.exit(1)
- url = sys.argv[8]
- certificate_path = sys.argv[7]
- certificate_name = sys.argv[6]
+ update_config = sys.argv[6]
filename_prefix = sys.argv[5]
temp_dir = sys.argv[4]
target_dir = sys.argv[3]
workdir = sys.argv[2]
product_name = sys.argv[1]
+ config = parse_config(update_config)
+
mar_executable = os.environ.get('MAR', 'mar')
language_pack_dir = os.path.join(workdir, "installation", product_name + "_languagepack", "archive", "install")
@@ -53,10 +55,10 @@ def main():
subprocess.call([os.path.join(current_dir_path, 'make_full_update.sh'), mar_file_name, directory])
signed_mar_file = make_complete_mar_name(target_dir, filename_prefix + '_signed', language)
- subprocess.call([mar_executable, '-C', target_dir, '-d', certificate_path, '-n', certificate_name, '-s', mar_file_name, signed_mar_file])
+ subprocess.call([mar_executable, '-C', target_dir, '-d', config.certificate_path, '-n', config.certificate_name, '-s', mar_file_name, signed_mar_file])
os.rename(signed_mar_file, mar_file_name)
- lang_infos.append(create_lang_infos(mar_file_name, language, url))
+ lang_infos.append(create_lang_infos(mar_file_name, language, config.base_url))
with open(os.path.join(target_dir, "complete_lang_info.json"), "w") as language_info_file:
json.dump({'languages' : lang_infos}, language_info_file, indent=4)
diff --git a/bin/update/tools.py b/bin/update/tools.py
index 5d0871b299af..84c7ae6fb0ab 100644
--- a/bin/update/tools.py
+++ b/bin/update/tools.py
@@ -42,3 +42,10 @@ def get_file_info(mar_file, url):
'url' : url + os.path.basename(mar_file)}
return data
+
+def replace_variables_in_string(string, **kwargs):
+ new_string = string
+ for key, val in kwargs.items():
+ new_string = new_string.replace('$(%s)'%key, val)
+
+ return new_string
diff --git a/bin/update/upload_build_config.py b/bin/update/upload_build_config.py
new file mode 100755
index 000000000000..0380cc1c323b
--- /dev/null
+++ b/bin/update/upload_build_config.py
@@ -0,0 +1,40 @@
+#! /usr/bin/env python3
+
+import sys
+import os
+import configparser
+import requests
+
+dir_path = os.path.dirname(os.path.realpath(__file__))
+
+def main(argv):
+
+ updater_config = sys.argv[2]
+
+ config = configparser.ConfigParser()
+ config.read(updater_config)
+
+ user = config["Updater"]["User"]
+ password = config["Updater"]["Password"]
+ base_address = config["Updater"]["ServerURL"]
+
+ login_url = base_address + "accounts/login/"
+
+ session = requests.session()
+ r1 = session.get(login_url)
+ csrftoken = session.cookies['csrftoken']
+
+ login_data = { 'username': user,'password': password,
+ 'csrfmiddlewaretoken': csrftoken }
+ r1 = session.post(login_url, data=login_data, headers={"Referer": login_url})
+
+ url = base_address + "update/upload/release"
+
+ build_config = os.path.join(sys.argv[1], "build_config.json")
+ r = session.post(url, files={'release_config': open(build_config, "r")})
+ print(r.content)
+ if r.status_code != 200:
+ sys.exit(1)
+
+if __name__ == "__main__":
+ main(sys.argv)
diff --git a/bin/update/upload_builds.py b/bin/update/upload_builds.py
new file mode 100755
index 000000000000..20d683d02ace
--- /dev/null
+++ b/bin/update/upload_builds.py
@@ -0,0 +1,29 @@
+#! /usr/bin/env python3
+
+import sys
+import os
+import subprocess
+
+from config import parse_config
+
+from tools import replace_variables_in_string
+
+def main():
+ product_name = sys.argv[1]
+ buildid = sys.argv[2]
+ platform = sys.argv[3]
+ update_dir = sys.argv[4]
+ update_config = sys.argv[5]
+
+ config = parse_config(update_config)
+ upload_url = replace_variables_in_string(config.upload_url, channel=config.channel, buildid=buildid, platform=platform)
+
+ target_url, target_dir = upload_url.split(':')
+
+ subprocess.call(['ssh', target_url, "'mkdir -p %s'"%(target_dir)])
+ for file in os.listdir(update_dir):
+ if file.endswith('.mar'):
+ subprocess.call(['scp', os.path.join(update_dir, file), upload_url])
+
+if __name__ == '__main__':
+ main()