|
| 1 | +<div class="hidden-warning"><a href="https://docs.haskellstack.org/"><img src="https://cdn.jsdelivr.net/gh/commercialhaskell/stack/doc/img/hidden-warning.svg"></a></div> |
| 2 | + |
| 3 | +# Upgrading 7-Zip |
| 4 | + |
| 5 | +When installing GHC or MSYS2 on Windows, Stack will also install |
| 6 | +[7-Zip](https://www.7-zip.org/). 7-Zip is a file archiver and is used by Stack |
| 7 | +to extract files from archives. This section explains the steps required to |
| 8 | +upgrade the 7-Zip version used by Stack. The 7-Zip functionality used by Stack |
| 9 | +is mature and stable. It is anticipated that the Stack-supplied 7-Zip will not |
| 10 | +need to be updated frequently. On 10 September 2022, it was updated from 7-Zip |
| 11 | +9.20 (released on 18 November 2010) to 7-Zip 22.01 (released on 15 July 2022). |
| 12 | + |
| 13 | +1. Download the latest installer for 64-bit x64 Windows from 7-Zip's website. |
| 14 | + |
| 15 | +2. Run the installer and install to the default location |
| 16 | + (`C:\C:\Program Files\7-Zip`). The four relevant files from those installed |
| 17 | + will be: |
| 18 | + |
| 19 | + ~~~text |
| 20 | + 7z.exe # 7-Zip Console |
| 21 | + 7z.dll # 7-Zip Engine |
| 22 | + license.txt # 7-Zip License |
| 23 | + readme.txt # 7-Zip Overview |
| 24 | + ~~~ |
| 25 | +
|
| 26 | +3. In the |
| 27 | + [commercialhaskell/stackage-content](https://github.com/commercialhaskell/stackage-content) |
| 28 | + GitHub repository, create a new draft release tagged and named `7z-XX.YY`, |
| 29 | + where `XX.YY` is the 7-Zip version number. |
| 30 | +
|
| 31 | +4. Upload the four relevant files in step 2 above into the draft release. |
| 32 | +
|
| 33 | +5. Provide a description for the release. For example: |
| 34 | +
|
| 35 | + ~~~text |
| 36 | + 7-Zip 22.01 (2022-07-15) for Windows 64-bit x64. |
| 37 | + ~~~ |
| 38 | +
|
| 39 | +6. Publish the release. |
| 40 | +
|
| 41 | +7. Changes need to be made to the |
| 42 | + [stackage-content/stack/stack-setup-2.yaml](https://github.com/commercialhaskell/stackage-content/blob/master/stack/stack-setup-2.yaml) |
| 43 | + file, to switch over to using the newly uploaded files. For example |
| 44 | + (extract): |
| 45 | +
|
| 46 | + ~~~yaml |
| 47 | + sevenzexe-info: |
| 48 | + url: "https://github.com/commercialhaskell/stackage-content/releases/download/7z-22.01/7z.exe" |
| 49 | + content-length: 545280 |
| 50 | + sha256: 254cf6411d38903b2440819f7e0a847f0cfee7f8096cfad9e90fea62f42b0c23 |
| 51 | +
|
| 52 | + sevenzdll-info: |
| 53 | + url: "https://github.com/commercialhaskell/stackage-content/releases/download/7z-22.01/7z.dll" |
| 54 | + content-length: 1814016 |
| 55 | + sha256: 73578f14d50f747efa82527a503f1ad542f9db170e2901eddb54d6bce93fc00e |
| 56 | + ~~~ |
| 57 | +
|
| 58 | + The `content-length:` key's value is the size of the file in bytes. It can |
| 59 | + be obtained from the `Length` field of the `dir` command. The `sha256:` |
| 60 | + key's value can be obtained from the commands (in PowerShell): |
| 61 | +
|
| 62 | + ~~~text |
| 63 | + (Get-FileHash 7z.exe -Algorithm SHA256).Hash.ToLower() |
| 64 | + (Get-FileHash 7z.dll -Algorithm SHA256).Hash.ToLower() |
| 65 | + ~~~ |
| 66 | +
|
| 67 | + The `sha256:` key only accepts lowercase hash results as values. |
| 68 | +
|
| 69 | +8. The changed `stack-setup-2.yaml` file should be tested locally. This can be |
| 70 | + done by: |
| 71 | +
|
| 72 | + * temporarily disabling the existing local copy of 7-Zip by changing the |
| 73 | + name of the `7z.exe` and `7z.dll` files in the `stack path --programs` |
| 74 | + directory; |
| 75 | +
|
| 76 | + * identifying a version of GHC not already installed in the |
| 77 | + `stack path --programs` directory; and |
| 78 | +
|
| 79 | + * executing the command: |
| 80 | +
|
| 81 | + ~~~text |
| 82 | + stack --resolver <snapshot> setup --setup-info-yaml <path to local copy of stack-setup-2.yaml> |
| 83 | + ~~~ |
| 84 | +
|
| 85 | + where `<snapshot>` requires the missing version of GHC. |
| 86 | +
|
| 87 | + If all is well, the command should proceed to download the missing version |
| 88 | + of GHC, download the `7z.exe` and `7z.dll` files, and use the 7-Zip version |
| 89 | + to extract files from the GHC archive. |
| 90 | +
|
| 91 | +9. Raise a pull request on `commercialhaskell/stackage-contents` for the |
| 92 | + changes to the locally-tested `stack-setup-2.yaml` file. |
0 commit comments