diff --git a/src/scriptapps/SELFSIGN.PS1 b/src/scriptapps/SELFSIGN.PS1 index e76d126a..af2efd7a 100644 --- a/src/scriptapps/SELFSIGN.PS1 +++ b/src/scriptapps/SELFSIGN.PS1 @@ -1,56 +1,61 @@ -[cmdletbinding()] -param( - [Parameter(Mandatory=$true)] - [string] $filename -) +# ---------------------------------------------------------------------------------------------------------------------------------------------------------- - - -if (($filename.length -eq 0) -or -not (test-path $filename)) { - write-host "file $filename not found" - exit 1 -} -$cert = Get-ChildItem -path Cert:\LocalMachine\My -CodeSigningCert | where {$_.subject -eq "CN=punkshell local"} | Select-Object -First 1 -if ($cert.length -eq 0) { - write-host "No self signing certificate found (Cert:\LocalMachine\My)" - exit 2 +function ParameterDefinitions { + param( + [Parameter(Mandatory)][string] $filename, + [Parameter(ValueFromRemainingArguments)] $opts + ) } +# see also https://vcsjones.dev/subject-interface-packages/ +# ---------------------------------------------------------------------------------------------------------------------------------------------------------- +function psmain { + [CmdletBinding()] + #Empty param block (extra params can be added) + param() + dynamicparam { GetDynamicParamDictionary ParameterDefinitions } + process { + #Called once - we get a single item being our PSBoundParameters dictionary + write-host "Bound Parameters:$($PSBoundParameters)" + switch ($PSBoundParameters.keys) { + 'filename' { + write-host "got filename " $PSBoundParameters.filename + Set-Variable -Name $_ -Value $PSBoundParameters."$_" + if (($filename.length -eq 0) -or -not (test-path $filename)) { + write-host "file $filename not found" + exit 1 + } + } + 'opts' { + write-warning "Unused parameters: $($PSBoundParameters.$_)" + } + Default { + write-warning "Unhandled parameter -> [$($_)]" + } + } + foreach ($boundparam in $PSBoundParameters.GetEnumerator()) { + + } + } + end { + # PSBoundParameters + write-host "filename:'$filename'" + + $cert = Get-ChildItem -path Cert:\LocalMachine\My -CodeSigningCert | Where-Object {$_.subject -eq "CN=punkshell local"} | Select-Object -First 1 + if ($cert.length -eq 0) { + write-host "No self signing certificate found (Cert:\LocalMachine\My)" + exit 2 + } + write-host "Using Certificate" + write-host $cert | Select-Object FriendlyName,Thumbprint,Subject,NotAfter + write-host "Processing '$filename' ..." + try { + Write-Host $(Set-AuthenticodeSignature -FilePath $filename -Certificate $cert) + } catch { + throw $_.Exception.Message + } -echo "Using Certificate" -echo $cert | select FriendlyName,Thumbprint,Subject,NotAfter -echo "Processing $filename ..." -Set-AuthenticodeSignature -FilePath $filename -Certificate $cert - -echo "-done-" -# SIG # Begin signature block -# MIIFkgYJKoZIhvcNAQcCoIIFgzCCBX8CAQExDzANBglghkgBZQMEAgEFADB5Bgor -# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG -# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCCfgqqTvE/X4m/K -# UC7uGTV6Lz+BDJQsjeZDk0vmylnQmaCCAwgwggMEMIIB7KADAgECAhBETzeKK6w7 -# vkayhsNPPi+IMA0GCSqGSIb3DQEBBQUAMBoxGDAWBgNVBAMMD3B1bmtzaGVsbCBs -# b2NhbDAeFw0yNDAxMTIxMTE1MTBaFw0yOTAxMTIxMTI1MTBaMBoxGDAWBgNVBAMM -# D3B1bmtzaGVsbCBsb2NhbDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB -# AMoQ58xHVHwNmqM3hb6KsBAYYalFJliY189Y+oNMHtgPbDuUae0Tcd79yssV4hqp -# ZnK4f45Jbs7+SUyqoGtHyXrzhtHUFdFb8yC4T8ET2V46ddFB/JyPDUWdJikT2Erc -# Gw5/4Ag7X8P6TVMkGSaVM0T+h8kBHkzG5CTpwsOP+wMSGStcZTvyon67D3CKnY78 -# JOmovfhj97eo8oU5AWGbYEPXBmaS+xqWJeU/eX/egMECbo9kT9Y0WQk+2axqZyeL -# p2+xsvmiNpLn1i0g+NzWUxNp5ibTr2rOm0jW3vh3NklCbjby2IvjukzuszeOU9sc -# qXK6+vdAMRMS/x2/whnrErUCAwEAAaNGMEQwDgYDVR0PAQH/BAQDAgeAMBMGA1Ud -# JQQM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YK1LXUP+h0p4QJK0iZfWxrjtHhb2PCQECsw7rPDxlm4wlw= -# SIG # End signature block + write-host "-done-" + return $PSBoundParameters + } +} +write-host (psmain @args) diff --git a/src/scriptapps/fetchruntime.ps1 b/src/scriptapps/fetchruntime.ps1 index 323ae8d1..34b772e2 100644 --- a/src/scriptapps/fetchruntime.ps1 +++ b/src/scriptapps/fetchruntime.ps1 @@ -1,22 +1,22 @@ - -$url = "https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master/win32-x86_64/tclsh902z.exe" - -$outbase = $PSScriptRoot -$outbase = Resolve-Path -Path $outbase -#expected script location is the bin folder of a punk project -$rtfolder = Join-Path -Path $outbase -ChildPath "runtime" -#$output = "$(join-path $PSScriptRoot "..\src\runtime\tclsh902z.exe")" -$output = "$(join-path $rtfolder "win32-x86_64\tclsh902z.exe")" - -$container = split-path -Path $output -Parent -new-item -Path $container -ItemType Directory -force #create with intermediary folders if not already present - -if (-not(Test-Path -Path $output -PathType Leaf)) { - Write-Host "Downloading from $url ..." - Invoke-WebRequest -Uri $url -OutFile $output - Write-Host "Runtime saved at $output" -} else { - Write-Host "Runtime already found at $output" -} - - + +$url = "https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master/win32-x86_64/tclsh902z.exe" + +$outbase = $PSScriptRoot +$outbase = Resolve-Path -Path $outbase +#expected script location is the bin folder of a punk project +$rtfolder = Join-Path -Path $outbase -ChildPath "runtime" +#$output = "$(join-path $PSScriptRoot "..\src\runtime\tclsh902z.exe")" +$output = "$(join-path $rtfolder "win32-x86_64\tclsh902z.exe")" + +$container = split-path -Path $output -Parent +new-item -Path $container -ItemType Directory -force #create with intermediary folders if not already present + +if (-not(Test-Path -Path $output -PathType Leaf)) { + Write-Host "Downloading from $url ..." + Invoke-WebRequest -Uri $url -OutFile $output + Write-Host "Runtime saved at $output" +} else { + Write-Host "Runtime already found at $output" +} + + diff --git a/src/scriptapps/fetchruntime_bits.ps1 b/src/scriptapps/fetchruntime_bits.ps1 index 2a0a390c..cdb53095 100644 --- a/src/scriptapps/fetchruntime_bits.ps1 +++ b/src/scriptapps/fetchruntime_bits.ps1 @@ -1,37 +1,37 @@ -$url = "https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master/win32-x86_64/tclsh901t.exe" -$output = "$(join-path $PSScriptRoot "..\src\runtime\tclsh901t.exe")" - -if (-not(Test-Path -Path $output -PathType Leaf)) { - if ((Get-Service -name "BITS").Status -eq "Running") { - Write-Host "OK - BITS services is running" - } else { - #If not running we can get a misleading error such as 'MUI error' - Write-Host "WARNING - BITS service does not seem to be running" - $answer = Read-Host "Do you want to start the Background Intelligent Transfer Service (BITS)? (Type Yes to start service)" - if ($answer -match "yes") { - #restart requires admin - use script marked for admin - #Restart-Service BITS - #Start-Process -FilePath "cmd.exe" -ArgumentList "-NoExit -NoNewWindow -File bits.cmd" - Start-Process -FilePath "bits.cmd" -ArgumentList "-NoExit -NoNewWindow" -Wait - #cmd /c bits.cmd - } else { - write-host "Unable to download. Exiting script.." - exit 1 - } - } - - - try { - #Invoke-WebRequest $url -OutFile - - Import-Module BitsTransfer - Start-BitsTransfer -Source $url -Destination $output - Write-Host "Runtime saved at $output" - } - catch { - throw $_.Exception.Message - } -} -else { - Write-Host "Runtime already found at $output" +$url = "https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master/win32-x86_64/tclsh901t.exe" +$output = "$(join-path $PSScriptRoot "..\src\runtime\tclsh901t.exe")" + +if (-not(Test-Path -Path $output -PathType Leaf)) { + if ((Get-Service -name "BITS").Status -eq "Running") { + Write-Host "OK - BITS services is running" + } else { + #If not running we can get a misleading error such as 'MUI error' + Write-Host "WARNING - BITS service does not seem to be running" + $answer = Read-Host "Do you want to start the Background Intelligent Transfer Service (BITS)? (Type Yes to start service)" + if ($answer -match "yes") { + #restart requires admin - use script marked for admin + #Restart-Service BITS + #Start-Process -FilePath "cmd.exe" -ArgumentList "-NoExit -NoNewWindow -File bits.cmd" + Start-Process -FilePath "bits.cmd" -ArgumentList "-NoExit -NoNewWindow" -Wait + #cmd /c bits.cmd + } else { + write-host "Unable to download. Exiting script.." + exit 1 + } + } + + + try { + #Invoke-WebRequest $url -OutFile + + Import-Module BitsTransfer + Start-BitsTransfer -Source $url -Destination $output + Write-Host "Runtime saved at $output" + } + catch { + throw $_.Exception.Message + } +} +else { + Write-Host "Runtime already found at $output" } \ No newline at end of file diff --git a/src/scriptapps/fetchruntime_old.ps1 b/src/scriptapps/fetchruntime_old.ps1 index 823336c8..16980324 100644 --- a/src/scriptapps/fetchruntime_old.ps1 +++ b/src/scriptapps/fetchruntime_old.ps1 @@ -1,22 +1,22 @@ -$url = "https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master/win64/tclkit901t.exe" -$output = "$(join-path $PSScriptRoot "..\runtime\tclkit901t.exe")" - -#padding - - - -if (-not(Test-Path -Path $output -PathType Leaf)) { - try { - #Invoke-WebRequest $url -OutFile - - Import-Module BitsTransfer - Start-BitsTransfer -Source $url -Destination $output - Write-Host "Runtime saved at $output" - } - catch { - throw $_.Exception.Message - } -} -else { - Write-Host "Runtime already found at $output" +$url = "https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master/win64/tclkit901t.exe" +$output = "$(join-path $PSScriptRoot "..\runtime\tclkit901t.exe")" + +#padding + + + +if (-not(Test-Path -Path $output -PathType Leaf)) { + try { + #Invoke-WebRequest $url -OutFile + + Import-Module BitsTransfer + Start-BitsTransfer -Source $url -Destination $output + Write-Host "Runtime saved at $output" + } + catch { + throw $_.Exception.Message + } +} +else { + Write-Host "Runtime already found at $output" } \ No newline at end of file diff --git a/src/scriptapps/fetchruntime_wrap.toml b/src/scriptapps/fetchruntime_wrap.toml index faa2316d..ea5f6472 100644 --- a/src/scriptapps/fetchruntime_wrap.toml +++ b/src/scriptapps/fetchruntime_wrap.toml @@ -1,21 +1,21 @@ - -[application] - template="punk.multishell.cmd" - as_admin=false - - scripts=[ - "fetchruntime.ps1", - "fetchruntime.tcl", - "fetchruntime.bash" - ] - - default_outputfile="fetchruntime.cmd" - default_nextshellpath="/usr/bin/env bash" - default_nextshelltype="bash" - - #valid nextshelltype entries are: tcl perl powershell bash. - #nextshellpath entries must be 64 characters or less. - - win32.nextshellpath="powershell" - win32.nextshelltype="powershell" - win32.outputfile="fetchruntime.cmd" + +[application] + template="punk.multishell.cmd" + as_admin=false + + scripts=[ + "fetchruntime.ps1", + "fetchruntime.tcl", + "fetchruntime.bash" + ] + + default_outputfile="fetchruntime.cmd" + default_nextshellpath="/usr/bin/env bash" + default_nextshelltype="bash" + + #valid nextshelltype entries are: tcl perl powershell bash. + #nextshellpath entries must be 64 characters or less. + + win32.nextshellpath="powershell" + win32.nextshelltype="powershell" + win32.outputfile="fetchruntime.cmd" diff --git a/src/scriptapps/punk.tcl b/src/scriptapps/punk.tcl index d75b086f..50c125e1 100644 --- a/src/scriptapps/punk.tcl +++ b/src/scriptapps/punk.tcl @@ -15,7 +15,7 @@ if {[file tail $dirname] eq "bin"} { set vfsfolder [file normalize [file join $dirname "../src/_build/punk86${ext}.vfs"]] } 9 { - set vfsfolder [file normalize [file join $dirname "../src/_build/punk9cook${ext}.vfs"]] + set vfsfolder [file normalize [file join $dirname "../src/_build/punk902z${ext}.vfs"]] } default { error "no vfs available for tcl major version $tclmajorv" diff --git a/src/scriptapps/selfsign_wrap.toml b/src/scriptapps/selfsign_wrap.toml new file mode 100644 index 00000000..8d4eb440 --- /dev/null +++ b/src/scriptapps/selfsign_wrap.toml @@ -0,0 +1,16 @@ + +[application] + template="punk.multishell.cmd" + as_admin=true + + scripts=[ + "selfsign.ps1", + ] + + default_outputfile="selfsign.cmd" + default_nextshellpath="pwsh" + default_nextshelltype="powershell" + + win32.nextshellpath="pwsh" + win32.nextshelltype="powershell" + win32.outputfile="selfsign.cmd" diff --git a/src/scriptapps/tcltm.tcl b/src/scriptapps/tcltm.tcl index 23c0975b..fc565830 100644 --- a/src/scriptapps/tcltm.tcl +++ b/src/scriptapps/tcltm.tcl @@ -1,13 +1,14 @@ -if { ![package vsatisfies [package provide Tcl] 8.5] } {puts stdout "Tcl: >= 8.5 is required"; return} -if { ![package vsatisfies [package require sha1] 2.0.3] } {puts stdout "sha1: >= 2.0.3 is required"; return} -if { ![package vsatisfies [package require yaml] 0.3.6] } {puts stdout "yaml: >= 0.3.6 is required"; return} +if { ![package vsatisfies [package provide Tcl] 8.5-] } {puts stdout "Tcl: >= 8.5 is required"; return} +if { ![package vsatisfies [package require sha1] 2.0.3-] } {puts stdout "sha1: >= 2.0.3 is required"; return} +if { ![package vsatisfies [package require yaml] 0.3.6-] } {puts stdout "yaml: >= 0.3.6 is required"; return} namespace eval ::tcltm::binary { proc readfile { dir file } { set b [open [file normalize [filename $dir $file]]] fconfigure $b -translation binary - fconfigure $b -encoding binary + #fconfigure $b -encoding binary + fconfigure $b -encoding iso8859-1 set data [read $b] close $b return $data @@ -233,7 +234,8 @@ namespace eval ::tcltm::binary { } set fh [open $tmp w] fconfigure $fh -translation binary - fconfigure $fh -encoding binary + #fconfigure $fh -encoding binary + fconfigure $fh -encoding iso8859-1 puts -nonewline $fh [string range $bindata $bindex [incr bindex [dict get $finfo SIZE]]-1] flush $fh close $fh @@ -668,7 +670,8 @@ namespace eval ::tcltm { set res [dict create] set b [open $f] fconfigure $b -translation binary - fconfigure $b -encoding binary + #fconfigure $b -encoding binary + fconfigure $b -encoding iso8859-1 set data [read $b] close $b set pkgs [list]