<feed xmlns='http://www.w3.org/2005/Atom'>
<title>unit.git/auto, branch 1.30.0</title>
<subtitle>Universal Web Application Server</subtitle>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/'/>
<entry>
<title>NJS: supported loadable modules.</title>
<updated>2023-05-08T08:00:25+00:00</updated>
<author>
<name>Zhidao HONG</name>
<email>z.hong@f5.com</email>
</author>
<published>2023-05-08T08:00:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=a3c3a29493798873ad04922bb2a7180b2ce267d5'/>
<id>a3c3a29493798873ad04922bb2a7180b2ce267d5</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>HTTP: added basic URI rewrite.</title>
<updated>2023-04-20T15:20:41+00:00</updated>
<author>
<name>Zhidao HONG</name>
<email>z.hong@f5.com</email>
</author>
<published>2023-04-20T15:20:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=14d6d97bacf9b06ba340ebd4211b2f1b6ad417dd'/>
<id>14d6d97bacf9b06ba340ebd4211b2f1b6ad417dd</id>
<content type='text'>
This commit introduced the basic URI rewrite. It allows users to change request URI. Note the "rewrite" option ignores the contained query if any and the query from the request is preserverd.
An example:
"routes": [
    {
        "match": {
            "uri": "/v1/test"
        },
        "action": {
            "return": 200
        }
    },
    {
        "action": {
            "rewrite": "/v1$uri",
            "pass": "routes"
        }
    }
]

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit introduced the basic URI rewrite. It allows users to change request URI. Note the "rewrite" option ignores the contained query if any and the query from the request is preserverd.
An example:
"routes": [
    {
        "match": {
            "uri": "/v1/test"
        },
        "action": {
            "return": 200
        }
    },
    {
        "action": {
            "rewrite": "/v1$uri",
            "pass": "routes"
        }
    }
]

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Docs: moved uintd.8 to man8/ subdirectory.</title>
<updated>2023-05-08T15:47:26+00:00</updated>
<author>
<name>Alejandro Colomar</name>
<email>alx@nginx.com</email>
</author>
<published>2023-04-24T15:59:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=1266eda80c2f3b67d50b13d88d1ea51729eab772'/>
<id>1266eda80c2f3b67d50b13d88d1ea51729eab772</id>
<content type='text'>
Reviewed-by: Artem Konev &lt;a.konev@f5.com&gt;
Signed-off-by: Alejandro Colomar &lt;alx@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reviewed-by: Artem Konev &lt;a.konev@f5.com&gt;
Signed-off-by: Alejandro Colomar &lt;alx@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove a bunch of dead code.</title>
<updated>2023-04-24T18:39:09+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-03-27T18:28:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=b9177d36e71a9f62198b00fa40f277c06d2264bb'/>
<id>b9177d36e71a9f62198b00fa40f277c06d2264bb</id>
<content type='text'>
This removes a bunch of unused files that would have been touched by
subsequent commits that switch to using nxt_bool_t (AKA unit6_t) in
structures.

In auto/sources we have

  NXT_LIB_SRC0=" \
      src/nxt_buf_filter.c \
      src/nxt_job_file.c \
      src/nxt_stream_module.c \
      src/nxt_stream_source.c \
      src/nxt_upstream_source.c \
      src/nxt_http_source.c \
      src/nxt_fastcgi_source.c \
      src/nxt_fastcgi_record_parse.c \
  \
      src/nxt_mem_pool_cleanup.h \
      src/nxt_mem_pool_cleanup.c \
  "

None of these seem to actually be used anywhere (other than within
themselves). That variable is _not_ referenced anywhere else.

Also remove the unused related header files: src/nxt_buf_filter.h,
src/nxt_fastcgi_source.h, src/nxt_http_source.h, src/nxt_job_file.h,
src/nxt_stream_source.h and src/nxt_upstream_source.h

