Skip to content

gimp@3.0.4: Persist data#15326

Open
Ra2-IFV wants to merge 1 commit intoScoopInstaller:masterfrom
Ra2-IFV:feat_gimp_persist
Open

gimp@3.0.4: Persist data#15326
Ra2-IFV wants to merge 1 commit intoScoopInstaller:masterfrom
Ra2-IFV:feat_gimp_persist

Conversation

@Ra2-IFV
Copy link
Copy Markdown
Contributor

@Ra2-IFV Ra2-IFV commented Apr 20, 2025

  • Use conventional PR title: <manifest-name[@version]|chore>: <general summary of the pull request>
  • I have read the Contributing Guide

@github-actions
Copy link
Copy Markdown
Contributor

All changes look good.

Wait for review from human collaborators.

gimp

  • Description
  • License
  • Hashes
  • Checkver
  • Autoupdate
  • Autoupdate Hash Extraction

@Lutra-Fs
Copy link
Copy Markdown
Member

@Ra2-IFV Ra2-IFV force-pushed the feat_gimp_persist branch from 545c723 to b26627b Compare May 25, 2025 13:59
Signed-off-by: Ryan Keane <the.ra2.ifv@gmail.com>
@Ra2-IFV Ra2-IFV force-pushed the feat_gimp_persist branch from b26627b to 72f3bca Compare May 25, 2025 14:04
@Ra2-IFV Ra2-IFV changed the title gimp@3.0.2-1: Persist data gimp@3.0.4: Persist data May 25, 2025
@SorYoshino
Copy link
Copy Markdown
Contributor

I think it would be simpler to use the following directly without obtaining the relevant version information through a script:

{
    "env_set": {
        "GIMP3_DIRECTORY": "$dir\\3.0"
    }
}

@Ra2-IFV
Copy link
Copy Markdown
Contributor Author

Ra2-IFV commented Sep 17, 2025

This prevents scoop from overwriting user's env.

@SorYoshino
Copy link
Copy Markdown
Contributor

This prevents scoop from overwriting user's env.

Hello, if my understanding of "preventing scoop from overwriting the user's environment" aligns with yours, I don't believe your current script achieves this for the following reasons:

The script in post_install runs during every installation or update. Although you check whether $Env:GIMP3_DIRECTORY exists and only add it to the environment variables if it doesn't exist, However, the script in post_uninstall runs during every update, which removes $Env:GIMP3_DIRECTORY. Consequently, when you later execute the script in post_install, $Env:GIMP3_DIRECTORY no longer exists.

{
    "post_install": [
      "if ($global) { $scope = 'Machine' } else { $scope = 'User' }",
      "if (!$Env:GIMP3_DIRECTORY) { [Environment]::SetEnvironmentVariable('GIMP3_DIRECTORY', \"$persist_dir\\3.0\", $scope) }"
    ],
    "post_uninstall": [
      "if ($global) { $scope = 'Machine' } else { $scope = 'User' }",
      "if ($Env:GIMP3_DIRECTORY -eq \"$persist_dir\\3.0\") { [Environment]::SetEnvironmentVariable('GIMP3_DIRECTORY', [NullString]::Value, $scope) }"
    ]
}

This behavior is identical to that of the env_set script.

If you check $cmd -eq uninstall, $Env:GIMP3_DIRECTORY won't be overwritten. However, this also prevents $Env:GIMP3_DIRECTORY from being deleted during future updates when $Env:GIMP4_DIRECTORY is needed.

@Ra2-IFV
Copy link
Copy Markdown
Contributor Author

Ra2-IFV commented Sep 19, 2025

Uh, I didn't get it...
In uninstall script GIMP3_DIRECTORY is removed only when the value of GIMP3_DIRECTORY equals to scoop's persist path, if not, it skips.
So confused... what you are talking about?
Don't know $cmd -eq uninstall, very useful to me, thanks!

@SorYoshino
Copy link
Copy Markdown
Contributor

SorYoshino commented Sep 19, 2025

I believe the following example illustrates my previous point.
# Modify the script within "post_uninstall"
┏[ D:\Temporary\Software\Microsoft\Windows Sandbox]
└─> jq -r '"post_install:", (.post_install[]), "", "post_uninstall:", (.post_uninstall[])' .\Gimp.json
post_install:
if ($global) { $scope = 'Machine' } else { $scope = 'User' }
if (!$Env:GIMP3_DIRECTORY) { [Environment]::SetEnvironmentVariable('GIMP3_DIRECTORY', "$persist_dir\3.0", $scope) }

