[cpp-sp] 01/04: CPPSP-53 Rewrite Windows Installer as a '.bat' file

Codeberg noreply at shibboleth.net
Mon Jun 29 14:38:09 UTC 2026


This is an automated email from the git hooks/post-receive script.

codeberg pushed a commit to branch main
in repository cpp-sp.

View the commit online:
https://codeberg.org/Shibboleth/cpp-sp/commit/c31da081691e42056a7f602da9d246c3191a324b

commit c31da081691e42056a7f602da9d246c3191a324b
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sun Jun 28 15:43:00 2026 +0100

    CPPSP-53 Rewrite Windows Installer as a '.bat' file
    
    https://shibboleth.atlassian.net/browse/CPPSP-53
    
    Less chatty output on update/install
    Allow a parameter to install.bat (to specify target)
    Check the registry for an existing install to allow the same batch file
    to be used to do an update.
---
 WindowsInstall/doupdate.bat | 25 ++++++++++++++-----------
 WindowsInstall/install.bat  | 43 ++++++++++++++++++++++++++++++++++++-------
 2 files changed, 50 insertions(+), 18 deletions(-)

diff --git a/WindowsInstall/doupdate.bat b/WindowsInstall/doupdate.bat
index bdc2461e..f5ea8a3b 100644
--- a/WindowsInstall/doupdate.bat
+++ b/WindowsInstall/doupdate.bat
@@ -11,7 +11,6 @@ set TargetDir=%cd%
 cd /d %~dp0
 set SourceDir=%cd%
 cd ..
-echo Installing from %cd%
 
 Rem Grab version as string
 for /f "delims=" %%a IN (version.txt) do (set /a Version=%%a)
@@ -21,9 +20,13 @@ Set /a PatchVersion = "%VERSION% & 0xFFFF" > nul:
 set VersionString=%MajorVersion%.%MinorVersion%.%PatchVersion%
 
 if exist %TargetDir%\lib\shibboleth-sp (
-  Echo Updating SP Agent Version to %VersionString%
+  Echo
+  Echo Updating SP Agent Version at %TargetDir% to %VersionString% from kit at %cd%
+  Echo
 ) else (
-  Echo Installing SP Agent Version %VersionString%
+  Echo
+  Echo Installing SP Agent Version %VersionString% at %TargetDir% from kit at %cd%
+  Echo
 )
 
 Rem
@@ -33,16 +36,16 @@ Rem /is copy eveything
 Rem /njh No job header
 Rem /njs No job summary
 echo Copying Distribution to %targetDir%\dist-%VersionString%
-mkdir  "%targetDir%\dist-%VersionString%"
-robocopy /s /is /njs /njh . "%targetDir%\dist-%VersionString%" 0> nul 1> nul
+mkdir  "%targetDir%\dist-%VersionString%" 2>nul:
+robocopy /s /is /njs /njh . "%targetDir%\dist-%VersionString%" 0> nul: 1> nul:
 
 echo Copying Batch Files to %targetdir%\bin\shibboleth-sp\
-mkdir  "%targetdir%\bin\shibboleth-sp\"
+mkdir  "%targetdir%\bin\shibboleth-sp\" 2>nul:
 robocopy /is /njs /njh bin "%targetdir%\bin\shibboleth-sp"
 copy /y dist-bin\uninstall.bat "%targetdir%\bin"
 
 echo Copying Dll Files to  %targetdir%\lib\shibboleth-sp\
-mkdir "%targetdir%\lib\shibboleth-sp\"
+mkdir "%targetdir%\lib\shibboleth-sp\" 2>nul:
 robocopy /is /njs /njh lib "%targetdir%\lib\shibboleth-sp"
 
 Rem /xc /xn /xo only new files
@@ -51,19 +54,19 @@ Rem  /xn exclude newer
 Rem  /xo exclude older
 Rem Hence /xo /xc /xn means "copy every file where a file of that name isn't there"
 echo Copying new config Files
-mkdir "%targetdir%\etc\shibboleth-sp\"
+mkdir "%targetdir%\etc\shibboleth-sp\" 2>nul:
 robocopy /xc /xn /xo /njs /njh etc "%targetdir%\etc\shibboleth-sp"
 
 echo Creating Session Cache Directory
-mkdir %targetdir%\var\cache\shibboleth-sp\sessions
+mkdir %targetdir%\var\cache\shibboleth-sp\sessions 2>nul:
 
 Rem Set registry
 Rem Firstly the "have I been installed" setting
 
