blob: 9ea3ddd495719e646463d763746393bb54af4f46 [file] [log] [blame]
Steve Dower0cd63912018-12-10 18:52:57 -08001<#
2.Synopsis
3 Compiles and signs a catalog file.
4.Description
5 Given the CDF definition file, builds and signs a catalog.
6.Parameter catalog
7 The path to the catalog definition file to compile and
8 sign. It is assumed that the .cat file will be the same
9 name with a new extension.
Steve Dower21a92f82019-06-14 08:29:20 -070010.Parameter outfile
11 The path to move the built .cat file to (optional).
Steve Dower0cd63912018-12-10 18:52:57 -080012.Parameter description
13 The description to add to the signature (optional).
14.Parameter certname
15 The name of the certificate to sign with (optional).
16.Parameter certsha1
17 The SHA1 hash of the certificate to sign with (optional).
18#>
19param(
20 [Parameter(Mandatory=$true)][string]$catalog,
Steve Dower21a92f82019-06-14 08:29:20 -070021 [string]$outfile,
Steve Dower606c66a2019-04-12 11:24:15 -070022 [switch]$sign,
Steve Dower0cd63912018-12-10 18:52:57 -080023 [string]$description,
24 [string]$certname,
25 [string]$certsha1,
26 [string]$certfile
27)
28
29$tools = $script:MyInvocation.MyCommand.Path | Split-Path -parent;
30Import-Module $tools\sdktools.psm1 -WarningAction SilentlyContinue -Force
31
32Set-Alias MakeCat (Find-Tool "makecat.exe") -Scope Script
33
34MakeCat $catalog
35if (-not $?) {
36 throw "Catalog compilation failed"
37}
Steve Dower606c66a2019-04-12 11:24:15 -070038if ($sign) {
39 Sign-File -certname $certname -certsha1 $certsha1 -certfile $certfile -description $description -files @($catalog -replace 'cdf$', 'cat')
40}
Steve Dower21a92f82019-06-14 08:29:20 -070041
42if ($outfile) {
43 Split-Path -Parent $outfile | ?{ $_ } | %{ mkdir -Force $_; }
44 Move-Item ($catalog -replace 'cdf$', 'cat') $outfile
45}