Skip to content

Commit 88f79aa

Browse files
committed
calibre: Switch to MSI Installer
1 parent 9aede7a commit 88f79aa

File tree

5 files changed

+1928
-24
lines changed

5 files changed

+1928
-24
lines changed

bucket/calibre.json

Lines changed: 77 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,83 @@
11
{
22
"version": "8.16.2",
3-
"description": "Powerful and easy to use e-book manager",
3+
"description": "Powerful and easy to use e-book manager.",
44
"homepage": "https://calibre-ebook.com",
55
"license": {
6-
"identifier": "GPL-3.0-only",
7-
"url": "https://github.com/kovidgoyal/calibre/blob/master/LICENSE"
6+
"identifier": "GPL-3.0-or-later",
7+
"url": "https://github.com/kovidgoyal/calibre/blob/HEAD/LICENSE"
88
},
9+
"notes": [
10+
"To register file associations, please execute the following command:",
11+
"reg import \"$dir\\install-associations.reg\"",
12+
"To register the URL protocol handler, please execute the following command:",
13+
"reg import \"$dir\\register-url-handler.reg\""
14+
],
915
"architecture": {
1016
"64bit": {
11-
"url": "https://download.calibre-ebook.com/8.16.2/calibre-portable-installer-8.16.2.exe",
12-
"hash": "sha512:010ee58b53ecb9c208f7229b73e86c1b98a67e3b3ee7691a1e19c277fd34c0d434acbe367aab9389ad916b4d373adf34eb07a9ec35f14b1b3e69fa982de83073"
17+
"url": "https://download.calibre-ebook.com/8.16.2/calibre-64bit-8.16.2.msi#/dl.msi_",
18+
"hash": "sha512:e028a251b382dc91f34f7979cece2c48e65fb03c7d75a51d83afa37ce416d87c724f83d68e709cbe71c632dd5323925ddd553dba482282e200ce5c1b9327ad93"
1319
}
1420
},
21+
"pre_install": [
22+
"ensure \"$persist_dir\\Calibre Settings\" | Out-Null",
23+
"if (Test-Path -Path \"$persist_dir\\Calibre Settings\\*\") { return }",
24+
"$original_cfg_dir = $env:CALIBRE_CONFIG_DIRECTORY, \"$env:APPDATA\\calibre\" | Select-Object -First 1",
25+
"if (Test-Path -Path \"$original_cfg_dir\\*\") {",
26+
" Write-Host \"`nINFO Migrating Calibre Configurations to '$persist_dir\\Calibre Settings'...\" -ForegroundColor DarkGray",
27+
" Copy-Item -Path \"$original_cfg_dir\\*\" -Destination \"$persist_dir\\Calibre Settings\" -Force -Recurse",
28+
"}"
29+
],
1530
"installer": {
1631
"script": [
17-
"Start-Process -FilePath \"$dir\\$fname\" -ArgumentList @($env:PUBLIC) -Wait",
18-
"Move-Item -Path \"$env:PUBLIC\\Calibre Portable\\*\" -Destination $dir -Force",
19-
"Remove-Item -Path \"$dir\\$fname\", \"$env:PUBLIC\\Calibre Portable\" -Recurse -Force -ErrorAction SilentlyContinue",
20-
"Icacls $dir /t /c /reset | Out-Null"
32+
"$default_dir = \"$env:APPDATA\\calibre\"",
33+
"$ErrorActionPreference = 'SilentlyContinue'",
34+
"$configuration_dir = \"$persist_dir\\Calibre Settings\"",
35+
"$config_link_target_dir = (Get-Item -Path $default_dir).Target",
36+
"$is_different = $config_link_target_dir -ne $configuration_dir",
37+
"$link_target_dir = @($config_link_target_dir) * $is_different",
38+
"$is_different = $env:CALIBRE_CONFIG_DIRECTORY -ne $configuration_dir",
39+
"$extra_config_dir = @($env:CALIBRE_CONFIG_DIRECTORY) * $is_different",
40+
"@($default_dir) + $link_target_dir + $extra_config_dir | Remove-Item -Recurse -Force",
41+
"Expand-MsiArchive -Path \"$dir\\$fname\" -DestinationPath \"$dir\\Calibre\" -ExtractDir 'PFiles64\\Calibre2' -Removal"
2142
]
2243
},
44+
"post_install": [
45+
"$calibre_dir = \"$dir\\Calibre\" -replace '\\\\', '\\\\'",
46+
"Get-ChildItem -Path \"$bucketsdir\\$bucket\\scripts\\$app\" -Filter '*.reg' -File | ForEach-Object {",
47+
" $content = Get-Content -Path $_.FullName -Encoding utf8",
48+
" if ($global) { $content = $content -replace 'HKEY_CURRENT_USER', 'HKEY_LOCAL_MACHINE' }",
49+
" $content -replace '{{calibre_dir}}', $calibre_dir | Set-Content -Path \"$dir\\$($_.Name)\" -Encoding unicode",
50+
"}",
51+
"'.tmp', '.cache' | ForEach-Object { ensure \"$persist_dir\\$_\" | Out-Null }",
52+
"if (-not (Test-Path -Path \"$persist_dir\\Calibre Settings\\global.py.json\" -PathType Leaf)) {",
53+
" New-Item -Path \"$persist_dir\\Calibre Settings\\global.py.json\" -ItemType File -Force | Out-Null",
54+
" $cfg = @{ 'library_path'= \"$persist_dir\\Calibre Library\" } | ConvertTo-Json -Depth 5",
55+
" Set-Content -Path \"$persist_dir\\Calibre Settings\\global.py.json\" -Value $cfg -Encoding utf8",
56+
"} else {",
57+
" $cfg = Get-Content -Path \"$persist_dir\\Calibre Settings\\global.py.json\" -Encoding utf8 | ConvertFrom-Json",
58+
" if ($cfg.library_path -eq \"$persist_dir\\Calibre Library\") { return }",
59+
" if (-not (Test-Path -Path \"$persist_dir\\Calibre Library\\*\") -and (Test-Path -Path \"$($cfg.library_path)\\*\")) {",
60+
" Write-Host \"`nINFO Migrating Calibre Library to '$persist_dir\\Calibre Library'...\" -ForegroundColor DarkGray",
61+
" Copy-Item -Path \"$($cfg.library_path)\\*\" -Destination \"$persist_dir\\Calibre Library\" -Force -Recurse",
62+
" }",
63+
" Remove-Item -Path $cfg.library_path -Recurse -Force -ErrorAction SilentlyContinue",
64+
" $cfg.library_path = \"$persist_dir\\Calibre Library\"",
65+
" $cfg | ConvertTo-Json -Depth 5 | Set-Content -Path \"$persist_dir\\Calibre Settings\\global.py.json\" -Encoding utf8",
66+
"}"
67+
],
68+
"env_set": {
69+
"CALIBRE_NO_DEFAULT_PROGRAMS": "1",
70+
"CALIBRE_TEMP_DIR": "$persist_dir\\.tmp",
71+
"CALIBRE_CACHE_DIRECTORY": "$persist_dir\\.cache",
72+
"CALIBRE_CONFIG_DIRECTORY": "$persist_dir\\Calibre Settings"
73+
},
2374
"bin": [
24-
[
25-
"calibre-portable.exe",
26-
"calibre"
27-
],
28-
"calibre-portable.exe",
29-
"Calibre\\calibre-complete.exe",
75+
"Calibre\\calibre.exe",
3076
"Calibre\\calibre-customize.exe",
31-
"Calibre\\calibredb.exe",
3277
"Calibre\\calibre-debug.exe",
33-
"Calibre\\calibre-parallel.exe",
3478
"Calibre\\calibre-server.exe",
3579
"Calibre\\calibre-smtp.exe",
80+
"Calibre\\calibredb.exe",
3681
"Calibre\\ebook-convert.exe",
3782
"Calibre\\ebook-device.exe",
3883
"Calibre\\ebook-edit.exe",
@@ -41,40 +86,48 @@
4186
"Calibre\\ebook-viewer.exe",
4287
"Calibre\\fetch-ebook-metadata.exe",
4388
"Calibre\\lrf2lrs.exe",
44-
"Calibre\\lrs2lrf.exe",
4589
"Calibre\\lrfviewer.exe",
90+
"Calibre\\lrs2lrf.exe",
4691
"Calibre\\markdown-calibre.exe",
4792
"Calibre\\web2disk.exe"
4893
],
4994
"shortcuts": [
5095
[
51-
"calibre-portable.exe",
52-
"Calibre"
96+
"Calibre\\calibre.exe",
97+
"Calibre - E-book Management\\Calibre - E-book Management"
5398
],
5499
[
55100
"Calibre\\ebook-edit.exe",
56-
"Calibre E-Book Editor"
101+
"Calibre - E-book Management\\E-Book Editor"
57102
],
58103
[
59104
"Calibre\\ebook-viewer.exe",
60-
"Calibre E-Book Viewer"
105+
"Calibre - E-book Management\\E-Book Viewer"
61106
],
62107
[
63108
"Calibre\\lrfviewer.exe",
64-
"Calibre LRF Viewer"
109+
"Calibre - E-book Management\\LRF Viewer"
65110
]
66111
],
67112
"persist": [
68113
"Calibre Library",
69114
"Calibre Settings"
70115
],
116+
"uninstaller": {
117+
"script": [
118+
"if ($cmd -eq 'uninstall') {",
119+
" reg import \"$dir\\install-associations.reg\" *> $null",
120+
" reg import \"$dir\\unregister-url-handler.reg\" *> $null",
121+
"}"
122+
]
123+
},
71124
"checkver": {
72125
"github": "https://github.com/kovidgoyal/calibre"
73126
},
74127
"autoupdate": {
75128
"architecture": {
76129
"64bit": {
77-
"url": "https://download.calibre-ebook.com/$version/calibre-portable-installer-$version.exe",
130+
"url": "https://download.calibre-ebook.com/$version/calibre-64bit-$version.msi#/dl.msi_",
78131
"hash": {
79132
"url": "https://calibre-ebook.com/signatures/$basename.sha512"
80133
}

0 commit comments

Comments
 (0)