Skip to content

Commit

Permalink
SNOW-1055755: windows build - back to wix 3
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-mraba committed Sep 11, 2024
1 parent 5a25ed4 commit 805cb53
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 143 deletions.
39 changes: 22 additions & 17 deletions scripts/packaging/win/build_snowflake_cli.bat
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
@echo off
echo %PATH%
echo "Updating PATH"
set PATH=C:\Program Files\Python310\;c:\Program Files (x86)\Windows Kits\8.1\bin\x86\;%PATH%
echo %PATH%

@echo on
REM dir /r "C:\Program Files (x86)\WiX Toolset v3.11\bin"
REM where candle
REM where lighs
REM where heat
call scripts\packaging\win\dotnet-install.ps1 -Verbose
dotnet tool install --global wix
where wix
wix --version
wix extension add -g WixToolset.Util.wixext
wix extension add -g WixToolset.UI.wixext
exit
python.exe --version
python.exe -m pip install --upgrade pip uv hatch

Expand All @@ -26,7 +16,8 @@ set CONTENTSDIR="snowflake-cli-%CLI_VERSION%"
echo %CONTENTSDIR%
set ENTRYPOINT=src\\snowflake\\cli\\_app\\__main__.py

exit
REM exit


@echo on
python.exe -m hatch -e packaging run ^
Expand All @@ -40,18 +31,32 @@ python.exe -m hatch -e packaging run ^
--contents-directory=%CONTENTSDIR% ^
%ENTRYPOINT%

REM tar -a -c -f snow.zip dist\snow
tar -a -c -f snow.zip dist\snow

cd dist\snow
dir /r .
signtool sign /debug /sm /t http://timestamp.digicert.com /a snow.exe

REM Build MSI-installer
cd ..\..
dir /r .
REM Generate wxs file for Wix
python.exe -m hatch -e packaging run ^
python scripts\packaging\win\wxs_builder.py

candle ^
-dSnowflakeCLIVersion=%CLI_VERSION% ^
scripts\packaging\win\snowflake_cli.wxs ^
scripts\packaging\win\snowflake_cli_exitdlg.wxs

dir /r .

wix build -d SnowflakeCLIVersion=3.0.0.2 ^
-o snowflake-cli-3.0.0.dev0.2-windows_x86_64.msi ^
-ext WixToolset.UI.wixext ^
scripts\packaging\win\snowflake_cli.wxs
light snowflake_cli.wixobj ^
snowflake_cli_exitdlg.wixobj ^
-cultures:en-us ^
-loc scripts\packaging\win\snowflake_cli_en-us.wxl ^
-ext WixUIExtension ^
-ext WixUtilExtension ^
-o dist\snowflake-cli-%CLI_VERSION%-windows_x86_64.msi

dir /r .
21 changes: 0 additions & 21 deletions scripts/packaging/win/snowflake_cli.wxs

This file was deleted.

108 changes: 108 additions & 0 deletions scripts/packaging/win/snowflake_cli_template_v4.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?xml version='1.0' encoding='utf-8'?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Package Name="Snowflake CLI" Language="1033" Version="$(var.SnowflakeCLIVersion)"
Manufacturer="Snowflake, Inc." UpgradeCode="42280567-AE10-4184-8BB4-F98F59519CB2"
InstallerVersion="405">
<SummaryInformation Manufacturer="Snowflake, Inc." />
<WixVariable Id="WixUIDialogBmp" Value="scripts\packaging\win\snowflake_msi_background.png" />
<WixVariable Id="WixUIBannerBmp" Value="scripts\packaging\win\snowflake_msi_banner.png" />
<Media Id="1" Cabinet="snow.cab" EmbedCab="yes" />
<MajorUpgrade AllowDowngrades="yes" />

<DirectoryRef Id="TESTFILEPRODUCTDIR">
<Component Id="snow.exe" Guid="3FDE264C-66C4-4B6C-AE4C-F42618FB98BC" Bitness="always64">
<Environment Id="PATH" Name="PATH" Value="[TESTFILEPRODUCTDIR]" Permanent="no" Part="last"
Action="set" System="yes" />
<File Id="snow.exe" Source="dist\snow\snow.exe" KeyPath="yes" Checksum="yes" />
</Component>
</DirectoryRef>
<Feature Id="MainApplication" Title="Snowflake CLI" Level="1">
<ComponentRef Id="snow.exe" />
</Feature>
<Icon Id="icon.ico" SourceFile="scripts\packaging\win\snowflake_msi.ico" />
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
<Property Id="ARPHELPLINK"
Value="https://docs.snowflake.net/manuals/user-guide/snowflake-cli.html" />
<Property Id="ARPNOMODIFY" Value="yes" Secure="yes" />
<Property Id="ARPURLINFOABOUT" Value="https://snowflake.com/" />
<Property Id="WIXUI_INSTALLDIR" Value="TESTFILEPRODUCTDIR" />
<UIRef Id="WixUI_InstallDir2" />
<Property Id="ApplicationFolderName" Value="Snowflake CLI" />
<Property Id="WixAppFolder" Value="WixUISupportPerUser" />
<util:BroadcastSettingChange />
<util:BroadcastEnvironmentChange />

