From c94e1a31ea11d459740e1ad529bb5626a5bde671 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Wed, 18 Oct 2023 13:10:48 +0200 Subject: [PATCH 1/5] add fetch-jdk --force --- src/mx/_impl/mx_fetchjdk.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mx/_impl/mx_fetchjdk.py b/src/mx/_impl/mx_fetchjdk.py index c6cf951c..3b598734 100644 --- a/src/mx/_impl/mx_fetchjdk.py +++ b/src/mx/_impl/mx_fetchjdk.py @@ -72,11 +72,13 @@ def fetch_jdk(args): if not is_quiet(): if not mx.ask_yes_no(f"Install {artifact} to {final_path}", default='y'): mx.abort("JDK installation canceled") - if exists(final_path): + if not settings["force"] and exists(final_path): if settings["keep-archive"]: mx.warn("The --keep-archive option is ignored when the JDK is already installed.") mx.log(f"Requested JDK is already installed at {final_path}") else: + if settings["force"] and exists(final_path): + mx.rmtree(final_path) # Try to extract on the same file system as the target to be able to atomically move the result. with mx.TempDir(parent_dir=jdks_dir) as temp_dir: part = 1 @@ -333,6 +335,7 @@ def _parse_args(args): parser.add_argument('--keep-archive', action='store_true', help='keep downloaded JDK archive') parser.add_argument('--strip-contents-home', action='store_true', help='strip Contents/Home if it exists from installed JDK') parser.add_argument('--list', action='store_true', help='list the available JDKs and exit') + parser.add_argument('--force', action='store_true', help='force download the JDK and overwrite existing files') args = parser.parse_args(args) if args.to is not None: @@ -378,6 +381,7 @@ def _parse_args(args): settings["keep-archive"] = args.keep_archive settings["strip-contents-home"] = args.strip_contents_home + settings["force"] = args.force return settings From 544b24db70a09f9931a8972517d2bb2ee48a2683 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Tue, 31 Oct 2023 15:24:31 +0100 Subject: [PATCH 2/5] add fetch-jdk --skip-digest-check (instead of --force) --- src/mx/_impl/mx_fetchjdk.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/mx/_impl/mx_fetchjdk.py b/src/mx/_impl/mx_fetchjdk.py index 3b598734..936ee34a 100644 --- a/src/mx/_impl/mx_fetchjdk.py +++ b/src/mx/_impl/mx_fetchjdk.py @@ -72,12 +72,12 @@ def fetch_jdk(args): if not is_quiet(): if not mx.ask_yes_no(f"Install {artifact} to {final_path}", default='y'): mx.abort("JDK installation canceled") - if not settings["force"] and exists(final_path): + if (not settings["digest-check"] or settings["keep-archive"]) and exists(final_path): if settings["keep-archive"]: mx.warn("The --keep-archive option is ignored when the JDK is already installed.") mx.log(f"Requested JDK is already installed at {final_path}") else: - if settings["force"] and exists(final_path): + if settings["digest-check"] and exists(final_path): mx.rmtree(final_path) # Try to extract on the same file system as the target to be able to atomically move the result. with mx.TempDir(parent_dir=jdks_dir) as temp_dir: @@ -335,7 +335,10 @@ def _parse_args(args): parser.add_argument('--keep-archive', action='store_true', help='keep downloaded JDK archive') parser.add_argument('--strip-contents-home', action='store_true', help='strip Contents/Home if it exists from installed JDK') parser.add_argument('--list', action='store_true', help='list the available JDKs and exit') - parser.add_argument('--force', action='store_true', help='force download the JDK and overwrite existing files') + parser.add_argument('--skip-digest-check', dest='digest_check', action='store_false', help=''' + Only check for existence of the destination directory but skip digest check of downloaded archive. + This is useful to avoid redownloading when the download cache has been deleted. + ''') args = parser.parse_args(args) if args.to is not None: @@ -381,7 +384,7 @@ def _parse_args(args): settings["keep-archive"] = args.keep_archive settings["strip-contents-home"] = args.strip_contents_home - settings["force"] = args.force + settings["digest-check"] = args.digest_check return settings From 0bd10d682b8746ef3a35f18a213a38af529f6568 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Tue, 31 Oct 2023 18:19:05 +0100 Subject: [PATCH 3/5] bump version --- src/mx/_impl/mx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mx/_impl/mx.py b/src/mx/_impl/mx.py index c1f47b48..d5524bc9 100755 --- a/src/mx/_impl/mx.py +++ b/src/mx/_impl/mx.py @@ -19247,7 +19247,7 @@ def alarm_handler(signum, frame): abort(1, killsig=signal.SIGINT) # The version must be updated for every PR (checked in CI) and the comment should reflect the PR's issue -version = VersionSpec("7.0.3") # GR-48571 Unittest configs are composed with configs from dependencies +version = VersionSpec("7.1.0") # mx fetch-jdk --skip-digest-check _mx_start_datetime = datetime.utcnow() _last_timestamp = _mx_start_datetime From 6045e1b16fc7136b8e005b1fad8dbd5df906f071 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Tue, 7 Nov 2023 11:40:58 +0100 Subject: [PATCH 4/5] fetch-jdk: delete stale destination directory only after downloading --- src/mx/_impl/mx_fetchjdk.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mx/_impl/mx_fetchjdk.py b/src/mx/_impl/mx_fetchjdk.py index 936ee34a..46469816 100644 --- a/src/mx/_impl/mx_fetchjdk.py +++ b/src/mx/_impl/mx_fetchjdk.py @@ -77,8 +77,6 @@ def fetch_jdk(args): mx.warn("The --keep-archive option is ignored when the JDK is already installed.") mx.log(f"Requested JDK is already installed at {final_path}") else: - if settings["digest-check"] and exists(final_path): - mx.rmtree(final_path) # Try to extract on the same file system as the target to be able to atomically move the result. with mx.TempDir(parent_dir=jdks_dir) as temp_dir: part = 1 @@ -118,6 +116,9 @@ def fetch_jdk(args): mx.log(f"Archive is located at {archive_target_location}") part += 1 + if settings["digest-check"] and exists(final_path): + mx.log(f"Deleting stale {final_path}...") + mx.rmtree(final_path) atomic_file_move_with_fallback(join(extracted_path, jdk_root_folder), final_path) curr_path = final_path From 4673f1b12d92caa26c4757babf5a67d0602f42f7 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Thu, 9 Nov 2023 11:30:16 +0100 Subject: [PATCH 5/5] Fix typo --- src/mx/_impl/mx_fetchjdk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mx/_impl/mx_fetchjdk.py b/src/mx/_impl/mx_fetchjdk.py index 46469816..b7bfa115 100644 --- a/src/mx/_impl/mx_fetchjdk.py +++ b/src/mx/_impl/mx_fetchjdk.py @@ -337,7 +337,7 @@ def _parse_args(args): parser.add_argument('--strip-contents-home', action='store_true', help='strip Contents/Home if it exists from installed JDK') parser.add_argument('--list', action='store_true', help='list the available JDKs and exit') parser.add_argument('--skip-digest-check', dest='digest_check', action='store_false', help=''' - Only check for existence of the destination directory but skip digest check of downloaded archive. + Only check for existence of the destination directory and skip verifying the digest of the downloaded archive. This is useful to avoid redownloading when the download cache has been deleted. ''') args = parser.parse_args(args)