Also, these files do not seem to be used, no mention under auto/ or build/

  src/nxt_file_cache.c
  src/nxt_cache.c
  src/nxt_job_file_cache.c

src/nxt_cache.h is #included in src/nxt_main.h, but AFAICT is not
actually used.

With all the above removed

  $ ./configure --openssl --debug --tests &amp;&amp; make -j &amp;&amp; make -j tests &amp;&amp;
  make libnxt

all builds.

Buildbot passes.

NOTE: You may need to do a 'make clean' before the next build attempt.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This removes a bunch of unused files that would have been touched by
subsequent commits that switch to using nxt_bool_t (AKA unit6_t) in
structures.

In auto/sources we have

  NXT_LIB_SRC0=" \
      src/nxt_buf_filter.c \
      src/nxt_job_file.c \
      src/nxt_stream_module.c \
      src/nxt_stream_source.c \
      src/nxt_upstream_source.c \
      src/nxt_http_source.c \
      src/nxt_fastcgi_source.c \
      src/nxt_fastcgi_record_parse.c \
  \
      src/nxt_mem_pool_cleanup.h \
      src/nxt_mem_pool_cleanup.c \
  "

None of these seem to actually be used anywhere (other than within
themselves). That variable is _not_ referenced anywhere else.

Also remove the unused related header files: src/nxt_buf_filter.h,
src/nxt_fastcgi_source.h, src/nxt_http_source.h, src/nxt_job_file.h,
src/nxt_stream_source.h and src/nxt_upstream_source.h

Also, these files do not seem to be used, no mention under auto/ or build/

  src/nxt_file_cache.c
  src/nxt_cache.c
  src/nxt_job_file_cache.c

src/nxt_cache.h is #included in src/nxt_main.h, but AFAICT is not
actually used.

With all the above removed

  $ ./configure --openssl --debug --tests &amp;&amp; make -j &amp;&amp; make -j tests &amp;&amp;
  make libnxt

all builds.

Buildbot passes.

NOTE: You may need to do a 'make clean' before the next build attempt.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Auto: mirroring installation structure in build tree.</title>
<updated>2023-03-28T22:41:08+00:00</updated>
<author>
<name>Alejandro Colomar</name>
<email>alx@nginx.com</email>
</author>
<published>2023-03-22T15:55:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=6e16d7ac5bb86140a55ea30a35c69ee0df3eff8d'/>
<id>6e16d7ac5bb86140a55ea30a35c69ee0df3eff8d</id>
<content type='text'>
This makes the build tree more organized, which is good for adding new
stuff.  Now, it's useful for example for adding manual pages in man3/,
but it may be useful in the future for example for extending the build
system to run linters (e.g., clang-tidy(1), Clang analyzer, ...) on the
C source code.

Previously, the build tree was quite flat, and looked like this (after
`./configure &amp;&amp; make`):

    $ tree -I src build
    build
    ├── Makefile
    ├── autoconf.data
    ├── autoconf.err
    ├── echo
    ├── libnxt.a
    ├── nxt_auto_config.h
    ├── nxt_version.h
    ├── unitd
    └── unitd.8

    1 directory, 9 files

And after this patch, it looks like this:

    $ tree -I src build
    build
    ├── Makefile
    ├── autoconf.data
    ├── autoconf.err
    ├── bin
    │   └── echo
    ├── include
    │   ├── nxt_auto_config.h
    │   └── nxt_version.h
    ├── lib
    │   ├── libnxt.a
    │   └── unit
    │       └── modules
    ├── sbin
    │   └── unitd
    ├── share
    │   └── man
    │       └── man8
    │           └── unitd.8
    └── var
        ├── lib
        │   └── unit
        ├── log
        │   └── unit
        └── run
            └── unit

    17 directories, 9 files

