Steve Dower | 0cd6391 | 2018-12-10 18:52:57 -0800 | [diff] [blame] | 1 | <# |
| 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 Dower | 21a92f8 | 2019-06-14 08:29:20 -0700 | [diff] [blame] | 10 | .Parameter outfile |
| 11 | The path to move the built .cat file to (optional). |
Steve Dower | 0cd6391 | 2018-12-10 18:52:57 -0800 | [diff] [blame] | 12 | .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 | #> |
| 19 | param( |
| 20 | [Parameter(Mandatory=$true)][string]$catalog, |
Steve Dower | 21a92f8 | 2019-06-14 08:29:20 -0700 | [diff] [blame] | 21 | [string]$outfile, |
Steve Dower | 606c66a | 2019-04-12 11:24:15 -0700 | [diff] [blame] | 22 | [switch]$sign, |
Steve Dower | 0cd6391 | 2018-12-10 18:52:57 -0800 | [diff] [blame] | 23 | [string]$description, |
| 24 | [string]$certname, |
| 25 | [string]$certsha1, |
| 26 | [string]$certfile |
| 27 | ) |
| 28 | |
| 29 | $tools = $script:MyInvocation.MyCommand.Path | Split-Path -parent; |
| 30 | Import-Module $tools\sdktools.psm1 -WarningAction SilentlyContinue -Force |
| 31 | |
| 32 | Set-Alias MakeCat (Find-Tool "makecat.exe") -Scope Script |
| 33 | |
| 34 | MakeCat $catalog |
| 35 | if (-not $?) { |
| 36 | throw "Catalog compilation failed" |
| 37 | } |
Steve Dower | 606c66a | 2019-04-12 11:24:15 -0700 | [diff] [blame] | 38 | if ($sign) { |
| 39 | Sign-File -certname $certname -certsha1 $certsha1 -certfile $certfile -description $description -files @($catalog -replace 'cdf$', 'cat') |
| 40 | } |
Steve Dower | 21a92f8 | 2019-06-14 08:29:20 -0700 | [diff] [blame] | 41 | |
| 42 | if ($outfile) { |
| 43 | Split-Path -Parent $outfile | ?{ $_ } | %{ mkdir -Force $_; } |
| 44 | Move-Item ($catalog -replace 'cdf$', 'cat') $outfile |
| 45 | } |