Skip to content

Commit

Permalink
tools: build.bat: sign drivers and msi
Browse files Browse the repository at this point in the history
  • Loading branch information
billziss-gh committed Dec 18, 2019
1 parent f29e911 commit 9b1f4e8
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 11 deletions.
65 changes: 65 additions & 0 deletions build/VStudio/winfuse.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,71 @@
<ItemGroup>
<ResourceCompile Include="..\..\src\winfuse\version.rc" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\src\winfuse\driver.inf.in">
<FileType>Document</FileType>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Writing driver-$(PlatformTarget).inf</Message>
<LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Writing driver-$(PlatformTarget).inf</Message>
<LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Writing driver-$(PlatformTarget).inf</Message>
<LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkObjects>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Writing driver-$(PlatformTarget).inf</Message>
<LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkObjects>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(OutDir)driver-$(PlatformTarget).inf</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(OutDir)driver-$(PlatformTarget).inf</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)driver-$(PlatformTarget).inf</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)driver-$(PlatformTarget).inf</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">set DriverFile=$(TargetFileName)
set Provider="$(MyCompanyName)"
set CatalogFile=driver-$(PlatformTarget).cat

setlocal EnableDelayedExpansion
if exist $(OutDir)driver-$(PlatformTarget).inf del $(OutDir)driver-$(PlatformTarget).inf
for /f "delims=" %%l in (%(FullPath)) do (
set line=%%l
echo !line! &gt;&gt;$(OutDir)driver-$(PlatformTarget).inf
)

stampinf -d * -v $(MyVersion) -f $(OutDir)driver-$(PlatformTarget).inf</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">set DriverFile=$(TargetFileName)
set Provider="$(MyCompanyName)"
set CatalogFile=driver-$(PlatformTarget).cat

setlocal EnableDelayedExpansion
if exist $(OutDir)driver-$(PlatformTarget).inf del $(OutDir)driver-$(PlatformTarget).inf
for /f "delims=" %%l in (%(FullPath)) do (
set line=%%l
echo !line! &gt;&gt;$(OutDir)driver-$(PlatformTarget).inf
)

stampinf -d * -v $(MyVersion) -f $(OutDir)driver-$(PlatformTarget).inf</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">set DriverFile=$(TargetFileName)
set Provider="$(MyCompanyName)"
set CatalogFile=driver-$(PlatformTarget).cat

setlocal EnableDelayedExpansion
if exist $(OutDir)driver-$(PlatformTarget).inf del $(OutDir)driver-$(PlatformTarget).inf
for /f "delims=" %%l in (%(FullPath)) do (
set line=%%l
echo !line! &gt;&gt;$(OutDir)driver-$(PlatformTarget).inf
)

stampinf -d * -v $(MyVersion) -f $(OutDir)driver-$(PlatformTarget).inf</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">set DriverFile=$(TargetFileName)
set Provider="$(MyCompanyName)"
set CatalogFile=driver-$(PlatformTarget).cat

setlocal EnableDelayedExpansion
if exist $(OutDir)driver-$(PlatformTarget).inf del $(OutDir)driver-$(PlatformTarget).inf
for /f "delims=" %%l in (%(FullPath)) do (
set line=%%l
echo !line! &gt;&gt;$(OutDir)driver-$(PlatformTarget).inf
)

stampinf -d * -v $(MyVersion) -f $(OutDir)driver-$(PlatformTarget).inf</Command>
</CustomBuild>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
5 changes: 5 additions & 0 deletions build/VStudio/winfuse.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,9 @@
<Filter>Source</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\..\src\winfuse\driver.inf.in">
<Filter>Source</Filter>
</None>
</ItemGroup>
</Project>
21 changes: 21 additions & 0 deletions src/winfuse/driver.inf.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[Version]
Signature = "$WINDOWS NT$"
Class = Volume
ClassGuid = {71a27cdd-812a-11d0-bec7-08002be2092f}
CatalogFile = !CatalogFile!
Provider = !Provider!

[DestinationDirs]
DefaultDestDir = 12

[DefaultInstall]
CopyFiles = Driver.CopyFiles

[Driver.CopyFiles]
!DriverFile!

[SourceDisksFiles]
!DriverFile! = 1

[SourceDisksNames]
1 = Disk1
30 changes: 30 additions & 0 deletions tools/DigiCert High Assurance EV Root CA.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-----BEGIN CERTIFICATE-----
MIIFOzCCAyOgAwIBAgIKYSBNtAAAAAAAJzANBgkqhkiG9w0BAQUFADB/MQswCQYD
VQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9uZDEe
MBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSkwJwYDVQQDEyBNaWNyb3Nv
ZnQgQ29kZSBWZXJpZmljYXRpb24gUm9vdDAeFw0xMTA0MTUxOTQ1MzNaFw0yMTA0
MTUxOTU1MzNaMGwxCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMx
GTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xKzApBgNVBAMTIkRpZ2lDZXJ0IEhp
Z2ggQXNzdXJhbmNlI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i3AV8zL7vcLXM0iQRC
ChyLefmj+hfv+qEaEN/gssGV61wMBZc7NT4YiE3bbL8kiY3Ivdifezk6JKDV39Hz
ShqX9qZveh+wkKmzrAE5kdNht2TxPlc4A6/OetK1kPWu3DmZ1bY8l+2myxbHfWsq
TJCU5kxU/R7NIOzOaJyHWOlhYL7rDsnVGX2f6Xi9DqwhdQePqW7gjGoqa5zj52W8
vC08bdwE3GdFNjKvBIG8qABuYUyVxVzUjo6fL8EydL29EWUDB83vt14CV9qG1Boo
NK+ISbLPpd2CVm9oqhTiWVT+/+ru7+qScCJggeMlI8CfzA9JsjWqWMM6w9kWlBA=
-----END CERTIFICATE-----
82 changes: 71 additions & 11 deletions tools/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,97 @@
setlocal
setlocal EnableDelayedExpansion

