2 # win-setup - Prepare a Windows development environment for building Wireshark.
4 # Copyright 2015 Gerald Combs <gerald@wireshark.org>
6 # Wireshark - Network traffic analyzer
7 # By Gerald Combs <gerald@wireshark.org>
8 # Copyright 1998 Gerald Combs
10 # SPDX-License-Identifier: GPL-2.0-or-later
15 # - Use Expand-Archive instead of `cmake -E tar`? That requires PS >= 5.0
19 Prepare a Windows development environment for building Wireshark
.
22 This script downloads and extracts third-party libraries required to compile
25 .PARAMETER Destination
26 Specifies the destination directory for the text files
. The path must
27 contain the pattern
"wireshark-*-libs".
30 Target platform
. Must be one of
"win64" or
"arm64".
32 .PARAMETER CMakeExecutable
33 Specifies the path to the CMake executable
, which is used to extract archives
.
36 -Destination Destination directory
.
37 -Platform Target platform
.
38 -CMakeExecutable Path to CMake
.
41 A
set of libraries required to compile Wireshark on Windows
, along with
42 their compressed archives
.
43 A manifest file
(library-manifest
.xml
)
46 C
:\PS
> .\tools\win-setup
.ps1
-Destination C
:\wireshark-master-64-libs
-Platform x64
50 [Parameter
(Mandatory
=$true, Position
=0)]
51 [ValidateScript
({$_ -like
"*[/\]wireshark-*-libs"})]
55 [Parameter
(Mandatory
=$true, Position
=1)]
56 [ValidateSet
("x64", "arm64")]
60 [Parameter
(Mandatory
=$false, Position
=3)]
61 [ValidateScript
({$_ | Test-Path -Type leaf
})]
63 $CMakeExecutable = "CMake"
68 # We create and delete files and directories. Bail out at the first sign of
69 # trouble instead of trying to catch exceptions everywhere.
70 $ErrorActionPreference = "Stop"
72 # Archive file / SHA256
74 "bcg729/bcg729-1.0.4-win64ws.zip" = "9a095fda4c39860d96f0c568830faa6651cd17635f68e27aa6de46c689aa0ee2";
75 "brotli/brotli-1.0.9-1-win64ws.zip" = "3f8d24aec8668201994327ff8d8542fe507d1d468a500a1aec50d0415f695aab";
76 "c-ares/c-ares-1.28.1-1-x64-windows-ws.zip" = "6509df8e15ed67e87fac84a3b0acaa7b804b59f272fdf9decfb6157d241e73da";
77 "falcosecurity-libs/falcosecurity-libs-0.18.1-1-x64-ws.zip" = "2b7751f179460f84d41fdc20dc0f67c740f0213b57f9b28075a5903c6e850e5a";
78 "falcosecurity-libs/falcosecurity-plugins-2024-07-30-2-x64-ws.zip" = "964e9df1af2a115238c2370a5d2ba00c39f080a9701cf375ea829fdc2b63214a";
79 "gnutls/gnutls-3.8.4-2-x64-mingw-dynamic-ws.zip" = "e875c6c34f633c487ce390e25a4d26a3e27d3dca3f9fdfa1d8fd66026d1e257c";
80 "krb5/krb5-1.21.3-1-x64-windows-ws.zip" = "49b83da4baa476c4c31ed3ee463f962114a469b8c3d601db68bdb6bc03a88e42";
81 "libgcrypt/libgcrypt-1.10.2-2-x64-mingw-dynamic-ws.zip" = "477cfce91d791b34df75a5ad83626f1ac2ee147eff7965e52266a4fc3da0f920";
82 "libilbc/libilbc-2.0.2-4-x64-windows-ws.zip" = "4f35a1ffa03c89bf473f38249282a7867b203988d2b6d3d2f0924764619fd5f5";
83 "libmaxminddb/libmaxminddb-1.4.3-1-win64ws.zip" = "ee89944a19ab6e1c873bdecb9fc6205d317c41e6da6ec1d30bc892fddfd143da";
84 "libpcap/libpcap-1.10.4-1-x64-windows-ws.zip" = "ad18ee1da72ce9df524b8baf9c185f237e534ef8e356c0b3eb3a5d6762004656";
85 "libsmi/libsmi-2021-01-15-2-x64-windows-ws.zip" = "ee8e349427d2a4ee9c18fc6b5839bd6df41685ecba03506179c21425e04f3413";
86 "libssh/libssh-0.11.0-1-x64-mingw-dynamic-ws.zip" = "c2c99819ddcffcd55085cb794beed03610453b234b60e35154c4b7542967832e";
87 "lua/lua-5.4.6-unicode-win64-vc14.zip" = "f0c6c7eb28733425b16717beb338d44c041dfbb5c6807e618d96bd754276aaff";
88 "lz4/lz4-1.10.0-1-x64-windows-ws.zip" = "8b838f68cc90efa2d7c37f2bc651d153487bc336525d67f9c224a3e4bccf3583";
89 "minizip/minizip-1.3-1-x64-windows-ws.zip" = "eb0bb5fffda5328e192d0d7951ff0254e64dcd736d46909fde7db792c1c53bcc";
90 "minizip-ng/minizip-ng-4.0.5-1-x64-windows-ws.zip" = "965c13ec9944ab3515cdfdec36c361f70d76ec773e0897bbe60bdcf1b4eac01b";
91 "nghttp2/nghttp2-1.62.1-1-x64-windows-ws.zip" = "381f995791bf48c43a4ab4bdbc68f89d51b8cde8501ded9ce280e3697bb911e5";
92 "nghttp3/nghttp3-1.1.0-1-x64-windows-ws.zip" = "e7e181f08ef6e7f592ba0cfef043822c2d516d130c2aad9447a588ade31a258a";
93 "opencore-amr/opencore-amr-0.1.6-1-x64-mingw-dynamic-ws.zip" = "013a7b29b62bec123482fed6acd8aed882be3478870c2ec8aec15b7cb81cda02";
94 "opus/opus-1.5.1-1-x64-windows-ws.zip" = "30d293b6e4902edae0ca5d747881d9a18f7f03b66a4758bf797f341f89592e6a";
95 "sbc/sbc-2.0-1-x64-windows-ws.zip" = "d1a58f977dcffa168b11b280bd10228191582d263b7c901e50cde7c1c43d9c04";
96 "snappy/snappy-1.2.1-1-x64-windows-ws.zip" = "e2ffccb26e91881b42d03061dcc728a98af9037705cb4595c8ccbe8d912b5d68";
97 "spandsp/spandsp-0.0.6-5-x64-windows-ws.zip" = "cbb18310876ec6f081662253a2d37f5174ac60c58b0b7cd6759852fbcfaa7d7f";
98 "speexdsp/speexdsp-1.21.1-1-win64ws.zip" = "d36db62e64ffaee38d9f607bef07d3778d8957ad29757f3eba169eb135f1a4e5";
99 "vcpkg-export/vcpkg-export-20240524-1-x64-windows-ws.zip" = "c566f41f20ae87fa4357d204f92cbbe2f236bc1df28c3d106fecfe21a8fbfa11";
100 "WinSparkle/WinSparkle-0.8.0-4-gb320893.zip" = "3ae42326bcd34594bc21b1e7948863a839ee76e87d9f4cf6b59b9d9f9a083881";
101 "zlib-ng/zlib-ng-2.1.5-1-x64-windows-ws.zip" = "a9f90e349d041d464afc1e0926d628ebee02e7093ab9983c5a7808e2b70d7873";
102 "zstd/zstd-1.5.6-1-x64-windows-ws.zip" = "f3f59351d273a1c1f2b84b60164556c8d2726155da2148f917d260d9efd16b6e";
107 "bcg729/bcg729-1.1.1-1-win64armws.zip" = "f4d76b9acf0d0e12e87a020e9805d136a0e8775e061eeec23910a10828153625";
108 "brotli/brotli-1.0.9-1-win64armws.zip" = "5ba1b62ebc514d55c3eae85a00ff107e587b6e7cb1275e2d33fcddcd49f8e2af";
109 "c-ares/c-ares-1.28.1-1-arm64-windows-ws.zip" = "84954f593d02d1af0ff5c7af1646b0fec5af3260fecda6cda7bbc84f9e343e10";
110 "falcosecurity-libs/falcosecurity-libs-0.18.1-1-arm64-ws.zip" = "da0f3631beaf10f499819c018cb400686195a615bf39b1904ed43a008d18672b";
111 "falcosecurity-libs/falcosecurity-plugins-2024-07-30-2-arm64-ws.zip" = "1d4b7cd664987f6efc3a2c5beb770119bafe8ba6ad8ad37cb7ed4fd07a2cf649";
112 "gnutls/gnutls-3.8.4-2-arm64-mingw-dynamic-ws.zip" = "17f28b4a47857db86d9c3f9b7ba12528c8e6368524314fb0fe5ea9303f1a58f9";
113 "krb5/krb5-1.21.3-1-arm64-windows-ws.zip" = "26166173cb653fdf2153c311a9f611a76575359393222cebd5228842632a0ccb";
114 "libgcrypt/libgcrypt-1.10.2-2-arm64-mingw-dynamic-ws.zip" = "cd42fa2739a204e129d655e1b0dda83ceb27399812b8b2eccddae4a9ecd8d0ce";
115 "libilbc/libilbc-2.0.2-4-arm64-windows-ws.zip" = "00a506cc1aac8a2e31856e463a555d899b5a6ccf376485a124104858ccf0be6d";
116 "libmaxminddb/libmaxminddb-1.4.3-1-win64armws.zip" = "9996327f301cb4a4de797bc024ad0471acd95c1850a2afc849c57fcc93360610";
117 "libpcap/libpcap-1.10.4-1-arm64-windows-ws.zip" = "98dbac265e3617eb0ab1a690902a4989e022d0761098c2753bff4cd0189419b3";
118 "libsmi/libsmi-2021-01-15-2-arm64-windows-ws.zip" = "3f5b7507a19436bd6494e2cbc89856a5980950f931f7cf0d637a8e764914d015";
119 "libssh/libssh-0.11.0-1-arm64-mingw-dynamic-ws.zip" = "3604a87444ab7d9343e2235047c85c5d68dbdb40abda8cbbcc09ccf8a20703d6";
120 "lua/lua-5.4.6-unicode-arm64-windows-vc14.zip" = "a28c38acde71de5c495420cd8bf480e2e41f1a14bac81503b700fc64a9679b95";
121 "lz4/lz4-1.10.0-1-arm64-windows-ws.zip" = "ee51fbf87bf359fa7835be89797c3488daf502e36e26337b0e649030aab7a09b";
122 "minizip/minizip-1.3-1-arm64-windows-ws.zip" = "e5b35d064ff10f1ab1ee9193a0965fd1eb3d1e16eab5a905ab3fea9b14fb5afe";
123 "minizip-ng/minizip-ng-4.0.5-1-arm64-windows-ws.zip" = "66ccd6ae1f6b0078632f87c9c9cc153ab0015874c8c65d855f8b90beef20cd4e";
124 "nghttp2/nghttp2-1.62.1-1-arm64-windows-ws.zip" = "3610c71da9deabf2edab4e09329817911a4e2b493d847035093a7e93d7993c12";
125 "nghttp3/nghttp3-1.1.0-1-arm64-windows-ws.zip" = "ae00b65fda2d5e9ffa979be406f127d050a95b0c59654acf7b7411e77b2feb1f";
126 "opencore-amr/opencore-amr-0.1.6-1-arm64-mingw-dynamic-ws.zip" = "581ec9e8ee4dde2236b689eec4d39802e2f998baa8d1604a4e91c1da32556b57";
127 "opus/opus-1.5.1-1-arm64-windows-ws.zip" = "b50db665b50f12185dacd8efd77cd28eb30e53ac5dcbb09b403e9fb90a9768f4";
128 "sbc/sbc-2.0-1-arm64-windows-ws.zip" = "83cfe4a8b6fa5bae253ecacc1c02e6e4c61b4ad9ad0e5e63f0f30422fb6eac96";
129 "snappy/snappy-1.2.1-1-arm64-windows-ws.zip" = "71d6987360eb1a10abd0d070768e6b7b250c6ea87feaee044ecbc8864c7e57f4";
130 "spandsp/spandsp-0.0.6-5-arm64-windows-ws.zip" = "fdf01e3c33e739ff9399b7d42cd8230c97cb27ce51865a0f06285a8f68206b6c";
131 "speexdsp/speexdsp-1.2.1-1-win64armws.zip" = "1759a9193065f27e50dd79dbb1786d24031ac43ccc48c40dca46d8a48552e3bb";
132 "vcpkg-export/vcpkg-export-20240524-1-arm64-windows-ws.zip" = "5d1e186b77ec3bc7072253be90b6aa36d7e317bccc382209c1570b60e488000b";
133 "WinSparkle/WinSparkle-0.8.0-4-gb320893.zip" = "3ae42326bcd34594bc21b1e7948863a839ee76e87d9f4cf6b59b9d9f9a083881";
134 "zlib-ng/zlib-ng-2.1.5-1-arm64-windows-ws.zip" = "de3a42d0096a17085b27630402a710b036cc8e3c85029ad37536d929697271e5";
135 "zstd/zstd-1.5.6-1-arm64-windows-ws.zip" = "167261f9605a28f8f5a45a2fa400daa5072290a89d5fdc218595da52d57f938b";
138 # Subdirectory to extract an archive to
139 $ArchivesSubDirectory = @
{
140 "AirPcap/AirPcap_Devpack_4_1_0_1622.zip" = "AirPcap_Devpack_4_1_0_1622";
143 # Plain file downloads
153 $Archives = $X64Archives;
156 if ($Platform -eq
"arm64") {
157 $Archives = $Arm64Archives;
158 $Files = $Arm64Files;
161 $CurrentManifest = $Archives + $Files
164 "bcg729-1.0.4-win??ws"
165 "brotli-1.0.*-win??ws"
166 "c-ares-1.9.1-1-win??ws"
167 "c-ares-1.1*-win??ws"
168 "gnutls-3.?.*-*-win??ws"
170 "libgcrypt-*-win??ws"
171 "libilbc-2.0.2-3-win??ws"
172 "libmaxminddb-1.4.3-1-win??ws"
173 "libpcap-1.9.1-1-win??ws"
175 "libsmi-svn-40773-win??ws"
181 "lua-5.?.?-unicode-win??-vc??"
183 "MaxMindDB-1.3.2-win??ws"
186 "opus-1.3.1-?-win??ws"
189 "snappy-1.1.*-win??ws"
190 "spandsp-0.0.6-win??ws"
193 "vcpkg-export-*-win??ws"
195 "AirPcap_Devpack_4_1_0_1622"
196 "WinSparkle-0.3-44-g2c8d9d3-win??ws"
199 "library-manifest.xml"
202 # The dev-libs site repository is at
203 # https://gitlab.com/wireshark/wireshark-development-libraries
204 [Uri
] $DownloadPrefix = "https://dev-libs.wireshark.org/windows/packages"
209 # Verifies the contents of a file against a SHA256 hash.
210 # Returns success (0) if the file exists and verifies.
211 # Returns error (1) if the file does not exist.
212 # Returns error (2) if the integrity check fails (an error is also printed).
213 function VerifyIntegrity
($filename, $hash) {
214 # Use absolute path because PS and .NET may have different working directories.
215 $filepath = Convert-Path -Path
$filename -ErrorAction SilentlyContinue
216 if (-not
($filepath)) {
219 # may throw due to permission error, I/O error, etc.
220 try { $stream = [IO
.File
]::OpenRead
($filepath) } catch { throw }
223 $sha256 = New-Object Security
.Cryptography
.SHA256Managed
224 $binaryHash = $sha256.ComputeHash
([IO
.Stream
]$stream)
225 $hexHash = ([System
.BitConverter
]::ToString
($binaryHash) -Replace
"-").ToLower
()
226 $hash = $hash.ToLower
()
227 if ($hexHash -ne
$hash) {
228 Write-Warning "$($filename): computed file hash $hexHash did NOT match $hash"
237 # Downloads a file and checks its integrity. If a corrupt file already exists,
238 # it is removed and re-downloaded. Succeeds only if the SHA256 hash matches.
239 function DownloadFile
($fileName, $fileHash, [Uri
] $fileUrl = $null) {
240 if ([string
]::IsNullOrEmpty
($fileUrl)) {
241 $fileUrl = "$DownloadPrefix/$fileName"
243 $destinationFile = "$Destination\" + [string
](Split-Path -Leaf
$fileName)
244 if (Test-Path $destinationFile -PathType
'Leaf') {
245 if ((VerifyIntegrity
$destinationFile $fileHash) -ne
0) {
246 Write-Output "$fileName is corrupt, removing and retrying download."
247 Remove-Item $destinationFile
249 Write-Output "$fileName already there; not retrieving."
254 if (-not
($Script:proxy
)) {
255 $Script:proxy
= [System
.Net
.WebRequest
]::GetSystemWebProxy
()
256 $Script:proxy
.Credentials
= [System
.Net
.CredentialCache
]::DefaultCredentials
259 Write-Output "Downloading $fileUrl into $Destination"
260 $webClient = New-Object System
.Net
.WebClient
261 $webClient.proxy
= $Script:proxy
262 $webClient.DownloadFile
($fileUrl, "$destinationFile")
263 Write-Output "Verifying $destinationFile"
264 if ((VerifyIntegrity
$destinationFile $fileHash) -ne
0) {
265 Write-Output "Download is corrupted, aborting!"
270 function DownloadArchive
($fileName, $fileHash, $subDir) {
271 DownloadFile
$fileName $fileHash
272 $archiveFile = "$Destination\" + [string
](Split-Path -Leaf
$fileName)
273 $archiveDir = "$Destination\$subDir"
274 if ($subDir -and
-not
(Test-Path $archiveDir -PathType
'Container')) {
275 New-Item -ItemType Directory
-Path
$archiveDir > $null
278 $activity = "Extracting into $($archiveDir)"
279 Write-Progress -Activity
"$activity" -Status
"Extracting $archiveFile using CMake ..."
280 Push-Location "$archiveDir"
281 & "$CMakeExecutable" -E tar xf
"$archiveFile" 2>&1 | Set-Variable -Name CMakeOut
282 $cmStatus = $LASTEXITCODE
284 Write-Progress -Activity
"$activity" -Status
"Done" -Completed
285 if ($cmStatus -gt
0) {
286 Write-Output $CMakeOut
293 # Make sure $Destination exists and do our work there.
294 if ( -not
(Test-Path $Destination -PathType
'Container') ) {
295 New-Item -ItemType
'Container' "$Destination" > $null
298 # CMake's file TO_NATIVE_PATH passive-aggressively omits the drive letter.
299 Set-Location "$Destination"
300 $Destination = $(Get-Item -Path ".\")
301 Write-Output "Working in $Destination"
303 # Check our last known state
304 $destinationManifest = @
{ "INVALID" = "INVALID" }
305 $manifestFile = "library-manifest.xml"
306 if ((Test-Path $manifestFile -PathType
'Leaf') -and
-not
($Force)) {
307 $destinationManifest = Import-Clixml $manifestFile
310 function ManifestList
($manifestHash) {
311 $manifestHash.keys
| Sort
| ForEach-Object { "$_ : $($manifestHash[$_])" }
314 if (Compare-Object -ReferenceObject
(ManifestList
($destinationManifest)) -DifferenceObject
(ManifestList
($CurrentManifest))) {
315 Write-Output "Current library manifest not found. Refreshing."
316 $activity = "Removing directories"
317 foreach ($oldItem in $CleanupItems) {
318 if (Test-Path $oldItem) {
319 Write-Progress -Activity
"$activity" -Status
"Removing $oldItem"
320 Remove-Item -force
-recurse
$oldItem
323 Write-Progress -Activity
"$activity" -Status
"Done" -Completed
325 Write-Output "Current library manifest found. Skipping download."
330 foreach ($item in $Files.GetEnumerator
() | Sort-Object -property key
) {
331 DownloadFile
$item.Name
$item.Value
334 # Download and extract archives
335 foreach ($item in $Archives.GetEnumerator
() | Sort-Object -property key
) {
336 $subDir = $ArchivesSubDirectory[$item.Name
]
337 DownloadArchive
$item.Name
$item.Value
$subDir
340 # Save our last known state
341 $CurrentManifest | Export-Clixml -Path
$manifestFile -Encoding utf8