Skip to content

Commit

Permalink
Generate zed.cat for zed.inf
Browse files Browse the repository at this point in the history
Both for CMake and the Deployment project

Signed-off-by: Jorgen Lundman <[email protected]>
  • Loading branch information
lundman committed Nov 21, 2024
1 parent a2b2709 commit 308e3bc
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 7 deletions.
22 changes: 22 additions & 0 deletions cmd/zed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,25 @@ install(FILES $<TARGET_PDB_FILE:zed>
DESTINATION "${CMAKE_INSTALL_BINDIR}"
OPTIONAL
)

add_custom_target(
zed_cat
BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/cmd/zed/os/windows/zed.cat"
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_BINARY_DIR}/zed.exe" "${CMAKE_CURRENT_BINARY_DIR}/cmd/zed/os/windows/zed.exe"
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/cmd/zed/os/windows/zed.inf" "${CMAKE_CURRENT_BINARY_DIR}/cmd/zed/os/windows/zed.inf"
COMMAND "${STAMPINF_PROGRAM}" -d "*" -a "amd64" -v "*" -f "${CMAKE_CURRENT_BINARY_DIR}\\cmd\\zed\\os\\windows\\zed.inf"
COMMAND "${INF2CAT_PROGRAM}" /verbose "/driver:${CMAKE_CURRENT_BINARY_DIR}/cmd/zed/os/windows" /os:10_19H1_X86,10_19H1_X64,ServerRS5_X64 /uselocaltime
COMMAND "${SIGNTOOL_PROGRAM}" sign /v /as /fd sha256 /td sha256 /sha1 "${OPENZFS_SIGNTOOL_SHA1}" /tr "${OPENZFS_SIGNTOOL_TSA}" "${CMAKE_CURRENT_BINARY_DIR}/cmd/zed/os/windows/zed.cat"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/cmd/zed/os/windows"
VERBATIM COMMENT "Generating and signing zed.cat file"
)

add_dependencies(zed_cat zed)