<StandardDirectory Id="ProgramFiles64Folder">
<Directory Id="TESTFILEPRODUCTDIR" Name="Snowflake CLI" />
</StandardDirectory>
</Package>
<Fragment>
<UI Id="WixUI_InstallDir2">
<TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
<TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
<TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />

<Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
<Property Id="WixUI_Mode" Value="InstallDir" />
<DialogRef Id="BrowseDlg" />
<DialogRef Id="DiskCostDlg" />
<DialogRef Id="ErrorDlg" />
<DialogRef Id="FatalError" />
<DialogRef Id="FilesInUse" />
<DialogRef Id="MsiRMFilesInUse" />
<DialogRef Id="PrepareDlg" />
<DialogRef Id="ProgressDlg" />
<DialogRef Id="ResumeDlg" />
<DialogRef Id="UserExit" />
<DialogRef Id="SnowflakeCLIExitDlg" />

<Publish Dialog="BrowseDlg" Control="OK" Event="DoAction"
Value="WixUIValidatePath_$(sys.BUILDARCHSHORT)" Order="3" />
<Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="4"
Condition="WIXUI_INSTALLDIR_VALID&lt;&gt;&quot;1&quot;" />

<Publish Dialog="SnowflakeCLIExitDlg" Control="Finish" Event="EndDialog" Value="Return"
Order="999" />

<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg"
Condition="NOT Installed" />
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg"
Condition="Installed AND PATCH" />

<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" />
<Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath"
Value="[WIXUI_INSTALLDIR]" Order="1" />
<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction"
Value="WixUIValidatePath_$(sys.BUILDARCHSHORT)" Order="2"
Condition="NOT WIXUI_DONTVALIDATEPATH" />
<Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg"
Order="3"
Condition="NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID&lt;&gt;&quot;1&quot;" />
<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg"
Order="4" Condition="WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID=&quot;1&quot;" />
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty"
Value="[WIXUI_INSTALLDIR]" Order="1" />
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg"
Order="2" />

<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="InstallDirDlg"
Order="1" Condition="NOT Installed" />
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg"
Order="2" Condition="Installed AND NOT PATCH" />
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2"
Condition="Installed AND PATCH" />

<Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog"
Value="MaintenanceTypeDlg" />

<Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog"
Value="VerifyReadyDlg" />
<Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog"
Value="VerifyReadyDlg" />
<Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog"
Value="MaintenanceWelcomeDlg" />
</UI>
<UIRef Id="WixUI_Common" />
</Fragment>
</Wix>
52 changes: 29 additions & 23 deletions scripts/packaging/win/wxs_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
WXS_OUTPUT_FILE = WXS_TEMPLATE_FILE.parent.joinpath("snowflake_cli.wxs")

ns = {
"util": "http://wixtoolset.org/schemas/v4/wxs/util",
"": "http://wixtoolset.org/schemas/v4/wxs",
"": "http://schemas.microsoft.com/wix/2006/wi",
"util": "http://schemas.microsoft.com/wix/UtilExtension",
}
for ns_name, ns_url in ns.items():
ElementTree.register_namespace(ns_name, ns_url)

wxs = ElementTree.parse(WXS_TEMPLATE_FILE)
root = wxs.getroot()
snow_files = root.find(".//DirectoryRef", namespaces=ns)
snow_files = root.find(".//Component[@Id='snow.exe']/..", namespaces=ns)
if snow_files is None:
raise ValueError("Component not found in the template")

Expand All @@ -31,31 +32,36 @@
relative_lib_path = lib_path.relative_to(LIBS)
relative_file = str(relative_lib_path)

environment = ElementTree.Element("Environment")
environment.set("Id", "PATH")
environment.set("Name", "PATH")
environment.set("VALUE", "[TESTFILEPRODUCTDIR]")
environment.set("Permanent", "no")
environment.set("Part", "last")
environment.set("Action", "set")
environment.set("System", "yes")

file = ElementTree.Element("File")
file.set("Id", str(relative_lib_path))
environment = ElementTree.Element(
"Environment",
Id="PATH",
Name="PATH",
VALUE="[TESTFILEPRODUCTDIR]",
Permanent="no",
Part="last",
Action="set",
System="yes",
)

source_path = lib_path.relative_to(PROJECT_ROOT_PATH)
file.set("Source", str(source_path))
file.set("KeyPath", "yes")
file.set("Checksum", "yes")
file = ElementTree.Element(
"File",
Id=str(relative_lib_path),
Source=str(source_path),
KeyPath="yes",
Checksum="yes",
)

component = ElementTree.Element("Component")
component.set("Id", relative_file)
guid_hash = str(uuid.uuid3(uuid.NAMESPACE_DNS, relative_file)).upper()
component.set("Guid", guid_hash)
component.set("Bitness", "always64")
component = ElementTree.Element(
"Component",
Id=relative_file,
Guid=str(uuid.uuid3(uuid.NAMESPACE_DNS, relative_file)).upper(),
Bitness="always64",
)

component.append(environment)
component.append(file)
snow_files.extend(component)
snow_files.append(component)


ElementTree.indent(root, space=" ", level=0)
Expand Down
82 changes: 0 additions & 82 deletions t.xml

This file was deleted.

0 comments on commit 805cb53

Please sign in to comment.