post_uninstall:
if ($global) { $scope = 'Machine' } else { $scope = 'User' }
Write-Host "INFO  `$Env:GIMP3_DIRECTORY = " -NoNewline
[Environment]::GetEnvironmentVariable('GIMP3_DIRECTORY')
$result = $Env:GIMP3_DIRECTORY -eq "$persist_dir\3.0"
Write-Host "INFO  result is $result"
if ($Env:GIMP3_DIRECTORY -eq "$persist_dir\3.0") {
    [Environment]::SetEnvironmentVariable('GIMP3_DIRECTORY', [NullString]::Value, $scope)
}

┏[ D:\Temporary\Software\Microsoft\Windows Sandbox]
└─> scoop install .\Gimp.json
Installing 'Gimp' (3.0.4) [64bit] from 'D:\Temporary\Software\Microsoft\Windows Sandbox\Gimp.json'
Loading gimp-3.0.4-setup.exe from cache.
Checking hash of gimp-3.0.4-setup.exe ... ok.
Extracting gimp-3.0.4-setup.exe ... done.
Running installer script...done.
Linking D:\Software\Scoop\Local\apps\Gimp\current => D:\Software\Scoop\Local\apps\Gimp\3.0.4
Creating shim for 'gimp-console-3.0'.
Creating shim for 'gimp-console'.
Creating shim for 'gimp'.
Creating shim for 'gimptool-3.0'.
Creating shim for 'gimptool'.
Creating shortcut for GIMP (gimp-3.0.exe)
Persisting _userdata
Running post_install script...done.
'Gimp' (3.0.4) was installed successfully!
Notes
-----
Scoop persists data since version 3.0.4. You may need to move data by yourself.
Before: '$Env:APPDATA\GIMP\3.0'
After : 'D:\Software\Scoop\Local\persist\Gimp\gimp\3.0'

# Open another PowerShell session
┏[ ~]
└─> scoop update Gimp -f
Gimp: 3.0.4 -> 3.0.4
Updating one outdated app:
Updating 'Gimp' (3.0.4 -> 3.0.4)
Downloading new version
Loading gimp-3.0.4-setup.exe from cache.
Checking hash of gimp-3.0.4-setup.exe ... ok.
Uninstalling 'Gimp' (3.0.4)
Removing shim 'gimp-console-3.0.shim'.
Removing shim 'gimp-console-3.0.exe'.
Removing shim 'gimp-console.shim'.
Removing shim 'gimp-console.exe'.
Removing shim 'gimp.shim'.
Removing shim 'gimp.exe'.
Removing shim 'gimptool-3.0.shim'.
Removing shim 'gimptool-3.0.exe'.
Removing shim 'gimptool.shim'.
Removing shim 'gimptool.exe'.
Unlinking D:\Software\Scoop\Local\apps\Gimp\current
Running post_uninstall script...INFO  $Env:GIMP3_DIRECTORY = D:\Software\Scoop\Local\persist\Gimp\3.0
INFO  result is True
done.
Installing 'Gimp' (3.0.4) [64bit] from 'D:\Temporary\Software\Microsoft\Windows Sandbox\Gimp.json'
Loading gimp-3.0.4-setup.exe from cache.
Extracting gimp-3.0.4-setup.exe ... done.
Running installer script...done.
Linking D:\Software\Scoop\Local\apps\Gimp\current => D:\Software\Scoop\Local\apps\Gimp\3.0.4
Creating shim for 'gimp-console-3.0'.
Creating shim for 'gimp-console'.
Creating shim for 'gimp'.
Creating shim for 'gimptool-3.0'.
Creating shim for 'gimptool'.
Creating shortcut for GIMP (gimp-3.0.exe)
Persisting _userdata
Running post_install script...done.
'Gimp' (3.0.4) was installed successfully!
Notes
-----
Scoop persists data since version 3.0.4. You may need to move data by yourself.
Before: '$Env:APPDATA\GIMP\3.0'
After : 'D:\Software\Scoop\Local\persist\Gimp\gimp\3.0'

$Env:GIMP3_DIRECTORY -eq \"$persist_dir\\3.0\ always evaluates to true.