-reg import dist-bin\regkeys.txt 1> nul:
+reg import dist-bin\regkeys.txt 2> nul:
 reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{D9DA52E3-F96E-4C84-B153-C3B17C34F730} /f /v DisplayIcon /t REG_SZ /d "%SourceDir%\shib.ico,0" 1> nul:
 reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{D9DA52E3-F96E-4C84-B153-C3B17C34F730} /f /v InstallSource /t REG_SZ /d "%SourceDir%" 1> nul:
-reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{D9DA52E3-F96E-4C84-B153-C3B17C34F730} /f /v Version /t REG_DWORD /d %Version% 2> nul:
+reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{D9DA52E3-F96E-4C84-B153-C3B17C34F730} /f /v Version /t REG_DWORD /d %Version% 1> nul:
 reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{D9DA52E3-F96E-4C84-B153-C3B17C34F730} /f /v DisplayVersion /t REG_SZ /d "%VersionString%" 1> nul:
 reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{D9DA52E3-F96E-4C84-B153-C3B17C34F730} /f /v VersionMinor /t REG_DWORD /d %MinorVersion% 1> nul:
 reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{D9DA52E3-F96E-4C84-B153-C3B17C34F730} /f /v InstallLocation /t REG_SZ /d "%TargetDir%" 1> nul:
diff --git a/WindowsInstall/install.bat b/WindowsInstall/install.bat
index 64dc8392..0025c1cd 100644
--- a/WindowsInstall/install.bat
+++ b/WindowsInstall/install.bat
@@ -15,20 +15,51 @@ set SAVE_WORKING_DIR=%cd%
 cd /d %~dp0
 set SOURCE_DIR=%cd%
 
+if NOT "%1"=="" (
+   Rem Scripted install
+   set TargetDir=%1
+   goto GotTargetDir
+)
+
+Rem No parameter so not a scripted install.  First find an
+Rem existing installation if there is one.
+
+Rem With thanks to StackOverflow we query the reg key we set up in install
+Rem
+Rem Deconstructing the line below:
+Rem    run the command in back quotes (usebackq)
+Rem    feed it into the tokenizer (for /f)
+Rem    skip one line (skip=1)
+Rem    fish out the 3rd token (tokens=3)
+Rem    and put it into TargetDir (%%a .... (set TargetDir=%%a))
+Rem    and if this spits to stderr swallow the output (2^nul) - because  ^ is the escape character
+
+Set KEYNAME=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{D9DA52E3-F96E-4C84-B153-C3B17C34F730}
+FOR /F "usebackq skip=1 tokens=3" %%A IN (`REG query %KEYNAME%  /v InstallLocation 2^>nul`) DO (set TargetDir=%%A)
+
+if defined TargetDir (
+   rem just an update
+   cmd /c dist\dist-bin\doupdate.bat "%targetDir%"
+   exit /b
+)
+
+Rem
+Rem So this is a new install
 Rem - Collect targetDir [opt\shibboleth-sp]
 set loc=%SystemDrive%\opt\shibboleth-sp
 set /p TargetDir="Location To Install [%loc%] :"
 if "%TargetDir%" == "" set TargetDir=%loc%
 
-Rem - Fail if lib or bin exist
+:GotTargetDir
+Rem - Fail if lib or bin exist - this is a partial install
 if exist "%TargetDir%\bin\shibboleth-sp" (
-    echo %TargetDir%\bin\shibboleth-sp exists.  Agent may already be installed
-    echo Did you mean %TargetDir%\bin\shibboleth-sp\update ?
+    echo %TargetDir%\bin\shibboleth-sp exists.  Partially deleted install detected
+    echo Rerun uninstall command
     exit /b
 )
 if exist "%TargetDir%\lib\shibboleth-sp" (
-    echo %TargetDir%\lib\shibboleth-sp exists.  Agent may already be installed
-    echo Did you mean %TargetDir%\bin\shibboleth-sp\update ?
+    echo %TargetDir%\lib\shibboleth-sp exists.  Partially deleted install detected
+    echo Rerun uninstall command
     exit /b
 )
 
@@ -46,9 +77,7 @@ if exist %SYSTEMROOT%\System32\INETSRV\appcmd.exe (
 
 Rem Ask whether to update ACLs and if so CALL SETACL
 
-:loop
 set /p YesNo="Run SetAcl.bat [Yn] "
 if /i "%YesNo%"=="n" exit /b
-if /i not "%YesNo%"=="y" goto loop
 
 cmd/c %TargetDir%\bin\shibboleth-sp\setacl.bat

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list