install(TARGETS OpenZFS RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/driver")
install(FILES
"${CMAKE_SOURCE_DIR}/cmd/zed/os/windows/zed.inf"
"${CMAKE_SOURCE_DIR}/cmd/zed/os/windows/zed.cat"
"${CMAKE_CURRENT_BINARY_DIR}/driver/zed.exe"
DESTINATION "${CMAKE_INSTALL_BINDIR}/driver"
)
77 changes: 77 additions & 0 deletions cmd/zed/os/windows/zed.inf
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
[Version]
Signature="$WINDOWS NT$"
Class=Application
ClassGuid={5c4c3332-344d-4f20-89c9-6800dd8809ff}
Provider=%ManufacturerName%
DriverVer = 11/21/2024,10.34.39.932
CatalogFile=zed.cat
PnpLockdown=1

[SourceDisksNames]
1="OpenZFS zed media",,0

[SourceDisksFiles]
zed.exe=1

[DefaultInstall.NTx86]
CustomDestination=ProgramFilesDir
CopyFiles=CopyZedFiles

[DefaultInstall.NTamd64]
CustomDestination=ProgramFilesDirNT
CopyFiles=CopyZedFiles

[DefaultInstall.NTx86.Services]
AddService=OpenZFS_zed,0x00000002,ServiceInstallSection

[DefaultInstall.NTamd64.Services]
AddService=OpenZFS_zed,0x00000002,ServiceInstallSection

[DefaultUninstall.NTx86]
LegacyUninstall=1
DelFiles=CopyZedFiles
UninstallServices=ServiceUninstallSection

[DefaultUninstall.NTamd64]
LegacyUninstall=1
DelFiles=CopyZedFiles
UninstallServices=ServiceUninstallSection

; Change 5 to 1 below to prompt user for path.
[ProgramFilesDir]
16422=DestA,5

[ProgramFilesDirNT]
16422=DestB,5

[DestA]
HKLM,"Software\Microsoft\Windows\CurrentVersion","ProgramFilesDir",,"C:\Program Files"

[DestB]
HKLM,"Software\Microsoft\Windows\CurrentVersion", "ProgramFilesDir",,"C:\Program Files"

[ServiceInstallSection]
DisplayName = "OpenZFS zed"
Description = "zed monitors ZFS events."
ServiceType = 0x10 ; Own Process
StartType = 2 ; Automatic
ErrorControl= 1 ; Normal error handling
ServiceBinary = %16422%\%OpenZFSDirName%\zed.exe
LoadOrderGroup = Base

[ServiceUninstallSection]
DelService=OpenZFS_zed,0x200 ; Removes service but not instance configuration

[Strings]
ManufacturerName="OpenZFS on Windows"
OpenZFSDirName="OpenZFS on Windows"

;here we tell setup where to dump our Files, dont change anything from here unless you know
;
[DestinationDirs]
CopyZedFiles=16422,%OpenZFSDirName%

[CopyZedFiles]
zed.exe

; ***** END OF FILE *****
9 changes: 7 additions & 2 deletions contrib/windows/OpenZFS/OpenZFS.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30621.155
# Visual Studio Version 17
VisualStudioVersion = 17.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenZFS", "OpenZFS\OpenZFS.vcxproj", "{CE4D8C0F-7C0C-48EA-A286-A3FD540BA4DE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{36A8D6D5-66DB-457F-A30B-80DB501F801C}"
ProjectSection(SolutionItems) = preProject
..\..\..\cmd\zed\os\windows\zed.inf = ..\..\..\cmd\zed\os\windows\zed.inf
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
Expand Down
16 changes: 12 additions & 4 deletions contrib/windows/OpenZFS/OpenZFS/OpenZFS.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,21 @@ copy /Y "$(SolutionDir)..\..\..\out\build\x64-Debug\cmd\zed\zed.exe" "$(TargetDi
</DriverSign>
</ItemDefinitionGroup>
<ItemGroup>
<FilesToPackage Include="$(TargetPath)" />
<FilesToPackage Include="C:\src\openzfs\contrib\windows\OpenZFS\..\..\..\out\build\x64-Debug\cmd\zed\cmd\zed\os\windows\zed.cat" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PackageRelativeDirectory>
</PackageRelativeDirectory>
</FilesToPackage>
<FilesToPackage Include="C:\src\openzfs\contrib\windows\OpenZFS\..\..\..\out\build\x64-Debug\cmd\zed\cmd\zed\os\windows\zed.inf" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PackageRelativeDirectory>
</PackageRelativeDirectory>
</FilesToPackage>
<FilesToPackage Include="C:\src\openzfs\contrib\windows\OpenZFS\x64\Debug\OpenZFS.sys">
<PackageRelativeDirectory>
</PackageRelativeDirectory>
</FilesToPackage>
</ItemGroup>
<ItemGroup>
<Inf Include="..\..\..\..\module\os\windows\OpenZFS.inf" />
<Inf Include="..\..\..\..\module\os\windows\zed.inf">
<SpecifyArchitecture Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</SpecifyArchitecture>
</Inf>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\..\module\os\windows\debug.c" />
Expand Down
5 changes: 4 additions & 1 deletion module/os/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ set_target_properties(OpenZFS

configure_file(OpenZFS.inf "${CMAKE_CURRENT_BINARY_DIR}/driver/OpenZFS.inf" COPYONLY)
configure_file(OpenZFS.man "${CMAKE_CURRENT_BINARY_DIR}/driver/OpenZFS.man" COPYONLY)
configure_file(OpenZFS.inf "${CMAKE_CURRENT_BINARY_DIR}/driver/zed.inf" COPYONLY)

add_custom_command(
TARGET OpenZFS
Expand All @@ -70,8 +71,10 @@ add_custom_command(
COMMAND "${SIGNTOOL_PROGRAM}" sign /v /as /fd sha256 /td sha256 /sha1 "${OPENZFS_SIGNTOOL_SHA1}" /tr "${OPENZFS_SIGNTOOL_TSA}" "${CMAKE_CURRENT_BINARY_DIR}/driver/OpenZFS.cat"
COMMAND "${SIGNTOOL_PROGRAM}" sign /v /as /fd sha256 /td sha256 /sha1 "${OPENZFS_SIGNTOOL_SHA1}" /tr "${OPENZFS_SIGNTOOL_TSA}" $<TARGET_FILE:OpenZFS>
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/driver"
VERBATIM COMMENT "Generating and signing .cat file"
VERBATIM COMMENT "Generating and signing OpenZFS.cat file"
)

add_dependencies(OpenZFS zed_cat)

install(TARGETS OpenZFS RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/driver")
install(FILES
Expand Down

0 comments on commit 308e3bc

Please sign in to comment.