diff --git a/lib/core.ps1 b/lib/core.ps1 index 70946d49a..bfd7224cd 100644 --- a/lib/core.ps1 +++ b/lib/core.ps1 @@ -230,7 +230,7 @@ function shim($path, $global, $name, $arg) { if($path -match '\.exe$') { # for programs with no awareness of any shell - cp "$(versiondir 'scoop' 'current')\supporting\shimexe\shim.exe" "$shim.exe" -force + cp "$(versiondir 'scoop' 'current')\supporting\shimexe\bin\shim.exe" "$shim.exe" -force write-output "path = $resolved_path" | out-file "$shim.shim" -encoding utf8 if($arg) { write-output "args = $arg" | out-file "$shim.shim" -encoding utf8 -append diff --git a/supporting/shimexe/.gitignore b/supporting/shimexe/.gitignore new file mode 100644 index 000000000..23053de09 --- /dev/null +++ b/supporting/shimexe/.gitignore @@ -0,0 +1 @@ +packages/ diff --git a/supporting/shimexe/bin/checksum.sha256 b/supporting/shimexe/bin/checksum.sha256 new file mode 100644 index 000000000..0480fa90a --- /dev/null +++ b/supporting/shimexe/bin/checksum.sha256 @@ -0,0 +1 @@ +0fb0a1d75fd6776841345fb99bae4d6db888732fed9ed9a5a1b9c1fad2020379 *shim.exe diff --git a/supporting/shimexe/bin/checksum.sha512 b/supporting/shimexe/bin/checksum.sha512 new file mode 100644 index 000000000..68bd1a345 --- /dev/null +++ b/supporting/shimexe/bin/checksum.sha512 @@ -0,0 +1 @@ +1239df21ed8ca1c6b5a0f8fba21c8bf16345605478a3c08899fb7d1d8ba9985ed40d41ce6354bdf05a475de3884557dd8359adc24ff99b32286a5aeda11291b7 *shim.exe diff --git a/supporting/shimexe/bin/shim.exe b/supporting/shimexe/bin/shim.exe new file mode 100644 index 000000000..fd8e32594 Binary files /dev/null and b/supporting/shimexe/bin/shim.exe differ diff --git a/supporting/shimexe/build.ps1 b/supporting/shimexe/build.ps1 index 07d2062b5..98fe2968f 100644 --- a/supporting/shimexe/build.ps1 +++ b/supporting/shimexe/build.ps1 @@ -1,5 +1,18 @@ -$fwdir = gci C:\Windows\Microsoft.NET\Framework\ -dir | sort -desc | select -first 1 +Push-Location $psscriptroot +. "$psscriptroot\..\..\lib\install.ps1" -pushd $psscriptroot -& "$($fwdir.fullname)\csc.exe" /nologo shim.cs -popd +Write-Host "Install dependencies ..." +Invoke-Expression "$psscriptroot\install.ps1" + +$output = "$psscriptroot\bin" +Write-Output 'Compiling shim.cs ...' +& "$psscriptroot\packages\Microsoft.Net.Compilers\tools\csc.exe" /deterministic /platform:anycpu /nologo /optimize /target:exe /out:"$output\shim.exe" shim.cs + +Write-Output 'Computing checksums ...' +Remove-Item "$psscriptroot\bin\checksum.sha256" -ErrorAction Ignore +Remove-Item "$psscriptroot\bin\checksum.sha512" -ErrorAction Ignore +Get-ChildItem "$psscriptroot\bin\*" -Include *.exe,*.dll | ForEach-Object { + "$(compute_hash $_ 'sha256') *$($_.Name)" | Out-File "$psscriptroot\bin\checksum.sha256" -Append -Encoding oem + "$(compute_hash $_ 'sha512') *$($_.Name)" | Out-File "$psscriptroot\bin\checksum.sha512" -Append -Encoding oem +} +Pop-Location diff --git a/supporting/shimexe/install.ps1 b/supporting/shimexe/install.ps1 new file mode 100644 index 000000000..f1ed1e78d --- /dev/null +++ b/supporting/shimexe/install.ps1 @@ -0,0 +1,8 @@ +# https://github.com/edymtt/nugetstandalone +$destinationFolder = "$psscriptroot\packages" +if ((Test-Path -path $destinationFolder)) { + Remove-Item -Path $destinationFolder -Recurse | Out-Null +} + +New-Item $destinationFolder -Type Directory | Out-Null +nuget install packages.config -o $destinationFolder -ExcludeVersion diff --git a/supporting/shimexe/packages.config b/supporting/shimexe/packages.config new file mode 100644 index 000000000..076a52e96 --- /dev/null +++ b/supporting/shimexe/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/supporting/shimexe/shim.cs b/supporting/shimexe/shim.cs index e2231c96f..af4c02c5e 100644 --- a/supporting/shimexe/shim.cs +++ b/supporting/shimexe/shim.cs @@ -8,7 +8,7 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Runtime.InteropServices; -namespace shim { +namespace Scoop { class Program { [DllImport("kernel32.dll", SetLastError=true)] diff --git a/supporting/shimexe/shim.csproj b/supporting/shimexe/shim.csproj new file mode 100644 index 000000000..c2484bc29 --- /dev/null +++ b/supporting/shimexe/shim.csproj @@ -0,0 +1,38 @@ + + + + + + + Debug + AnyCPU + {381F9D2E-2355-4F84-9206-06BB9175F97B} + Exe + Scoop.Shim + Scoop.Shim + v4.0.0 + 512 + true + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}. + + + + + diff --git a/supporting/shimexe/shim.exe b/supporting/shimexe/shim.exe deleted file mode 100644 index fdbe7a3e4..000000000 Binary files a/supporting/shimexe/shim.exe and /dev/null differ diff --git a/supporting/shimexe/update.ps1 b/supporting/shimexe/update.ps1 new file mode 100644 index 000000000..f0bc1e218 --- /dev/null +++ b/supporting/shimexe/update.ps1 @@ -0,0 +1,10 @@ +# https://github.com/edymtt/nugetstandalone +$destinationFolder = "$psscriptroot\packages" +if (!(Test-Path -path $destinationFolder)) { + Write-Host -f Red "Run .\install.ps1 first!" + exit 1 +} + +nuget update packages.config -r $destinationFolder +Remove-Item $destinationFolder -Force -Recurse | Out-Null +nuget install packages.config -o $destinationFolder -ExcludeVersion diff --git a/supporting/validator/Newtonsoft.Json.Schema.dll b/supporting/validator/Newtonsoft.Json.Schema.dll deleted file mode 100644 index 2714c6447..000000000 Binary files a/supporting/validator/Newtonsoft.Json.Schema.dll and /dev/null differ diff --git a/supporting/validator/Scoop.Validator.cs b/supporting/validator/Scoop.Validator.cs index 2d75a0765..b092dec34 100644 --- a/supporting/validator/Scoop.Validator.cs +++ b/supporting/validator/Scoop.Validator.cs @@ -83,6 +83,16 @@ namespace Scoop public bool Validate() { + if (!this.SchemaFile.Exists) + { + Console.WriteLine("ERROR: Please provide schema.json!"); + return false; + } + if (!this.ManifestFile.Exists) + { + Console.WriteLine("ERROR: Please provide manifest.json!"); + return false; + } this.Errors.Clear(); try { diff --git a/supporting/validator/Scoop.Validator.dll b/supporting/validator/Scoop.Validator.dll deleted file mode 100644 index e8852ffe9..000000000 Binary files a/supporting/validator/Scoop.Validator.dll and /dev/null differ diff --git a/supporting/validator/bin/Newtonsoft.Json.Schema.dll b/supporting/validator/bin/Newtonsoft.Json.Schema.dll new file mode 100644 index 000000000..44292af58 Binary files /dev/null and b/supporting/validator/bin/Newtonsoft.Json.Schema.dll differ diff --git a/supporting/validator/Newtonsoft.Json.dll b/supporting/validator/bin/Newtonsoft.Json.dll similarity index 100% rename from supporting/validator/Newtonsoft.Json.dll rename to supporting/validator/bin/Newtonsoft.Json.dll diff --git a/supporting/validator/bin/Scoop.Validator.dll b/supporting/validator/bin/Scoop.Validator.dll new file mode 100644 index 000000000..4c4a2034f Binary files /dev/null and b/supporting/validator/bin/Scoop.Validator.dll differ diff --git a/supporting/validator/bin/checksum.sha256 b/supporting/validator/bin/checksum.sha256 new file mode 100644 index 000000000..84055541a --- /dev/null +++ b/supporting/validator/bin/checksum.sha256 @@ -0,0 +1,4 @@ +52cc6ddf77990fbaaae4db593f655610652133ceeadb32262c122d8c9eea1bad *Newtonsoft.Json.dll +8643f860be0e5592e73219b6d5e993265f336d3bf2c93d6db5a2e918d3c3f177 *Newtonsoft.Json.Schema.dll +306de31359895c96e1b91df29a216b65a7aa3f353251ba3e5ad129906fcfc77b *Scoop.Validator.dll +cc82c9659716b564a69690a8b67e5472ea1e8e060b974306314acdd42767bf6d *validator.exe diff --git a/supporting/validator/bin/checksum.sha512 b/supporting/validator/bin/checksum.sha512 new file mode 100644 index 000000000..f42ed2013 --- /dev/null +++ b/supporting/validator/bin/checksum.sha512 @@ -0,0 +1,4 @@ +4639a7f77f7a9cafa38c632332dd5085355623f3d84475374241a64bd110569f504086b479b519e90ddbd471d4a5034239418ebc03277424212e0e6698e64418 *Newtonsoft.Json.dll +0c39a3c8e514fde4d629f11f94e6c7acdcd196cd1229c3ef5a6a0455c1cdf4dbf3fda24dd9392b05e917cb85ec745393595086078d1437343dded52f2c0011f3 *Newtonsoft.Json.Schema.dll +d133d47dbeda60571090fc4159e3575b40ddaddef858b56e0103ad531dc4612a9d4bdbee8a6b5dd4e0d5abeb549afadd059767058b568e4d5d31990a42631743 *Scoop.Validator.dll +384d22bfb21b2767de862f95945dca91aefb4b5eca687d20e410dc64059c5402a13c085517cb807635ff07397fee9bda31b0fdc0090c24cb424f62b285ea0477 *validator.exe diff --git a/supporting/validator/validator.exe b/supporting/validator/bin/validator.exe similarity index 64% rename from supporting/validator/validator.exe rename to supporting/validator/bin/validator.exe index 359ea42a1..7f95ce9e0 100644 Binary files a/supporting/validator/validator.exe and b/supporting/validator/bin/validator.exe differ diff --git a/supporting/validator/build.ps1 b/supporting/validator/build.ps1 index 99c554bb3..3e5f62edb 100644 --- a/supporting/validator/build.ps1 +++ b/supporting/validator/build.ps1 @@ -1,6 +1,21 @@ -pushd $psscriptroot -iex "$psscriptroot\install.ps1" -gci $psscriptroot\packages\Newtonsoft.*\lib\net40\*.dll -file | % { copy-item $_ $psscriptroot } -& "$psscriptroot\packages\Microsoft.Net.Compilers\tools\csc.exe" /deterministic /platform:anycpu /nologo /optimize /target:library /reference:Newtonsoft.Json.dll,Newtonsoft.Json.Schema.dll Scoop.Validator.cs -& "$psscriptroot\packages\Microsoft.Net.Compilers\tools\csc.exe" /deterministic /platform:anycpu /nologo /optimize /target:exe /reference:Scoop.Validator.dll,Newtonsoft.Json.dll,Newtonsoft.Json.Schema.dll validator.cs -popd +Push-Location $psscriptroot +. "$psscriptroot\..\..\lib\install.ps1" + +Write-Host "Install dependencies ..." +Invoke-Expression "$psscriptroot\install.ps1" + +$output = "$psscriptroot\bin" +Get-ChildItem "$psscriptroot\packages\Newtonsoft.*\lib\net40\*.dll" -File | ForEach-Object { Copy-Item $_ $output } +Write-Output 'Compiling Scoop.Validator.cs ...' +& "$psscriptroot\packages\Microsoft.Net.Compilers\tools\csc.exe" /deterministic /platform:anycpu /nologo /optimize /target:library /reference:"$output\Newtonsoft.Json.dll","$output\Newtonsoft.Json.Schema.dll" /out:"$output\Scoop.Validator.dll" Scoop.Validator.cs +Write-Output 'Compiling validator.cs ...' +& "$psscriptroot\packages\Microsoft.Net.Compilers\tools\csc.exe" /deterministic /platform:anycpu /nologo /optimize /target:exe /reference:"$output\Scoop.Validator.dll","$output\Newtonsoft.Json.dll","$output\Newtonsoft.Json.Schema.dll" /out:"$output\validator.exe" validator.cs + +Write-Output 'Computing checksums ...' +Remove-Item "$psscriptroot\bin\checksum.sha256" -ErrorAction Ignore +Remove-Item "$psscriptroot\bin\checksum.sha512" -ErrorAction Ignore +Get-ChildItem "$psscriptroot\bin\*" -Include *.exe,*.dll | ForEach-Object { + "$(compute_hash $_ 'sha256') *$($_.Name)" | Out-File "$psscriptroot\bin\checksum.sha256" -Append -Encoding oem + "$(compute_hash $_ 'sha512') *$($_.Name)" | Out-File "$psscriptroot\bin\checksum.sha512" -Append -Encoding oem +} +Pop-Location diff --git a/supporting/validator/packages.config b/supporting/validator/packages.config index 27c672f32..080c82f97 100644 --- a/supporting/validator/packages.config +++ b/supporting/validator/packages.config @@ -1,6 +1,6 @@  - - - + + + \ No newline at end of file diff --git a/supporting/validator/validator.csproj b/supporting/validator/validator.csproj index 5cc95efcf..424582662 100644 --- a/supporting/validator/validator.csproj +++ b/supporting/validator/validator.csproj @@ -1,5 +1,6 @@ + @@ -19,7 +20,7 @@ True - packages\Newtonsoft.Json.Schema.3.0.3\lib\net40\Newtonsoft.Json.Schema.dll + packages\Newtonsoft.Json.Schema.3.0.5\lib\net40\Newtonsoft.Json.Schema.dll True @@ -44,5 +45,6 @@ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}. + diff --git a/test/00-Project.Tests.ps1 b/test/00-Project.Tests.ps1 index 07ce170e2..514137dfd 100644 --- a/test/00-Project.Tests.ps1 +++ b/test/00-Project.Tests.ps1 @@ -6,7 +6,8 @@ $project_file_exclusions = @( $([regex]::Escape($repo_dir)+'(\\|/).git(\\|/).*$'), '.sublime-workspace$', '.DS_Store$', - 'supporting(\\|/)validator(\\|/)packages(\\|/)*' + 'supporting(\\|/)validator(\\|/)packages(\\|/)*', + 'supporting(\\|/)shimexe(\\|/)packages(\\|/)*' ) describe 'Project code' { diff --git a/test/Scoop-Manifest.Tests.ps1 b/test/Scoop-Manifest.Tests.ps1 index e4760d677..579629902 100644 --- a/test/Scoop-Manifest.Tests.ps1 +++ b/test/Scoop-Manifest.Tests.ps1 @@ -6,9 +6,9 @@ describe "manifest-validation" { beforeall { $working_dir = setup_working "manifest" $schema = "$psscriptroot/../schema.json" - Add-Type -Path "$psscriptroot\..\supporting\validator\Newtonsoft.Json.dll" - Add-Type -Path "$psscriptroot\..\supporting\validator\Newtonsoft.Json.Schema.dll" - Add-Type -Path "$psscriptroot\..\supporting\validator\Scoop.Validator.dll" + Add-Type -Path "$psscriptroot\..\supporting\validator\bin\Newtonsoft.Json.dll" + Add-Type -Path "$psscriptroot\..\supporting\validator\bin\Newtonsoft.Json.Schema.dll" + Add-Type -Path "$psscriptroot\..\supporting\validator\bin\Scoop.Validator.dll" } it "Scoop.Validator is available" {