Skip to content

Commit 2b7e637

Browse files
committed
build: Move registry setup in a dedicated component for MSI packaging
1 parent 09efeef commit 2b7e637

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

contrib/windows/glpi-agent-packaging.pl

+17-11
Original file line numberDiff line numberDiff line change
@@ -507,17 +507,31 @@ sub _tree2xml {
507507
# see: http://stackoverflow.com/questions/10358989/wix-using-keypath-on-components-directories-files-registry-etc-etc
508508
$result .= $ident ." ". qq[<Component Id="$component_id" Guid="{$component_guid}" Feature="$this_feat">\n];
509509
$result .= $ident ." ". qq[ <File Id="$file_id" Name="$file_basename" ShortName="$file_shortname" Source="$f->{full_name}" KeyPath="yes"$vital />\n];
510-
# Add service, registry and firewall definitions on feat_AGENT
510+
# Only add service setup on feat_AGENT
511511
if ($this_feat eq "feat_AGENT") {
512512
my $servicename = $self->global->{service_name};
513-
my $installversion = $self->global->{agent_version};
514-
my $regpath = "Software\\".$self->global->{_provider}."-Agent";
515513
$result .= $ident ." ". qq[ <ServiceInstall Name="$servicename" Start="auto"\n];
516514
$result .= $ident ." ". qq[ ErrorControl="normal" DisplayName="!(loc.ServiceDisplayName)" Description="!(loc.ServiceDescription)" Interactive="no"\n];
517515
$result .= $ident ." ". qq[ Type="ownProcess" Arguments='-I"[INSTALLDIR]perl\\agent" -I"[INSTALLDIR]perl\\site\\lib" -I"[INSTALLDIR]perl\\vendor\\lib" -I"[INSTALLDIR]perl\\lib" "[INSTALLDIR]perl\\bin\\glpi-win32-service"'>\n];
518516
$result .= $ident ." ". qq[ <util:ServiceConfig FirstFailureActionType="restart" SecondFailureActionType="restart" ThirdFailureActionType="restart" RestartServiceDelayInSeconds="60" />\n];
519517
$result .= $ident ." ". qq[ </ServiceInstall>\n];
520518
$result .= $ident ." ". qq[ <ServiceControl Id="SetupService" Name="$servicename" Start="install" Stop="both" Remove="both" Wait="yes" />\n];
519+
} elsif ($file_id eq "f_agentmonitor_exe") {
520+
my $regpath = "Software\\Microsoft\\Windows\\CurrentVersion\\Run";
521+
# Install GLPI-AgentMonitor only when required
522+
$result .= $ident ." ". qq[ <Condition>AGENTMONITOR=1 AND EXECMODE=1</Condition>\n];
523+
# Add registry entry dedicated to GLPI-AgentMonitor autorun
524+
$result .= $ident ." ". qq[ <RegistryValue Root="HKLM" Key="$regpath" Name="GLPI-AgentMonitor" Type="string" Value="[#f_agentmonitor_exe]" />\n];
525+
# Add Start menu shortcut for GLPI-AgentMonitor
526+
$result .= $ident ." ". qq[ <Shortcut Id="AgentMonitorStartMenu" Advertise="yes" Directory="ProgramMenuFolder" Name="GLPI Agent Monitor" WorkingDirectory="d_perl_bin" Icon="agentmonitor.ico" />\n];
527+
}
528+
# Add dedicated component for registry just after feat_AGENT
529+
if ($this_feat eq "feat_AGENT") {
530+
my $installversion = $self->global->{agent_version};
531+
my $regpath = "Software\\".$self->global->{_provider}."-Agent";
532+
($component_id, $component_guid) = $self->_gen_component_id("registry");
533+
$result .= $ident ." ". qq[</Component>\n];
534+
$result .= $ident ." ". qq[<Component Id="$component_id" Guid="{$component_guid}" Feature="$this_feat">\n];
521535
$result .= $ident ." ". qq[ <RegistryKey Root="HKLM" Key="$regpath">\n];
522536
$result .= $ident ." ". qq[ <RegistryValue Name="additional-content" Type="string" Value="[ADDITIONAL_CONTENT]" />\n];
523537
$result .= $ident ." ". qq[ <RegistryValue Name="debug" Type="string" Value="[DEBUG]" />\n];
@@ -572,14 +586,6 @@ sub _tree2xml {
572586
# Add registry entry dedicated to deployment vbs check
573587
$result .= $ident ." ". qq[ <RegistryValue Name="Version" Type="string" Value="$installversion" />\n];
574588
$result .= $ident ." ". qq[ </RegistryKey>\n];
575-
} elsif ($file_id eq "f_agentmonitor_exe") {
576-
my $regpath = "Software\\Microsoft\\Windows\\CurrentVersion\\Run";
577-
# Install GLPI-AgentMonitor only when required
578-
$result .= $ident ." ". qq[ <Condition>AGENTMONITOR=1 AND EXECMODE=1</Condition>\n];
579-
# Add registry entry dedicated to GLPI-AgentMonitor autorun
580-
$result .= $ident ." ". qq[ <RegistryValue Root="HKLM" Key="$regpath" Name="GLPI-AgentMonitor" Type="string" Value="[#f_agentmonitor_exe]" />\n];
581-
# Add Start menu shortcut for GLPI-AgentMonitor
582-
$result .= $ident ." ". qq[ <Shortcut Id="AgentMonitorStartMenu" Advertise="yes" Directory="ProgramMenuFolder" Name="GLPI Agent Monitor" WorkingDirectory="d_perl_bin" Icon="agentmonitor.ico" />\n];
583589
}
584590
$result .= $ident ." ". qq[</Component>\n];
585591
}

0 commit comments

Comments
 (0)