You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "meator (via GitHub)" <gi...@apache.org> on 2026/09/17 20:21:28 UTC
[I] [ENHANCEMENT]: Simplify couchdb wrapper script logic [couchdb]
meator opened a new issue, #6117:
URL: https://github.com/apache/couchdb/issues/6117
### Provide a brief overview of what the new feature is all about
I propose the following:
```diff
diff --git a/rel/files/couchdb.in b/rel/files/couchdb.in
index 332bfe0f2..7837d794f 100755
--- a/rel/files/couchdb.in
+++ b/rel/files/couchdb.in
@@ -12,19 +12,8 @@
# License for the specific language governing permissions and limitations under
# the License.
-canonical_readlink ()
- {
- FILE=$(dirname "$1")/$(basename "$1");
- if [ -h "$FILE" ]; then
- cd $(dirname "$1")
- canonical_readlink $(readlink "$FILE");
- else
- cd "${1%/*}" && pwd -P;
- fi
-}
-COUCHDB_BIN_DIR=$(canonical_readlink "$0")
-ERTS_BIN_DIR=$COUCHDB_BIN_DIR/../
-cd "$COUCHDB_BIN_DIR/../"
+ERTS_BIN_DIR="{{prefix}}"
+cd "$ERTS_BIN_DIR"
export ROOTDIR=${ERTS_BIN_DIR%/*}
```
This makes the script work when it is `exec`ed. `$0` cannot be relied upon when `exec`ing and it is kinda unreliable in general (there are bunch of edge cases related to it), it should be avoided wherever possible. `prefix` is the ideal substitute solving all inconveniences.
I would make a PR out of it, but the `configure` script is very rudimentary and there is (to my knowledge) no way to override the location of `root` other than editing `rel/couchdb.config` after configuring.
I find it likely that there are users/distros/packagers which install couchdb into custom locations but are unaware that `rel/couchdb.config` requires editing (I don't think that this fact is documented anywhere), so substituting `{{prefix}}` will lead to `.`, which will break existing and new deployments of couchdb.
This is all a result of couchdb's highly non-standard build process which was designed to not support installing couchdb. I think that I read somewhere that making couchdb properly installable is on the roadmap. If it ever gets implemented, this proposed change could be added too.
The advantages provided by this change are miniscule (I consider the `exec` and `$0` things to be very minor issues, I see the main value of this change in simplifying the script and being able to dump `canonical_readlink()`), the disadvantages are significant.
### Tell us how the new feature should work. Be specific
_No response_
### Not required. Suggest how to implement the addition or change
_No response_
### Additional Context
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [ENHANCEMENT]: Simplify couchdb wrapper script logic [couchdb]
Posted by "big-r81 (via GitHub) via notifications" <no...@couchdb.apache.org>.
big-r81 commented on issue #6117:
URL: https://github.com/apache/couchdb/issues/6117#issuecomment-6711464779
Does CouchDB starts from symlinks with your change. This was the reasone for adding `canonical_readlinks()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org