It also solves one issue introduced in
5a37171f733f ("Added default values for pathnames.").  Before that
commit, it was possible to run unitd from the build system
(`./build/unitd`).  Now, since it expects files in a very specific
location, that has been broken.  By having a directory structure that
mirrors the installation, it's possible to trick it to believe it's
installed, and run it from there:

    $ ./configure --prefix=./build
    $ make
    $ ./build/sbin/unitd

Fixes: 5a37171f733f ("Added default values for pathnames.")
Reported-by: Liam Crilly &lt;liam@nginx.com&gt;
Reviewed-by: Konstantin Pavlov &lt;thresh@nginx.com&gt;
Reviewed-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
Cc: Andrei Zeliankou &lt;zelenkov@nginx.com&gt;
Cc: Zhidao Hong &lt;z.hong@f5.com&gt;
Signed-off-by: Alejandro Colomar &lt;alx@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This makes the build tree more organized, which is good for adding new
stuff.  Now, it's useful for example for adding manual pages in man3/,
but it may be useful in the future for example for extending the build
system to run linters (e.g., clang-tidy(1), Clang analyzer, ...) on the
C source code.

Previously, the build tree was quite flat, and looked like this (after
`./configure &amp;&amp; make`):

    $ tree -I src build
    build
    ├── Makefile
    ├── autoconf.data
    ├── autoconf.err
    ├── echo
    ├── libnxt.a
    ├── nxt_auto_config.h
    ├── nxt_version.h
    ├── unitd
    └── unitd.8

    1 directory, 9 files

And after this patch, it looks like this:

    $ tree -I src build
    build
    ├── Makefile
    ├── autoconf.data
    ├── autoconf.err
    ├── bin
    │   └── echo
    ├── include
    │   ├── nxt_auto_config.h
    │   └── nxt_version.h
    ├── lib
    │   ├── libnxt.a
    │   └── unit
    │       └── modules
    ├── sbin
    │   └── unitd
    ├── share
    │   └── man
    │       └── man8
    │           └── unitd.8
    └── var
        ├── lib
        │   └── unit
        ├── log
        │   └── unit
        └── run
            └── unit

    17 directories, 9 files

It also solves one issue introduced in
5a37171f733f ("Added default values for pathnames.").  Before that
commit, it was possible to run unitd from the build system
(`./build/unitd`).  Now, since it expects files in a very specific
location, that has been broken.  By having a directory structure that
mirrors the installation, it's possible to trick it to believe it's
installed, and run it from there:

    $ ./configure --prefix=./build
    $ make
    $ ./build/sbin/unitd

Fixes: 5a37171f733f ("Added default values for pathnames.")
Reported-by: Liam Crilly &lt;liam@nginx.com&gt;
Reviewed-by: Konstantin Pavlov &lt;thresh@nginx.com&gt;
Reviewed-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
Cc: Andrei Zeliankou &lt;zelenkov@nginx.com&gt;
Cc: Zhidao Hong &lt;z.hong@f5.com&gt;
Signed-off-by: Alejandro Colomar &lt;alx@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Renamed --libstatedir to --statedir.</title>
<updated>2023-03-28T22:40:40+00:00</updated>
<author>
<name>Alejandro Colomar</name>
<email>alx@nginx.com</email>
</author>
<published>2023-03-27T11:43:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=5ba79b9b524ef746bc3269520c3f6b893f39275c'/>
<id>5ba79b9b524ef746bc3269520c3f6b893f39275c</id>
<content type='text'>
In BSD systems, it's usually &lt;/var/db&gt; or some other dir under &lt;/var&gt;
that is not &lt;/var/lib&gt;, so $statedir is a more generic name.  See
hier(7).

Reported-by: Andrei Zeliankou &lt;zelenkov@nginx.com&gt;
Reported-by: Zhidao Hong &lt;z.hong@f5.com&gt;
Reviewed-by: Konstantin Pavlov &lt;thresh@nginx.com&gt;
Reviewed-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
Cc: Liam Crilly &lt;liam@nginx.com&gt;
Signed-off-by: Alejandro Colomar &lt;alx@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In BSD systems, it's usually &lt;/var/db&gt; or some other dir under &lt;/var&gt;
that is not &lt;/var/lib&gt;, so $statedir is a more generic name.  See
hier(7).

