From 9b8a7d74cc9c9b1dbb81a3dace591d6a05751707 Mon Sep 17 00:00:00 2001 From: "Magomed Kostoev (mkostoevr)" Date: Sat, 4 Dec 2021 10:35:34 +0000 Subject: [PATCH] [WS] Cache kolibri.img in _tools/cache git-svn-id: svn://kolibrios.org@9383 a494cfbc-eb01-0410-851d-a64ba20cac60 --- _tools/get_started.py | 6 ++++++ _tools/lib/constants.py | 8 ++++++++ _tools/workspace/run.py | 6 ++---- 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 _tools/lib/constants.py diff --git a/_tools/get_started.py b/_tools/get_started.py index 5d206a2cfe..89c6b39c09 100755 --- a/_tools/get_started.py +++ b/_tools/get_started.py @@ -4,7 +4,9 @@ import os +from lib.network import download_if_not_exist from lib.logging import log +from lib.constants import tools_cache, tools_cache_kolibri_img def generate_script_executing_script(script_to_execute): script_to_execute = script_to_execute.replace("\\", "\\\\") @@ -35,3 +37,7 @@ if __name__ == "__main__": # Initalize tup here # TODO: Do anything if tup doesn't exist os.system("tup init") + # Download IMG to _tools/cache + os.makedirs(tools_cache, exist_ok = True) + img_url = "http://builds.kolibrios.org/eng/data/data/kolibri.img" + download_if_not_exist(img_url, tools_cache_kolibri_img) diff --git a/_tools/lib/constants.py b/_tools/lib/constants.py new file mode 100644 index 0000000000..5f9e40b721 --- /dev/null +++ b/_tools/lib/constants.py @@ -0,0 +1,8 @@ +import os + +tools_lib_constants_py = os.path.abspath(__file__) +tools_lib = os.path.dirname(tools_lib_constants_py) +tools = os.path.dirname(tools_lib) +tools_cache = os.path.join(tools, "cache") +tools_cache_kolibri_img = os.path.join(tools_cache, "kolibri.img") + diff --git a/_tools/workspace/run.py b/_tools/workspace/run.py index 2c02140191..f50c4d9bf2 100644 --- a/_tools/workspace/run.py +++ b/_tools/workspace/run.py @@ -15,6 +15,7 @@ from lib.makeflop import Floppy from lib.platform import is_win32, path from lib.logging import log from lib.network import download_if_not_exist +from lib.constants import tools_cache_kolibri_img # TODO: Move into _tools/lib def run_qemu(start_dir = "workspace"): @@ -44,11 +45,8 @@ if __name__ == "__main__": os.makedirs("workspace", exist_ok = True) - img_url = "http://builds.kolibrios.org/eng/data/data/kolibri.img" - download_if_not_exist(img_url, "workspace/kolibri.unmodified.img") - # Create a copy of IMG - shutil.copyfile("workspace/kolibri.unmodified.img", "workspace/kolibri.img") + shutil.copyfile(tools_cache_kolibri_img, "workspace/kolibri.img") # Open the IMG with open("workspace/kolibri.img", "rb") as img: