From 99f65101eb3f4ad718374cc1c1b91dbf876b7fce Mon Sep 17 00:00:00 2001 From: Diego Fonseca Date: Mon, 4 Dec 2023 11:09:17 -0500 Subject: [PATCH 01/10] Hopefully Stable --- src/net/pickhaxe/tools/commands/Setup.hx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/net/pickhaxe/tools/commands/Setup.hx b/src/net/pickhaxe/tools/commands/Setup.hx index 88e05fe..3edbd6e 100644 --- a/src/net/pickhaxe/tools/commands/Setup.hx +++ b/src/net/pickhaxe/tools/commands/Setup.hx @@ -78,9 +78,17 @@ class Setup implements ICommand function setupMac():Void { - // TODO: Implement this. - // https://github.com/openfl/lime/blob/develop/tools/utils/PlatformSetup.hx#L824 - CLI.print('Sorry, this command is not supported on your platform.'); + var haxePathEnv:String = Sys.getEnv('HAXEPATH') ?? '/usr/local/bin'; + var haxePath:Path = new Path(haxePathEnv); + + try + { + var source:Path = IO.libraryDir().joinPaths('templates/bin/${Constants.LIBRARY_ID}.sh'); + var target:Path = haxePath.joinPaths('${Constants.LIBRARY_ID}'); + + IO.copyFile(source, target); + } + catch (e:Dynamic) {} } function setupLinux():Void From 785bcf4c2b620eca385077592480fa8ae91f2dc5 Mon Sep 17 00:00:00 2001 From: Diego Fonseca Date: Mon, 4 Dec 2023 11:13:31 -0500 Subject: [PATCH 02/10] Update IO.hx --- src/net/pickhaxe/tools/util/IO.hx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/net/pickhaxe/tools/util/IO.hx b/src/net/pickhaxe/tools/util/IO.hx index 25959cb..6117b65 100644 --- a/src/net/pickhaxe/tools/util/IO.hx +++ b/src/net/pickhaxe/tools/util/IO.hx @@ -279,6 +279,8 @@ class IO */ public static function copyFile(source:Path, dest:Path):Void { + CFI.print("source: " + source.toString() + ", dest: " + dest.toString())); + sys.io.File.copy(source.toString(), dest.toString()); } From 2a3b1d58bbbeae8a392153f042fec663ff94f70b Mon Sep 17 00:00:00 2001 From: Diego Fonseca Date: Mon, 4 Dec 2023 11:13:56 -0500 Subject: [PATCH 03/10] Update IO.hx --- src/net/pickhaxe/tools/util/IO.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net/pickhaxe/tools/util/IO.hx b/src/net/pickhaxe/tools/util/IO.hx index 6117b65..6bfe5fe 100644 --- a/src/net/pickhaxe/tools/util/IO.hx +++ b/src/net/pickhaxe/tools/util/IO.hx @@ -279,7 +279,7 @@ class IO */ public static function copyFile(source:Path, dest:Path):Void { - CFI.print("source: " + source.toString() + ", dest: " + dest.toString())); + CFI.print("source: " + source.toString() + ", dest: " + dest.toString()); sys.io.File.copy(source.toString(), dest.toString()); } From 27d3f44b2d2e3588d4724f95180f05802e114e9c Mon Sep 17 00:00:00 2001 From: Diego Fonseca Date: Mon, 4 Dec 2023 11:14:28 -0500 Subject: [PATCH 04/10] Update IO.hx --- src/net/pickhaxe/tools/util/IO.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net/pickhaxe/tools/util/IO.hx b/src/net/pickhaxe/tools/util/IO.hx index 6bfe5fe..92571de 100644 --- a/src/net/pickhaxe/tools/util/IO.hx +++ b/src/net/pickhaxe/tools/util/IO.hx @@ -279,7 +279,7 @@ class IO */ public static function copyFile(source:Path, dest:Path):Void { - CFI.print("source: " + source.toString() + ", dest: " + dest.toString()); + trace("source: " + source.toString() + ", dest: " + dest.toString()); sys.io.File.copy(source.toString(), dest.toString()); } From ef0d2451b4ad7b02d9204f52a75a219845903170 Mon Sep 17 00:00:00 2001 From: Diego Fonseca Date: Mon, 4 Dec 2023 11:15:45 -0500 Subject: [PATCH 05/10] Update Setup.hx --- src/net/pickhaxe/tools/commands/Setup.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net/pickhaxe/tools/commands/Setup.hx b/src/net/pickhaxe/tools/commands/Setup.hx index 3edbd6e..87b1abf 100644 --- a/src/net/pickhaxe/tools/commands/Setup.hx +++ b/src/net/pickhaxe/tools/commands/Setup.hx @@ -84,7 +84,7 @@ class Setup implements ICommand try { var source:Path = IO.libraryDir().joinPaths('templates/bin/${Constants.LIBRARY_ID}.sh'); - var target:Path = haxePath.joinPaths('${Constants.LIBRARY_ID}'); + var target:Path = haxePath.joinPaths('${Constants.LIBRARY_ID}.sh'); IO.copyFile(source, target); } From 82cd1926ea8c2148c60a74e3d619e307e2b0e1d3 Mon Sep 17 00:00:00 2001 From: Diego Fonseca Date: Mon, 4 Dec 2023 11:19:01 -0500 Subject: [PATCH 06/10] Update Setup.hx --- src/net/pickhaxe/tools/commands/Setup.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net/pickhaxe/tools/commands/Setup.hx b/src/net/pickhaxe/tools/commands/Setup.hx index 87b1abf..3edbd6e 100644 --- a/src/net/pickhaxe/tools/commands/Setup.hx +++ b/src/net/pickhaxe/tools/commands/Setup.hx @@ -84,7 +84,7 @@ class Setup implements ICommand try { var source:Path = IO.libraryDir().joinPaths('templates/bin/${Constants.LIBRARY_ID}.sh'); - var target:Path = haxePath.joinPaths('${Constants.LIBRARY_ID}.sh'); + var target:Path = haxePath.joinPaths('${Constants.LIBRARY_ID}'); IO.copyFile(source, target); } From 5765b60c38959251893897f461e6f70a1bb4f044 Mon Sep 17 00:00:00 2001 From: Diego Fonseca Date: Mon, 4 Dec 2023 11:30:08 -0500 Subject: [PATCH 07/10] Update for cross platform-ability --- src/net/pickhaxe/tools/commands/Setup.hx | 2 +- src/net/pickhaxe/tools/util/IO.hx | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/net/pickhaxe/tools/commands/Setup.hx b/src/net/pickhaxe/tools/commands/Setup.hx index 3edbd6e..a68df56 100644 --- a/src/net/pickhaxe/tools/commands/Setup.hx +++ b/src/net/pickhaxe/tools/commands/Setup.hx @@ -86,7 +86,7 @@ class Setup implements ICommand var source:Path = IO.libraryDir().joinPaths('templates/bin/${Constants.LIBRARY_ID}.sh'); var target:Path = haxePath.joinPaths('${Constants.LIBRARY_ID}'); - IO.copyFile(source, target); + IO.copyFileUnix(source, target); } catch (e:Dynamic) {} } diff --git a/src/net/pickhaxe/tools/util/IO.hx b/src/net/pickhaxe/tools/util/IO.hx index 92571de..0aa6c53 100644 --- a/src/net/pickhaxe/tools/util/IO.hx +++ b/src/net/pickhaxe/tools/util/IO.hx @@ -279,11 +279,20 @@ class IO */ public static function copyFile(source:Path, dest:Path):Void { - trace("source: " + source.toString() + ", dest: " + dest.toString()); - sys.io.File.copy(source.toString(), dest.toString()); } + /** + * Copy a file from one location to another + * , requesting administrative access. + * @param source The path to the file to copy. + * @param dest The path to copy the file to. + */ + public static function copyFileUnix(source:Path, dest:Path):Void + { + Sys.command("sudo", ["cp", source.toString(), dest.toString()]); + } + /** * Clean up a path and convert it to a Path object. * @param input The path to clean up. From 7004b56ea3e28b8a9830afa321f4de83b3c64a3d Mon Sep 17 00:00:00 2001 From: Diego Fonseca Date: Mon, 4 Dec 2023 11:35:09 -0500 Subject: [PATCH 08/10] Update Permissions --- src/net/pickhaxe/tools/commands/Setup.hx | 1 + src/net/pickhaxe/tools/util/IO.hx | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/net/pickhaxe/tools/commands/Setup.hx b/src/net/pickhaxe/tools/commands/Setup.hx index a68df56..a7f8016 100644 --- a/src/net/pickhaxe/tools/commands/Setup.hx +++ b/src/net/pickhaxe/tools/commands/Setup.hx @@ -87,6 +87,7 @@ class Setup implements ICommand var target:Path = haxePath.joinPaths('${Constants.LIBRARY_ID}'); IO.copyFileUnix(source, target); + IO.updatePermissions(target) } catch (e:Dynamic) {} } diff --git a/src/net/pickhaxe/tools/util/IO.hx b/src/net/pickhaxe/tools/util/IO.hx index 0aa6c53..a64e2ba 100644 --- a/src/net/pickhaxe/tools/util/IO.hx +++ b/src/net/pickhaxe/tools/util/IO.hx @@ -293,6 +293,15 @@ class IO Sys.command("sudo", ["cp", source.toString(), dest.toString()]); } + /* + * Update permissions for file to not require administration access. (Unix only) + * @param path The path to the file to update permissions for. + */ + public static function updatePermissions(path:Path):Void + { + Sys.command("sudo", ["chmod", "+x", binPath + "/spoopy"]); + } + /** * Clean up a path and convert it to a Path object. * @param input The path to clean up. From 04ead4fdc6f60cf570ec83e8ed7c86264372acb8 Mon Sep 17 00:00:00 2001 From: Diego Fonseca Date: Mon, 4 Dec 2023 11:35:44 -0500 Subject: [PATCH 09/10] Update Setup.hx --- src/net/pickhaxe/tools/commands/Setup.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net/pickhaxe/tools/commands/Setup.hx b/src/net/pickhaxe/tools/commands/Setup.hx index a7f8016..611f228 100644 --- a/src/net/pickhaxe/tools/commands/Setup.hx +++ b/src/net/pickhaxe/tools/commands/Setup.hx @@ -87,7 +87,7 @@ class Setup implements ICommand var target:Path = haxePath.joinPaths('${Constants.LIBRARY_ID}'); IO.copyFileUnix(source, target); - IO.updatePermissions(target) + IO.updatePermissions(target); } catch (e:Dynamic) {} } From c103bfdeb9ecdcd9f3af7a6d9c44934cc511a0b8 Mon Sep 17 00:00:00 2001 From: Diego Fonseca Date: Mon, 4 Dec 2023 11:36:11 -0500 Subject: [PATCH 10/10] Update IO.hx --- src/net/pickhaxe/tools/util/IO.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net/pickhaxe/tools/util/IO.hx b/src/net/pickhaxe/tools/util/IO.hx index a64e2ba..1a1c2a6 100644 --- a/src/net/pickhaxe/tools/util/IO.hx +++ b/src/net/pickhaxe/tools/util/IO.hx @@ -299,7 +299,7 @@ class IO */ public static function updatePermissions(path:Path):Void { - Sys.command("sudo", ["chmod", "+x", binPath + "/spoopy"]); + Sys.command("sudo", ["chmod", "+x", path.toString()]); } /**