@Ra2-IFV
Copy link
Copy Markdown
Contributor Author

Ra2-IFV commented Oct 7, 2025

No way...

Details
bash-5.2 $ echo $GIMP3_DIRECTORY
C:\ProgramData\scoop\persist\gimp1
bash-5.2 $ scoop uninstall -g gimp
Uninstalling 'gimp' (3.0.4).
Removing shim 'gimp-console-3.0.shim'.
Removing shim 'gimp-console-3.0.exe'.
Removing shim 'gimp-console.shim'.
Removing shim 'gimp-console.exe'.
Removing shim 'gimp.shim'.
Removing shim 'gimp.exe'.
Removing shim 'gimptool-3.0.shim'.
Removing shim 'gimptool-3.0.exe'.
Removing shim 'gimptool.shim'.
Removing shim 'gimptool.exe'.
Removing shortcut C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Scoop Apps\GIMP.lnk
Unlinking C:\ProgramData\scoop\apps\gimp\current
'gimp' was uninstalled.
bash-5.2 $ scoop cat gimp
{
    "##": "Maintainer reminder: After major releases, update version number in notes, and variable in post install/uninstall scripts",
    "version": "3.0.4",
    "description": "GNU Image Manipulation Program",
    "homepage": "https://www.gimp.org",
    "license": "GPL-3.0-only",
    "url": "https://download.gimp.org/mirror/pub/gimp/v3.0/windows/gimp-3.0.4-setup.exe",
    "hash": "385e36fe577cbdbfc71ba79d6c046d6f4eaabc01effd7f067bf15fd98410b2a1",
    "notes": [
        "Scoop persists data since version 3.0.4. You may need to move data by yourself.",
        "Before: '$Env:APPDATA\\GIMP\\3.0'",
        "After : '$persist_dir\\gimp\\3.0'"
    ],
    "innosetup": true,
    "installer": {
        "script": [
            "$scriptver = $version -split '[-.]'",
            "$shortver = $scriptver[0] + '.' + $scriptver[1]",
            "Push-Location \"$dir\"",
            "Get-ChildItem -Filter '*.debug' -Recurse | Remove-Item -Recurse",
            "$file64 = Get-ChildItem -Recurse -Filter '*,?.*' | Where-Object {",
            "   $_.Name -match '^(.*?),[12]\\.(.*?)$' -and",
            "   (-not (Test-Path (Join-Path $_.Directory.FullName \"$($matches[1]),3.$($matches[2])\"))) -and",
            "   $matches[1] -ne 'libhwy'",
            "}",
            "$file64 | Rename-Item -NewName { $_.name -Replace ',2', ',3' }",
            "$file64 | Rename-Item -NewName { $_.name -Replace ',1', ',2' }",
            "if ($architecture -eq '32bit') {",
            "   Get-ChildItem -Filter '*,1*' -Recurse | Rename-Item -NewName { $_.name -Replace ',1', '' }",
            "} else {",
            "   # 'twain.exe' is for 'gimp32on64' which is not included.",
            "   Remove-Item \"lib\\gimp\\$shortver\\plug-ins\\twain\" -Recurse -Force",
            "   if ($architecture -eq '64bit') {",
            "       Get-ChildItem -Filter '*,2*' -Recurse | Rename-Item -NewName { $_.name -Replace ',2', '' }",
            "   } else {",
            "       Get-ChildItem -Filter '*,3*' -Recurse | Rename-Item -NewName { $_.name -Replace ',3', '' }",
            "   }",
            "}",
            "Get-ChildItem -Filter '*,*' -Recurse | Remove-Item",
            "Pop-Location"
        ]
    },
    "post_install": [
        "if ($global) { $scope = 'Machine' } else { $scope = 'User' }",
        "if (!$Env:GIMP3_DIRECTORY) { [Environment]::SetEnvironmentVariable('GIMP3_DIRECTORY', \"$persist_dir\\3.0\", $scope) }"
    ],
    "bin": [
        "bin\\gimp-console-3.0.exe",
        [
            "bin\\gimp-console-3.0.exe",
            "gimp-console"
        ],
        [
            "bin\\gimp-console-3.0.exe",
            "gimp"
        ],
        "bin\\gimptool-3.0.exe",
        [
            "bin\\gimptool-3.0.exe",
            "gimptool"
        ]
    ],
    "shortcuts": [
        [
            "bin\\gimp-3.0.exe",
            "GIMP"
        ]
    ],
    "persist": [
        [
            "_userdata",
            "3.0"
        ]
    ],
    "post_uninstall": [
        "if ($global) { $scope = 'Machine' } else { $scope = 'User' }",
        "if ($Env:GIMP3_DIRECTORY -eq \"$persist_dir\\3.0\") { [Environment]::SetEnvironmentVariable('GIMP3_DIRECTORY', [NullString]::Value, $scope) }"
    ],
    "checkver": {
        "url": "https://www.gimp.org/downloads/",
        "regex": "gimp-(?[\\d.]+)-setup(?-\\d)?\\.exe",
        "replace": "${version}${build}"
    },
    "autoupdate": {
        "url": "https://download.gimp.org/mirror/pub/gimp/v$majorVersion.$minorVersion/windows/gimp-$matchHead-setup$matchTail.exe",
        "hash": {
            "url": "$baseurl/SHA256SUMS"
        },
        "bin": [
            "bin\\gimp-console-$majorVersion.$minorVersion.exe",
            [
                "bin\\gimp-console-$majorVersion.$minorVersion.exe",
                "gimp-console"
            ],
            [
                "bin\\gimp-console-$majorVersion.$minorVersion.exe",
                "gimp"
            ],
            "bin\\gimptool-$majorVersion.$minorVersion.exe",
            [
                "bin\\gimptool-$majorVersion.$minorVersion.exe",
                "gimptool"
            ]
        ],
        "shortcuts": [
            [
                "bin\\gimp-$majorVersion.$minorVersion.exe",
                "GIMP"
            ]
        ]
    }
}
  

