An installer from commandland

posted in dwn
Published January 19, 2011
Advertisement
Been sick for a couple of days, but felt better today - whew. :)

Pride in your shell scripts is a bit like a builder showing off his scaffolding. Still, since it's the frame of mind I've been in most recently when tinkering with this project, here is my make-installer batch file. It uses the NullSoft Installer System (NSIS) and 7-Zip. Instead of registering each file with NSIS, it directly copies the directories, and it must tell the NSIS script what size the installation is so that it can know the correct size to display during the installation. The one downside with not registering each file with NSIS, it seems, is that the installation progress bar doesn't move very smoothly during the installation process, instead jumping from a low level to full. If redoing it, it might be preferable to inject files individually or use some other method, but it doesn't really bother me; it's just a little Windows installer. :)


@echo off

rem /////////////////////////////////////////////////////////////////////
rem //WARNING! DO NOT DISTRIBUTE THIS INFORMATION!
rem /////////////////////////////////////////////////////////////////////

set POIESISLICENSEGENERATOR=xxxxxxxxxxxx
set POIESISUSERNAME=Dan Nielsen
set POIESISUSERROLE=Developer

rem /////////////////////////////////////////////////////////////////////

set POIESISVERSION=11.2.1

rem INITAL READ-WRITE ATTRIBUTE SETTINGS
attrib -r poiesis\TEXT\main.c
echo Initial read-write attributes set
echo.
rem pause
echo.

rem INITIAL CLEANUP
del \\School-2065a8c5\SHARE\RELEASE\poiesis.zip /q
del poiesis\OUTPUT\*.* /q
del poiesis\bin\*.pdb /q
del poiesis\bin\*.exp /q
del poiesis\TEXT\main.c /q
if not exist poiesis\bin\cyan.exe goto skipRewriteMainExecutable
del poiesis\bin\poiesis.exe
copy poiesis\bin\cyan.exe poiesis\bin\poiesis.exe
del poiesis\bin\cyan.exe
:skipRewriteMainExecutable
echo Initial cleanup performed
echo.
rem pause
echo.

rem SETS LICENSE INFORMATION
echo License generator of this machine:
cmd\rlmutil.exe rlmhostid -q -ether
echo.
src\licenseMaker\Release\licenseMaker.exe %POIESISLICENSEGENERATOR% %POIESISUSERNAME% %POIESISUSERROLE%
copy license.c+init.c+update.c poiesis\TEXT\main.c
echo License information set
echo.
rem pause
echo.

rem SETS VERSION INFORMATION
copy README.template.txt poiesis\README.txt
cmd\change.com poiesis\README.txt "REPLACE.VERSION" "%POIESISVERSION%"
echo.
echo Version information set
echo.
rem pause
echo.

rem SETS INSTALLATION SIZE INFORMATION IN KILOBYTES
cd poiesis
for /f "tokens=*" %%a in ('"dir /s /-c | find "bytes" | find /v "free""') do @Set summaryout=%%a
rem echo %summaryout%
for /f "tokens=1,2 delims=)" %%a in ("%summaryout%") do @set filesout=%%a&set sizeout=%%b
rem echo %filesout%
rem echo %sizeout%
set sizeout=%sizeout:bytes=%
rem echo %sizeout%
set sizeout=%sizeout: =%
cd..
copy poiesis.template.nsi poiesis.nsi
cmd\change.com poiesis.nsi "REPLACE.SIZE" "%sizeout:~0,-3%"
echo.
echo Installation size information set
echo.
rem pause
echo.

rem FINAL READ-WRITE ATTRIBUTE SETTINGS
attrib +r poiesis\TEXT\main.c
echo Final read-write attributes set
echo.
rem pause
echo.

rem BUILDS INSTALLER
cmd\makensis.exe poiesis.nsi
echo Installer built
echo.
rem pause
echo.

rem MAKES ZIP PACKAGE AND PLACES IT IN SHARED DIRECTORY
cmd\7z.exe a \\School-2065a8c5\SHARE\RELEASE\poiesis.zip poiesisInstall.exe poiesis\
echo Compressed and placed installation package
echo.
rem pause
echo.

rem FINAL CLEANUP
del license.c /q
del poiesis.nsi /q
del poiesisInstall.exe /q
del poiesis\README.txt /q
rem del poiesis\TEXT\main.c /q
echo Final cleanup performed
echo.
rem pause
echo.


And the following is the NSIS .nsi file, mostly just ripped from an example included with the NSIS package:


; The name of the installer
Name "Poiesis"

; The file to write
OutFile "poiesisInstall.exe"

; The default installation directory
InstallDir $PROGRAMFILES\Poiesis

; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\Poiesis" "Install_Dir"

; Request application privileges for Windows Vista
RequestExecutionLevel admin

;--------------------------------

; Pages

Page components
Page directory
Page instfiles

UninstPage uninstConfirm
UninstPage instfiles

;--------------------------------

; The stuff to install
Section "Poiesis (required)"

SectionIn RO

; MUST CHANGE THE FOLLOWING TO SIZE IN KILOBYTES!!
AddSize REPLACE.SIZE

; Set output path to the installation directory.
SetOutPath $INSTDIR

; Create installation directory
CreateDirectory $INSTDIR

; Copy files to installation directory
CopyFiles /SILENT "$EXEDIR\poiesis\*.*" $INSTDIR

; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\Poiesis "Install_Dir" "$INSTDIR"

; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Poiesis" "DisplayName" "Poiesis"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Poiesis" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Poiesis" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Poiesis" "NoRepair" 1
WriteUninstaller "uninstall.exe"

SectionEnd

; Optional section (can be disabled by the user)
Section "Start Menu Shortcuts"

CreateDirectory "$SMPROGRAMS\Poiesis"
CreateShortCut "$SMPROGRAMS\Poiesis\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
CreateShortCut "$SMPROGRAMS\Poiesis\Poiesis11.1.1.lnk" "$INSTDIR\RUN.bat" "" "$INSTDIR\RUN.bat" 0
CreateShortCut "$SMPROGRAMS\Poiesis\GlyphMaker1.modified.lnk" "$INSTDIR\glyphMaker1.modified.bat" "" "$INSTDIR\glyphMaker1.modified.bat" 0
CreateShortCut "$SMPROGRAMS\Poiesis\Scala2.28r.lnk" "$INSTDIR\scala2.28r.bat" "" "$INSTDIR\scala2.28r.bat" 0

SectionEnd

;--------------------------------

; Uninstaller

Section "Uninstall"

; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Poiesis"
DeleteRegKey HKLM SOFTWARE\Poiesis

; Remove files and uninstaller
RMDir /r $INSTDIR

; Remove shortcuts, if any
Delete "$SMPROGRAMS\Poiesis\*.*"

; Remove directories used
RMDir "$SMPROGRAMS\Poiesis"
RMDir "$INSTDIR"

SectionEnd
Previous Entry Poiesis cameo
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Advertisement