Skip to content

Commit

Permalink
Merge pull request #983 from vktr/feature/better-installer
Browse files Browse the repository at this point in the history
Better installer
  • Loading branch information
vktr committed Dec 19, 2020
2 parents b0e6338 + be037ab commit fabd5a2
Show file tree
Hide file tree
Showing 49 changed files with 2,287 additions and 96 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ build-x64/
build-x86/
build/
docs/build
src/installer/bin
src/installer/obj
src/picotorrent/buildinfo.cpp
tools
.vscode
Expand Down
31 changes: 24 additions & 7 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ var configuration = Argument("configuration", "Release");
var platform = Argument("platform", "x64");

// Parameters
var OutputDirectory = Directory("./build-" + platform);
var BuildDirectory = OutputDirectory + Directory(configuration);
var PackagesDirectory = BuildDirectory + Directory("packages");
var PublishDirectory = BuildDirectory + Directory("publish");
var ResourceDirectory = Directory("./res");
var OutputDirectory = Directory("./build-" + platform);
var BuildDirectory = OutputDirectory + Directory(configuration);
var PackagesDirectory = BuildDirectory + Directory("packages");
var PublishDirectory = BuildDirectory + Directory("publish");
var BootstrapperDirectory = Directory("./src/installer/bin") + Directory(configuration);
var ResourceDirectory = Directory("./res");

var Version = GitVersion();
var Installer = string.Format("PicoTorrent-{0}-{1}.msi", Version.SemVer, platform);
Expand All @@ -30,6 +31,7 @@ var SymbolsPackage = string.Format("PicoTorrent-{0}-{1}.symbols.zip", Versio
Task("Clean")
.Does(() =>
{
CleanDirectory(BootstrapperDirectory);
CleanDirectory(BuildDirectory);
});

Expand Down Expand Up @@ -130,19 +132,34 @@ Task("Build-Installer")
{ "ResourceDirectory", ResourceDirectory },
{ "Version", Version.MajorMinorPatch }
},
Extensions = new [] { "WixUtilExtension" },
Extensions = new [] { "WixFirewallExtension", "WixUtilExtension" },
OutputDirectory = BuildDirectory
});
WiXLight(objFiles, new LightSettings
{
Extensions = new [] { "WixUtilExtension" },
ArgumentCustomization = args =>
args.Append("-sice:ICE38")
.Append("-sice:ICE91"),
Extensions = new [] { "WixFirewallExtension", "WixUtilExtension" },
OutputFile = PackagesDirectory + File(Installer)
});
});

Task("Build-Installer-Bootstrapper")
.Does(() =>
{
var settings = new MSBuildSettings()
.SetConfiguration(configuration)
.SetMaxCpuCount(0)
.UseToolVersion(MSBuildToolVersion.VS2019);
MSBuild("./src/installer/PicoTorrentBootstrapper.sln", settings);
});