Reported-by: Andrei Zeliankou &lt;zelenkov@nginx.com&gt;
Reported-by: Zhidao Hong &lt;z.hong@f5.com&gt;
Reviewed-by: Konstantin Pavlov &lt;thresh@nginx.com&gt;
Reviewed-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
Cc: Liam Crilly &lt;liam@nginx.com&gt;
Signed-off-by: Alejandro Colomar &lt;alx@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Enable the PR_SET_CHILD_SUBREAPER prctl(2) option on Linux.</title>
<updated>2023-02-17T21:24:18+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2022-11-30T00:13:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=d98a1b0dd7c5a4105c44fa1696d4f01b9f3e0db0'/>
<id>d98a1b0dd7c5a4105c44fa1696d4f01b9f3e0db0</id>
<content type='text'>
This prctl(2) option can be used to set the "child subreaper" attribute
of the calling process.  This allows a process to take on the role of
'init', which means the process will inherit descendant processes when
their immediate parent terminates.

This will be used in an upcoming commit that uses a double fork(2) +
unshare(2) to create a new PID namespace.  The parent from the second
fork will terminate leaving the child process to be inherited by 'init'.
Aside from it being better to maintain the parent/child relationships
between the various unit processes, without setting this you need to ^C
twice to fully quit unit when running in the foreground after the double
fork.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This prctl(2) option can be used to set the "child subreaper" attribute
of the calling process.  This allows a process to take on the role of
'init', which means the process will inherit descendant processes when
their immediate parent terminates.

This will be used in an upcoming commit that uses a double fork(2) +
unshare(2) to create a new PID namespace.  The parent from the second
fork will terminate leaving the child process to be inherited by 'init'.
Aside from it being better to maintain the parent/child relationships
between the various unit processes, without setting this you need to ^C
twice to fully quit unit when running in the foreground after the double
fork.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Isolation: Rename NXT_HAVE_CLONE -&gt; NXT_HAVE_LINUX_NS.</title>
<updated>2023-02-17T21:24:18+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2022-11-18T23:42:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=3ecdd2c69c4864526c63b8e55df22ad1a86f3c72'/>
<id>3ecdd2c69c4864526c63b8e55df22ad1a86f3c72</id>
<content type='text'>
Due to the need to replace our use of clone/__NR_clone on Linux with
fork(2)/unshare(2) for enabling Linux namespaces(7) to keep the
pthreads(7) API working.  Let's rename NXT_HAVE_CLONE to
NXT_HAVE_LINUX_NS, i.e name it after the feature, not how it's
implemented, then in future if we change how we do namespaces again we
don't have to rename this.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Due to the need to replace our use of clone/__NR_clone on Linux with
fork(2)/unshare(2) for enabling Linux namespaces(7) to keep the
pthreads(7) API working.  Let's rename NXT_HAVE_CLONE to
NXT_HAVE_LINUX_NS, i.e name it after the feature, not how it's
implemented, then in future if we change how we do namespaces again we
don't have to rename this.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Isolation: Fix the enablement of PR_SET_NO_NEW_PRIVS.</title>
<updated>2023-02-17T21:24:18+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2022-11-25T10:32:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=763396b8be07be41b1baf336952fd222cbeb8db7'/>
<id>763396b8be07be41b1baf336952fd222cbeb8db7</id>
<content type='text'>
This prctl(2) option is checked for in auto/isolation, unfortunately due
to a typo this feature has never been enabled.

In the auto/isolation script the feature name was down as
NXT_HAVE_PR_SET_NO_NEW_PRIVS0, which means we end up with the following
in build/nxt_auto_config.h

  #ifndef NXT_HAVE_PR_SET_NO_NEW_PRIVS0
  #define NXT_HAVE_PR_SET_NO_NEW_PRIVS0  1
  #endif

