####################################################################
;
;Christoph Herdeg, April 07/2008
;http://www.cs-it-solutions.de
;
####################################################################
;Cygwin package-files
!define PACKAGE_FILES "cygwin_mirror\*.*"

;Additional source-files to be included
!define SOURCE_UNATT "cygwin_setup\*.*"
!define SOURCE_IBM_SCRIPT "cygwin_custom\*.*"
!define SOURCE_IBM_ADDONS "cygwin_addons\*.*"
!define SOURCE_PWCO "cygwin_setup\pwco*.*"

;Filenames
!define FILE_KEYFILE "id_dsa.pub"
!define FILE_IBM_SCRIPT "ibm_customize_cygwin.sh"
!define FILE_PSINFO "psinfo.exe"
!define FILE_REG "reg.exe"
!define FILE_INSTALL "install_cygwin.bat"
!define FILE_REMOVE "remove_cygwin.bat"
!define FILE_PWCO_ON "pwco_on.inf"
!define FILE_PWCO_OFF "pwco_off.inf"
!define FILE_SECEDIT "secedit.sdb"

;Foldernames
!define DEST_BIN "bin"
!define DEST_SCRIPT "etc\profile.d"

####################################################################

;Use lzma compression
SetCompressor lzma

;The name of the installer
Name "CygwinInstaller, Date 2008/04/07 (x32, x64)"

;The name of the built installer file
OutFile "Cygwin20080407-32x64.exe"

;The default installation directory
InstallDir "C:\cygwin"

;Automatically close the installer when done.
AutoCloseWindow true

;Hide the "show details" box
ShowInstDetails nevershow

####################################################################

;The stuff to install, section start -  this is no components page, so the section name is not important
Section ""
	;Extract cygwin(-package)_mirror
	SetOutPath "$INSTDIR\cygwin_mirror"
	File /r ${PACKAGE_FILES}
	
	;Extract Cygwin-Install Script and ecurity template files
	SetOutPath "$INSTDIR"
	File ${SOURCE_UNATT}
	File ${SOURCE_PWCO}
	
	;Install Cygwin
	ExecWait '"$INSTDIR\${FILE_INSTALL}"'
	
	;Extract "id_dsa.pub", "psinfo.exe" and "reg.exe" to folder c:\cygwin\bin
	SetOutPath "$INSTDIR\${DEST_BIN}" 
	File ${SOURCE_IBM_ADDONS}

	;Extract IBM-Setup-Script
	SetOutPath "$INSTDIR\${DEST_SCRIPT}"
	File ${SOURCE_IBM_SCRIPT}
		;AccessControl::GrantOnFile "$INSTDIR\${DEST_SCRIPT}\${IBM_SCRIPT}" "(S-1-1-0)" "FullAccess"
		;AccessControl::EnableFileInheritance  "$INSTDIR\${DEST_SCRIPT}\${IBM_SCRIPT}"
	
	;Start Cygwin to run all scripts existing in "profile.d" (including especially our runonce-postinstall script)
	ExecWait '"$INSTDIR\cygwin.bat"'
	
	;Delete copied and created Stuff
	Delete "$INSTDIR\${DEST_BIN}\${FILE_KEYFILE}"
	Delete "$INSTDIR\${DEST_SCRIPT}\${FILE_IBM_SCRIPT}"	
	Delete "$INSTDIR\${FILE_INSTALL}"
	Delete "$INSTDIR\${FILE_PWCO_ON}"
	Delete "$INSTDIR\${FILE_PWCO_OFF}"
	Delete "$INSTDIR\${FILE_SECEDIT}"
	RMDir /r "$INSTDIR\cygwin_mirror"
SectionEnd 
;section end