@SorYoshino
Copy link
Copy Markdown
Contributor

SorYoshino commented Oct 8, 2025

Thank you for your explanation. I think I understand your point now. You are considering the scenario where this environment variable already exists during installation, while I am considering a fresh installation or a situation where the environment variable does not exist.

However, I still believe this approach is problematic for the following reasons:

  1. If this manifest is used to install or upgrade Gimp when the environment variable does exist, it can indeed prevent the user-defined variable from being overwritten. However, due to the presence of this variable, related data might be stored outside the $persist_dir directory. In that case, the notes and persist fields in the manifest would lose their purpose and could even become contradictory.
  2. When the environment variable does not exist, the behavior of the relevant code inside the manifest becomes identical to using env_set. In this situation, the contents of the post_install and post_uninstall sections would become meaningless.

In addition, I have concerns about the persist field in the manifest:

  1. It does not follow the expected format and should be written in the same way as the shortcuts field.

  2. You chose to store related data in $persist_dir\3.0. I assume the main reason is that you want to separate user data for different major versions. Moreover, you added a ## comment to remind future maintainers to update the version number in the notes, post_install, and post_uninstall fields.

    • However, this approach undoubtedly increases the maintenance burden for the community. If no one updates the manifest in the future, continuing to use $persist_dir\3.0 when the version reaches 4.x will definitely cause problems.

    • The content of the ## comment is also unclear — in fact, the version number in the persist field must also be updated. Otherwise, it could lead to data loss or other related issues.


Please note that the above opinions are solely my personal views. I am not a maintainer, nor do I intend to impose any requirement for you to modify the manifest based on my suggestions.

@Ra2-IFV Ra2-IFV mentioned this pull request Dec 6, 2025
2 tasks
@Ra2-IFV
Copy link
Copy Markdown
Contributor Author

Ra2-IFV commented Dec 6, 2025

However, due to the presence of this variable, related data might be stored outside the $persist_dir directory.

Expected. If it exists, then user knows what he really wants. Don't break it.
Actually scoop should integrate this check before setting the ENV. This is just a dirty workaround.

Why use 3.0 for persisting: GIMP officially use a separate folder for different major versions, I have no idea what to do with this...

However, this approach undoubtedly increases the maintenance burden for the community.

If autoupdate is working as expected then it shouldn't take too much to maintain this manifest. Manual intervention is expected following major releases, or why call it a major release?

The content of the ## comment is also unclear

I'll try to improve it.

@Ra2-IFV
Copy link
Copy Markdown
Contributor Author

Ra2-IFV commented Dec 6, 2025

