This is an automated email from the ASF dual-hosted git repository.
ronny pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb-pkg.git
The following commit(s) were added to refs/heads/main by this push:
new 4dbff64 Snap package updated to 3.3.3 (#119)
4dbff64 is described below
commit 4dbff649b303d2198e25fe602d6306b0f538af81
Author: Simon Klassen <[email protected]>
AuthorDate: Tue Jan 2 16:37:53 2024 +0800
Snap package updated to 3.3.3 (#119)
Summary of changes:
* fixes for snapcraft
* Added configure hook 'snap set couchdb admin=[password]'
* Added port to the list snap configured parameters
* Split packages into build and stage to reduce snap size; (some formating)
* Rewrote cluster HOWTO with new snap functionality without using LXC
* Formatting changes
* Expanded Explanation
* Added back the layout stanza
* Re-wrote building snap section
* Added warning on /var size and replaced the building snap section
* Rolled version and removed post-refresh hook
* SM68 and removed auto binding and added explicit directory into local.ini
* Added prefix to snapcraft file
* Added local.d creation to install hook
* Add softlink for libmozjs broken package
* libmozjs soft link use full path
* Removed debug statements
* Cleaner ln of libmozjs
* Re-run install script when refreshing
* Updated URL and added extra enviroment
* updated libraries
* updated configure
* remove libmozjs-68 hack
* Rolled base to core22 --beta (removed build-base)
* Fresh install set random cookie
* Support spaces in regex
* Switch to snaps erlang/rebar3
* lxc released version
* Rolled version number in example
* Use /dev/random to bake a better cookie
* Adds arch for remote-build; override-build now runs on one line; verbose
is now verbosity.
* Added additional architectures
* Rolled the 3.3.3 and removed disable docs
---------
Co-authored-by: Joan Touzet <[email protected]>
Co-authored-by: Simon Klassen <[email protected]>
Co-authored-by: Ronny Berndt <[email protected]>
---
.gitignore | 2 +-
README-SNAP.md | 148 ++++++++++++++++++++++++++++--------------------
snap/hooks/configure | 9 +--
snap/hooks/install | 40 +++++++++++--
snap/hooks/post-refresh | 51 +++++++++++++++++
snap/snapcraft.yaml | 129 +++++++++++++++++------------------------
6 files changed, 227 insertions(+), 152 deletions(-)
diff --git a/.gitignore b/.gitignore
index 395f1d0..fb84283 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,7 +17,7 @@ rpm/SPECS/couchdb.spec
repo/db
repo/dists
repo/pool
-couchdb_*.snap
+couchdb*.snap
parts/
prime/
snap/.snapcraft/
diff --git a/README-SNAP.md b/README-SNAP.md
index 3ee137c..1c2e0bc 100644
--- a/README-SNAP.md
+++ b/README-SNAP.md
@@ -18,33 +18,44 @@ The snap can be installed from a file or directly from the
snap store:
$ sudo snap install couchdb
```
-If this is your first time installing couchdb then you will need to set an
admin password
-and manually start CouchDB.
+If you are installing on ChromeOS you will need to install snapd, and its
prerequisites, first.
```bash
-$ sudo snap set couchdb admin=[your-password-goes-here]
+sudo apt install libsquashfuse0 squashfuse fuse
+sudo apt install snapd
+```
+
+If this is your first time installing couchdb then you will need to set an
admin password,
+a (random) cookie, and manually start CouchDB.
+
+```bash
+$ sudo snap set couchdb admin=[your-password-goes-here]
setcookie=[your-cookie-goes-here]
$ sudo snap start couchdb
```
## Enable snap permissions
-The snap installation uses AppArmor to protect your system. CouchDB requests
access to two
-interfaces: mount-observe, which is used by the disk compactor to know when to
initiate a
-cleanup; and process-control, which is used by the indexer to set the priority
of couchjs
-to 'nice'. These two interfaces are required for CouchDB to run correctly.
+The snap installation uses AppArmor to protect your system. CouchDB requests
access to
+mount-observe, which is used by the disk compactor to know when to initiate a
+cleanup.
-To connect the interfaces type:
+To connect the interface type:
```bash
$ sudo snap connect couchdb:mount-observe
-$ sudo snap connect couchdb:process-control
```
# Configuration <a name="configuration"></a>
Be sure to read the [CouchDB
documentation](http://docs.couchdb.org/en/stable/) first.
-CouchDB defaults are stored **read-only** in
`/snap/couchdb/current/opt/couchdb/etc/`.
+Snaps enforce -- what was previous merely suggested -- the Unix philosophy
that local
+binaries or libraries sit in `/usr/local/...` and anything variable is stored
separately
+in `/var/local/...`. With this in mind, if are you going to use snaps for your
database,
+the files will be stored in `/var/snap/couchdb/common` and your `/var`
partition will need
+to be large enough for your database size.
+
+CouchDB defaults are stored **read-only** in `/snap/couchdb/current/etc/`.
This includes `default.ini` and any `default.d/*` files added in the snap
build process.
These are all read-only and should never be changed.
@@ -56,9 +67,15 @@ Erlang settings are stored in the
`/var/snap/couchdb/current/etc/vm.args` file.
configuration tool can be used to quickly change the node name and security
cookie:
```bash
-$ sudo snap set couchdb [email protected] setcookie=cutter
+$ sudo snap set couchdb [email protected] setcookie=$COOKIE
```
+Where COOKIE is an enviroment variable. You can auto generated a cookie with
the command
+below.
+
+```bash
+$ export COOKIE=`echo $(dd if=/dev/random bs=1 count=38 status=none | base64 |
tr -cd '[:alnum:]')`
+
Be sure to read `vm.args` to understand what these settings do before changing
them.
*Any configuration file changes require restarting CouchDB before they are
effective:*
@@ -105,8 +122,6 @@ $ sudo snap remove couchdb --purge
You can set up a snap-based cluster on your desktop in no time using the
couchdb snap.
-## Create three nodes
-
In the example below, we are going to set up a three node CouchDB cluster.
(Three is the
minimum number needed to support clustering features.) We'll also set up a
separate,
single machine for making backups. In this example we will be using parallel
instance of
@@ -121,8 +136,7 @@ and set a admin password.
```bash
$> snap install couchdb_1
$> snap connect couchdb_1:mount-observe
-$> snap connect couchdb_1:process-control
-$> snap set couchdb_1 [email protected] setcookie=cutter port=5981
admin=Be1stDB
+$> snap set couchdb_1 [email protected] setcookie=$COOKIE port=5981
admin=$PASSWD
```
You will need to edit the local configuration file to manually set the data
directories.
You can find the local.ini at ```/var/snap/couchdb_1/current/etc/local.ini```
ensure
@@ -134,81 +148,90 @@ that the ```[couchdb]``` stanza should look like this
database_dir = /var/snap/couchdb_1/common/data
view_index_dir = /var/snap/couchdb_1/common/data
```
-Start your engine ... and confirm that couchdb is running.
+Start your engine(s) ...
```bash
$> snap start couchdb_1
-
+```
+... and confirm that couchdb is running
+```bash
$> curl -X GET http://localhost:5981
```
-Then repeat for couchdb_1, couchdb_2 and couchdb_bkup, editing the local.ini
and changing
+Then repeat for couchdb_2 and couchdb_3, editing the local.ini and changing
the name, port number for each. They should all have the same admin password
and cookie.
```bash
$> snap install couchdb_2
$> snap connect couchdb_2:mount-observe
-$> snap connect couchdb_2:process-control
-$> snap set couchdb_2 [email protected] setcookie=cutter port=5982
admin=Be1stDB
+$> snap set couchdb_2 [email protected] setcookie=$COOKIE port=5982
admin=$PASSWD
$> snap install couchdb_3
$> snap connect couchdb_3:mount-observe
-$> snap connect couchdb_3:process-control
-$> snap set couchdb_3 [email protected] setcookie=cutter port=5983
admin=Be1stDB
+$> snap set couchdb_3 [email protected] setcookie=$COOKIE port=5983
admin=$PASSWD
```
## Enable CouchDB Cluster (using the http interface)
-Have the first node generate two uuids
+Have the first node generate two uuids (which couchdb can generate for you).
```bash
$> curl http://localhost:5981/_uuids?count=2
```
+
+These can also be set by batch script.
+
+```bash
+$> export UUID=`curl "http://localhost:5984/_uuids" | jq .uuids[0]`
+$> export SECRET=`curl "http://localhost:5984/_uuids" | jq .uuids[0]`
+```
+
+
The each instances within a cluster needs to share the same uuid ...
```bash
-curl -X PUT
http://admin:[email protected]:5981/_node/_local/_config/couchdb/uuid -d
'"f6f22e2c664b49ba2c6dc88379002548"'
-curl -X PUT
http://admin:[email protected]:5982/_node/_local/_config/couchdb/uuid -d
'"f6f22e2c664b49ba2c6dc88379002548"'
-curl -X PUT
http://admin:[email protected]:5983/_node/_local/_config/couchdb/uuid -d
'"f6f22e2c664b49ba2c6dc88379002548"'
+curl -X PUT
http://admin:[email protected]:5981/_node/_local/_config/couchdb/uuid -d '$UUID'
+curl -X PUT
http://admin:[email protected]:5982/_node/_local/_config/couchdb/uuid -d '$UUID'
+curl -X PUT
http://admin:[email protected]:5983/_node/_local/_config/couchdb/uuid -d '$UUID'
```
... and a (different) but common secret ...
```bash
-curl -X PUT
http://admin:[email protected]:5981/_node/_local/_config/couch_httpd_auth/secret
-d '"f6f22e2c664b49ba2c6dc88379002a80"'
-curl -X PUT
http://admin:[email protected]:5982/_node/_local/_config/couch_httpd_auth/secret
-d '"f6f22e2c664b49ba2c6dc88379002a80"'
-curl -X PUT
http://admin:[email protected]:5983/_node/_local/_config/couch_httpd_auth/secret
-d '"f6f22e2c664b49ba2c6dc88379002a80"'
+curl -X PUT
http://admin:[email protected]:5981/_node/_local/_config/couch_httpd_auth/secret
-d '$SECRET'
+curl -X PUT
http://admin:[email protected]:5982/_node/_local/_config/couch_httpd_auth/secret
-d '$SECRET'
+curl -X PUT
http://admin:[email protected]:5983/_node/_local/_config/couch_httpd_auth/secret
-d '$SECRET'
```
... after which they can be enabled for clustering
```bash
-curl -X POST -H "Content-Type: application/json"
http://admin:[email protected]:5981/_cluster_setup -d '{"action":
"enable_cluster", "bind_address":"0.0.0.0", "username": "admin",
"password":"Be1stDB", "node_count":"3"}'
-curl -X POST -H "Content-Type: application/json"
http://admin:[email protected]:5982/_cluster_setup -d '{"action":
"enable_cluster", "bind_address":"0.0.0.0", "username": "admin",
"password":"Be1stDB", "node_count":"3"}'
-curl -X POST -H "Content-Type: application/json"
http://admin:[email protected]:5983/_cluster_setup -d '{"action":
"enable_cluster", "bind_address":"0.0.0.0", "username": "admin",
"password":"Be1stDB", "node_count":"3"}'
+curl -X POST -H "Content-Type: application/json"
http://admin:[email protected]:5981/_cluster_setup -d '{"action":
"enable_cluster", "bind_address":"0.0.0.0", "username": "admin",
"password":"$PASSWD", "node_count":"3"}'
+curl -X POST -H "Content-Type: application/json"
http://admin:[email protected]:5982/_cluster_setup -d '{"action":
"enable_cluster", "bind_address":"0.0.0.0", "username": "admin",
"password":"$PASSWD", "node_count":"3"}'
+curl -X POST -H "Content-Type: application/json"
http://admin:[email protected]:5983/_cluster_setup -d '{"action":
"enable_cluster", "bind_address":"0.0.0.0", "username": "admin",
"password":"$PASSWD", "node_count":"3"}'
```
You can check the status here.
```bash
-curl http://admin:[email protected]:5981/_cluster_setup
-curl http://admin:[email protected]:5982/_cluster_setup
-curl http://admin:[email protected]:5983/_cluster_setup
+curl http://admin:[email protected]:5981/_cluster_setup
+curl http://admin:[email protected]:5982/_cluster_setup
+curl http://admin:[email protected]:5983/_cluster_setup
```
## Configure CouchDB Cluster (using the http interface)
Next we want to join the three nodes together. We do this through requests to
the first node.
```bash
-curl -X PUT
"http://admin:[email protected]:5981/_node/_local/_nodes/[email protected]" -d
'{"port":5982}'
-curl -X PUT
"http://admin:[email protected]:5981/_node/_local/_nodes/[email protected]" -d
'{"port":5983}'
+curl -X PUT
"http://admin:[email protected]:5981/_node/_local/_nodes/[email protected]" -d
'{"port":5982}'
+curl -X PUT
"http://admin:[email protected]:5981/_node/_local/_nodes/[email protected]" -d
'{"port":5983}'
-curl -X POST -H "Content-Type: application/json"
http://admin:[email protected]:5981/_cluster_setup -d '{"action":
"finish_cluster"}'
+curl -X POST -H "Content-Type: application/json"
http://admin:[email protected]:5981/_cluster_setup -d '{"action":
"finish_cluster"}'
-curl http://admin:[email protected]:5981/_cluster_setup
+curl http://admin:[email protected]:5981/_cluster_setup
```
If everthing as been successful, then the three notes can be seen here.
```bash
-$> curl -X GET "http://admin:[email protected]:5981/_membership"
+$> curl -X GET "http://admin:[email protected]:5981/_membership"
```
Now we have a functioning three node cluster. Next we will test it.
## An Example Database
Let's create an example database ...
```bash
-$ curl -X PUT http://admin:Be1stDB@localhost:5981/example
-$ curl -X PUT http://admin:Be1stDB@localhost:5981/example/aaa -d '{"test":1}'
-H "Content-Type: application/json"
-$ curl -X PUT http://admin:Be1stDB@localhost:5981/example/aab -d '{"test":2}'
-H "Content-Type: application/json"
-$ curl -X PUT http://admin:Be1stDB@localhost:5981/example/aac -d '{"test":3}'
-H "Content-Type: application/json"
+$ curl -X PUT http://admin:$PASSWD@localhost:5981/example
+$ curl -X PUT http://admin:$PASSWD@localhost:5981/example/aaa -d '{"test":1}'
-H "Content-Type: application/json"
+$ curl -X PUT http://admin:$PASSWD@localhost:5981/example/aab -d '{"test":2}'
-H "Content-Type: application/json"
+$ curl -X PUT http://admin:$PASSWD@localhost:5981/example/aac -d '{"test":3}'
-H "Content-Type: application/json"
```
... and verify that it is created on all three nodes ...
```bash
@@ -225,16 +248,17 @@ $ curl -X GET http://localhost:5983/example/_all_docs
The backup machine we will configure as a single instance (`n=1, q=1`).
```bash
$> snap install couchdb_bkup
-$> snap set couchdb_bkup name=couchdb0@localhost setcookie=cutter port=5980
admin=Be1stDB
-$> curl -X PUT
http://admin:Be1stDB@localhost:5980/_node/_local/_config/cluster/n -d '"1"'
-$> curl -X PUT
http://admin:Be1stDB@localhost:5980/_node/_local/_config/cluster/q -d '"1"'
+$> snap connect couchdb_3:mount-observe
+$> snap set couchdb_bkup name=couchdb0@localhost setcookie=$COOKIE port=5980
admin=$PASSWD
+$> curl -X PUT
http://admin:$PASSWD@localhost:5980/_node/_local/_config/cluster/n -d '"1"'
+$> curl -X PUT
http://admin:$PASSWD@localhost:5980/_node/_local/_config/cluster/q -d '"1"'
```
We will manually replicate to this from one (can be any one) of the nodes.
```bash
-$ curl -X POST http://admin:Be1stDB@localhost:5980/_replicate \
+$ curl -X POST http://admin:$PASSWD@localhost:5980/_replicate \
-d
'{"source":"http://localhost:5981/example","target":"example","continuous":false,"create_target":true}'
\
-H "Content-Type: application/json"
-$ curl -X GET http://admin:Be1stDB@localhost:5980/example/_all_docs
+$ curl -X GET http://admin:$PASSWD@localhost:5980/example/_all_docs
```
The backup database has a single shard and single directory:
```bash
@@ -251,30 +275,30 @@ you are using the default.
```bash
/snap/bin/couchdb.remsh -n couchdb@localhost -c $COOKIE
```
+
# Building this snap <a name="building"></a>
-This build requires `core20`. On Ubuntu 18.04, you will need to do the
following:
+The snapcraft tool can be installed from the snap store as such
-```
-sudo apt remove snapcraft
-sudo snap remove snapcraft
+```bash
sudo snap install snapcraft --classic
```
-Then building is easy:
-
-```bash
-$ snapcraft
-```
+If you run snapcraft on your base system it will start either a mutlipass or
lxd
+container and execute the installation within there.
-The self-built snap will need to be installed using `--dangerous`:
+This can be tedious if errors occur. An alternative is to create your own lxd
+container and run snapcraft in destructive mode (within the LXD container).
```bash
-sudo snap install ./couchdb_3.0.0_amd64.snap --dangerous
+> lxc launch ubuntu-daily:22.04 cdb
+> lxc shell cdb
+$ snapcraft --destructive-mode --verbosity=debug
```
-Clean up with:
+Once the snap has been built, the snap can be installed locally using
`--dangerous`:
```bash
-$ sudo snapcraft clean # sudo may not be required but is safe
+sudo snap install ./couchdb_3.3.3_amd64.snap --dangerous
```
+
diff --git a/snap/hooks/configure b/snap/hooks/configure
index c833af2..a4af362 100755
--- a/snap/hooks/configure
+++ b/snap/hooks/configure
@@ -22,9 +22,8 @@ _modify_vm_args() {
opt=$1
value="$2"
replace_line="-$opt $value"
- if $(grep -q "^-$opt " $VM_ARGS); then
- sed "s/^-$opt .*/$replace_line/" $VM_ARGS 2>/dev/null >${VM_ARGS}.new
- mv -f ${VM_ARGS}.new $VM_ARGS 2>/dev/null
+ if $(grep -q "^[#|[:space:]]*-$opt " $VM_ARGS); then
+ sed --in-place "s/^[#|[:space:]]*-$opt .*/$replace_line/" $VM_ARGS
else
echo $replace_line >> $VM_ARGS
fi
@@ -36,14 +35,12 @@ _modify_ini_args() {
value="$2"
replace_line="$opt = $value"
if $(grep -q "^[;|[:space:]]*$opt[[:space:]]*=" $LOCAL_INI); then
- sed "s/^[;|[:space:]]*$opt[[:space:]]*=.*/$replace_line/" $LOCAL_INI
2>/dev/null >${LOCAL_INI}.new
- mv -f ${LOCAL_INI}.new $LOCAL_INI 2>/dev/null
+ sed --in-place "s/^[;|[:space:]]*$opt[[:space:]]*=.*/$replace_line/"
$LOCAL_INI
else
echo $replace_line >> $LOCAL_INI
fi
}
-
# The vm_args file can only be changed from the filesystem
# configutaion vm.args file
diff --git a/snap/hooks/install b/snap/hooks/install
index e6e8e21..d80f9e9 100755
--- a/snap/hooks/install
+++ b/snap/hooks/install
@@ -12,15 +12,43 @@
# License for the specific language governing permissions and limitations under
# the License.
-mkdir -p ${SNAP_COMMON}/data
-mkdir -p ${SNAP_DATA}/etc/local.d
+if [ -z ${SNAP_INSTANCE_KEY} ]
+then
+ SNAP_INSTANCE_DATA=${SNAP_DATA}
+ SNAP_INSTANCE_COMMON=${SNAP_COMMON}
+else
+ SNAP_INSTANCE_DATA=$(echo ${SNAP_DATA} | sed -e
s/${SNAP_NAME}/${SNAP_INSTANCE_NAME}/)
+ SNAP_INSTANCE_COMMON=$(echo ${SNAP_COMMON} | sed -e
s/${SNAP_NAME}/${SNAP_INSTANCE_NAME}/)
+fi
+
+LOG=${SNAP_INSTANCE_DATA}/snap-install.log
+
+mkdir -p ${SNAP_INSTANCE_DATA}/etc
+mkdir -p ${SNAP_INSTANCE_DATA}/etc/local.d
+mkdir -p ${SNAP_INSTANCE_COMMON}/data
+
+if [ ! -s ${SNAP_INSTANCE_DATA}/etc/vm.args ]; then
+ cat ${SNAP}/etc/vm.args > ${SNAP_INSTANCE_DATA}/etc/vm.args
+fi
-if [ ! -s ${SNAP_DATA}/etc/vm.args ]; then
- cat ${SNAP}/opt/couchdb/etc/vm.args.dist > ${SNAP_DATA}/etc/vm.args
+LOCAL_INI=$SNAP_INSTANCE_DATA/etc/local.ini
+if [ ! -s ${LOCAL_INI} ]; then
+ cat ${SNAP}/etc/local.ini > ${LOCAL_INI}
fi
-if [ ! -s ${SNAP_DATA}/etc/local.ini ]; then
- cat ${SNAP}/opt/couchdb/etc/local.ini.dist > ${SNAP_DATA}/etc/local.ini
+# Ensure that local.ini has the view_index_dir specified
+if ! $(grep -q "^view_index_dir" ${LOCAL_INI}); then
+ view_line=$(echo "view_index_dir = ${SNAP_INSTANCE_COMMON}/data" | sed
's/\//\\\//g')
+ sed --in-place "/^\[couchdb\].*$/a ${view_line}" ${LOCAL_INI}
fi
+# Ensure that local.ini has the database_dir specified
+if ! $(grep -q "^database_dir" ${LOCAL_INI}); then
+ database_line=$(echo "database_dir = ${SNAP_INSTANCE_COMMON}/data" | sed
's/\//\\\//g')
+ sed --in-place "/^\[couchdb\].*$/a ${database_line}" ${LOCAL_INI}
+fi
+
+
+#snap set ${SNAP_INSTANCE_NAME} setcookie=`echo $RANDOM | md5sum | head -c 20;
echo;`
+
diff --git a/snap/hooks/post-refresh b/snap/hooks/post-refresh
new file mode 100755
index 0000000..0196f62
--- /dev/null
+++ b/snap/hooks/post-refresh
@@ -0,0 +1,51 @@
+#!/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.
+
+
+if [ -z ${SNAP_INSTANCE_KEY} ]
+then
+ SNAP_INSTANCE_DATA=${SNAP_DATA}
+ SNAP_INSTANCE_COMMON=${SNAP_COMMON}
+else
+ SNAP_INSTANCE_DATA=$(echo ${SNAP_DATA} | sed -e
s/${SNAP_NAME}/${SNAP_INSTANCE_NAME}/)
+ SNAP_INSTANCE_COMMON=$(echo ${SNAP_COMMON} | sed -e
s/${SNAP_NAME}/${SNAP_INSTANCE_NAME}/)
+fi
+
+LOG=${SNAP_INSTANCE_DATA}/snap-install.log
+
+mkdir -p ${SNAP_INSTANCE_DATA}/etc
+mkdir -p ${SNAP_INSTANCE_DATA}/etc/local.d
+mkdir -p ${SNAP_INSTANCE_COMMON}/data
+
+if [ ! -s ${SNAP_INSTANCE_DATA}/etc/vm.args ]; then
+ cat ${SNAP}/etc/vm.args > ${SNAP_INSTANCE_DATA}/etc/vm.args
+fi
+
+LOCAL_INI=$SNAP_INSTANCE_DATA/etc/local.ini
+if [ ! -s ${LOCAL_INI} ]; then
+ cat ${SNAP}/etc/local.ini > ${LOCAL_INI}
+fi
+
+# Ensure that local.ini has the view_index_dir specified
+if ! $(grep -q "^view_index_dir" ${LOCAL_INI}); then
+ view_line=$(echo "view_index_dir = ${SNAP_INSTANCE_COMMON}/data" | sed
's/\//\\\//g')
+ sed --in-place "/^\[couchdb\].*$/a ${view_line}" ${LOCAL_INI}
+fi
+
+# Ensure that local.ini has the database_dir specified
+if ! $(grep -q "^database_dir" ${LOCAL_INI}); then
+ database_line=$(echo "database_dir = ${SNAP_INSTANCE_COMMON}/data" | sed
's/\//\\\//g')
+ sed --in-place "/^\[couchdb\].*$/a ${database_line}" ${LOCAL_INI}
+fi
+
diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index 6340c7d..78ee191 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -1,106 +1,81 @@
+---
name: couchdb
-version: 3.1.1
+version: 3.3.3
+type: app
+base: core22
summary: Official Apache CouchDB snap - a clustering document oriented database
description: |
CouchDB is a database that completely embraces the web. Store your data with
JSON documents. Access your documents and query your indexes with your web
browser, via HTTP. Index, combine, and transform your documents with
JavaScript.
-
-architectures:
- - build-on: amd64
- run-on: amd64
assumes: [command-chain, common-data-dir]
-base: core20
grade: stable
confinement: strict
+architectures:
+ - build-on: s390x
+ - build-on: ppc64el
+ - build-on: arm64
+ - build-on: armhf
+ - build-on: amd64
+
parts:
- add-repo:
- plugin: nil
- override-pull: |
- apt-get update
- apt-get upgrade -yy
- apt-get install -y --no-install-recommends apt-transport-https \
- gnupg ca-certificates
- echo "deb https://apache.bintray.com/couchdb-deb focal main" | \
- tee /etc/apt/sources.list.d/custom.list
- apt-key adv --keyserver keyserver.ubuntu.com --recv-keys \
- 8756C4F765C9AC3CB6B85D62379CE192D401AB61
- apt-get update
couchdb:
- after: [add-repo]
- plugin: dump
- source:
https://apache.bintray.com/couchdb-deb/pool/C/CouchDB/couchdb_3.1.1~focal_amd64.deb
- source-type: deb
- # because this doesn't use apt, we have to manually list all of our
- # dependencies :(
+ plugin: make
+ source:
https://dlcdn.apache.org/couchdb/source/3.3.3/apache-couchdb-3.3.3.tar.gz
+ source-type: tar
+ override-build: ./configure --spidermonkey-version 91 && make release &&
cp -r rel/couchdb/* $SNAPCRAFT_PART_INSTALL
build-packages:
- - adduser
- - debconf
- - ca-certificates
- - init-system-helpers
- - lsb-base
- - libgcc1
+ - gcc
+ - g++
+ - libc6-dev
+ - libcurl4-openssl-dev
+ - libicu-dev
+ - icu-devtools
+ # For erlang/rebar processing
+ - erlang-dev
+ - erlang-base
+ - erlang-reltool
+ - erlang-nox
+ - erlang-eunit
+ - erlang-os-mon
+ - erlang-syntax-tools
+ # mozjs
+ - libmozjs-91-dev
+ # For fauxton
+ - libnode-dev
+ - npm
stage-packages:
- - libmozjs-68-0
- procps
- libcurl4
- - libicu66
- - libssl1.1
- - libtinfo6
- override-pull: |
- snapcraftctl pull
- rm -f opt/couchdb/data opt/couchdb/var/log opt/couchdb/etc/default.d/*
- mkdir -p opt/couchdb/etc/default.d.dist/
- mv opt/couchdb/etc/vm.args opt/couchdb/etc/vm.args.dist
- mv opt/couchdb/etc/local.ini opt/couchdb/etc/local.ini.dist
- override-build: |
- echo "couchdb couchdb/mode select none" | debconf-set-selections
- snapcraftctl build
- override-stage: |
- # focal libmozjs is busted...
- ln -s libmozjs-68.so.68.6.0
/root/parts/couchdb/install/usr/lib/x86_64-linux-gnu/libmozjs-68.so.0
- snapcraftctl stage
- override-prime: |
- snapcraftctl prime
-
-layout:
- # Database and log files are common across upgrades
- # We do not bind default.ini or default.d/ as these are
- # intended to be immutable
- $SNAP/opt/couchdb/data:
- bind: $SNAP_COMMON/data
- $SNAP/opt/couchdb/var/log:
- bind: $SNAP_COMMON/log
- # Local configuration files may change across upgrades
- $SNAP/opt/couchdb/etc/vm.args:
- bind-file: $SNAP_DATA/etc/vm.args
- $SNAP/opt/couchdb/etc/local.d:
- bind: $SNAP_DATA/etc/local.d
- $SNAP/opt/couchdb/etc/local.ini:
- bind-file: $SNAP_DATA/etc/local.ini
+ - libicu70
+ - libmozjs-91-0
+ - libssl3
+ - libtinfo5
+ stage:
+ - -usr/share/doc
+ - -usr/share/man
+ - -var
environment:
COUCHDB_ARGS_FILE: ${SNAP_DATA}/etc/vm.args
- ERL_FLAGS: "-couch_ini ${SNAP}/opt/couchdb/etc/default.ini
- ${SNAP}/opt/couchdb/etc/default.d
- ${SNAP_DATA}/etc/local.ini
- ${SNAP_DATA}/etc/local.d"
+ COUCHDB_FAUXTON_DOCROOT: ${SNAP}/share/www
+ COUCHDB_QUERY_SERVER_JAVASCRIPT: ${SNAP}/bin/couchjs ${COUCHJS_ARGS}
${SNAP}/share/server/main.js
+ COUCHDB_QUERY_SERVER_COFFEESCRIPT: ${SNAP}/bin/couchjs ${COUCHJS_ARGS}
${SNAP}/share/server/main-coffee.js
+ COUCHDB_INI_FILES: ${SNAP}/etc/default.ini ${SNAP}/etc/default.d
${SNAP_DATA}/etc/local.ini ${SNAP_DATA}/etc/local.d
apps:
couchdb:
- adapter: full
- command: opt/couchdb/bin/couchdb
- plugs: [network, network-bind, process-control, mount-observe]
+ command: bin/couchdb
+ plugs: [network, network-bind, mount-observe]
server:
daemon: simple
- adapter: full
- command: opt/couchdb/bin/couchdb
- plugs: [network, network-bind, process-control, mount-observe]
+ command: bin/couchdb
+ plugs: [network, network-bind, mount-observe]
remsh:
- command: opt/couchdb/bin/remsh
+ command: bin/remsh
plugs: [network, network-bind]
couchjs:
- command: opt/couchdb/bin/couchjs
+ command: bin/couchjs
plugs: [network, network-bind]