diff --git a/bucket/attribute-changer.json b/bucket/attribute-changer.json index d61c25cb51ba02..f8c49dfe408412 100644 --- a/bucket/attribute-changer.json +++ b/bucket/attribute-changer.json @@ -5,54 +5,142 @@ "description": "A Windows Explorer shell extension that allows users to easily change file and folder properties with a right-click.", "license": "Freeware", "notes": [ - "BRAZILIAN PORTUGUESE is unavailable due to the developer removing support for the language.", - "", "IMPORTANT FOR NON-ENGLISH SPEAKERS!!!", "If you want this application translated to your native language, please run the following command:", "change-ac-language.ps1 ", + "Launch argumentless to see the list of available languages and their corresponding IDs.", "", - "1 = CZECH 5 = HUNGARIAN 9 = POLISH 13 = ENGLISH", - "2 = DANISH 6 = ITALIAN 10 = SPANISH", - "3 = FRENCH 7 = KOREAN 11 = SWEDISH", - "4 = GERMAN 8 = DUTCH 12 = TURKISH", - "", - "Ex. If you want the Attribute Changer interface language to Czech, you would run:", - "change-ac-language.ps1 1" + "Scoop persists the selected language, but the language IDs could be changed at any time by the developer.", + "If this happens, you can always run the command above to set the language again." ], "url": "https://www.petges.lu/pubfiles/ac-11_40b.exe", "hash": "md5:16bf84bb8e68853a05a000140e4ee6b4", - "innosetup": true, - "architecture": { - "64bit": { - "pre_install": [ - "if (!(is_admin)) { error \"$app requires admin rights to $cmd\"; break }", - "Get-ChildItem \"$dir\\*,1*\" -Include '*.exe', '*.dll' | Remove-Item", - "Get-ChildItem \"$dir\\*,2*\" -Include '*.exe', '*.dll' | Rename-Item -NewName { $_ -replace '\\,2', '' }", - "Start-Process 'regsvr32' -ArgumentList @(\"$dir\\acshell.dll\", '/s') -Verb 'RunAs' -Wait; Stop-Process -Name 'explorer' -ErrorAction 'SilentlyContinue' -Force", - "Start-Sleep -Seconds 2" - ] - }, - "32bit": { - "pre_install": [ - "if (!(is_admin)) { error \"$app requires admin rights to $cmd\"; break }", - "Get-ChildItem \"$dir\\*,2*\" -Include '*.exe', '*.dll' | Remove-Item", - "Get-ChildItem \"$dir\\*,1*\" -Include '*.exe', '*.dll' | Rename-Item -NewName { $_ -replace '\\,1', '' }", - "Start-Process 'regsvr32' -ArgumentList @(\"$dir\\acshell.dll\", '/s') -Verb 'RunAs' -Wait; Stop-Process -Name 'explorer' -ErrorAction 'SilentlyContinue' -Force", - "Start-Sleep -Seconds 2" - ] - } - }, + "pre_install": "if (!(is_admin)) { error \"$app requires admin rights to $cmd\"; break }", "installer": { "script": [ + "# Innosetup flag doesn't work correctly with this installer, due to the way the devoloper structured langs in the installer", + "# Using a custom installer script to work around it.", + "Expand-InnoArchive -Path \"$dir\\$fname\"", + "Invoke-ExternalCommand -FilePath (Get-HelperPath -Helper Innounp) -ArgumentList '-x', \"$dir\\$fname\", \"-d$dir\", 'install_script.iss' -LogPath \"$dir\\innounp-iss.log\" | Out-Null", + "$installScript = Get-Content -Path \"$dir\\install_script.iss\" -Raw", + "", + "", + "# Copying common and architecture-specific files according to the install script", + "$patternArc = 'Source: \"(?\\{app\\}\\\\(?!messages,)(?!ac,)(?!template)[^\"]*?)\"; DestDir: \"(?\\{app\\}[^\"]*?)?\"(?:; DestName: \"(?[^\"]*?)\")?(?:; Tasks: [^\"]*?)?; Check: \"(?[^\"]*?)\";'", + "$matchesArc = [regex]::Matches($installScript, $patternArc)", + "foreach ($match in $matchesArc) {", + " $source = $match.Groups['Source'].Value -replace '{app}', $dir", + " $destDir = $match.Groups['DestDir'].Value -replace '{app}', $dir", + " $destName = $match.Groups['DestName'].Value", + " $check = $match.Groups['Check'].Value", + " $is64bit = $check -eq 'Is64BitInstallMode'", + " $is32bit = $check -eq 'Not Is64BitInstallMode'", + " $isArchitectureIncompatible = if ($architecture -eq '64bit') {", + " -not $is64bit -and $is32bit", + " } else {", + " -not $is32bit -and $is64bit", + " }", + " if ($isArchitectureIncompatible) {", + " Remove-Item -Path $source -Force", + " continue", + " }", + " if (-not $destDir) { $destDir = $source }", + " if (-not $destName) { $destName = Split-Path -Path $source -Leaf }", + " $destPath = Join-Path -Path $destDir -ChildPath $destName", + " if ($source -ne $destPath) {", + " Move-Item -Path $source -Destination $destPath", + " }", + "}", + "", + "", + "# Copying and renaming template.ini to the messages,english.ini file according to the install script", + "$patternTemplate = 'Source: \"(?\\{app\\}\\\\template[^\"]*?)\"; DestDir: \"(?\\{app\\}[^\"]*?)\"(?:; DestName: \"(?[^\"]*?)\")?;'", + "$matchesTemplate = [regex]::Matches($installScript, $patternTemplate)", + "foreach ($match in $matchesTemplate) {", + " $source = $match.Groups['Source'].Value -replace '{app}', $dir", + " $destDir = $match.Groups['DestDir'].Value -replace '{app}', $dir", + " $destName = 'messages,english.ini'", + " if (-not $destDir) { $destDir = $source }", + " $destPath = Join-Path -Path $destDir -ChildPath $destName", + " if ($source -ne $destPath) {", + " Move-Item -Path $source -Destination $destPath", + " }", + "}", + "", + "", + "# Copying messages files according to the install script", + "$patternMes = 'Source: \"(?\\{app\\}\\\\messages,[^\"]*?)\"; DestDir: \"(?\\{app\\}[^\"]*?)\"(?:; DestName: \"(?[^\"]*?)\")?; Languages: \"(?[^\"]*?)\";'", + "$matchesMes = [regex]::Matches($installScript, $patternMes)", + "foreach ($match in $matchesMes) {", + " $source = $match.Groups['Source'].Value -replace '{app}', $dir", + " $destDir = $match.Groups['DestDir'].Value -replace '{app}', $dir", + " $lang = $match.Groups['Lang'].Value", + " $destName = 'messages,' + $lang + '.ini'", + " if (-not $destDir) { $destDir = $source }", + " $destPath = Join-Path -Path $destDir -ChildPath $destName", + " if ($source -ne $destPath) {", + " Move-Item -Path $source -Destination $destPath", + " }", + "}", + "", + "", + "# Copying ac files according to the install script", + "$patternAc = 'Source: \"(?\\{app\\}\\\\ac,[^\"]*?)\"; DestDir: \"(?\\{app\\}[^\"]*?)\"(?:; DestName: \"(?[^\"]*?)\")?; Languages: \"(?[^\"]*?)\";'", + "$matchesAc = [regex]::Matches($installScript, $patternAc)", + "$langs = @()", + "foreach ($match in $matchesAc) {", + " $source = $match.Groups['Source'].Value -replace '{app}', $dir", + " $destDir = $match.Groups['DestDir'].Value -replace '{app}', $dir", + " $lang = $match.Groups['Lang'].Value", + " $destName = 'ac,' + $lang + '.pdf'", + " $langs += $lang", + " if (-not $destDir) { $destDir = $source }", + " $destPath = Join-Path -Path $destDir -ChildPath $destName", + " if ($source -ne $destPath) {", + " Move-Item -Path $source -Destination $destPath", + " }", + "}", + "", + "", + "# Removing the installer files after installation", + "Remove-Item -Path \"$dir\\$fname\" -Force", + "Remove-Item -Path \"$dir\\install_script.iss\" -Force", + "", + "", + "# Creating the change-ac-language.ps1 script to allow users to change the language after installation", "$value = @\"", - "if (!(`$args.Count -eq 1)) { Write-Host 'INVALID USAGE! Please run ``scoop info attribute-changer`` for help on proper command usage.'; exit }", - "`$ac_language = `$args[0].toString()", + "`$langs = @(\"$($langs -join '\", \"')\")", + "if (!(`$args.Count -eq 1))", + "{", + " Write-Host 'INVALID USAGE! Add a language as argument following this scheme: ';", + " for (`$i = 0; `$i -lt `$langs.Count; `$i++) {", + " Write-Host \"`$(`$i + 1) = `$(`$langs[`$i])\"", + " }", + " exit", + "}", + "`$index = [int]`$args[0] - 1", + "if (`$index -lt 0 -or `$index -ge `$langs.Count) { `$index = `$langs.IndexOf('english'); if (`$index -lt 0) { `$index = 0 } }", + "`$ac_language = `$langs[`$index]", "Copy-Item \"$dir\\messages,`$ac_language.ini\" \"$dir\\messages.ini\" -Force", "Copy-Item \"$dir\\ac,`$ac_language.pdf\" \"$dir\\ac.pdf\" -Force", + "Set-Content \"$dir\\langCode\" (`$index + 1) -Encoding utf8 -Force", "\"@", - "Set-Content \"$dir\\change-ac-language.ps1\" $value -Encoding 'utf8' -Force" + "Set-Content \"$dir\\change-ac-language.ps1\" $value -Encoding 'utf8' -Force", + "", + "", + "if (!(Test-Path \"$persist_dir\\langCode\")) {", + " $defaultIdx = $langs.IndexOf('english'); if ($defaultIdx -lt 0) { $defaultIdx = 0 }", + " Set-Content \"$dir\\langCode\" ($defaultIdx + 1) -Encoding utf8", + "}" ] }, + "post_install": [ + "if (!(is_admin)) { error \"$app requires admin rights to $cmd\"; break }", + "& \"$dir\\change-ac-language.ps1\" (Get-Content \"$dir\\langCode\" -Raw)", + "Start-Process 'regsvr32' -ArgumentList @(\"$dir\\acshell.dll\", '/s') -Verb 'RunAs' -Wait; Stop-Process -Name 'explorer' -ErrorAction 'SilentlyContinue' -Force", + "Start-Sleep -Seconds 2" + ], + "persist": "langCode", "bin": [ "acmain.exe", "change-ac-language.ps1" @@ -63,16 +151,6 @@ "Attribute Changer" ] ], - "post_install": [ - "$documents = (Get-ChildItem $dir -Filter '*.pdf').Length; $subtract = $documents - 5", - "Copy-Item \"$dir\\template.ini\" \"$dir\\messages,$documents.ini\"; Copy-Item \"$dir\\template.ini\" \"$dir\\messages.ini\"; Copy-Item \"$dir\\ac,$(($documents - $subtract) - 2).pdf\" \"$dir\\ac.pdf\"", - "Remove-Item \"$dir\\ac,$(($documents - $subtract) - 2).pdf\"; Copy-Item \"$dir\\messages,$(($documents - $subtract) - 2).ini\" \"$dir\\messages.ini\" -Force", - "$Value = $documents - $subtract", - "for ($count = 0; $count -le ($documents - 3); $count++) {", - " $OriginalValue = $Value + $count; $NewValue = $OriginalValue - 1; Rename-Item \"$dir\\ac,$OriginalValue.pdf\" \"ac,$NewValue.pdf\" -ErrorAction 'SilentlyContinue'", - "}", - "Copy-Item \"$dir\\ac.pdf\" \"$dir\\ac,$documents.pdf\"" - ], "pre_uninstall": [ "if (!(is_admin)) { error \"$app requires admin rights to $cmd\"; break }", "Start-Process 'regsvr32' -ArgumentList @('/u', \"$dir\\acshell.dll\", '/s') -Verb 'RunAs' -Wait; Stop-Process -Name 'explorer' -Force",