Skip to content

Commit

Permalink
Add support to build a WiX-based installer
Browse files Browse the repository at this point in the history
  • Loading branch information
wohali committed Jul 19, 2016
1 parent 7855579 commit 5c29d3f
Show file tree
Hide file tree
Showing 10 changed files with 1,922 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ bits/*.7z
bits/a2session.txt
/.project
*~
*.wixobj
*.wixpdb
*.msi
installer/couchdb.wxs
installer/couchdbfiles.wxs
build_*.txt
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ These packages install silently, without intervention. Cut and paste them
into a command prompt, leave it running, and open another one for the next
section.

cinst -y git 7zip.commandline StrawberryPerl nasm cyg-get wixtoolset python aria2 nodejs.install
cinst -y git 7zip.commandline StrawberryPerl nasm cyg-get wixtoolset python aria2 nodejs.install nssm

*NOTE*: There is a bug presently in the Chocolatey cygwin package. After the `cinst` above, download the cygwin installer from https://cygwin.com/, rename the installer to cygwinsetup.exe, and move the installer to `C:\tools\cygwin`. This will enable the cyg-get line below.

Expand Down Expand Up @@ -196,12 +196,10 @@ _release_), after running the above use:

make -f Makefile.win release

## Installer
To build an installer using WiX to creates a full Windows .msi:

The installer is built using WiX and creates a full Windows .msi installer
package. The installer optionalkl sets up CouchDB running as a Windows Service.

TODO: Complete installer work
cd \relax\glazier
bin\build_installer.cmd

# Appendix

Expand Down
68 changes: 68 additions & 0 deletions bin/build_installer.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
@ECHO OFF

:: Licensed under the Apache License, Version 2.0 (the "License"); you may not
:: use this file except in compliance with the License. You may obtain a copy of
:: the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
:: WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
:: License for the specific language governing permissions and limitations under
:: the License.

SETLOCAL ENABLEEXTENSIONS
SETLOCAL DISABLEDELAYEDEXPANSION

IF EXIST %~dp0..\..\couchdb\rel\couchdb (
SET COUCHDB=%~dp0..\..\couchdb\rel\couchdb
) ELSE (
ECHO Error, couchdb release directory not found. Have you run make release?
GOTO END
)

SET OLDDIR=%cd%

SET GLAZIER=%~dp0..
SET /P START_ERL= < %COUCHDB%\releases\start_erl.data
FOR /F "tokens=2" %%G IN ("%START_ERL%") DO SET APP_VSN=%%G

:: pre-execution cleanup
cd %GLAZIER%\installer
rmdir /s /q release >NUL 2>&1
del /f *.wixobj >NUL 2>&1
del /f *.wixpdb >NUL 2>&1
del /f couchdb.wxs couchdbfiles.wxs >NUL 2>&1

:: add necessary DLLs to release directory
xcopy %ICU_PATH%\bin64\icu*.dll %COUCHDB%\bin /Y >NUL 2>&1
xcopy %RELAX%\js-1.8.5\js\src\dist\bin\*.dll %COUCHDB%\bin /Y >NUL 2>&1
copy %RELAX%\curl\lib\libcurl.dll %COUCHDB%\bin /Y >NUL 2>&1


:: update version number
:: commented out because WiX insists on a #.#.#.# number format and there's
:: no guarantee that's what we'll see
copy couchdb.wxs.in couchdb.wxs >NUL 2>&1
:: cscript //NoLogo %GLAZIER%\bin\sed.vbs s/####VERSION####/%APP_VSN% < couchdb.wxs.in >couchdb.wxs

:: Package CouchDB as a fragment
:: WiX skips empty directories, so we create a dummy logfile
echo New Log >%COUCHDB%\var\log\couchdb.log
:: We don't want to re-run heat unless files have changed. And even then,
:: we'd want to manually merge. heat will regenerate all GUIDS and that will
:: cause problems in the field if we ever start upgrading rather than
:: uninstall/reinstall. It's the -gg flag that results in this behaviour.
heat dir %COUCHDB% -dr APPLICATIONFOLDER -cg CouchDBFilesGroup -gg -g1 -sfrag -srd -sw5150 -var "var.CouchDir" -out couchdbfiles.wxs

:: Build MSI for installation
candle -arch x64 -ext WiXUtilExtension couchdb.wxs
candle -arch x64 -dCouchDir=%COUCHDB% couchdbfiles.wxs
candle -arch x64 -ext WiXUtilExtension couchdb_wixui.wxs
candle -arch x64 -ext WiXUtilExtension dirwarning.wxs
light -sw1076 -ext WixUIExtension -ext WiXUtilExtension -cultures:en-us couchdb.wixobj couchdbfiles.wixobj couchdb_wixui.wixobj dirwarning.wixobj -out couchdb-%APP_VSN%.msi
copy couchdb-%APP_VSN%.msi %OLDDIR%

cd %OLDDIR%
:END
12 changes: 12 additions & 0 deletions bin/sed.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Dim pat, patparts, rxp, inp
pat = WScript.Arguments(0)
patparts = Split(pat,"/")
Set rxp = new RegExp
rxp.Global = True
rxp.Multiline = False
rxp.Pattern = patparts(1)
Do While Not WScript.StdIn.AtEndOfStream
inp = WScript.StdIn.ReadLine()
WScript.Echo rxp.Replace(inp, patparts(2))
Loop

4 changes: 2 additions & 2 deletions bin/shell.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ set ERL_TOP=%WERL_DIR%\otp_src_%OTP_REL%
echo Type exit to stop relaxing.
title On the couch. Type exit to stop relaxing.
:: Need these things on the path to build/run CouchDB
set PATH=%ERL_TOP%\release\win32\erts-%ERTS_VSN%\bin;%ERL_TOP%\bootstrap\bin;%ERL_TOP%\erts\etc\win32\cygwin_tools\vc;%ERL_TOP%\erts\etc\win32\cygwin_tools;%RELAX%\bin;%PATH%;%ICU_PATH%\bin64;%RELAX%\js-1.8.5\js\src\dist\bin;%RELAX%\curl\lib;c:\ProgramData\chocolatey\lib\python3\tools\Scripts;C:\Program Files\nodejs
set PATH=%ERL_TOP%\release\win32\erts-%ERTS_VSN%\bin;%ERL_TOP%\bootstrap\bin;%ERL_TOP%\erts\etc\win32\cygwin_tools\vc;%ERL_TOP%\erts\etc\win32\cygwin_tools;%RELAX%\bin;%PATH%;%ICU_PATH%\bin64;%RELAX%\js-1.8.5\js\src\dist\bin;%RELAX%\curl\lib;c:\ProgramData\chocolatey\lib\python3\tools\Scripts;C:\Program Files\nodejs;C:\Program Files (x86)\WiX Toolset v3.10\bin
cmd.exe /k
goto eof

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:ps_shell
echo Type exit to stop relaxing.
title On the couch. Type exit to stop relaxing.
set PATH=%ERL_TOP%\release\win32\erts-%ERTS_VSN%\bin;%ERL_TOP%\bootstrap\bin;%ERL_TOP%\erts\etc\win32\cygwin_tools\vc;%ERL_TOP%\erts\etc\win32\cygwin_tools;c:\relax\bin;%PATH%;%ICU_PATH%\bin64;C:\Relax\js-1.8.5\js\src\dist\bin;C:\relax\curl\lib;c:\ProgramData\chocolatey\lib\python3\tools\Scripts;C:\Program Files\nodejs
set PATH=%ERL_TOP%\release\win32\erts-%ERTS_VSN%\bin;%ERL_TOP%\bootstrap\bin;%ERL_TOP%\erts\etc\win32\cygwin_tools\vc;%ERL_TOP%\erts\etc\win32\cygwin_tools;c:\relax\bin;%PATH%;%ICU_PATH%\bin64;C:\Relax\js-1.8.5\js\src\dist\bin;C:\relax\curl\lib;c:\ProgramData\chocolatey\lib\python3\tools\Scripts;C:\Program Files\nodejs;C:\Program Files (x86)\WiX Toolset v3.10\bin
powershell
goto eof

Expand Down
Binary file added bits/exclamic.ico
Binary file not shown.
Loading

0 comments on commit 5c29d3f

Please sign in to comment.