Slacking on the Couch

I run Slackware. I also use CouchDB. Seems like a natural fit, but the slackbuild on is stuck at 0.11.

That’s okay, it is a good script and works well with the latest version. However, I don’t want to run the latest release of CouchDB, I want to run 1.2.x from the git repository, because I really like the new replication engine for my work.

So, I had to do some tinkering with the SlackBuild script. First go to SlackBuilds and get the slackbuild script for CouchDB and its dependencies. Okay, now I’m seeing that this is perhaps more involved that I thought when I started writing this!

Most of the dependencies are slightly out of date on SlackBuilds. I’d help out, but my slackbuild-fu is zilcho. That’s okay, so is yours or you wouldn’t still be reading, and it’s easy to get around this stuff.

First, Erlang. Get the slackbuild for Erlang, then click on the homepage URL and download the latest source and man page (14B04 at the time of htis writing). Unzip the slackbuild, move the source and man packages into the directory, and change into the directory

tar xvf erlang-otp.tar.gz
mv otp_src_R14B04.tar.gz erlang-otp/.
mv otp_doc_man_R14B04.tar.gz erlang-otp/.
cd erlang-otp

Then fire up your favorite editor and edit the erlang-otp.SlackBuild so that you can use the new version. Change the line:


to read


This change lets you specify the version on the command line. Then run the script with the incantation:

sudo VERSION=14B04 ./erlang-otp.SlackBuild

Do similar stuff to install js and icu4c:

When these packages are built and installed (or upgraded), then it is time to turn to CouchDB.

As with the other packages, get the SlackBuild, but don’t bother getting the source this time. Instead go to github and clone it from there.

tar xvf couchdb.tar.gz
cd couchdb

Then clone the source from github and make a local checkout that mirrors the upstream 1.2.x branch. (Never build from trunk or master or whatever unless you are testing stuff).

git clone -o github source
cd source
git checkout -b github/1.2.x

Then modify the slackbuild to use this as the source of the build, rather than some tarball.
But in doing that, I found that I needed to add a hard checkout as well, because over time older stuff (prior builds, messing around, you know, stuff you do with git-based code) builds up and can break the build (I fought with this today 6 times before I wised up!).

The edits need to go in a few places, as follows. First tweak the version as before. Set the default to 1.2.x, but make it so you can set it on the command line too (1.3 is coming soon, I’m sure).



Then skip down over the super-useful architecture and bail out stuff, until you see a line all by itself saying set -e. Instead of unzipping a tgz file, I deleted that line and instead use rsync to copy the git repository. Yes I could use git, or I could use plain old copy, but I’m using rsync. Also, I really want to keep the .git stuff, because CouchDB’s build script checks if it is being build from a git repository and appends the git revision hash to the couch version, which is pretty cool.

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rsync -av  $CWD/source/. .

Then it is really important to add the following two lines.

git reset --hard

The git reset –hard “Resets the index and working tree. Any changes to tracked files in the working tree since are discarded.” In other words, you can rest assured the source is in a clean state and all your trials and errors are dropped.

The bootstrap command is how CouchDB builds up its configure command and other stuff it needs.

One final change to the stock slackbuild is to modify the configure command, as follows:

  ./configure \
  --prefix=/usr \
  --sysconfdir=/etc \
  --mandir=/usr/man \
  --localstatedir=/var \
  --libdir=/usr/lib$LIBDIRSUFFIX \

All I did was delete the erlang and js options, as they aren’t necessary in the latest version of CouchDB, at least not on my machine.

Then run the slackbuild and install

sudo ./couchdb.SlackBuild
sudo /sbin/upgradepkg --install-new /tmp/couchdb-1.2.x-x86_64-1_SBo.tgz

After that, make sure the file permissions and ownerships are correct.

sudo chmod 0770 /var/lib/couchdb 
sudo chmod 0770 /var/run/couchdb 
sudo chmod 0770 /var/log/couchdb 
sudo chmod 0770 /etc/couchdb
sudo chown couchdb:couchdb /etc/couchdb -R 
sudo chown couchdb:couchdb /var/run/couchdb -R 
sudo chown couchdb:couchdb /var/log/couchdb -R 
sudo chown couchdb:couchdb /etc/couchdb -R

Then make sure to inspect /etc/couchdb/ and copy over changes to /etc/couchdb/default.ini, and you should be good to go.

Slacking on the couch.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.