diff options
-rw-r--r-- | Makefile.gbuild | 15 | ||||
-rwxr-xr-x | bin/update/create_full_mar.py | 20 | ||||
-rwxr-xr-x | bin/update/create_full_mar_for_languages.py | 14 | ||||
-rwxr-xr-x | bin/update/create_partial_update.py | 53 |
4 files changed, 49 insertions, 53 deletions
diff --git a/Makefile.gbuild b/Makefile.gbuild index ed08c6217d13..44637577da52 100644 --- a/Makefile.gbuild +++ b/Makefile.gbuild @@ -32,12 +32,10 @@ create-update-info: $(eval MAR_DIR := $(WORKDIR)/mar) rm -rf $(MAR_DIR) || true rm -rf $(UPDATE_DIR) || true - mkdir -p $(UPDATE_DIR) - mkdir -p $(MAR_DIR)/current-build mkdir -p $(MAR_DIR)/language - MAR=$(INSTDIR)/program/mar $(SRCDIR)/bin/update/create_full_mar.py "$(PRODUCTNAME)" "$(WORKDIR)" "$(UPDATE_DIR)" "$(MAR_DIR)/current-build/" "$(MAR_NAME_PREFIX)" "$(UPDATE_CONFIG)" - MAR=$(INSTDIR)/program/mar $(SRCDIR)/bin/update/create_full_mar_for_languages.py "$(PRODUCTNAME)" "$(WORKDIR)" "$(UPDATE_DIR)" "$(MAR_DIR)/language" "$(MAR_NAME_PREFIX)" "$(UPDATE_CONFIG)" - $(SRCDIR)/bin/update/create_build_config.py "$(PRODUCTNAME)" "$(VERSION)" "$(BUILDID)" "$(PLATFORM)" "$(UPDATE_DIR)" "$(UPDATE_CONFIG)" "$(UPDATE_CONFIG)" + MAR=$(INSTDIR)/program/mar $(SRCDIR)/bin/update/create_full_mar.py "$(PRODUCTNAME)" "$(WORKDIR)" "$(MAR_NAME_PREFIX)" "$(UPDATE_CONFIG)" + MAR=$(INSTDIR)/program/mar $(SRCDIR)/bin/update/create_full_mar_for_languages.py "$(PRODUCTNAME)" "$(WORKDIR)" "$(MAR_NAME_PREFIX)" "$(UPDATE_CONFIG)" + $(SRCDIR)/bin/update/create_build_config.py "$(PRODUCTNAME)" "$(VERSION)" "$(BUILDID)" "$(PLATFORM)" "$(UPDATE_DIR)" "$(UPDATE_CONFIG)" upload-update-info: $(eval BUILDID := $(shell git -C $(SRCDIR) log -1 --format=%H)) @@ -51,11 +49,6 @@ create-partial-info: $(eval VERSION := $(LIBO_VERSION_MAJOR).$(LIBO_VERSION_MINOR).$(LIBO_VERSION_MICRO).$(LIBO_VERSION_PATCH)$(LIBO_VERSION_SUFFIX)$(LIBO_VERSION_SUFFIX_SUFFIX)) $(eval PLATFORM := $(RTL_OS)_$(RTL_ARCH)) $(eval MAR_NAME_PREFIX := $(PRODUCTNAME)_$(VERSION)_$(PLATFORM)_$(BUILDID)) - $(eval UPDATE_DIR := $(WORKDIR)/update-info) - $(eval MAR_DIR := $(WORKDIR)/mar) - $(eval CURRENT_BUILD := $(WORKDIR)/mar/current-build/) - mkdir -p $(UPDATE_DIR) - mkdir -p $(UPDATE_DIR)/previous-builds - MAR=$(INSTDIR)/program/mar $(SRCDIR)/bin/update/create_partial_update.py "$(PRODUCTNAME)" "$(WORKDIR)" "$(UPDATE_DIR)" "$(MAR_DIR)/previous-builds/" "$(MAR_NAME_PREFIX)" "$(UPDATE_CONFIG)" "$(PLATFORM)" "$(CURRENT_BUILD)" "$(BUILDID)" "$(MAR_DIR)" + MAR=$(INSTDIR)/program/mar $(SRCDIR)/bin/update/create_partial_update.py "$(WORKDIR)" "$(MAR_NAME_PREFIX)" "$(UPDATE_CONFIG)" "$(PLATFORM)" "$(BUILDID)" # vim: set noet sw=4 ts=4: diff --git a/bin/update/create_full_mar.py b/bin/update/create_full_mar.py index 649eafe2bfa6..a9d7aa2b9fe5 100755 --- a/bin/update/create_full_mar.py +++ b/bin/update/create_full_mar.py @@ -8,19 +8,19 @@ import json from tools import uncompress_file_to_dir, get_file_info, make_complete_mar_name from config import parse_config from signing import sign_mar_file +from path import UpdaterPath current_dir_path = os.path.dirname(os.path.realpath(__file__)) +def ensure_dir_exist() + def main(): - print(sys.argv) - if len(sys.argv) < 7: - print("Usage: create_full_mar_for_languages.py $PRODUCTNAME $WORKDIR $TARGETDIR $TEMPDIR $FILENAMEPREFIX $UPDATE_CONFIG") + if len(sys.argv) < 5: + print("Usage: create_full_mar_for_languages.py $PRODUCTNAME $WORKDIR $FILENAMEPREFIX $UPDATE_CONFIG") sys.exit(1) - update_config = sys.argv[6] - filename_prefix = sys.argv[5] - temp_dir = sys.argv[4] - target_dir = sys.argv[3] + update_config = sys.argv[4] + filename_prefix = sys.argv[3] workdir = sys.argv[2] product_name = sys.argv[1] @@ -28,6 +28,12 @@ def main(): print("missing update config") sys.exit(1) + update_path = UpdaterPath(workdir) + update_path.ensure_dir_exist() + + target_dir = update_path.get_update_dir() + temp_dir = update_path.get_current_build_dir() + config = parse_config(update_config) tar_dir = os.path.join(workdir, "installation", product_name, "archive", "install", "en-US") diff --git a/bin/update/create_full_mar_for_languages.py b/bin/update/create_full_mar_for_languages.py index 7daf5fe6034e..98e1b1c539e7 100755 --- a/bin/update/create_full_mar_for_languages.py +++ b/bin/update/create_full_mar_for_languages.py @@ -8,6 +8,7 @@ import json from tools import uncompress_file_to_dir, get_file_info from config import parse_config +from path import UpdaterPath current_dir_path = os.path.dirname(os.path.realpath(__file__)) @@ -22,18 +23,19 @@ def create_lang_infos(mar_file_name, language, url): return data def main(): - print(sys.argv) - if len(sys.argv) < 7: + if len(sys.argv) < 5: print("Usage: create_full_mar_for_languages.py $PRODUCTNAME $WORKDIR $TARGETDIR $TEMPDIR $FILENAMEPREFIX $UPDATE_CONFIG") sys.exit(1) - update_config = sys.argv[6] - filename_prefix = sys.argv[5] - temp_dir = sys.argv[4] - target_dir = sys.argv[3] + update_config = sys.argv[4] + filename_prefix = sys.argv[3] workdir = sys.argv[2] product_name = sys.argv[1] + updater_path = UpdaterPath(workdir) + target_dir = updater_path.get_update_dir() + temp_dir = updater_path.get_language_dir() + config = parse_config(update_config) mar_executable = os.environ.get('MAR', 'mar') diff --git a/bin/update/create_partial_update.py b/bin/update/create_partial_update.py index ca194325d20d..419a8f65226b 100755 --- a/bin/update/create_partial_update.py +++ b/bin/update/create_partial_update.py @@ -10,12 +10,19 @@ import json from config import parse_config from uncompress_mar import extract_mar -from tools import get_file_info +from tools import get_file_info, get_hash from signing import sign_mar_file +from path import UpdaterPath, mkdir_p + BUF_SIZE = 1024 current_dir_path = os.path.dirname(os.path.realpath(__file__)) +def InvalidFileException(Exception): + + def __init__(self, *args, **kwargs): + super().__init__(self, *args, **kwargs) + def download_file(filepath, url, hash_string): with open(filepath, "wb") as f: response = requests.get(url, stream=True) @@ -26,26 +33,10 @@ def download_file(filepath, url, hash_string): for block in response.iter_content(1024): f.write(block) - with open(filepath, "rb") as f: - sha512 = hashlib.sha512() - while True: - data = f.read(BUF_SIZE) - if not data: - break - sha512.update(data) - file_hash = sha512.hexdigest() + file_hash = get_hash(filepath) if file_hash != hash_string: - pass - -def mkdir_p(path): - try: - os.makedirs(path) - except OSError as exc: # Python >2.5 - if exc.errno == errno.EEXIST and os.path.isdir(path): - pass - else: - raise + raise InvalidFileException() def handle_language(lang_entries, filedir): mar = os.environ.get('MAR', 'mar') @@ -109,16 +100,20 @@ def add_single_dir(path): return dir_name[0] def main(): - product_name = sys.argv[1] - workdir = sys.argv[2] - update_dir = sys.argv[3] - temp_dir = sys.argv[4] - mar_name_prefix = sys.argv[5] - update_config = sys.argv[6] - platform = sys.argv[7] - current_build_path = sys.argv[8] - build_id = sys.argv[9] - mar_dir = sys.argv[10] + workdir = sys.argv[1] + + updater_path = UpdaterPath(workdir) + updater_path.ensure_dir_exist() + + mar_name_prefix = sys.argv[2] + update_config = sys.argv[3] + platform = sys.argv[4] + build_id = sys.argv[5] + + current_build_path = updater_path.get_current_build_dir() + mar_dir = updater_path.get_mar_dir() + temp_dir = updater_path.get_previous_build_dir() + update_dir = updater_path.get_update_dir() current_build_path = add_single_dir(current_build_path) |