[wpkg-users] How to define remove with logical or

Rainer Meier r.meier at wpkg.org
Thu Jan 29 19:50:29 CET 2009


Hi Stefan,

Pendl Stefan wrote:
> Currently I have the following two lines in the package:
> 
>   <!-- remove 32-bit version -->
>    <remove cmd="msiexec /x {BF141CE6-067D-47E5-AEC0-B080B107BD02}" />
>   <!-- remove 64-bit version -->
>    <remove cmd="msiexec /x {78566424-2104-4258-84D3-AA050FDF8205}" />
> Is ther something similar like the following:
> 
>   <check type='logical' condition='or'>
>    <check type='file' condition='versiongreaterorequal' path='%ProgramFiles(x86)%\UGS\Teamcenter 2007\Visualization\Program\PLMXMLConverter.dll' value='7.1.0.8338' />
>    <check type='file' condition='versiongreaterorequal' path='%ProgramFiles%\UGS\Teamcenter 2007\Visualization\Program\PLMXMLConverter.dll' value='7.1.0.8338' />
>   </check>

I usually use a bunch of batch scripts for this.

Package example:
<?xml version="1.0" encoding="utf-8" ?>
<packages>

<package id='TortoiseSVN' name='TortoiseSVN' revision='156'
priority='50' reboot='false' >
  <!-- TortoiseSVN -->
  <check type='logical' condition='or'>
  <check type='uninstall' condition='exists' path='TortoiseSVN
1.5.6.14908 (32 bit)' />
  <check type='uninstall' condition='exists' path='TortoiseSVN
1.5.6.14908 (64 bit)' />
  </check>
  <install cmd='"%SOFTWARE%\software.free\TortoiseSVN
v.1.5.6.14908\unattended.cmd"' >
    <exit code='3010' />
  </install>
  <remove cmd='"%SOFTWARE%\software.free\TortoiseSVN
v.1.5.6.14908\unattended-uninstall.cmd"' >
    <exit code='3010' />
  </remove>
  <upgrade cmd='"%SOFTWARE%\software.free\TortoiseSVN
v.1.5.6.14908\unattended.cmd"' >
    <exit code='3010' />
  </upgrade>
</package>

</packages>



unattended.cmd:
@echo off

set CMD32=TortoiseSVN-1.5.6.14908-win32-svn-1.5.5.msi
set CMD64=TortoiseSVN-1.5.6.14908-x64-svn-1.5.5.msi
set INSTALLER=install.cmd
set INSTALLER_LOC=%~dp0

echo Installing TortoiseSVN

call "%INSTALLER_LOC%%INSTALLER%" msiinstall "%CMD32%" "%CMD64%"





unattended-uninstall.cmd:
@echo off

set CMD32=TortoiseSVN-1.5.5.14361-win32-svn-1.5.4.msi
set CMD64=TortoiseSVN-1.5.5.14361-x64-svn-1.5.4.msi
set INSTALLER=install.cmd
set INSTALLER_LOC=%~dp0

echo Removing TortoiseSVN

call "%INSTALLER_LOC%%INSTALLER%" msiuninstall "%CMD32%" "%CMD64%"






install.cmd:
@echo off

REM Usage:
REM msiinstall.cmd <type> <32-bit-installer> <64-bit-installer>
[installer-location [custom-options]]
REM where type is one of
REM     msiinstall     Install the given MSI package
REM     msiuninstall   Uninstall the given MSI package
REM     install4j      Install4J setup
REM     innosetup      Inno setup
REM     installshield  Install shield
REM     nsis           Nullsoft install system (NSIS)
REM     custom         Custom installer - options required in this case
REM 32-bit-installer   Full file name (including extension) of 32-bit
installer
REM 64-bit-installer   Full file name (including extension) of 64-bit
installer
REM installer-location Path where the installers are stored, if empty
assumes directory where install.cmd is
REM custom-options     Replace the default installer options with the
ones given

REM Global variables
set INSTALL_CMD=
set EXIT_CODE=0

REM Get command type
set TYPE=%~1

REM Get 32-bit installer name
set CMD32=%~2

REM Get 64-bit installer name
set CMD64=%~3

REM get file path
set INSTALLER_PATH=%~dp0
if not "%~4" == "" (
set INSTALLER_PATH=%~4
)

set OPTIONS=
if not "%~5" == "" (
set OPTIONS=%~5
)


REM Detect which system is used
if not "%ProgramFiles(x86)%" == "" goto 64bit
goto 32bit


