Skip to content
Permalink
Browse files
Refactor pkg build process to not rely on couchdb-ci (#39)
  • Loading branch information
wohali committed Dec 6, 2018
1 parent 6836d21 commit 9672bc3c1259a5dc46bb3346e28f02d85cd5adde
Showing 11 changed files with 703 additions and 81 deletions.
@@ -4,8 +4,6 @@ debian/*.substvars
debian/files
debian/couchdb
debian/tmp
js/couch-*
js/couch-*
js/build
rpm/BUILD
rpm/BUILDROOT
@@ -14,11 +12,9 @@ rpm/SRPMS
repo/db
repo/dists
repo/pool
pkgs/
couchdb/
couchdb_*.snap
parts/
prime/
snap/.snapcraft/
stage/
apache-couchdb*.tar.gz
*.tar.gz
@@ -0,0 +1,41 @@
dist: xenial

language: minimal

services:
- docker

# Avoid double build on PRs (See https://github.com/travis-ci/travis-ci/issues/1147)
branches:
only:
- master

env:
global:
- ERLANGVER=19.3.6
- TARBALL_URL=https://dist.apache.org/repos/dist/release/couchdb/source/2.3.0/apache-couchdb-2.3.0.tar.gz
- TARBALL=apache-couchdb-2.3.0.tar.gz
matrix:
- TARGET="js debian-jessie"
- TARGET="couch debian-jessie ${TARBALL_URL}"
- TARGET="js debian-stretch"
- TARGET="couch debian-stretch ${TARBALL_URL}"
- TARGET="js ubuntu-trusty"
- TARGET="couch ubuntu-trusty ${TARBALL_URL}"
- TARGET="js ubuntu-xenial"
- TARGET="couch ubuntu-xenial ${TARBALL_URL}"
- TARGET="js ubuntu-bionic"
- TARGET="couch ubuntu-bionic ${TARBALL_URL}"
- TARGET="js centos-6"
- TARGET="couch centos-6 ${TARBALL_URL}"
- TARGET="js centos-7"
- TARGET="couch centos-7 ${TARBALL_URL}"

before_install:
- docker --version

script:
- ./build.sh ${TARGET}

after_script:
- ls -laR pkgs/
@@ -20,19 +20,25 @@ export DEBFULLNAME="CouchDB Developers"
export DEBEMAIL="dev@couchdb.apache.org"

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

# Debian 8
debian-jessie: PLATFORM=jessie
debian-jessie: DIST=debian-jessie
debian-jessie: jessie
jessie: debian

# Debian 9
debian-stretch: PLATFORM=stretch
debian-stretch: DIST=debian-stretch
debian-stretch: stretch
stretch: debian

# Ubuntu 12.04
ubuntu-precise: PLATFORM=precise
ubuntu-precise: DIST=ubuntu-precise
ubuntu-precise: precise
precise: find-couch-dist copy-debian precise-prep update-changelog dpkg
precise: find-couch-dist copy-debian precise-prep update-changelog dpkg copy-pkgs

precise-prep:
sed -i '/dh-systemd/d' $(DISTDIR)/debian/control
@@ -44,28 +50,36 @@ precise-prep:
# No lintian run because of bogus failure on
# postrm-does-not-call-updaterc.d-for-init.d-script
# See Ubuntu ufw changelog for why they disabled this check
ubuntu-trusty: PLATFORM=trusty
ubuntu-trusty: DIST=ubuntu-trusty
ubuntu-trusty: trusty
trusty: find-couch-dist copy-debian trusty-prep update-changelog dpkg
trusty: find-couch-dist copy-debian trusty-prep update-changelog dpkg copy-pkgs

# see changelog for ubuntu ufw package, this is safe
trusty-prep:
#sudo sed -i 's/conffile/conffile, postrm-does-not-call-updaterc.d-for-init.d-script/' /usr/share/lintian/profiles/couchdb/main.profile
sed -i '/erlang-*/d' $(DISTDIR)/debian/control

# Ubuntu 16.04
ubuntu-xenial: PLATFORM=xenial
ubuntu-xenial: DIST=ubuntu-xenial
ubuntu-xenial: xenial
xenial: debian

# Ubuntu 18.04
ubuntu-bionic: PLATFORM=bionic
ubuntu-bionic: DIST=ubuntu-bioniC
ubuntu-bionic: bionic
bionic: debian

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

centos-6: DIST=centos-6
centos-6: centos6
centos6: make-rpmbuild centos

centos-7: DIST=centos-7
centos-7: centos7
centos7: make-rpmbuild centos

@@ -140,13 +154,13 @@ build-rpm:

# ######################################
copy-pkgs:
mkdir -p pkgs/$(PLATFORM)
-cp ../rpmbuild/RPMS/x86_64/*.rpm pkgs/$(PLATFORM)
-cp ../couchdb/*deb pkgs/$(PLATFORM)
-chmod -R a+rwx pkgs/$(PLATFORM)
-chmod a+rwx ../rpmbuild/RPMS/x86_64/couchdb-* ../couchdb/couchdb_* 2>/dev/null
-mkdir -p pkgs/couch/$(DIST) && chmod 777 pkgs/couch/$(DIST)
-cp ../rpmbuild/RPMS/x86_64/couchdb-* pkgs/couch/$(DIST) 2>/dev/null
-cp ../couchdb/couchdb_* pkgs/couch/$(DIST) 2>/dev/null

clean:
rm -rf couchdb_2.0_amd64.snap parts prime snap/.snapcraft stage js/build
rm -rf parts prime stage js/build

# ######################################
couch-js-clean:
@@ -1,12 +1,76 @@
# CouchDB Packaging support files
# CouchDB Packaging support repo

Quickstart:
The main purpose of this repository is to provide packaging support files for Apache CouchDB and its SpiderMoneky 1.8.5 dependency, for a number of well-known and used packaging formats, namely:

* `.deb` files, as used by Debian, Ubuntu, and derivatives
* `.rpm` files, as used by CentOS, RedHat, and derivatives
* `snapcraft` files, as used by the Ubuntu Snappy package manager

# Usage

## On a system with all necessary build-time dependencies:

### SpiderMonkey 1.8.5

#### rpms

```shell
make couch-js-rpms
```

#### debs

```shell
$ cd .. && git clone https://github.com/apache/couchdb
$ cd couchdb-pkg && make build-couch $(lsb_release -cs) PLATFORM=$(lsb_release -cs)
make couch-js-debs PLATFORM=$(lsb_release -cs)
```

### CouchDB

#### rpms or debs from `master` branch:

```shell
cd .. && git clone https://github.com/apache/couchdb
cd couchdb-pkg && make build-couch $(lsb_release -cs) PLATFORM=$(lsb_release -cs)
```

#### rpms or debs from a release tarball:

```shell
make copy-couch $(lsb_release -cs) COUCHTARBALL=path/to/couchdb-#.#.#.tar.gz PLATFORM=$(lsb_release -cs)
```

-----

## Building inside the `couchdbdev` docker containers

You must first pull down the image or images you need from Docker Hub, or build the images using the [apache/couchdb-ci](https://github.com/apache/couchdb-ci) repository. Example:

```shell
docker pull couchdbdev/<osname>-<codename>-erlang-<erlang-version>
```

A full list of supported environments is at https://hub.docker.com/u/couchdbdev/ .

### SpiderMonkey 1.8.5

```shell
./build.sh js <os>-<codename> # for example, debian-stretch, ubuntu-bionic or centos-7.
```

### CouchDB

```shell
./build.sh couch <os>-<codename> path/to/couchdb-#.#.#.tar.gz
```

or, if you want to build directly from the Apache distribution repository,

```shell
./build.sh couch <os>-<codename> https://dist.apache.org/repos/dist/release/couchdb/source/#.#.#/apache-couchdb-#.#.#.tar.gz
```

-----

# Building packages for a release

## Prerequisites
@@ -25,13 +89,27 @@ will be derived from the filename of the CouchDB dist tarball.

Run:

$ ./make-packages path/to/apache-couchdb-VERSION.tar.gz
$ ./build.sh couch-all path/to/apache-couchdb-VERSION.tar.gz

or

$ ./make-packages http://url/to/apache-couchdb-VERSION.tar.gz
$ ./build.sh couch-all http://url/to/apache-couchdb-VERSION.tar.gz

Packages will be placed in the `pkgs/couch` subdirectory.

A similar `js-all` target exists, should the SpiderMonkey packages need to be regenerated.

## Uploading the packages

If you have Apache Bintray credentials (set your `BINTRAY_USER` and `BINTRAY_API_KEY` environment variables appropriately), after building all CouchDB packages above, simply run:

./build.sh couch-upload-all

Or, for the SpiderMonkey packages:

./build.sh js-upload-all

Packages will be placed in the `pkgs/` subdirectory.
-----

# Building snaps

@@ -42,7 +120,7 @@ Packages will be placed in the `pkgs/` subdirectory.

## How to do it

1. Edit `snap/snapcraft.yaml` to point to the correct tag (e.g. `2.1.0`)
1. Edit `snap/snapcraft.yaml` to point to the correct tag (e.g. `2.3.0`)
1. `snapcraft`

# Feedback, Issues, Contributing
@@ -0,0 +1,65 @@
#!/usr/bin/env bash

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

# This shell script builds and tests CouchDB on the current host.
# It assumes the build environment is already set up correctly.
# It needs no special privileges.

# stop on error
set -e

SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

. ${SCRIPTPATH}/detect-os.sh

redhats='(rhel|centos|fedora)'
debians='(debian|ubuntu)'

cd /home/jenkins

if [[ $1 ]]; then
# use copied package
mkdir couchdb
tar -xf ${SCRIPTPATH}/../$1 -C couchdb
cp ${SCRIPTPATH}/../$1 couchdb
else
# use master branch
git clone https://github.com/apache/couchdb
cd couchdb
./configure -c
make dist
cd ..
fi

# now, build the package
cd couchdb-pkg
platform=${ID}-${VERSION_CODENAME}
make $platform PLATFORM=${VERSION_CODENAME}

# and save the output
if [[ ${ID} =~ ${redhats} ]]; then
mv ../rpmbuild/RPMS/* ${SCRIPTPATH}/../couch/$platform
elif [[ ${ID} =~ ${debians} ]]; then
mv ../couchdb/*.deb ${SCRIPTPATH}/../couch/$platform
else
echo "Sorry, we don't support this Linux (${ID}) yet."
exit 1
fi
# and make sure we can delete it if necessary
chmod -R a+rwx ${SCRIPTPATH}/../couch/$platform/*
@@ -0,0 +1,60 @@
#!/usr/bin/env bash

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

# This shell script builds a CouchDB-compatible SpiderMonkey 1.8.5
# and assumes the build environment is already set up correctly.
# It expects to be run as root.

# stop on error
set -e

# This works if we're not called through a symlink
# otherwise, see https://stackoverflow.com/questions/59895/
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ARCH=$(arch)

# Check if running as root
if [[ ${EUID} -ne 0 ]]; then
echo "Sorry, this script must be run as root."
echo "Try: sudo $0 $*"
exit 1
fi

. ${SCRIPTPATH}/detect-os.sh

cd ${SCRIPTPATH}/..

redhats='(rhel|centos|fedora)'
debians='(debian|ubuntu)'
if [[ ${ID} =~ ${redhats} ]]; then
# it will always place the build path at /root/rpmbuild :(
cp -r ${SCRIPTPATH}/.. /root/couchdb-pkg
cd /root/couchdb-pkg
make couch-js-rpms
mkdir -p ${SCRIPTPATH}/../pkgs/js/${ID}-${VERSION_CODENAME}
mv /root/rpmbuild/RPMS/${ARCH}/couch-js-* ${SCRIPTPATH}/../pkgs/js/${ID}-${VERSION_CODENAME}
elif [[ ${ID} =~ ${debians} ]]; then
make couch-js-debs PLATFORM=${VERSION_CODENAME}
mkdir -p pkgs/js/${ID}-${VERSION_CODENAME}
mv js/couch-lib* pkgs/js/${ID}-${VERSION_CODENAME}
else
echo "Sorry, we don't support this Linux (${ID}) yet."
exit 1
fi
chmod a+rw ${SCRIPTPATH}/../pkgs/js/*

0 comments on commit 9672bc3

Please sign in to comment.