set MsiName="WinFuse - FUSE for the Windows kernel"
set CrossCert="%~dp0DigiCert High Assurance EV Root CA.crt"
set Issuer="DigiCert"
set Subject="Navimatics LLC"

set Configuration=Release
set SignedPackage=

if not X%1==X set Configuration=%1
if not X%2==X set SignedPackage=%2

set vswhere="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
for /f "usebackq tokens=*" %%i in (`%vswhere% -find VC\**\vcvarsall.bat`) do (
call "%%i" x64
)

if not X%SignedPackage%==X (
if not exist "%~dp0..\build\VStudio\build\%Configuration%\winfuse-*.msi" (echo previous build not found >&2 & exit /b 1)
if not exist "%SignedPackage%" (echo signed package not found >&2 & exit /b 1)
del "%~dp0..\build\VStudio\build\%Configuration%\winfuse-*.msi"
if exist "%~dp0..\build\VStudio\build\%Configuration%\winfuse.*.nupkg" del "%~dp0..\build\VStudio\build\%Configuration%\winfuse.*.nupkg"
for /R "%SignedPackage%" %%f in (*.sys) do (
copy "%%f" "%~dp0..\build\VStudio\build\%Configuration%" >nul
)
)

cd %~dp0..\build\VStudio
set signfail=0

if exist build\ for /R build\ %%d in (%Configuration%) do (
if exist "%%d" rmdir /s/q "%%d"
)
if X%SignedPackage%==X (
if exist build\ for /R build\ %%d in (%Configuration%) do (
if exist "%%d" rmdir /s/q "%%d"
)

devenv winfuse.sln /build "%Configuration%|x64"
if errorlevel 1 goto fail
call %~dp0build-libfuse.bat %Configuration% x64 build\%Configuration%\libfuse\x64
if errorlevel 1 goto fail
devenv winfuse.sln /build "%Configuration%|x64"
if errorlevel 1 goto fail
call %~dp0build-libfuse.bat %Configuration% x64 build\%Configuration%\libfuse\x64
if errorlevel 1 goto fail

devenv winfuse.sln /build "%Configuration%|x86"
if errorlevel 1 goto fail
call %~dp0build-libfuse.bat %Configuration% x86 build\%Configuration%\libfuse\x86
if errorlevel 1 goto fail
devenv winfuse.sln /build "%Configuration%|x86"
if errorlevel 1 goto fail
call %~dp0build-libfuse.bat %Configuration% x86 build\%Configuration%\libfuse\x86
if errorlevel 1 goto fail

for %%f in (build\%Configuration%\winfuse-x64.sys build\%Configuration%\winfuse-x86.sys) do (
signtool sign /ac %CrossCert% /i %Issuer% /n %Subject% /fd sha1 /t http://timestamp.digicert.com %%f
if errorlevel 1 set /a signfail=signfail+1
signtool sign /as /ac %CrossCert% /i %Issuer% /n %Subject% /fd sha256 /tr http://timestamp.digicert.com /td sha256 %%f
if errorlevel 1 set /a signfail=signfail+1
)

pushd build\%Configuration%
echo .OPTION EXPLICIT >driver.ddf
echo .Set CabinetFileCountThreshold=0 >>driver.ddf
echo .Set FolderFileCountThreshold=0 >>driver.ddf
echo .Set FolderSizeThreshold=0 >>driver.ddf
echo .Set MaxCabinetSize=0 >>driver.ddf
echo .Set MaxDiskFileCount=0 >>driver.ddf
echo .Set MaxDiskSize=0 >>driver.ddf
echo .Set CompressionType=MSZIP >>driver.ddf
echo .Set Cabinet=on >>driver.ddf
echo .Set Compress=on >>driver.ddf
echo .Set CabinetNameTemplate=driver.cab >>driver.ddf
echo .Set DiskDirectory1=. >>driver.ddf
echo .Set DestinationDir=x64 >>driver.ddf
echo driver-x64.inf >>driver.ddf
echo winfuse-x64.sys >>driver.ddf
echo .Set DestinationDir=x86 >>driver.ddf
echo driver-x86.inf >>driver.ddf
echo winfuse-x86.sys >>driver.ddf
makecab /F driver.ddf
signtool sign /ac %CrossCert% /i %Issuer% /n %Subject% /t http://timestamp.digicert.com driver.cab
if errorlevel 1 set /a signfail=signfail+1
popd
)

devenv winfuse.sln /build "Installer.%Configuration%|x64"
if errorlevel 1 goto fail

devenv winfuse.sln /build "Installer.%Configuration%|x86"
if errorlevel 1 goto fail

for %%f in (build\%Configuration%\winfuse-*.msi) do (
signtool sign /ac %CrossCert% /i %Issuer% /n %Subject% /fd sha1 /t http://timestamp.digicert.com /d %MsiName% %%f
if errorlevel 1 set /a signfail=signfail+1
REM signtool sign /ac %CrossCert% /i %Issuer% /n %Subject% /fd sha256 /tr http://timestamp.digicert.com /td sha256 /d %MsiName% %%f
REM if errorlevel 1 set /a signfail=signfail+1
)

if not %signfail%==0 echo SIGNING FAILED! The product has been successfully built, but not signed.

exit /b 0

:fail
Expand Down

0 comments on commit 9b1f4e8

Please sign in to comment.