From 45f2aeda3f357191809bad29e2f0a9329cb73d1e Mon Sep 17 00:00:00 2001 From: sklassen Date: Sat, 7 Dec 2024 11:44:17 +0800 Subject: [PATCH 1/2] To support instances, moved most of the work to nouveau.sh --- .../couchdb-nouveau/snap/hooks/configure | 33 -------- snapcraft/couchdb-nouveau/snap/hooks/install | 24 ++---- .../couchdb-nouveau/snap/hooks/post-refresh | 43 ----------- .../couchdb-nouveau/snap/local/bin/nouveau.sh | 11 +++ snapcraft/couchdb-nouveau/snap/snapcraft.yaml | 77 ++----------------- 5 files changed, 27 insertions(+), 161 deletions(-) delete mode 100755 snapcraft/couchdb-nouveau/snap/hooks/configure delete mode 100755 snapcraft/couchdb-nouveau/snap/hooks/post-refresh diff --git a/snapcraft/couchdb-nouveau/snap/hooks/configure b/snapcraft/couchdb-nouveau/snap/hooks/configure deleted file mode 100755 index 0e99d17..0000000 --- a/snapcraft/couchdb-nouveau/snap/hooks/configure +++ /dev/null @@ -1,33 +0,0 @@ -#!/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. - -set -e - -#if grep -q "rootDir: {{nouveau_index_dir}}" nouveau.yaml; then -# sed -i.bak 's/{{nouveau_index_dir}}/.\/bla\/blup/' nouveau.yaml -#else -# echo "1: not run" -#fi -# -#if grep -q "{{nouveau_port}}" nouveau.yaml; then -# sed -i.bak 's/{{nouveau_port}}/1234/' nouveau.yaml -#else -# echo "2: not run" -#fi -# -#if grep -q "{{nouveau_admin_port}}" nouveau.yaml; then -# sed -i.bak 's/{{nouveau_admin_port}}/5678/' nouveau.yaml -#else -# echo "3: not run" -#fi \ No newline at end of file diff --git a/snapcraft/couchdb-nouveau/snap/hooks/install b/snapcraft/couchdb-nouveau/snap/hooks/install index 2176e87..31476db 100755 --- a/snapcraft/couchdb-nouveau/snap/hooks/install +++ b/snapcraft/couchdb-nouveau/snap/hooks/install @@ -12,7 +12,6 @@ # License for the specific language governing permissions and limitations under # the License. - if [ -z ${SNAP_INSTANCE_KEY} ] then SNAP_INSTANCE_DATA=${SNAP_DATA} @@ -25,19 +24,12 @@ fi mkdir -p ${SNAP_INSTANCE_DATA}/etc mkdir -p ${SNAP_INSTANCE_COMMON}/data/nouveau -## Ensure that nouveau.yaml 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 nouveau.yaml 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 -# ## If nouveau yaml file is there, copy to cfg directory (without overwriting) -#if [ -s ${SNAP}/etc/nouveau.yaml ] && [ ! -s ${COUCHDB_NOUVEAU_CFG} ]; then -# cat ${SNAP}/etc/nouveau.yaml > ${COUCHDB_NOUVEAU_CFG} -#fi +NOUVEAU_CFG=${SNAP_INSTANCE_DATA}/etc/nouveau.yaml +if [ -s ${SNAP}/nouveau/etc/nouveau.yaml ] && [ ! -s ${NOUVEAU_CFG} ]; then + cat ${SNAP}/nouveau/etc/nouveau.yaml > ${NOUVEAU_CFG} + index_line=$(echo "${SNAP_INSTANCE_COMMON}/data/nouveau" | sed 's/\//\\\//g') + sed --in-place "s/{{nouveau_index_dir}}/${index_line}/" ${NOUVEAU_CFG} + sed --in-place "s/{{nouveau_port}}/${COUCHDB_NOUVEAU_NOUVEAU_PORT}/" ${NOUVEAU_CFG} + sed --in-place "s/{{nouveau_admin_port}}/${COUCHDB_NOUVEAU_NOUVEAU_ADMIN_PORT}/" ${NOUVEAU_CFG} +fi diff --git a/snapcraft/couchdb-nouveau/snap/hooks/post-refresh b/snapcraft/couchdb-nouveau/snap/hooks/post-refresh deleted file mode 100755 index effd1b9..0000000 --- a/snapcraft/couchdb-nouveau/snap/hooks/post-refresh +++ /dev/null @@ -1,43 +0,0 @@ -#!/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 - -mkdir -p ${SNAP_INSTANCE_DATA}/etc -mkdir -p ${SNAP_INSTANCE_COMMON}/data/nouveau - -## 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 -# -## If nouveau yaml file is there, copy to cfg directory (without overwriting) -#if [ -s ${SNAP}/etc/nouveau.yaml ] && [ ! -s ${COUCHDB_NOUVEAU_CFG} ]; then -# cat ${SNAP}/etc/nouveau.yaml > ${COUCHDB_NOUVEAU_CFG} -#fi diff --git a/snapcraft/couchdb-nouveau/snap/local/bin/nouveau.sh b/snapcraft/couchdb-nouveau/snap/local/bin/nouveau.sh index 9127d71..8f21c15 100755 --- a/snapcraft/couchdb-nouveau/snap/local/bin/nouveau.sh +++ b/snapcraft/couchdb-nouveau/snap/local/bin/nouveau.sh @@ -11,9 +11,20 @@ # 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} +else + SNAP_INSTANCE_DATA=$(echo ${SNAP_DATA} | sed -e s/${SNAP_NAME}/${SNAP_INSTANCE_NAME}/) +fi +export JAVA_PATH="${SNAP}/usr/lib/jvm/java-1.21.0-openjdk-${SNAP_ARCH}/bin/java" export JAVA_OPTS="-server -Djava.awt.headless=true -Xmx2g" +COUCHDB_NOUVEAU_JAR: ${SNAP}/nouveau/lib/nouveau-1.0-SNAPSHOT.jar +COUCHDB_NOUVEAU_CFG: ${SNAP_INSTANCE_DATA}/etc/nouveau.yaml + echo "Starting nouveau (java)" echo "java path : ${JAVA_PATH}" echo "java opts : ${JAVA_OPTS}" diff --git a/snapcraft/couchdb-nouveau/snap/snapcraft.yaml b/snapcraft/couchdb-nouveau/snap/snapcraft.yaml index f2a6198..b1a3609 100755 --- a/snapcraft/couchdb-nouveau/snap/snapcraft.yaml +++ b/snapcraft/couchdb-nouveau/snap/snapcraft.yaml @@ -38,32 +38,6 @@ architectures: #- build-on: [ppc64el] parts: -# erlang-elixir-gradle: -# plugin: dump -# build-environment: -# - ASDF_ERLANG_VERSION: "25.3.2.15" -# - ASDF_ELIXIR_VERSION: "1.15.8-otp-25" -# - ASDF_GRADLE_VERSION: "8.10" -# source: https://github.com/asdf-vm/asdf.git -# source-branch: v0.14.1 -# source-type: git -# build-packages: -# - libncurses-dev -# - unzip -# - curl -# override-build: | -# source "./asdf.sh" -# -# # Install Erlang -# asdf plugin add erlang -# asdf install erlang "$ASDF_ERLANG_VERSION" -# asdf global erlang "$ASDF_ERLANG_VERSION" -# -# # Install Erlang -# asdf plugin add elixir -# asdf install elixir "$ASDF_ELIXIR_VERSION" -# asdf global elixir "$ASDF_ELIXIR_VERSION" - nouveau: #after: [erlang-elixir-gradle] plugin: make @@ -77,32 +51,19 @@ parts: # set-up gradle to use launchpad proxy settings (for snapcraft remote-build) source "$(pwd)/../../nouveau-launcher/src/setup_gradle_launchpad.sh" - + # Configure, build and release CouchDB binaries # ./configure --with-nouveau --spidermonkey-version "$SPIDERMONKEY_VERSION" && make nouveau make -f "$(pwd)/../../nouveau-launcher/src/Makefile" release && cp -r rel/couchdb/* $SNAPCRAFT_PART_INSTALL - + build-packages: - #- gcc - #- g++ - #- libc6-dev - #- libicu-dev - #- libssl-dev - # Mozilla JS engine - #- libmozjs-91-dev - openjdk-21-jdk-headless stage-packages: - #- libicu70 - #- libssl3 - #- libmozjs-91-0 - #- libgraphite2-3 - #- libharfbuzz0b - #- libasound2 - openjdk-21-jre-headless - #stage: - #- -usr/share/doc - #- -usr/share/man - #- -var + stage: + - -usr/share/doc + - -usr/share/man + - -var nouveau-launcher: source: snap/local source-type: local @@ -112,33 +73,11 @@ parts: - -Makefile environment: - #COUCHDB_ARGS_FILE: ${SNAP_DATA}/etc/vm.args - #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 - COUCHDB_NOUVEAU_JAR: ${SNAP}/nouveau/lib/nouveau-1.0-SNAPSHOT.jar - COUCHDB_NOUVEAU_CFG: ${SNAP_DATA}/etc/nouveau.yaml - COUCHDB_NOUVEAU_NOUVEAU_PORT: 5987 - COUCHDB_NOUVEAU_NOUVEAU_ADMIN_PORT: 5988 + COUCHDB_NOUVEAU_PORT: 5987 + COUCHDB_NOUVEAU_ADMIN_PORT: 5988 apps: - #couchdb: - # command: bin/couchdb - # plugs: [network, network-bind, mount-observe] - #server: - # daemon: simple - # command: bin/couchdb - # plugs: [network, network-bind, mount-observe] nouveau: - environment: - JAVA_PATH: ${SNAP}/usr/lib/jvm/java-1.21.0-openjdk-${SNAP_ARCH}/bin/java daemon: simple command: bin/nouveau.sh plugs: [network, network-bind, mount-observe] - #remsh: - # command: bin/remsh - # plugs: [network, network-bind] - #couchjs: - # command: bin/couchjs - # plugs: [network, network-bind] From 22fb21db39bb96fa0500d346d41050744ede64e2 Mon Sep 17 00:00:00 2001 From: sklassen Date: Sat, 7 Dec 2024 12:13:44 +0800 Subject: [PATCH 2/2] correct variables --- snapcraft/couchdb-nouveau/snap/hooks/install | 4 ++-- snapcraft/couchdb-nouveau/snap/local/bin/nouveau.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/snapcraft/couchdb-nouveau/snap/hooks/install b/snapcraft/couchdb-nouveau/snap/hooks/install index 31476db..ef6b2dd 100755 --- a/snapcraft/couchdb-nouveau/snap/hooks/install +++ b/snapcraft/couchdb-nouveau/snap/hooks/install @@ -30,6 +30,6 @@ if [ -s ${SNAP}/nouveau/etc/nouveau.yaml ] && [ ! -s ${NOUVEAU_CFG} ]; then cat ${SNAP}/nouveau/etc/nouveau.yaml > ${NOUVEAU_CFG} index_line=$(echo "${SNAP_INSTANCE_COMMON}/data/nouveau" | sed 's/\//\\\//g') sed --in-place "s/{{nouveau_index_dir}}/${index_line}/" ${NOUVEAU_CFG} - sed --in-place "s/{{nouveau_port}}/${COUCHDB_NOUVEAU_NOUVEAU_PORT}/" ${NOUVEAU_CFG} - sed --in-place "s/{{nouveau_admin_port}}/${COUCHDB_NOUVEAU_NOUVEAU_ADMIN_PORT}/" ${NOUVEAU_CFG} + sed --in-place "s/{{nouveau_port}}/${COUCHDB_NOUVEAU_PORT}/" ${NOUVEAU_CFG} + sed --in-place "s/{{nouveau_admin_port}}/${COUCHDB_NOUVEAU_ADMIN_PORT}/" ${NOUVEAU_CFG} fi diff --git a/snapcraft/couchdb-nouveau/snap/local/bin/nouveau.sh b/snapcraft/couchdb-nouveau/snap/local/bin/nouveau.sh index 8f21c15..dd4eef6 100755 --- a/snapcraft/couchdb-nouveau/snap/local/bin/nouveau.sh +++ b/snapcraft/couchdb-nouveau/snap/local/bin/nouveau.sh @@ -22,8 +22,8 @@ fi export JAVA_PATH="${SNAP}/usr/lib/jvm/java-1.21.0-openjdk-${SNAP_ARCH}/bin/java" export JAVA_OPTS="-server -Djava.awt.headless=true -Xmx2g" -COUCHDB_NOUVEAU_JAR: ${SNAP}/nouveau/lib/nouveau-1.0-SNAPSHOT.jar -COUCHDB_NOUVEAU_CFG: ${SNAP_INSTANCE_DATA}/etc/nouveau.yaml +COUCHDB_NOUVEAU_JAR=${SNAP}/nouveau/lib/nouveau-1.0-SNAPSHOT.jar +COUCHDB_NOUVEAU_CFG=${SNAP_INSTANCE_DATA}/etc/nouveau.yaml echo "Starting nouveau (java)" echo "java path : ${JAVA_PATH}"