Compare commits

..

2 Commits

Author SHA1 Message Date
2f1f0784ad keep only fabricapi 2024-04-15 16:20:17 +02:00
b8718a2250 fixes + content move to external 2024-04-15 16:19:26 +02:00
4 changed files with 124 additions and 13 deletions

View File

@ -1,17 +1,19 @@
# NSIS Installer for PolyMC instances
*Warning*
## Prerequisites
### Warning
- Only for PolyMC Minecraft installation!
- There are destructive operations into PolyMC data folders!
- Overrides instances defined in PolyMC!
*Notice*
### Notice
- Using NSIS installer for packaging
- Using CMD for batch installation _(trapped into NSIS)_
*Fonctionnalities*
### Functionnalities
- Ask for previous installation _(can be bypassed or uninstalled silently)_
- Create uninstaller
@ -19,6 +21,12 @@
## Changelog
### 2024-04-15
- Moved content to external 7zip file _(with download & extract during install process)_
- Fixes in registry keys
- Minor fixes in logic
### 2024-04-14
- Initial release

View File

@ -1,6 +1,6 @@
@echo off
SETLOCAL
REM 2024-04-08
REM 2024-04-15
cls
REM Define locale paths

121
mods.nsi
View File

@ -1,4 +1,10 @@
;2024-04-14
;2024-04-15
;Used NSIS Plug-ins
; https://github.com/negrutiu/nsis-nsxfer
; https://nsis.sourceforge.io/Locate_plugin
; https://nsis.sourceforge.io/Nsis7z_plug-in
; (https://nsis.sourceforge.io/PassDialog_plug-in)
;Define installer compression method and level
SetCompressor /SOLID LZMA
@ -6,11 +12,17 @@ SetCompressor /SOLID LZMA
;Activate CRC check
CRCCheck on
;Active XP style
XPStyle on
;--------------------------------------------------------------------------------
;Constants
!define PRODUCT_YEAR "2024"
!define PRODUCT_VERSION "${PRODUCT_YEAR}.04.14.0"
!define PRODUCT_MONTH "04"
!define PRODUCT_DAY "15"
!define PRODUCT_ITERATION "1"
!define PRODUCT_VERSION "${PRODUCT_YEAR}.${PRODUCT_MONTH}.${PRODUCT_DAY}.${PRODUCT_ITERATION}"
!define PRODUCT_UUID "1e626553-03f9-47e1-a0cd-858e8effe76e" ;Change for each new product
!define PRODUCT_BRAND "Zogg"
!define PRODUCT_NAME "Mods"
@ -22,6 +34,9 @@ CRCCheck on
!define PRODUCT_TITLE "${PRODUCT_BRAND} ${PRODUCT_NAME}"
!define PRODUCT_COMPONENTS "Fabric mods, Ressources Packs & Shaders"
!define PRODUCT_BASEURL "https://dl.zogg.fr/files/minecraft"
!define PRODUCT_CONTENTFILE "mods.7z"
!define PRODUCT_DEST "$LOCALAPPDATA"
!define PRODUCT_SMDIR "NSIS:StartMenuDir"
@ -43,7 +58,10 @@ CRCCheck on
!include "Library.nsh"
!include "x64.nsh"
!include "WinVer.nsh"
!include "Locate.nsh"
!include "LogicLib.nsh"
!include "Sections.nsh"
!include "StrFunc.nsh"
;--------------------------------------------------------------------------------
;Macros
@ -195,7 +213,7 @@ CRCCheck on
;Translations
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_RESERVEFILE_LANGDLL
;--------------------------------------------------------------------------------
;Version Tab (in the )Properties of the file)
@ -222,18 +240,19 @@ CRCCheck on
;Set output path to the installation directory
SetOutPath $INSTDIR
;Copy a file to the current SetOutPath directory
File /r "files\*.*"
;process content (download and uncompress)
call proceedContent
;Execute specific shell script
call runCommandBatch
;Make uninstall
call addRegistryUninstall
WriteUninstaller "${PRODUCT_UNINSTALLER}"
; Add Start Menu entries
call addStartMenu
;Execute specific shell script
call runCommandBatch
SectionEnd
;Uninstall component
@ -341,6 +360,7 @@ FunctionEnd
;Execute specific shell script
Function runCommandBatch
DetailPrint "Mise en place..."
nsExec::ExecToLog /OEM '"$INSTDIR\install.cmd"'
Pop $0
@ -374,6 +394,13 @@ Function checkForPolyMC
Done:
FunctionEnd
;Open url on error, then quit application
Function errorOpenUrl
MessageBox MB_OK "Une erreur est survenue !"
call openProductUrl
Quit
FunctionEnd
;Check for previous installed version
Function checkForPrevious
@ -388,3 +415,79 @@ Function checkForPrevious
${EndIf}
FunctionEnd
;Download content to temps
Function downloadContent
Retry:
NSxfer::Transfer /URL "${PRODUCT_BASEURL}/${PRODUCT_CONTENTFILE}" /LOCAL "$TEMP\${PRODUCT_CONTENTFILE}" /MODE Page /ABORT "Annuler" "Etes-vous sur ?" /END
Pop $0
${If} $0 != "OK"
MessageBox MB_YESNO|MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_USERICON "Erreur de telechargement !$\r$\nVoulez-vous recommencer ?" IDYES true IDNO false
true:
goto Retry
false:
goto Exit
${Else}
goto Done
${EndIf}
Exit:
call errorOpenUrl
Done:
FunctionEnd
;Uncompress content to $INSTDIR
Function uncompressContent
locate::_GetSize /NOUNLOAD "$TEMP\${PRODUCT_CONTENTFILE}" "/G=0"
Pop $5
Retry:
ClearErrors
SetOutPath $INSTDIR
GetFunctionAddress $R9 extractCallbackTest
Nsis7z::ExtractWithCallback "$TEMP\${PRODUCT_CONTENTFILE}" $R9
Pop $6
;Check if extracted size <> content file size
${If} $6 != $5
MessageBox MB_YESNO|MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_USERICON "Erreur de decompression !$\r$\nVoulez-vous recommencer ?" IDYES true IDNO false
true:
goto Retry
false:
goto Exit
${Else}
goto Done
${EndIf}
Exit:
Delete "$TEMP\${PRODUCT_CONTENTFILE}"
call errorOpenUrl
Done:
Delete "$TEMP\${PRODUCT_CONTENTFILE}"
FunctionEnd
;Download content to installation folder
Function proceedContent
call downloadContent
call uncompressContent
FunctionEnd
;Progression callback for extraction
Function extractCallbackTest
Pop $R8 ;current
Pop $R9 ;total
Math::Script "R5 = $R8 * 100 / $R9"
SetDetailsPrint textonly
DetailPrint "Extraction $R5%"
SetDetailsPrint both
FunctionEnd