From 7b1423a2365429ab6b636b46a5404d638b31cb55 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 4 Dec 2018 01:11:30 -0500 Subject: [PATCH] Add old-install-list.txt to explicitly define which old install files need to be moved Replaces MoveOldExeDlls routine in installer staging --- .../staging/new-install/old-install-list.txt | 15 +++++ .../staging/new-install/staging.bat | 55 ++++++++++++++----- .../staging/new-install/uninstall.bat | 22 +++++--- 3 files changed, 68 insertions(+), 24 deletions(-) create mode 100644 windows-installer/staging/new-install/old-install-list.txt diff --git a/windows-installer/staging/new-install/old-install-list.txt b/windows-installer/staging/new-install/old-install-list.txt new file mode 100644 index 000000000..6f33660ac --- /dev/null +++ b/windows-installer/staging/new-install/old-install-list.txt @@ -0,0 +1,15 @@ +exchndl.dll +fmodex.dll +libFLAC-8.dll +libgme.dll +libintl-8.dll +libmikmod-2.dll +libogg-0.dll +libvorbis-0.dll +libvorbisfile-3.dll +r_opengl.dll +SDL2.dll +SDL2_mixer.dll +smpeg2.dll +srb2dd.exe +srb2win.exe \ No newline at end of file diff --git a/windows-installer/staging/new-install/staging.bat b/windows-installer/staging/new-install/staging.bat index 85568efba..d58947b27 100644 --- a/windows-installer/staging/new-install/staging.bat +++ b/windows-installer/staging/new-install/staging.bat @@ -15,11 +15,6 @@ cls :: 3. Moves new installaton files into install folder :: -:: For 2.1.21, we are changing the DLL structure -:: So move everything that's EXE or DLL - -set MoveOldExesDlls=1 - :: Get Parent folder (the SRB2 install folder) :: :: https://wiert.me/2011/08/30/batch-file-to-get-parent-directory-not-the-directory-of-the-batch-file-but-the-parent-of-that-directory/ @@ -205,24 +200,54 @@ if exist "!INSTALLDIR!\old-install\*" ( mkdir "!OLDINSTALLDIR!" -: -: Move all EXEs and DLLs -: +:: +:: Move all old install files +:: We support a list of explicit files to copy to old-install +:: And later, we also loop through our staging files, look for the pre-existing copy in +:: install root, then copy that also to old-install +:: set OLDINSTALLCHANGED= -if ["!MoveOldExesDlls!"] == ["1"] ( - goto MoveOldInstallExeDll +if exist "!STAGINGDIR!\old-install-list.txt" ( + goto MoveOldInstallOldFiles ) else ( goto MoveOldInstallNewFiles ) -: MoveOldInstallExeDll +: MoveOldInstallOldFiles -xcopy /y /v "!INSTALLDIR!\*.exe" "!OLDINSTALLDIR!" -if errorlevel 0 del /f /q "!INSTALLDIR!\*.exe" -xcopy /y /v "!INSTALLDIR!\*.dll" "!OLDINSTALLDIR!" -if errorlevel 0 del /f /q "!INSTALLDIR!\*.dll" +set "TESTFILE=!TEMP!\!RANDOM!.txt" + +:: Do our failsafes before copying the file in the list +:: See uninstall.bat for details +for /F "usebackq tokens=*" %%A in ("!STAGINGDIR!\old-install-list.txt") do ( + if exist "!INSTALLDIR!\%%A" ( + if ["%%A"] == [""] ( + echo. + ) else ( + if ["%%A"] == ["%~nx0"] ( + echo. + ) else ( + echo %%A> "!TESTFILE!" + findstr /r ".*[<>:\"\"/\\|?*%%].*" "!TESTFILE!" >nul + if !errorlevel! equ 0 ( + echo %%A has invalid characters, skipping... + ) else ( + if exist "!INSTALLDIR!\%%A\*" ( + echo %%A is a folder, skipping... + ) else ( + echo Moving !INSTALLDIR!\%%A to "old-install" folder + echo f | xcopy /y /v "!INSTALLDIR!\%%A" "!OLDINSTALLDIR!\%%A" + if errorlevel 0 del /f /q "!INSTALLDIR!\%%A" + ) + ) + ) + ) + ) +) + +del /q /f "!STAGINGDIR!\old-install-list.txt" for %%F in ("!OLDINSTALLDIR!\*") DO ( set OLDINSTALLCHANGED=1 diff --git a/windows-installer/staging/new-install/uninstall.bat b/windows-installer/staging/new-install/uninstall.bat index a0995eb49..55112bc99 100644 --- a/windows-installer/staging/new-install/uninstall.bat +++ b/windows-installer/staging/new-install/uninstall.bat @@ -74,19 +74,23 @@ set "TESTFILE=!TEMP!\!RANDOM!.txt" for /F "usebackq tokens=*" %%A in ("!INSTALLDIR!\uninstall-list.txt") do ( if exist "!INSTALLDIR!\%%A" ( - if ["%%A"] == ["%~nx0"] ( + if ["%%A"] == [""] ( echo. ) else ( - echo %%A> "!TESTFILE!" - findstr /r ".*[<>:\"\"/\\|?*%%].*" "!TESTFILE!" >nul - if !errorlevel! equ 0 ( - echo %%A has invalid characters, skipping... + if ["%%A"] == ["%~nx0"] ( + echo. ) else ( - if exist "!INSTALLDIR!\%%A\*" ( - echo %%A is a folder, skipping... + echo %%A> "!TESTFILE!" + findstr /r ".*[<>:\"\"/\\|?*%%].*" "!TESTFILE!" >nul + if !errorlevel! equ 0 ( + echo %%A has invalid characters, skipping... ) else ( - echo Deleting !INSTALLDIR!\%%A - del /q /f "!INSTALLDIR!\%%A" + if exist "!INSTALLDIR!\%%A\*" ( + echo %%A is a folder, skipping... + ) else ( + echo Deleting !INSTALLDIR!\%%A + del /q /f "!INSTALLDIR!\%%A" + ) ) ) )