Whereas everywhere else is checking for NXT_HAVE_PR_SET_NO_NEW_PRIVS.

This also guards the inclusion of sys/prctl.h in src/nxt_process.c which
is required by a subsequent commit.

Fixes: e2b53e1 ("Added "rootfs" feature.")
Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This prctl(2) option is checked for in auto/isolation, unfortunately due
to a typo this feature has never been enabled.

In the auto/isolation script the feature name was down as
NXT_HAVE_PR_SET_NO_NEW_PRIVS0, which means we end up with the following
in build/nxt_auto_config.h

  #ifndef NXT_HAVE_PR_SET_NO_NEW_PRIVS0
  #define NXT_HAVE_PR_SET_NO_NEW_PRIVS0  1
  #endif

Whereas everywhere else is checking for NXT_HAVE_PR_SET_NO_NEW_PRIVS.

This also guards the inclusion of sys/prctl.h in src/nxt_process.c which
is required by a subsequent commit.

Fixes: e2b53e1 ("Added "rootfs" feature.")
Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Added default values for pathnames.</title>
<updated>2023-01-31T22:47:53+00:00</updated>
<author>
<name>Alejandro Colomar</name>
<email>alx.manpages@gmail.com</email>
</author>
<published>2022-07-14T11:25:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=5a37171f733fa8c7326161cc49af3df0be5dfae4'/>
<id>5a37171f733fa8c7326161cc49af3df0be5dfae4</id>
<content type='text'>
This allows one to simply run `./configure` and expect it to
produce sane defaults for an install.

Previously, without specifying `--prefix=...`, `make install`
would simply fail, recommending to set `--prefix` or `DESTDIR`,
but that recommendation was incomplete at best, since it didn't
set many of the subdirs needed for a good organization.

Setting `DESTDIR` was even worse, since that shouldn't even affect
an installation (it is required to be transparent to the
installation).

/usr/local is the historic Unix standard path to use for
installations from source made manually by the admin of the
system.  Some package managers (Homebrew, I'm looking specifically
at you) have abused that path to install their things, but 1) it's
not our fault that someone else incorrectly abuses that path (and
they seem to be fixing it for newer archs; e.g., they started
using /opt/homebrew for Apple Silicon), 2) there's no better path
than /usr/local, 3) we still allow changing it for systems where
this might not be the desired path (MacOS Intel with hombrew), and
4) it's _the standard_.

See a related conversation with Ingo (OpenBSD maintainer):