Manual intervention is expected following major releases, or why call it a major release?

Only eligible for projects with long term release periods, like GIMP. Major release is rare and will definitely break something.

@SorYoshino
Copy link
Copy Markdown
Contributor

Expected. If it exists, then user knows what he really wants. Don't break it.
Actually scoop should integrate this check before setting the ENV. This is just a dirty workaround.

But doesn’t the content in the notes field contradict the script?

If GIMP3_DIRECTORY exists before installation, then the related data may not be located in $Env:APPDATA\GIMP. After installation, since GIMP3_DIRECTORY previously existed, the data generated when the program runs may also not end up in $persist_dir\gimp. This could lead to user data loss, and such a situation should be avoided.

I still believe that if an application is installed through Scoop and its related data can be stored in $persist_dir, then the maintainer’s responsibility should be limited to reminding users to migrate their data into $persist_dir, or writing a script that performs the migration automatically. It should not be handled in this self-contradictory manner.


Why use 3.0 for persisting: GIMP officially use a separate folder for different major versions, I have no idea what to do with this...

Only eligible for projects with long term release periods, like GIMP. Major release is rare and will definitely break something.

Based on my testing, it is not necessary to store data in $majorVersion.$minorVersion, so cross-version migration may not be required.

┏[ ~]
└─> Get-ChildItem -Path Env: -Include '*GIMP*' -Recurse

Name                           Value
----                           -----
GIMP3_DIRECTORY                D:\Download\Others\Aria2\Zertw\Test\Test

┏[ ~]
└─> Get-ChildItem -Path 'D:\Download\Others\Aria2\Zertw\Test\Test'

        Directory: D:\Download\Others\Aria2\Zertw\Test\Test


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d----         2025/12/6     16:35                  backups
d----         2025/12/6     16:35                  fonts
d----         2025/12/6     16:35                  tool-options
-a---         2025/12/6     16:35            977   gimprc
-a---         2025/12/6     16:35         290031   pluginrc
-a---         2025/12/6     16:35            517   theme.css

However, if we take data compatibility between different versions into account, then on the basis of the script below, the only remaining concern would be handling the migration. What we aim for is not to eliminate manual maintenance entirely, but to reduce its likelihood to the lowest possible level.

┏[ ~]
└─> jq '{post_install, post_uninstall}' 'D:\Temporary\Software\Microsoft\Windows Sandbox\gimp-test.json'
{
  "post_install": [
    "$majorVersion = ($version -split '\\.')[0]",
    "$name = 'GIMP{0}_DIRECTORY' -f $majorVersion",
    "$majorMinor = ($version -split '\\.')[0..1] -join '.'",
    "if ($global) { $scope = 'Machine' } else { $scope = 'User' }",
    "[Environment]::SetEnvironmentVariable($name, \"$persist_dir\\gimp\\$majorMinor\", $scope)"
  ],
  "post_uninstall": [
    "$majorVersion = ($version -split '\\.')[0]",
    "$name = 'GIMP{0}_DIRECTORY' -f $majorVersion",
    "if ($global) { $scope = 'Machine' } else { $scope = 'User' }",
    "[Environment]::SetEnvironmentVariable($name, [NullString]::Value, $scope)"
  ]
}

P.S. Ideally, the method shown below would be the best approach, but it is currently not supported at all. Even using Version variables other than $version within the scripts is not allowed.

"env_set": { 
    "GIMP$majorVersion_DIRECTORY": "$persist_dir\\gimp" 
}

@Ra2-IFV
Copy link
Copy Markdown
Contributor Author

Ra2-IFV commented Dec 6, 2025

This could lead to user data loss

In normal cases this variable would not point to any location outside $persist_dir, if it really points to somewhere else, user must set it by hand, in this situation why override?
Of cource proceeding without a notice is inappropriate, a warning is enough I think.

it is not necessary to store data in $majorVersion.$minorVersion

I mean only $majorVersion, like this 2.0 3.0 4.0

Please notice I still need to review my changes previously pushed to Github, I fucked up with rebasing

GIMP$majorVersion_DIRECTORY

DON'T

@Ra2-IFV
Copy link
Copy Markdown
Contributor Author

Ra2-IFV commented Dec 6, 2025

Damn, is it really difficult to do find-replacing? If you insist I'll take it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants