From 87b537acb40e2adb84f5e139400499cfdcddaaf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20P=C3=89RON?= Date: Tue, 23 Dec 2025 11:26:50 +0100 Subject: [PATCH 1/8] support windows --- hooks/post_install.lua | 43 +++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/hooks/post_install.lua b/hooks/post_install.lua index 3c9ffd5..cf8cac5 100644 --- a/hooks/post_install.lua +++ b/hooks/post_install.lua @@ -24,26 +24,47 @@ function PLUGIN:PostInstall(ctx) -- So we need to reorganize: move rootPath/* to rootPath/cmdline-tools/VERSION/ local temp_path = root_path .. "-temp" - local target_path = file.join_path(root_path, "cmdline-tools", version) + local parent_path = file.join_path(root_path, "cmdline-tools") + local target_path = file.join_path(parent_path, version) + -- Cross-platform file operations (works on Unix and Windows) + local win = package.config:sub(1,1) == "\\" + + local function move(src, dst) + if win then + print('move "' .. src .. '" "' .. dst .. '"') + return os.execute('move "' .. src .. '" "' .. dst .. '"') + else + return os.execute('mv "' .. src .. '" "' .. dst .. '"') + end + end + + local function mkdir(path) + if win then + os.execute('mkdir "' .. path .. '"') + else + os.execute('mkdir -p "' .. path .. '"') + end + end + -- Move current rootPath to temp location - os.execute("mv " .. root_path .. " " .. temp_path) + move(root_path, temp_path) - -- Recreate rootPath with proper structure - os.execute("mkdir -p " .. target_path) + -- Recreate parent_path with proper structure + mkdir(target_parent) - -- Move contents from temp to target - os.execute("mv " .. temp_path .. "/* " .. target_path .. "/") - - -- Clean up temp - os.execute("rm -rf " .. temp_path) + -- Move temp to target + move(temp_path, target_path) -- Verify installation - local sdkmanager_path = file.join_path(target_path, "bin", "sdkmanager") + if win then ext = ".bat" else ext = "" end + local sdkmanager_path = file.join_path(target_path, "bin", "sdkmanager" .. ext) if not file.exists(sdkmanager_path) then error("Installation verification failed: sdkmanager not found at " .. sdkmanager_path) end -- Make sure binaries are executable (for Unix systems) - os.execute("chmod +x " .. file.join_path(target_path, "bin", "*") .. " 2>/dev/null || true") + if not win then + os.execute("chmod +x " .. file.join_path(target_path, "bin", "*") .. " 2>/dev/null || true") + end end From f5a0d60df4687cf116afea23239894abd03dd453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20P=C3=89RON?= Date: Wed, 15 Apr 2026 14:30:09 +0200 Subject: [PATCH 2/8] fix: use correct path variable in post_install --- hooks/post_install.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/post_install.lua b/hooks/post_install.lua index cf8cac5..00705a0 100644 --- a/hooks/post_install.lua +++ b/hooks/post_install.lua @@ -51,7 +51,7 @@ function PLUGIN:PostInstall(ctx) move(root_path, temp_path) -- Recreate parent_path with proper structure - mkdir(target_parent) + mkdir(parent_path) -- Move temp to target move(temp_path, target_path) From 009247717706b87f36214de852ae7999467c703e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20P=C3=89RON?= Date: Wed, 13 May 2026 07:17:25 +0200 Subject: [PATCH 3/8] OS detection based on RUNTIME.osType --- hooks/post_install.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/post_install.lua b/hooks/post_install.lua index 00705a0..02cf745 100644 --- a/hooks/post_install.lua +++ b/hooks/post_install.lua @@ -28,7 +28,7 @@ function PLUGIN:PostInstall(ctx) local target_path = file.join_path(parent_path, version) -- Cross-platform file operations (works on Unix and Windows) - local win = package.config:sub(1,1) == "\\" + local win = RUNTIME.osType == "windows" local function move(src, dst) if win then From 82cf18e82e000df25fd97eb3f377d42301dcb9a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20P=C3=89RON?= Date: Wed, 13 May 2026 10:09:44 +0200 Subject: [PATCH 4/8] use os.rename instead of os.execute --- hooks/post_install.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hooks/post_install.lua b/hooks/post_install.lua index 02cf745..aa31c0d 100644 --- a/hooks/post_install.lua +++ b/hooks/post_install.lua @@ -31,11 +31,9 @@ function PLUGIN:PostInstall(ctx) local win = RUNTIME.osType == "windows" local function move(src, dst) - if win then - print('move "' .. src .. '" "' .. dst .. '"') - return os.execute('move "' .. src .. '" "' .. dst .. '"') - else - return os.execute('mv "' .. src .. '" "' .. dst .. '"') + local ok, err = os.rename(src, dst) + if not ok then + error("Failed to move " .. src .. " to " .. dst .. ": " .. err) end end From 6cd7c34002bee665d557a8e812ca6c28a593f408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20P=C3=89RON?= Date: Thu, 14 May 2026 21:36:14 +0200 Subject: [PATCH 5/8] use os.rename and cmd.exec with cwd defined on windows --- hooks/post_install.lua | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/hooks/post_install.lua b/hooks/post_install.lua index aa31c0d..c4db112 100644 --- a/hooks/post_install.lua +++ b/hooks/post_install.lua @@ -30,32 +30,23 @@ function PLUGIN:PostInstall(ctx) -- Cross-platform file operations (works on Unix and Windows) local win = RUNTIME.osType == "windows" - local function move(src, dst) - local ok, err = os.rename(src, dst) - if not ok then - error("Failed to move " .. src .. " to " .. dst .. ": " .. err) - end - end - - local function mkdir(path) - if win then - os.execute('mkdir "' .. path .. '"') - else - os.execute('mkdir -p "' .. path .. '"') - end - end - -- Move current rootPath to temp location - move(root_path, temp_path) + os.rename(root_path, temp_path) -- Recreate parent_path with proper structure - mkdir(parent_path) + local cmd = require("cmd") + if win then + local systemroot = os.getenv("SystemRoot") or "C:\\Windows" + cmd.exec('mkdir "' .. parent_path .. '"', {cwd = systemroot}) + else + cmd.exec('mkdir -p "' .. parent_path .. '"') + end -- Move temp to target - move(temp_path, target_path) + os.rename(temp_path, target_path) -- Verify installation - if win then ext = ".bat" else ext = "" end + local ext = win and ".bat" or "" local sdkmanager_path = file.join_path(target_path, "bin", "sdkmanager" .. ext) if not file.exists(sdkmanager_path) then error("Installation verification failed: sdkmanager not found at " .. sdkmanager_path) From 237ac93d70a80c7d4b03a0abeb08a833fbe898a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20P=C3=89RON?= Date: Fri, 15 May 2026 09:32:35 +0200 Subject: [PATCH 6/8] Revert "use os.rename and cmd.exec with cwd defined on windows" This reverts commit 6cd7c34002bee665d557a8e812ca6c28a593f408. --- hooks/post_install.lua | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/hooks/post_install.lua b/hooks/post_install.lua index c4db112..aa31c0d 100644 --- a/hooks/post_install.lua +++ b/hooks/post_install.lua @@ -30,23 +30,32 @@ function PLUGIN:PostInstall(ctx) -- Cross-platform file operations (works on Unix and Windows) local win = RUNTIME.osType == "windows" + local function move(src, dst) + local ok, err = os.rename(src, dst) + if not ok then + error("Failed to move " .. src .. " to " .. dst .. ": " .. err) + end + end + + local function mkdir(path) + if win then + os.execute('mkdir "' .. path .. '"') + else + os.execute('mkdir -p "' .. path .. '"') + end + end + -- Move current rootPath to temp location - os.rename(root_path, temp_path) + move(root_path, temp_path) -- Recreate parent_path with proper structure - local cmd = require("cmd") - if win then - local systemroot = os.getenv("SystemRoot") or "C:\\Windows" - cmd.exec('mkdir "' .. parent_path .. '"', {cwd = systemroot}) - else - cmd.exec('mkdir -p "' .. parent_path .. '"') - end + mkdir(parent_path) -- Move temp to target - os.rename(temp_path, target_path) + move(temp_path, target_path) -- Verify installation - local ext = win and ".bat" or "" + if win then ext = ".bat" else ext = "" end local sdkmanager_path = file.join_path(target_path, "bin", "sdkmanager" .. ext) if not file.exists(sdkmanager_path) then error("Installation verification failed: sdkmanager not found at " .. sdkmanager_path) From 947b0671a2abf3b6a2ba224e533b9572bcc60f4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20P=C3=89RON?= Date: Fri, 15 May 2026 09:34:11 +0200 Subject: [PATCH 7/8] Revert "use os.rename instead of os.execute" This reverts commit 82cf18e82e000df25fd97eb3f377d42301dcb9a3. --- hooks/post_install.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hooks/post_install.lua b/hooks/post_install.lua index aa31c0d..02cf745 100644 --- a/hooks/post_install.lua +++ b/hooks/post_install.lua @@ -31,9 +31,11 @@ function PLUGIN:PostInstall(ctx) local win = RUNTIME.osType == "windows" local function move(src, dst) - local ok, err = os.rename(src, dst) - if not ok then - error("Failed to move " .. src .. " to " .. dst .. ": " .. err) + if win then + print('move "' .. src .. '" "' .. dst .. '"') + return os.execute('move "' .. src .. '" "' .. dst .. '"') + else + return os.execute('mv "' .. src .. '" "' .. dst .. '"') end end From 6d0a6e7ada3609211095b97ccb52e3a39169495f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20P=C3=89RON?= Date: Fri, 15 May 2026 09:39:07 +0200 Subject: [PATCH 8/8] use cmd.exec instead of os.execute to define cwd on windows --- hooks/post_install.lua | 45 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/hooks/post_install.lua b/hooks/post_install.lua index 02cf745..4549001 100644 --- a/hooks/post_install.lua +++ b/hooks/post_install.lua @@ -29,35 +29,34 @@ function PLUGIN:PostInstall(ctx) -- Cross-platform file operations (works on Unix and Windows) local win = RUNTIME.osType == "windows" - - local function move(src, dst) - if win then - print('move "' .. src .. '" "' .. dst .. '"') - return os.execute('move "' .. src .. '" "' .. dst .. '"') - else - return os.execute('mv "' .. src .. '" "' .. dst .. '"') - end - end - - local function mkdir(path) - if win then - os.execute('mkdir "' .. path .. '"') - else - os.execute('mkdir -p "' .. path .. '"') - end - end - + local cmd = require("cmd") + -- Move current rootPath to temp location - move(root_path, temp_path) + if win then + local systemroot = os.getenv("SystemRoot") or "C:\\Windows" + cmd.exec('move "' .. root_path .. '" "' .. temp_path .. '"', {cwd = systemroot}) + else + cmd.exec('mv "' .. root_path .. '" "' .. temp_path .. '"') + end -- Recreate parent_path with proper structure - mkdir(parent_path) + if win then + local systemroot = os.getenv("SystemRoot") or "C:\\Windows" + cmd.exec('mkdir "' .. parent_path .. '"', {cwd = systemroot}) + else + cmd.exec('mkdir -p "' .. parent_path .. '"') + end -- Move temp to target - move(temp_path, target_path) + if win then + local systemroot = os.getenv("SystemRoot") or "C:\\Windows" + cmd.exec('move "' .. temp_path .. '" "' .. target_path .. '"', {cwd = systemroot}) + else + cmd.exec('mv "' .. temp_path .. '" "' .. target_path .. '"') + end -- Verify installation - if win then ext = ".bat" else ext = "" end + local ext = win and ".bat" or "" local sdkmanager_path = file.join_path(target_path, "bin", "sdkmanager" .. ext) if not file.exists(sdkmanager_path) then error("Installation verification failed: sdkmanager not found at " .. sdkmanager_path) @@ -65,6 +64,6 @@ function PLUGIN:PostInstall(ctx) -- Make sure binaries are executable (for Unix systems) if not win then - os.execute("chmod +x " .. file.join_path(target_path, "bin", "*") .. " 2>/dev/null || true") + cmd.exec("chmod +x " .. file.join_path(target_path, "bin", "*") .. " 2>/dev/null || true") end end