Task("Build-Installer-Bundle")
.IsDependentOn("Build-Installer")
.IsDependentOn("Build-Installer-Bootstrapper")
.Does(() =>
{
var arch = Architecture.X64;
Expand Down
162 changes: 99 additions & 63 deletions packaging/WiX/PicoTorrent.Components.wxs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:fw="http://schemas.microsoft.com/wix/FirewallExtension">
<Fragment>
<ComponentGroup Id="CG_MainApplication" Directory="INSTALLDIR">
<Component Id="C_PicoTorrent.exe" Guid="5eb6d6ac-dc76-4fac-80ff-f31a4c05f205">
Expand All @@ -9,29 +10,97 @@
Name="PicoTorrent.exe"
Source="$(var.PublishDirectory)\PicoTorrent.exe" />

<ProgId Id="PicoTorrent.Document" Icon="F_PicoTorrent.exe" IconIndex="0">
<Extension Id="torrent">
<Verb Id="open" Command="Open with PicoTorrent" TargetFile="F_PicoTorrent.exe" Argument="&quot;%1&quot;" />
<MIME ContentType="application/x-bittorrent" Default="yes" />
</Extension>
</ProgId>
<Shortcut Id="S_PicoTorrent"
Directory="ProgramMenuFolder"
Name="PicoTorrent"
WorkingDirectory="INSTALLDIR"
Icon="I_PicoTorrent.ico"
IconIndex="0"
Advertise="yes" />
</Component>

<!-- Register magnet: URI handler -->
<RegistryKey Root="HKCR" Key="magnet">
<RegistryValue Type="string" Value="PicoTorent magnet link" />
<RegistryValue Type="string" Name="URL Protocol" Value="" />
<Component Id="C_coredb.sqlite" Guid="8a2a5387-391b-4a72-9915-403441906b83">
<File Id="F_coredb.sqlite"
KeyPath="yes"
Name="coredb.sqlite"
Source="$(var.PublishDirectory)\coredb.sqlite" />
</Component>

<RegistryKey Key="DefaultIcon">
<RegistryValue Type="string" Value="[INSTALLDIR]PicoTorrent.exe,0" />
</RegistryKey>
<Component Id="C_crashpad_handler.exe" Guid="99f10c73-7f2e-466b-a46b-cf755f884823">
<File Id="F_crashpad_handler.exe"
KeyPath="yes"
Name="crashpad_handler.exe"
Source="$(var.PublishDirectory)\crashpad_handler.exe" />
</Component>

<RegistryKey Key="shell\open\command">
<RegistryValue Type="string" Value="&quot;[INSTALLDIR]PicoTorrent.exe&quot; &quot;%1&quot;" />
</RegistryKey>
<Component Id="C_Plugin_Updater.dll" Guid="32b14933-0426-4e75-a115-56f2a9d21286">
<File Id="F_Plugin_Updater.dll"
KeyPath="yes"
Name="Plugin_Updater.dll"
Source="$(var.PublishDirectory)\Plugin_Updater.dll" />
</Component>

<Component Id="C_Registry" Guid="e0744554-572b-449a-9365-a8cc260239a9">
<RegistryKey Root="HKLM" Key="SOFTWARE\PicoTorrent">
<RegistryValue Name="InstallDirectory" Value="[INSTALLDIR]" Type="string" />
</RegistryKey>
</Component>
</ComponentGroup>

<ComponentGroup Id="CG_FirewallException" Directory="INSTALLDIR">
<Component Id="C_FirewallException_PicoTorrent" Guid="3971bf28-9c36-4df9-b1ef-b8ce16098593" KeyPath="yes">
<fw:FirewallException
Id="FW_FirewallException_PicoTorrent"
File="F_PicoTorrent.exe"
Name="PicoTorrent: Allow TCP and UDP"
Scope="any" />
</Component>
</ComponentGroup>

<RegistryKey Root="HKLM" Key="Software">
<ComponentGroup Id="CG_Associations" Directory="INSTALLDIR">
<Component Id="C_Associations" Guid="75bc84d7-6c0e-4962-a757-90c9199488dd" KeyPath="yes">
<RegistryKey Root="HKLM" Key="SOFTWARE">
<RegistryKey Key="Classes">
<!-- Register magnet link protocol -->
<RegistryKey Key="magnet">
<RegistryValue Type="string" Value="URL:BitTorrent magnet link" />

<RegistryValue Type="string" Name="Content Type" Value="application/x-magnet" />
<RegistryValue Type="string" Name="URL Protocol" Value="" />

<RegistryKey Key="OpenWithProgIds">
<RegistryValue Type="string" Name="PicoTorrent" Value="" />
</RegistryKey>

<RegistryKey Key="shell\open\command">
<RegistryValue Type="string" Value="&quot;[INSTALLDIR]PicoTorrent.exe&quot; &quot;%1&quot;" />
</RegistryKey>
</RegistryKey>

<!-- Register file type -->
<RegistryKey Key=".torrent">
<RegistryValue Type="string" Value="PicoTorrent" />
<RegistryValue Type="string" Name="Content Type" Value="application/x-bittorrent" />

<RegistryKey Key="OpenWithProgIds">
<RegistryValue Type="string" Name="PicoTorrent" Value="" />
</RegistryKey>
</RegistryKey>

<!-- Register ProgId -->
<RegistryKey Key="PicoTorrent">
<RegistryValue Type="string" Value="PicoTorrent BitTorrent file" />

<RegistryKey Key="DefaultIcon">
<RegistryValue Type="string" Value="[INSTALLDIR]PicoTorrent.exe,0" />
</RegistryKey>

<RegistryKey Key="shell\open\command">
<RegistryValue Type="string" Value="&quot;[INSTALLDIR]PicoTorrent.exe&quot; &quot;%1&quot;" />
</RegistryKey>
</RegistryKey>

<!-- Application information -->
<RegistryKey Key="Applications\PicoTorrent.exe">
<RegistryKey Key="SupportedTypes">
<RegistryValue Name=".torrent" Value="" Type="string" />
Expand All @@ -41,20 +110,10 @@
<RegistryValue Name="FriendlyAppName" Value="PicoTorrent" Type="string" />
</RegistryKey>
</RegistryKey>

<RegistryKey Key="PicoTorrent.Document">
<RegistryValue Name="FriendlyTypeName" Value="BitTorrent file" Type="string" />
</RegistryKey>
</RegistryKey>

<RegistryKey Key="Microsoft\Windows\CurrentVersion\App Paths\PicoTorrent.exe">
<RegistryValue Value="[#F_PicoTorrent.exe]" Type="string" />
</RegistryKey>

<!-- Software and capabilities -->
<RegistryKey Key="PicoTorrent">
<RegistryValue Name="InstallDirectory" Value="[INSTALLDIR]" Type="string" />
<RegistryValue Name="InstalledVersion" Value="$(var.Version)" Type="string" />

<RegistryKey Key="Capabilities">
<RegistryValue Name="ApplicationDescription" Value="A tiny, hackable BitTorrent client" Type="string" />
<RegistryValue Name="ApplicationIcon" Value="[INSTALLDIR]PicoTorrent.exe,0" Type="string" />
Expand All @@ -65,52 +124,29 @@
</RegistryKey>

<RegistryKey Key="FileAssociations">
<RegistryValue Name=".torrent" Value="PicoTorrent.Document" Type="string" />
<RegistryValue Name=".torrent" Value="PicoTorrent" Type="string" />
</RegistryKey>

<RegistryKey Key="MIMEAssociations">
<RegistryValue Name="application/x-bittorrent" Value="PicoTorrent.Document" Type="string" />
<RegistryValue Name="application/x-bittorrent" Value="PicoTorrent" Type="string" />
</RegistryKey>

<RegistryKey Key="shell\open\command">
<RegistryValue Value="&quot;[INSTALLDIR]PicoTorrent.exe&quot; &quot;%1&quot;" Type="string" />
<RegistryKey Key="UrlAssociations">
<RegistryValue Type="string" Name="magnet" Value="PicoTorrent" />
</RegistryKey>
</RegistryKey>
</RegistryKey>

<!-- Registered applications -->
<RegistryKey Key="RegisteredApplications">
<RegistryValue Name="PicoTorrent" Value="Software\PicoTorrent\Capabilities" Type="string" />
<RegistryValue Type="string" Name="PicoTorrent" Value="SOFTWARE\PicoTorrent\Capabilities" />
</RegistryKey>
</RegistryKey>

<Shortcut Id="S_PicoTorrent"
Directory="ProgramMenuFolder"
Name="PicoTorrent"
WorkingDirectory="INSTALLDIR"
Icon="I_PicoTorrent.ico"
IconIndex="0"
Advertise="yes" />
</Component>

<Component Id="C_coredb.sqlite" Guid="8a2a5387-391b-4a72-9915-403441906b83">
<File Id="F_coredb.sqlite"
KeyPath="yes"
Name="coredb.sqlite"
Source="$(var.PublishDirectory)\coredb.sqlite" />
</Component>

<Component Id="C_crashpad_handler.exe" Guid="99f10c73-7f2e-466b-a46b-cf755f884823">
<File Id="F_crashpad_handler.exe"
KeyPath="yes"
Name="crashpad_handler.exe"
Source="$(var.PublishDirectory)\crashpad_handler.exe" />
</Component>

<Component Id="C_Plugin_Updater.dll" Guid="32b14933-0426-4e75-a115-56f2a9d21286">
<File Id="F_Plugin_Updater.dll"
KeyPath="yes"
Name="Plugin_Updater.dll"
Source="$(var.PublishDirectory)\Plugin_Updater.dll" />
<RegistryKey Key="Microsoft\Windows\CurrentVersion\App Paths\PicoTorrent.exe">
<RegistryValue Type="string" Value="[INSTALLDIR]PicoTorrent.exe" />
<RegistryValue Type="string" Name="SupportedProtocols" Value="magnet" />
</RegistryKey>
</RegistryKey>
</Component>
</ComponentGroup>
</Fragment>
Expand Down
7 changes: 1 addition & 6 deletions packaging/WiX/PicoTorrent.Directories.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.PlatformProgramFilesFolder)" Name="PFiles">
<Directory Id="INSTALLDIR" Name="PicoTorrent">
<Directory Id="SCRIPTS" Name="scripts" />
<Directory Id="QTIMAGEFORMATS" Name="imageformats" />
<Directory Id="QTPLATFORMS" Name="platforms" />
<Directory Id="QTSTYLES" Name="styles" />
</Directory>
<Directory Id="INSTALLDIR" Name="PicoTorrent" />
</Directory>

<Directory Id="ProgramMenuFolder" />
Expand Down
14 changes: 14 additions & 0 deletions packaging/WiX/PicoTorrent.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@
Level="1">

<ComponentGroupRef Id="CG_MainApplication" />

<Feature Id="F_Firewall"
Absent="allow"
Level="1">
<Condition Level="0">SKIP_FIREWALL_EXCEPTION = 1</Condition>
<ComponentGroupRef Id="CG_FirewallException" />
</Feature>

<Feature Id="F_Handlers"
Absent="allow"
Level="1">
<Condition Level="0">SKIP_ASSOCIATE_FILES = 1</Condition>
<ComponentGroupRef Id="CG_Associations" />
</Feature>
</Feature>

<Property Id="ARPPRODUCTICON" Value="I_PicoTorrent.ico" />
Expand Down

0 comments on commit fabd5a2

Please sign in to comment.