On 7/27/22 16:16, Ingo Schwarze wrote:
&gt; Hi Alejandro,
[...]
&gt;
&gt; Alejandro Colomar wrote on Sun, Jul 24, 2022 at 07:07:18PM +0200:
&gt;&gt; On 7/24/22 16:57, Ingo Schwarze wrote:
&gt;&gt;&gt; Alejandro Colomar wrote on Sun, Jul 24, 2022 at 01:20:46PM +0200:
&gt;
&gt;&gt;&gt;&gt; /usr/local is for sysadmins to build from source;
&gt;
&gt;&gt;&gt; Doing that is *very* strongly discouraged on OpenBSD.
&gt;
&gt;&gt; I guess that's why the directory was reused in the BSDs to install ports
&gt;&gt; (probably ports were installed by the sysadmin there, and by extension,
&gt;&gt; ports are now always installed there, but that's just a guess).
&gt;
&gt; Maybe.  In any case, the practice of using /usr/local for packages
&gt; created from ports is significantly older than the recommendation
&gt; to refrain from using upstream "make install" outside the ports
&gt; framework.
&gt;
&gt;   * The FreeBSD ports framework was started by Jordan Hubbard in 1993.
&gt;   * The ports framework was ported from FreeBSD to OpenBSD
&gt;     by Niklas Hallqvist in 1996.
&gt;   * NetBSD pkgsrc was forked from FreeBSD ports by Alistair G. Crooks
&gt;     and Hubert Feyrer in 1997.
&gt;
&gt; I failed to quickly find Jordan's original version, but rev. 1.1
&gt; of /usr/ports/infrastructure/mk/bsd.port.mk in OpenBSD (dated Jun 3
&gt; 22:47:10 1996 UTC) already said
&gt;
&gt;    LOCALBASE ?= /usr/local
&gt;    PREFIX    ?= ${LOCALBASE}
&gt;
[...]
&gt;&gt; I had a discussion in NGINX Unit about it, and
&gt;&gt; the decission for now has been: "support prefix=/usr/local for default
&gt;&gt; manual installation through the Makefile, and let BSD users adjust to
&gt;&gt; their preferred path".
&gt;
&gt; That's an *excellent* solution for the task, thanks for doing it
&gt; the right way.  By setting PREFIX=/usr/local by default in the
&gt; upstream Makefile, you are minimizing the work for *BSD porters.
&gt;
&gt; The BSD ports frameworks will typically run the upstreak "make install"
&gt; with the variable DESTDIR set to a custom value, for example
&gt;
&gt;    DESTDIR=/usr/ports/pobj/groff-1.23.0/fake-amd64
&gt;
&gt; so if the upstream Makefile sets PREFIX=/usr/local ,
&gt; that's perfect, everything gets installed to the right place
&gt; without an intervention by the person doing the porting.
&gt;
&gt; Of course, if the upstream Makefile would use some other PREFIX,
&gt; that would not be a huge obstacle.  All we have to do in that case
&gt; is pass the option --prefix=/usr/local to the ./configure script,
&gt; or something equivalent if the software isn't using GNU configure.
&gt;
&gt;&gt; We were concerned that we might get collisions
&gt;&gt; with the BSD port also installing in /usr/local, but that's the least
&gt;&gt; evil (and considering BSD users don't typically run `make install`, it's
&gt;&gt; not so bad).
&gt;
&gt; It's not bad at all.  It's perfect.
&gt;
&gt; Of course, if a user wants to install *without* the ports framework,
&gt; they have to provide their own --prefix.  But that's not an issue
&gt; because it is easy to do, and installing without a port is discouraged
&gt; anyway.

===

Directory variables should never contain a trailing slash (I've
learned that the hard way, where some things would break
unexpectedly).  Especially, make(1) is likely to have problems
when things have double slashes or a trailing slash, since it
treats filenames as text strings.  I've removed the trailing slash
from the prefix, and added it to the derivate variables just after
the prefix.  pkg-config(1) also expects directory variables to have
no trailing slash.

===

I also removed the code that would set variables as depending on
the prefix if they didn't start with a slash, because that is a
rather non-obvious behavior, and things should not always depend
on prefix, but other dirs such as $(runstatedir), so if we keep
a similar behavior it would be very unreliable.  Better keep
variables intact if set, or use the default if unset.

===

Print the real defaults for ./configure --help, rather than the actual
values.

===

I used a subdirectory under the standard /var/lib for NXT_STATE,
instead of a homemade "state" dir that does the same thing.

===

Modified the Makefile to create some dirs that weren't being
created, and also remove those that weren't being removed in
uninstall, probably because someone forgot to add them.

===

Add new options for setting the new variables, and rename some to be
consistent with the standard names.  Keep the old ones at configuration
time for compatibility, but mark them as deprecated.  Don't keep the old
ones at exec time.

===

A summary of the default config is:

Unit configuration summary:

  bin directory: ............. "/usr/local/bin"
  sbin directory: ............ "/usr/local/sbin"
  lib directory: ............. "/usr/local/lib"
  include directory: ......... "/usr/local/include"
  man pages directory: ....... "/usr/local/share/man"
  modules directory: ......... "/usr/local/lib/unit/modules"
  state directory: ........... "/usr/local/var/lib/unit"
  tmp directory: ............. "/tmp"

  pid file: .................. "/usr/local/var/run/unit/unit.pid"
  log file: .................. "/usr/local/var/log/unit/unit.log"

  control API socket: ........ "unix:/usr/local/var/run/unit/control.unit.sock"

Link: &lt;https://www.gnu.org/prep/standards/html_node/Directory-Variables.html&gt;
Link: &lt;https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html&gt;
Reviewed-by: Artem Konev &lt;a.konev@f5.com&gt;
Reviewed-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
Tested-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
Reviewed-by: Konstantin Pavlov &lt;thresh@nginx.com&gt;
Signed-off-by: Alejandro Colomar &lt;alx@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This allows one to simply run `./configure` and expect it to
produce sane defaults for an install.

Previously, without specifying `--prefix=...`, `make install`
would simply fail, recommending to set `--prefix` or `DESTDIR`,
but that recommendation was incomplete at best, since it didn't
set many of the subdirs needed for a good organization.

Setting `DESTDIR` was even worse, since that shouldn't even affect
an installation (it is required to be transparent to the
installation).

/usr/local is the historic Unix standard path to use for
installations from source made manually by the admin of the
system.  Some package managers (Homebrew, I'm looking specifically
at you) have abused that path to install their things, but 1) it's
not our fault that someone else incorrectly abuses that path (and
they seem to be fixing it for newer archs; e.g., they started
using /opt/homebrew for Apple Silicon), 2) there's no better path
than /usr/local, 3) we still allow changing it for systems where
this might not be the desired path (MacOS Intel with hombrew), and
4) it's _the standard_.