REM
##########################################################################
REM 64-bit system detected
REM
##########################################################################
:64bit
REM Determine 64-bit installer to be used
echo 64-bit system detected.
REM set INSTALLER64=
if not "%CMD64%" == "" (
set INSTALLER64=%CMD64%
) else (
REM Use 32-bit installer if available, no 64-bit installer available.
if not "%CMD32%" == "" (
echo Using 32-bit installer, no 64-bit installer specified.
set INSTALLER64=%CMD32%
) else (
echo Neither 64-bit nor 32-bit installer specified. Exiting.
goto usage
)
)

REM Check if installer is valid
if exist "%INSTALLER_PATH%%INSTALLER64%" (
set INSTALL_CMD=%INSTALLER_PATH%%INSTALLER64%
) else (
echo Installer "%INSTALLER_PATH%%INSTALLER64%" cannot be found! Exiting.
exit /B 97
)
goto installerselection


REM
##########################################################################
REM 32-bit system detected
REM
##########################################################################
:32bit
REM Determine 32-bit installer to be used
echo 32-bit system detected.
set INSTALLER32=
if not "%CMD32%" == "" (
set INSTALLER32=%CMD32%
) else (
echo No 32-bit installer specified. Exiting.
exit /B 96
)


REM Check if installer is valid
if exist "%INSTALLER_PATH%%INSTALLER32%" (
set INSTALL_CMD=%INSTALLER_PATH%%INSTALLER32%
) else (
echo Installer "%INSTALLER_PATH%%INSTALLER32%" cannot be found! Exiting.
exit /B 95
)
goto installerselection



REM
##########################################################################
REM select installer system
REM
##########################################################################
:installerselection
if /i "%TYPE%" == "msiinstall"    goto msiinstaller
if /i "%TYPE%" == "msiuninstall"  goto msiuninstaller
if /i "%TYPE%" == "install4j"     goto install4j
if /i "%TYPE%" == "innosetup"     goto innoinstaller
if /i "%TYPE%" == "installshield" goto installshieldinstaller
if /i "%TYPE%" == "nsis"          goto nsisinstaller
if /i "%TYPE%" == "custom"        goto custominstaller
goto usage



:msiinstaller
echo Installing "%INSTALL_CMD%"
if "%OPTIONS%" == "" (
set OPTIONS=/qn /norestart
)
start /wait "Software installation" msiexec /i "%INSTALL_CMD%" %OPTIONS%
set EXIT_CODE=%ERRORLEVEL%
goto end


:msiuninstaller
echo Uninstalling "%INSTALL_CMD%"
if "%OPTIONS%" == "" (
set OPTIONS=/qn /norestart
)
start /wait "Software uninstallation" msiexec /x "%INSTALL_CMD%" %OPTIONS%
set EXIT_CODE=%ERRORLEVEL%
goto end


:install4j
echo Installing "%INSTALL_CMD%"
start /wait "Software installation" "%INSTALL_CMD%" -q %OPTIONS%
set EXIT_CODE=%ERRORLEVEL%
goto end


:innoinstaller
echo Installing "%INSTALL_CMD%"
REM if "%OPTIONS%" == "" (
REM set OPTIONS=/verysilent /norestart /sp-
REM )
start /wait "Software installation" "%INSTALL_CMD%" /verysilent
/norestart /sp- %OPTIONS%
set EXIT_CODE=%ERRORLEVEL%
goto end


:installshieldinstaller
echo Installing "%INSTALL_CMD%"
start /wait "Software installation" "%INSTALL_CMD%" /s %OPTIONS%
set EXIT_CODE=%ERRORLEVEL%
goto end


:nsisinstaller
echo Installing "%INSTALL_CMD%"
start /wait "Software installation" "%INSTALL_CMD%" /S %OPTIONS%
set EXIT_CODE=%ERRORLEVEL%
goto end

:custominstaller
if "%OPTIONS%" == "" goto usage
echo Installing "%INSTALL_CMD%"
start /wait "Software installation" "%INSTALL_CMD%" %OPTIONS%
set EXIT_CODE=%ERRORLEEL%
goto end

:usage
echo Usage:
echo "%~nx0 <type> <32-bit-installer> <64-bit-installer>
[installer-location [custom-options]]"
echo where type is one of
echo     msiinstall        Install the given MSI package
echo     msiuninstall      Uninstall the given MSI package
echo     innosetup         Inno setup
echo     installshield     Install shield
echo     nsis              Nullsoft install system (NSIS)
echo     custom            Custom installer - options required in this case
echo 32-bit-installer      Full file name (including extension) of
32-bit installer
echo 64-bit-installer      Full file name (including extension) of
64-bit installer
echo installer-location    Path where the installers are stored
echo custom-options        Replace the default installer options with
the ones given
exit /B 99

:end
exit /B %EXIT_CODE%





br,
Rainer



More information about the wpkg-users mailing list