This is a general-purpose guide designed to onboard people into the CouchDB release cycle. Parts of it can also be adapted to troubleshoot building CouchDB on your local device (something that, as an end user, you shouldn't need to do unless we don't support your architecture/OS).
This guide is currently a work in progress.
To build CouchDB, you will need:
couchdb-pkg
, it should be OTP 20 (I use 20.3.8.26, the latest in the 20 release line). I'd recommend asdf for managing multiple Erlang installations.gcc
and g++
if you're using it.pip install sphinx
), but more recent Sphinx versions are broken. I've had success with pip install "sphinx==3.1.2"
.pip install sphinx_rtd_theme
).libmozjs
or just js
. CouchDB supports several versions of this: 1.8.5, 60, 68, and 86. One of these versions should ideally be available in your package manager, if you're on a M1 Mac, you can use one of these Homebrew formulas.For packaging CouchDB, you also need:
apt install curl gpg rpm
)CouchDB follows the regular Unix procedue of building programs from source:
You can get a fresh copy of the CouchDB source code via a Git checkout:
If you're building a specific version, you can checkout to the specific tag:
If you're releasing, check out to the major version branch (3.x at the time of writing):
As is convention for Unix programs, CouchDB contains a Bash script that generates a Makefile tailored for your system. This script is called configure
, and you can run it like this once you're in your CouchDB source code directory:
This'll check out CouchDB's dependencies, and initialize the tooling used to build CouchDB. Notably, it doesn't strictly check for build-time dependencies such as Spidermonkey - this will error during the build step instead.
By default, the configure script will assume you have Spidermonkey 1.8.5 installed. You can specify a different version by setting a command line flag like this:
CouchDB has a variety of make tasks available. The most important ones are these:
make all
- builds all components. This is the default when you run make without any argumentsmake dist
- creates a release tarball. This is what we're going to need as a basis to build binaries from.make distclean
- gets rid of build and distribution artifacts so you can do a clean buildIf you're just looking to build CouchDB for your own usage, run make
. If you want to package CouchDB after, run make dist
.
TBD :)
CouchDB releases are distributed in the following ways:
The CouchDB project does not distribute any packages to Linux/BSD distributions' package archives. This is a task performed by volunteers not in association with the project. Additionally, these packages end up being several years out of date (you can see an overview here).
Mac releases are currently handled by Jan Lehnardt.
Before we do anything, we need a release tag. This can be an RC version (e.g. 3.3.0-RC1), or a plain release (e.g. 3.3.0). Once that's been created, we checkout to the tag and run make dist
. This will create a source tarball that we can distribute.
TODO: how to generate SHA hashes for the tarball
TODO: how to sign this tarball
This is enabled via couchdb-pkg
, a repository that provides support files and scripts in order to automatically build DEBs and RPMs for different systems, using Docker. This will need to be run on a machine that supports building DEB files, as building RPM files on a non-RPM machine is easier. Ideally, this would be Ubuntu 20.04.
Make sure you have the dependencies listed under "Prerequisites" above. You will want to clone couchdb-pkg
:
From here on, your main interaction will be with the build.sh
script. To display a short info text about what build.sh
can do:
You will need the tarball you built as the first step of the release somewhere where it's accessible. To build for every platform and arch that we support, run:
This will take a while. Basically, for every arch/platform, it:
In the end, we'll have our generated packages in pkgs/couch
.
The RPM packages for CentOS/RHEL need to have correct file permissions, so we run:
TODO: how to sign rpms
TODO: how to upload packages to artifactory
TODO
To build for Windows, you're going to need some kind of Windows installed somewhere. For ideal use of existing hardware, a laptop or something running Windows is ideal, but running it in a VM (as long as you give it enough system resources) is fine, too.
If you're setting up a fresh copy of Windows, make sure it's 64-bit. Any version of Windows above 7 is 64-bit-only, but we recommend Windows 10 (preferrably a N version, as those come without media bloat).
You want to make sure to install all available Windows updates. This can take quite a while, be sure to keep checking the Windows update screen, as it can download multiple updates in sequence instead of at the same time. Once all of your updates are done, create a snapshot of your VM (if you're running Windows in a VM).
couchdb-glazier
Windows builds are made easier via couchdb-glazier, a collection of scripts that aims to automate the setup and build process, much like couchdb-pkg
does for DEBs and RPMs.
Open an Administrator PowerShell, and run the following:
At this point, you may need to restart PowerShell for it to recognize git
as a command. Once that's done:
This will take a loooong time. Make sure your disk that Windows is on has around 50GB of free space or more.
Your PowerShell may not immediately recognize some of the commands available to you as a result of running that script. If, during the script execution, it complains about pip
not being available, simply execute it after you've restarted PowerShell:
As a shortcut from now on, in case you reopen PowerShell, you can set the important environment variables using the shell.ps1
script:
In addition to what the installer has installed for you, you'll want to have pkg-config
installed via choco:
Next up, you'll want to build Erlang. This should Just Work™ for you if you follow the relevant section in the glazier readme.
For building SpiderMonkey, save yourself the trouble of cloning the entire gecko-dev
repository. Instead, just download the relevant sources in a tarball:
The only difference in the build process is that you will need to run the configure script without the --with-system-icu
option, as we want to use the bundled ICU. You will also need to set the PKG_CONFIG_PATH and PATH to make the Mozilla build tools aware of your library locations:
CouchDB's build tools may complain about a missing mozjs-60.lib
file later, so after you've finished building SpiderMonkey, you want to make sure CouchDB's LIBPATH includes said .lib
file. You can do this either by setting the LIBPATH yourself (TODO how?) or copying the file to somewhere in the existing LIBPATH, like this:
The rest of the CouchDB build process should now run exactly as described in the relevant section. Hooray!