See a related conversation with Ingo (OpenBSD maintainer):

On 7/27/22 16:16, Ingo Schwarze wrote:
&gt; Hi Alejandro,
[...]
&gt;
&gt; Alejandro Colomar wrote on Sun, Jul 24, 2022 at 07:07:18PM +0200:
&gt;&gt; On 7/24/22 16:57, Ingo Schwarze wrote:
&gt;&gt;&gt; Alejandro Colomar wrote on Sun, Jul 24, 2022 at 01:20:46PM +0200:
&gt;
&gt;&gt;&gt;&gt; /usr/local is for sysadmins to build from source;
&gt;
&gt;&gt;&gt; Doing that is *very* strongly discouraged on OpenBSD.
&gt;
&gt;&gt; I guess that's why the directory was reused in the BSDs to install ports
&gt;&gt; (probably ports were installed by the sysadmin there, and by extension,
&gt;&gt; ports are now always installed there, but that's just a guess).
&gt;
&gt; Maybe.  In any case, the practice of using /usr/local for packages
&gt; created from ports is significantly older than the recommendation
&gt; to refrain from using upstream "make install" outside the ports
&gt; framework.
&gt;
&gt;   * The FreeBSD ports framework was started by Jordan Hubbard in 1993.
&gt;   * The ports framework was ported from FreeBSD to OpenBSD
&gt;     by Niklas Hallqvist in 1996.
&gt;   * NetBSD pkgsrc was forked from FreeBSD ports by Alistair G. Crooks
&gt;     and Hubert Feyrer in 1997.
&gt;
&gt; I failed to quickly find Jordan's original version, but rev. 1.1
&gt; of /usr/ports/infrastructure/mk/bsd.port.mk in OpenBSD (dated Jun 3
&gt; 22:47:10 1996 UTC) already said
&gt;
&gt;    LOCALBASE ?= /usr/local
&gt;    PREFIX    ?= ${LOCALBASE}
&gt;
[...]
&gt;&gt; I had a discussion in NGINX Unit about it, and
&gt;&gt; the decission for now has been: "support prefix=/usr/local for default
&gt;&gt; manual installation through the Makefile, and let BSD users adjust to
&gt;&gt; their preferred path".
&gt;
&gt; That's an *excellent* solution for the task, thanks for doing it
&gt; the right way.  By setting PREFIX=/usr/local by default in the
&gt; upstream Makefile, you are minimizing the work for *BSD porters.
&gt;
&gt; The BSD ports frameworks will typically run the upstreak "make install"
&gt; with the variable DESTDIR set to a custom value, for example
&gt;
&gt;    DESTDIR=/usr/ports/pobj/groff-1.23.0/fake-amd64
&gt;
&gt; so if the upstream Makefile sets PREFIX=/usr/local ,
&gt; that's perfect, everything gets installed to the right place
&gt; without an intervention by the person doing the porting.
&gt;
&gt; Of course, if the upstream Makefile would use some other PREFIX,
&gt; that would not be a huge obstacle.  All we have to do in that case
&gt; is pass the option --prefix=/usr/local to the ./configure script,
&gt; or something equivalent if the software isn't using GNU configure.
&gt;
&gt;&gt; We were concerned that we might get collisions
&gt;&gt; with the BSD port also installing in /usr/local, but that's the least
&gt;&gt; evil (and considering BSD users don't typically run `make install`, it's
&gt;&gt; not so bad).
&gt;
&gt; It's not bad at all.  It's perfect.
&gt;
&gt; Of course, if a user wants to install *without* the ports framework,
&gt; they have to provide their own --prefix.  But that's not an issue
&gt; because it is easy to do, and installing without a port is discouraged
&gt; anyway.

===

Directory variables should never contain a trailing slash (I've
learned that the hard way, where some things would break
unexpectedly).  Especially, make(1) is likely to have problems
when things have double slashes or a trailing slash, since it
treats filenames as text strings.  I've removed the trailing slash
from the prefix, and added it to the derivate variables just after
the prefix.  pkg-config(1) also expects directory variables to have
no trailing slash.

===

I also removed the code that would set variables as depending on
the prefix if they didn't start with a slash, because that is a
rather non-obvious behavior, and things should not always depend
on prefix, but other dirs such as $(runstatedir), so if we keep
a similar behavior it would be very unreliable.  Better keep
variables intact if set, or use the default if unset.

===

Print the real defaults for ./configure --help, rather than the actual
values.

===

I used a subdirectory under the standard /var/lib for NXT_STATE,
instead of a homemade "state" dir that does the same thing.

===

Modified the Makefile to create some dirs that weren't being
created, and also remove those that weren't being removed in
uninstall, probably because someone forgot to add them.

===

Add new options for setting the new variables, and rename some to be
consistent with the standard names.  Keep the old ones at configuration
time for compatibility, but mark them as deprecated.  Don't keep the old
ones at exec time.

===

A summary of the default config is:

Unit configuration summary:

  bin directory: ............. "/usr/local/bin"
  sbin directory: ............ "/usr/local/sbin"
  lib directory: ............. "/usr/local/lib"
  include directory: ......... "/usr/local/include"
  man pages directory: ....... "/usr/local/share/man"
  modules directory: ......... "/usr/local/lib/unit/modules"
  state directory: ........... "/usr/local/var/lib/unit"
  tmp directory: ............. "/tmp"

  pid file: .................. "/usr/local/var/run/unit/unit.pid"
  log file: .................. "/usr/local/var/log/unit/unit.log"

  control API socket: ........ "unix:/usr/local/var/run/unit/control.unit.sock"

Link: &lt;https://www.gnu.org/prep/standards/html_node/Directory-Variables.html&gt;
Link: &lt;https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html&gt;
Reviewed-by: Artem Konev &lt;a.konev@f5.com&gt;
Reviewed-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
Tested-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
Reviewed-by: Konstantin Pavlov &lt;thresh@nginx.com&gt;
Signed-off-by: Alejandro Colomar &lt;alx@nginx.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
