From 0eca72d046528633452bb759205f0e8509a08d8b Mon Sep 17 00:00:00 2001 From: Daniel Santa Cruz Date: Sun, 12 Jun 2022 06:38:51 -0600 Subject: [PATCH] ant@1.10.12: Persist user libs (#3664) * ant@1.10.12: Import user libs from persist dir Import any extra libs persisted by the user in $persist_dir\lib, such as ant-contrib, that are not part of the default ant install. * Remove checking that the path is a dir Co-authored-by: Issac Lin * Copy only libs from the persist lib dir that are not already in lib * ant: improve uninstall logic persist user added libs to $dir/lib Co-authored-by: Issac Lin --- bucket/ant.json | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/bucket/ant.json b/bucket/ant.json index 9da16ef667..aad9463f8b 100644 --- a/bucket/ant.json +++ b/bucket/ant.json @@ -9,10 +9,31 @@ "url": "https://www.apache.org/dist/ant/binaries/apache-ant-1.10.12-bin.zip", "hash": "sha512:7e6fbcc3563df4bd87c883ad86a161a71da2774e0ed71a1b3aad82cbff1a7656ed9a0acb5ce40652129376dfd79f1ef74ec3369c1067d412a63062fea62ceccd", "extract_dir": "apache-ant-1.10.12", + "pre_install": [ + "# Record built-in libs in builtin_libs.json", + "$builtin_libs = Get-ChildItem \"$dir\\lib\" | Select -ExpandProperty Name", + "$builtin_libs | ConvertTo-Json | Out-File \"$dir\\lib\\builtin_libs.json\" -Encoding Ascii", + "# Copy user libs to $dir", + "if (Test-Path \"$persist_dir\\lib\") {", + " Get-ChildItem \"$persist_dir\\lib\" | Select -ExpandProperty Name | ForEach-Object {", + " if (!(Test-Path \"$dir\\lib\\$_\")) { Copy-Item \"$persist_dir\\lib\\$_\" \"$dir\\lib\" }", + " }", + "}" + ], "env_add_path": "bin", "env_set": { "ANT_HOME": "$dir" }, + "uninstaller": { + "script": [ + "# Only persist libs that were added by the user, but not built-in ones", + "ensure \"$persist_dir\\lib\" | Out-Null", + "$builtin_libs = Get-Content \"$dir\\lib\\builtin_libs.json\" | ConvertFrom-Json", + "Get-ChildItem \"$dir\\lib\" -Exclude builtin_libs.json | Select -ExpandProperty Name | ForEach-Object {", + " if (!($builtin_libs -contains \"$_\")) { Copy-Item \"$dir\\lib\\$_\" \"$persist_dir\\lib\" }", + "}" + ] + }, "checkver": { "url": "https://ant.apache.org/bindownload.cgi", "regex": "Currently, Apache Ant (?:[\\d.]+ and )?([\\d.]+) (?:is|are) the best"