From f5a88fcdd86a93b30315155913c09d4addbd3c66 Mon Sep 17 00:00:00 2001 From: Leo Liu <11664880+silver886@users.noreply.github.com> Date: Tue, 7 Jan 2025 16:55:21 -0800 Subject: [PATCH 1/8] persist config, data, and connections --- bucket/podman.json | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/bucket/podman.json b/bucket/podman.json index 150f540e6d34f..13bccf843ed38 100644 --- a/bucket/podman.json +++ b/bucket/podman.json @@ -10,6 +10,7 @@ } }, "bin": "podman.exe", + "pre_install": "if (Test-Path \"$persist_dir\\config\\*\") { Copy-Item \"$persist_dir\\config\\*\" \"$Env:UserProfile\\.config\\containers\" -Recurse }", "installer": { "script": [ "Expand-DarkArchive \"$dir\\podman-$version-setup.exe\" \"$dir\\_tmp\" -Removal", @@ -20,9 +21,42 @@ "Add-Path -Path $original_dir -TargetEnvVar $scoopPathEnvVar -Global:$global -Force" ] }, + "post_install": [ + "if ((Test-Path \"$Env:UserProfile\\.local\\share\\containers\\cache\\*\") -and !(Test-Path \"$dir\\data\\cache\\*\")) {", + " info '[Persist Data]: Moving data (cache) from default data directory to scoop persist directory . . .'", + " Move-Item \"$Env:UserProfile\\.local\\share\\containers\\cache\\*\" \"$dir\\data\\cache\"", + "}", + "if ((Test-Path \"$Env:UserProfile\\.local\\share\\containers\\podman\\*\") -and !(Test-Path \"$dir\\data\\podman\\*\")) {", + " info '[Persist Data]: Moving data (podman) from default data directory to scoop persist directory . . .'", + " Move-Item \"$Env:UserProfile\\.local\\share\\containers\\podman\\*\" \"$dir\\data\\podman\"", + "}", + "if ((Test-Path \"$Env:UserProfile\\.local\\share\\containers\\storage\\*\") -and !(Test-Path \"$dir\\data\\storage\\*\")) {", + " info '[Persist Data]: Moving data (storage) from default data directory to scoop persist directory . . .'", + " Move-Item \"$Env:UserProfile\\.local\\share\\containers\\storage\\*\" \"$dir\\data\\storage\"", + "}", + "if ((Test-Path \"$Env:AppData\\containers\\*\") -and !(Test-Path \"$dir\\connections\\*\")) {", + " info '[Persist Data]: Moving connections from default data directory to scoop persist directory . . .'", + " Move-Item \"$Env:AppData\\containers\\*\" \"$dir\\connections\"", + "}" + ], + "pre_uninstall": [ + "if (Test-Path \"$Env:UserProfile\\.config\\containers\\*\") {", + " Remove-Item \"$dir\\config\\*\" -Recurse -Force", + " Move-Item \"$Env:UserProfile\\.config\\containers\\*\" \"$dir\\config\"", + "}" + ], "uninstaller": { "script": "Remove-Path -Path $dir -TargetEnvVar $scoopPathEnvVar -Global:$global -Force" }, + "env_set": { + "XDG_DATA_HOME": "$dir\\data", + "PODMAN_CONNECTIONS_CONF": "$dir\\connections\\podman-connections.json" + }, + "persist": [ + "data", + "config", + "connections" + ], "checkver": { "github": "https://github.com/containers/podman" }, From c7aaa98ad36c28bfb0a2ebddf4cd0dcfca7410bb Mon Sep 17 00:00:00 2001 From: Leo Liu <11664880+silver886@users.noreply.github.com> Date: Tue, 7 Jan 2025 22:51:49 -0800 Subject: [PATCH 2/8] remove XDG_DATA_HOME from env var --- bucket/podman.json | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/bucket/podman.json b/bucket/podman.json index 13bccf843ed38..4365a6303b343 100644 --- a/bucket/podman.json +++ b/bucket/podman.json @@ -10,7 +10,12 @@ } }, "bin": "podman.exe", - "pre_install": "if (Test-Path \"$persist_dir\\config\\*\") { Copy-Item \"$persist_dir\\config\\*\" \"$Env:UserProfile\\.config\\containers\" -Recurse }", + "pre_install": [ + "if (Test-Path \"$persist_dir\\config\\*\") { Copy-Item \"$persist_dir\\config\\*\" \"$Env:UserProfile\\.config\\containers\" -Recurse }", + "if (Test-Path \"$persist_dir\\data\\cache\\*\") { Copy-Item \"$persist_dir\\data\\cache\\*\" \"$Env:UserProfile\\.local\\share\\containers\\cache\" -Recurse }", + "if (Test-Path \"$persist_dir\\data\\podman\\*\") { Copy-Item \"$persist_dir\\data\\podman\\*\" \"$Env:UserProfile\\.local\\share\\containers\\podman\" -Recurse }", + "if (Test-Path \"$persist_dir\\data\\storage\\*\") { Copy-Item \"$persist_dir\\data\\storage\\*\" \"$Env:UserProfile\\.local\\share\\containers\\storage\" -Recurse }" + ], "installer": { "script": [ "Expand-DarkArchive \"$dir\\podman-$version-setup.exe\" \"$dir\\_tmp\" -Removal", @@ -22,18 +27,6 @@ ] }, "post_install": [ - "if ((Test-Path \"$Env:UserProfile\\.local\\share\\containers\\cache\\*\") -and !(Test-Path \"$dir\\data\\cache\\*\")) {", - " info '[Persist Data]: Moving data (cache) from default data directory to scoop persist directory . . .'", - " Move-Item \"$Env:UserProfile\\.local\\share\\containers\\cache\\*\" \"$dir\\data\\cache\"", - "}", - "if ((Test-Path \"$Env:UserProfile\\.local\\share\\containers\\podman\\*\") -and !(Test-Path \"$dir\\data\\podman\\*\")) {", - " info '[Persist Data]: Moving data (podman) from default data directory to scoop persist directory . . .'", - " Move-Item \"$Env:UserProfile\\.local\\share\\containers\\podman\\*\" \"$dir\\data\\podman\"", - "}", - "if ((Test-Path \"$Env:UserProfile\\.local\\share\\containers\\storage\\*\") -and !(Test-Path \"$dir\\data\\storage\\*\")) {", - " info '[Persist Data]: Moving data (storage) from default data directory to scoop persist directory . . .'", - " Move-Item \"$Env:UserProfile\\.local\\share\\containers\\storage\\*\" \"$dir\\data\\storage\"", - "}", "if ((Test-Path \"$Env:AppData\\containers\\*\") -and !(Test-Path \"$dir\\connections\\*\")) {", " info '[Persist Data]: Moving connections from default data directory to scoop persist directory . . .'", " Move-Item \"$Env:AppData\\containers\\*\" \"$dir\\connections\"", @@ -43,13 +36,24 @@ "if (Test-Path \"$Env:UserProfile\\.config\\containers\\*\") {", " Remove-Item \"$dir\\config\\*\" -Recurse -Force", " Move-Item \"$Env:UserProfile\\.config\\containers\\*\" \"$dir\\config\"", + "}", + "if (Test-Path \"$Env:UserProfile\\.local\\share\\containers\\cache\\*\") {", + " Remove-Item \"$dir\\data\\cache\\*\" -Recurse -Force", + " Move-Item \"$Env:UserProfile\\.local\\share\\containers\\cache\\*\" \"$dir\\data\\cache\"", + "}", + "if (Test-Path \"$Env:UserProfile\\.local\\share\\containers\\podman\\*\") {", + " Remove-Item \"$dir\\data\\podman\\*\" -Recurse -Force", + " Move-Item \"$Env:UserProfile\\.local\\share\\containers\\podman\\*\" \"$dir\\data\\podman\"", + "}", + "if (Test-Path \"$Env:UserProfile\\.local\\share\\containers\\storage\\*\") {", + " Remove-Item \"$dir\\data\\storage\\*\" -Recurse -Force", + " Move-Item \"$Env:UserProfile\\.local\\share\\containers\\storage\\*\" \"$dir\\data\\storage\"", "}" ], "uninstaller": { "script": "Remove-Path -Path $dir -TargetEnvVar $scoopPathEnvVar -Global:$global -Force" }, "env_set": { - "XDG_DATA_HOME": "$dir\\data", "PODMAN_CONNECTIONS_CONF": "$dir\\connections\\podman-connections.json" }, "persist": [ From 9c86e172c16c4c676a4282af9df0ec7f90363110 Mon Sep 17 00:00:00 2001 From: Leo Liu <11664880+silver886@users.noreply.github.com> Date: Tue, 7 Jan 2025 22:54:06 -0800 Subject: [PATCH 3/8] fix directory not exist error --- bucket/podman.json | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/bucket/podman.json b/bucket/podman.json index 4365a6303b343..b341d12776567 100644 --- a/bucket/podman.json +++ b/bucket/podman.json @@ -11,10 +11,22 @@ }, "bin": "podman.exe", "pre_install": [ - "if (Test-Path \"$persist_dir\\config\\*\") { Copy-Item \"$persist_dir\\config\\*\" \"$Env:UserProfile\\.config\\containers\" -Recurse }", - "if (Test-Path \"$persist_dir\\data\\cache\\*\") { Copy-Item \"$persist_dir\\data\\cache\\*\" \"$Env:UserProfile\\.local\\share\\containers\\cache\" -Recurse }", - "if (Test-Path \"$persist_dir\\data\\podman\\*\") { Copy-Item \"$persist_dir\\data\\podman\\*\" \"$Env:UserProfile\\.local\\share\\containers\\podman\" -Recurse }", - "if (Test-Path \"$persist_dir\\data\\storage\\*\") { Copy-Item \"$persist_dir\\data\\storage\\*\" \"$Env:UserProfile\\.local\\share\\containers\\storage\" -Recurse }" + "if (Test-Path \"$persist_dir\\config\\*\") {", + " New-Item \"$Env:UserProfile\\.config\\containers\" -ItemType Directory -Force | Out-Null", + " Copy-Item \"$persist_dir\\config\\*\" \"$Env:UserProfile\\.config\\containers\" -Recurse", + "}", + "if (Test-Path \"$persist_dir\\data\\cache\\*\") {", + " New-Item \"$Env:UserProfile\\.local\\share\\containers\\cache\" -ItemType Directory -Force | Out-Null", + " Copy-Item \"$persist_dir\\data\\cache\\*\" \"$Env:UserProfile\\.local\\share\\containers\\cache\" -Recurse", + "}", + "if (Test-Path \"$persist_dir\\data\\podman\\*\") {", + " New-Item \"$Env:UserProfile\\.local\\share\\containers\\podman\" -ItemType Directory -Force | Out-Null", + " Copy-Item \"$persist_dir\\data\\podman\\*\" \"$Env:UserProfile\\.local\\share\\containers\\podman\" -Recurse", + "}", + "if (Test-Path \"$persist_dir\\data\\storage\\*\") {", + " New-Item \"$Env:UserProfile\\.local\\share\\containers\\storage\" -ItemType Directory -Force | Out-Null", + " Copy-Item \"$persist_dir\\data\\storage\\*\" \"$Env:UserProfile\\.local\\share\\containers\\storage\" -Recurse", + "}" ], "installer": { "script": [ From 6752ce32643a1c19a9179aa5ab1cde3d144d5a83 Mon Sep 17 00:00:00 2001 From: Leo Liu <11664880+silver886@users.noreply.github.com> Date: Mon, 27 Jan 2025 22:15:42 -0800 Subject: [PATCH 4/8] add machine detection --- bucket/podman.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bucket/podman.json b/bucket/podman.json index b341d12776567..a4dedecc223e3 100644 --- a/bucket/podman.json +++ b/bucket/podman.json @@ -11,6 +11,11 @@ }, "bin": "podman.exe", "pre_install": [ + "if (Get-Command -ErrorAction SilentlyContinue podman) {", + " if ((podman machine info --format '{{.Host.MachineState}}') -like '*ing') {", + " error 'Podman virtual machine is still running. Stop it and try again.'; break", + " }", + "}", "if (Test-Path \"$persist_dir\\config\\*\") {", " New-Item \"$Env:UserProfile\\.config\\containers\" -ItemType Directory -Force | Out-Null", " Copy-Item \"$persist_dir\\config\\*\" \"$Env:UserProfile\\.config\\containers\" -Recurse", @@ -45,6 +50,11 @@ "}" ], "pre_uninstall": [ + "if (Get-Command -ErrorAction SilentlyContinue podman) {", + " if ((podman machine info --format '{{.Host.MachineState}}') -like '*ing') {", + " error 'Podman virtual machine is still running. Stop it and try again.'; break", + " }", + "}", "if (Test-Path \"$Env:UserProfile\\.config\\containers\\*\") {", " Remove-Item \"$dir\\config\\*\" -Recurse -Force", " Move-Item \"$Env:UserProfile\\.config\\containers\\*\" \"$dir\\config\"", From 04daaa0b75be88d741a71dcc22f04851f631be64 Mon Sep 17 00:00:00 2001 From: Leo Liu <11664880+silver886@users.noreply.github.com> Date: Wed, 12 Feb 2025 03:31:54 -0800 Subject: [PATCH 5/8] Use copy --- bucket/podman.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bucket/podman.json b/bucket/podman.json index a4dedecc223e3..11651a962a467 100644 --- a/bucket/podman.json +++ b/bucket/podman.json @@ -45,8 +45,8 @@ }, "post_install": [ "if ((Test-Path \"$Env:AppData\\containers\\*\") -and !(Test-Path \"$dir\\connections\\*\")) {", - " info '[Persist Data]: Moving connections from default data directory to scoop persist directory . . .'", - " Move-Item \"$Env:AppData\\containers\\*\" \"$dir\\connections\"", + " info '[Persist Data]: Copying connections from default data directory to scoop persist directory . . .'", + " Copy-Item \"$Env:AppData\\containers\\*\" \"$dir\\connections\"", "}" ], "pre_uninstall": [ From 5c7b0cb9acdda03ad41e2bc045582e720fa7ab42 Mon Sep 17 00:00:00 2001 From: Hsiao-nan Cheung Date: Thu, 13 Feb 2025 11:26:26 +0800 Subject: [PATCH 6/8] Fix manifest --- bucket/podman.json | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bucket/podman.json b/bucket/podman.json index 0a297de01f424..5059c749db604 100644 --- a/bucket/podman.json +++ b/bucket/podman.json @@ -40,9 +40,14 @@ ] }, "post_install": [ - "if ((Test-Path \"$Env:AppData\\containers\\*\") -and !(Test-Path \"$dir\\connections\\*\")) {", - " info '[Persist Data]: Copying connections from default data directory to scoop persist directory . . .'", - " Copy-Item \"$Env:AppData\\containers\\*\" \"$dir\\connections\"", + "if ((Test-Path \"$Env:AppData\\containers\\podman-connections*\") -and !(Test-Path \"$dir\\connections\\podman-connections*\")) {", + " # [Persist Data]: Moving connections from default data directory to scoop persist directory ...", + " Move-Item \"$Env:AppData\\containers\\podman-connections*\" \"$dir\\connections\"", + "}", + "'cache', 'podman', 'storage' | ForEach-Object {", + " if (!(Test-Path \"$dir\\data\\$_\")) {", + " New-Item \"$dir\\data\\$_\" -ItemType Directory -Force | Out-Null", + " }", "}" ], "pre_uninstall": [ From bb880b7793bc3ed726c0828958683ac8f8e6aa2b Mon Sep 17 00:00:00 2001 From: Leo Liu <11664880+silver886@users.noreply.github.com> Date: Thu, 13 Feb 2025 20:22:23 -0800 Subject: [PATCH 7/8] use matching coding style --- bucket/podman.json | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/bucket/podman.json b/bucket/podman.json index 5059c749db604..292721cb18c4c 100644 --- a/bucket/podman.json +++ b/bucket/podman.json @@ -20,17 +20,11 @@ " New-Item \"$Env:UserProfile\\.config\\containers\" -ItemType Directory -Force | Out-Null", " Copy-Item \"$persist_dir\\config\\*\" \"$Env:UserProfile\\.config\\containers\" -Recurse", "}", - "if (Test-Path \"$persist_dir\\data\\cache\\*\") {", - " New-Item \"$Env:UserProfile\\.local\\share\\containers\\cache\" -ItemType Directory -Force | Out-Null", - " Copy-Item \"$persist_dir\\data\\cache\\*\" \"$Env:UserProfile\\.local\\share\\containers\\cache\" -Recurse", - "}", - "if (Test-Path \"$persist_dir\\data\\podman\\*\") {", - " New-Item \"$Env:UserProfile\\.local\\share\\containers\\podman\" -ItemType Directory -Force | Out-Null", - " Copy-Item \"$persist_dir\\data\\podman\\*\" \"$Env:UserProfile\\.local\\share\\containers\\podman\" -Recurse", - "}", - "if (Test-Path \"$persist_dir\\data\\storage\\*\") {", - " New-Item \"$Env:UserProfile\\.local\\share\\containers\\storage\" -ItemType Directory -Force | Out-Null", - " Copy-Item \"$persist_dir\\data\\storage\\*\" \"$Env:UserProfile\\.local\\share\\containers\\storage\" -Recurse", + "'cache', 'podman', 'storage' | ForEach-Object {", + " if (Test-Path \"$persist_dir\\data\\$_\\*\") {", + " New-Item \"$Env:UserProfile\\.local\\share\\containers\\$_\" -ItemType Directory -Force | Out-Null", + " Copy-Item \"$persist_dir\\data\\$_\\*\" \"$Env:UserProfile\\.local\\share\\containers\\$_\" -Recurse", + " }", "}" ], "installer": { @@ -53,24 +47,19 @@ "pre_uninstall": [ "if (Get-Command -ErrorAction SilentlyContinue podman) {", " if ((podman machine info --format '{{.Host.MachineState}}') -like '*ing') {", - " error 'Podman virtual machine is still running. Stop it and try again.'; break", + " abort 'Podman virtual machine is still running. Stop it and try again.'", " }", "}", "if (Test-Path \"$Env:UserProfile\\.config\\containers\\*\") {", " Remove-Item \"$dir\\config\\*\" -Recurse -Force", " Move-Item \"$Env:UserProfile\\.config\\containers\\*\" \"$dir\\config\"", "}", - "if (Test-Path \"$Env:UserProfile\\.local\\share\\containers\\cache\\*\") {", - " Remove-Item \"$dir\\data\\cache\\*\" -Recurse -Force", - " Move-Item \"$Env:UserProfile\\.local\\share\\containers\\cache\\*\" \"$dir\\data\\cache\"", - "}", - "if (Test-Path \"$Env:UserProfile\\.local\\share\\containers\\podman\\*\") {", - " Remove-Item \"$dir\\data\\podman\\*\" -Recurse -Force", - " Move-Item \"$Env:UserProfile\\.local\\share\\containers\\podman\\*\" \"$dir\\data\\podman\"", - "}", - "if (Test-Path \"$Env:UserProfile\\.local\\share\\containers\\storage\\*\") {", - " Remove-Item \"$dir\\data\\storage\\*\" -Recurse -Force", - " Move-Item \"$Env:UserProfile\\.local\\share\\containers\\storage\\*\" \"$dir\\data\\storage\"", + "'cache', 'podman', 'storage' | ForEach-Object {", + " if (Test-Path \"$Env:UserProfile\\.local\\share\\containers\\$_\\*\") {", + " Remove-Item \"$dir\\data\\$_\\*\" -Recurse -Force", + " Move-Item \"$Env:UserProfile\\.local\\share\\containers\\$_\\*\" \"$dir\\data\\$_\" -ErrorAction Continue", + " error \"Cannot move '$Env:UserProfile\\.local\\share\\containers\\$_\\*' to '$dir\\data\\$_'\"", + " }", "}" ], "env_set": { From c27a9f3dcd7f2e5b40366b2a4879fe631b3ecdc0 Mon Sep 17 00:00:00 2001 From: Leo Liu <11664880+silver886@users.noreply.github.com> Date: Thu, 13 Feb 2025 20:26:01 -0800 Subject: [PATCH 8/8] fix error message --- bucket/podman.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bucket/podman.json b/bucket/podman.json index 292721cb18c4c..9c08d400fad14 100644 --- a/bucket/podman.json +++ b/bucket/podman.json @@ -58,7 +58,7 @@ " if (Test-Path \"$Env:UserProfile\\.local\\share\\containers\\$_\\*\") {", " Remove-Item \"$dir\\data\\$_\\*\" -Recurse -Force", " Move-Item \"$Env:UserProfile\\.local\\share\\containers\\$_\\*\" \"$dir\\data\\$_\" -ErrorAction Continue", - " error \"Cannot move '$Env:UserProfile\\.local\\share\\containers\\$_\\*' to '$dir\\data\\$_'\"", + " if (-not $?) { error \"Cannot move '$Env:UserProfile\\.local\\share\\containers\\$_\\*' to '$dir\\data\\$_'\" }", " }", "}" ],