Skip to content
Permalink
Browse files
Add RPM support, top-level Makefile
  • Loading branch information
wohali committed May 6, 2017
1 parent 501148e commit 75b9105ee8563cf8166acad0cf219741dfb45720
Show file tree
Hide file tree
Showing 18 changed files with 1,231 additions and 39 deletions.
@@ -4,3 +4,7 @@ debian/*.substvars
debian/files
debian/couchdb
debian/tmp
rpm/BUILD
rpm/BUILDROOT
rpm/RPMS
rpm/SRPMS
@@ -0,0 +1,95 @@
# 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.

COUCHDIR=../couchdb
DEBCHANGELOG="Automatically generated package from upstreasm."
ERLANG_VERSION=18.3

export DEBFULLNAME="CouchDB Developers"
export DEBEMAIL="dev@couchdb.apache.org"

# Debian default
debian: find-couch-dist copy-debian update-changelog dpkg lintian

# Debian 8
jessie: debian

# Ubuntu 12.04
precise: find-couch-dist copy-debian precise-prep dpkg lintian

precise-prep:
sed -i '/dh-systemd/d' $(DISTDIR)/debian/control
sed -i '/init-system-helpers/d' $(DISTDIR)/debian/control
sed -i 's/ --with=systemd//' $(DISTDIR)/debian/rules

# Ubuntu 14.04
trusty: debian

# Ubuntu 16.04
xenial: debian

# RPM default
centos: find-couch-dist link-couch-dist build-rpm

centos6: make-rpmbuild install-js185 centos

centos7: make-rpmbuild centos

# ######################################
get-couch:
mkdir -p $(COUCHDIR)
git clone https://github.com/apache/couchdb

build-couch:
cd $(COUCHDIR) && make dist

# ######################################
find-couch-dist:
$(eval ORIGDISTDIR := $(shell cd $(COUCHDIR) && find . -type d -name apache-couchdb-\*))
$(eval NEWDIR := $(shell echo $(ORIGDISTDIR) | sed 's/.\/apache-couchdb/couchdb/'))
mv $(COUCHDIR)/$(ORIGDISTDIR) $(COUCHDIR)/$(NEWDIR)
$(eval DISTDIR := $(COUCHDIR)/$(NEWDIR))

copy-debian:
rm -rf $(DISTDIR)/debian
cp -R debian $(DISTDIR)

update-changelog:
cd $(DISTDIR) && dch -d $(DEBCHANGELOG)

dpkg:
cd $(DISTDIR) && dpkg-buildpackage -b -us -uc

lintian:
cd $(DISTDIR)/.. && lintian --profile couchdb couch*deb

# ######################################
link-couch-dist:
rm -rf ~/rpmbuild/BUILD
ln -s $(DISTDIR) ~/rpmbuild/BUILD

make-rpmbuild:
rm -rf ~/rpmbuild
mkdir -p ~/rpmbuild
cp -R rpm/* ~/rpmbuild

build-rpm:
cd ~/rpmbuild && rpmbuild --verbose -bb SPECS/couchdb.spec --define "erlang_version $(ERLANG_VERSION)"

# ######################################
make-js185:
spectool -g -R rpm/SPECS/js-1.8.5.spec
cd ~/rpmbuild && rpmbuild --verbose -bb SPECS/js-1.8.5.spec

install-js185:
sudo rpm -i ~/rpmbuild/RPMS/x86_64/js-1*
sudo rpm -i ~/rpmbuild/RPMS/x86_64/js-devel*
@@ -1,3 +1,8 @@
# CouchDB Packaging support files

TBD - testing GH-ASF integration
Quickstart:

```shell
$ cd .. && git clone https://github.com/apache/couchdb
$ cd couchdb-pkg && make -f Makefile.nightly build-couch $(lsb_release)
```
@@ -34,6 +34,7 @@ Depends: adduser,
debconf,
init-system-helpers,
procps,
python,
python-requests,
${misc:Depends},
${shlibs:Depends},
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
[log]
writer = file
file = /var/log/couchdb/couchdb.log
level = info
@@ -0,0 +1,131 @@
#!/bin/sh
# 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.
#
# chkconfig: - 26 74
# description: Starts and stops the CouchDB daemon that handles \
# all database requests.
#
### BEGIN INIT INFO
# Provides: couchdb
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Apache CouchDB, a RESTful document oriented database
# Description: Apache CouchDB is a distributed, fault-tolerant and schema-free
# document-oriented database accessible via a RESTful HTTP/JSON API. Among other
# features, it provides robust, incremental replication with bi-directional
# conflict detection and resolution, and is queryable and indexable using a
# table-oriented view engine with JavaScript acting as the default view
# definition language.
### END INIT INFO
# Author: CouchDB Developers <dev@couchdb.apache.org>

# Source function library.
. /etc/rc.d/init.d/functions

prog=couchdb
exec=/opt/couchdb/bin/$prog

COUCHDB_USER=couchdb
COUCHDB_PIDFILE=/var/run/$prog.pid

[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

PID="$(pgrep -u couchdb beam* || true)"
LOCKFILE=/var/lock/subsys/$prog

start() {
[ -x $exec ] || exit 5
echo -n $"Starting $prog: "
status_q && echo -n "already running" && warning && echo && exit 0
daemon --user $COUCHDB_USER \
--pidfile $COUCHDB_PIDFILE \
nohup $exec $COUCHDB_OPTIONS >/dev/null 2>&1 &
retval=$?
[ $retval -eq 0 ] && touch $LOCKFILE && success || failure
echo
return $retval
}

stop() {
echo -n $"Stopping $prog: "
retval=0
if ! status_q ; then
echo -n "already stopped" && warning
else
pkill -u $COUCHDB_USER beam\*
retval=$?
[ $retval -eq 0 ] && rm -f $lockfile && success || failure
fi
echo
return $retval
}

restart() {
stop
start
}

reload() {
restart
}

usage() {
echo "Usage: couchdb {start|stop|status|restart|force-reload}" >&2
}

status() {
pgrep -u couchdb beam* > /dev/null && status="$?" || status="$?"
if [ "$status" = 0 ]; then
echo "$prog is running"
return 0
elif [ "$status" = 4 ]; then
echo "could not access PID file for $prog"
return $status
else
echo "$prog is not running"
return $status
fi
}

status_q() {
status >/dev/null 2>&1
}

case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
reload)
usage
exit 3
;;
force-reload)
reload
;;
restart)
restart
;;
'')
usage
exit 3
;;
esac
exit 0
@@ -0,0 +1,9 @@
/var/log/couchdb/couchdb.log {
weekly
rotate 10
copytruncate
delaycompress
compress
notifempty
missingok
}
@@ -0,0 +1,15 @@
[Unit]
Description=Apache CouchDB
Wants=network-online.target
After=network-online.target

[Service]
RuntimeDirectory=couchdb
User=couchdb
Group=couchdb
ExecStart=/opt/couchdb/bin/couchdb
Restart=on-failure

[Install]
WantedBy=multi-user.target

0 comments on commit 75b9105

Please sign in to comment.