Configure phase fails because file with same name as WRKSRC cannot be created

I started porting iocaine, a garbage generator to "poison AI bots". I'm using poudriere.
I'm stuck in the configure phase with the error:
Code:
=======================<phase: configure      >============================          
===== env: NO_DEPENDS=yes USER=nobody UID=65534 GID=65534                            
===>  Configuring for iocaine-2.1.0                                                  
/bin/sh: cannot create /wrkdirs/usr/ports/www/iocaine/work/iocaine: Is a directory  
*** Error code 2

I followed the instructions in https://docs.freebsd.org/en/books/porters-handbook/makefiles/#makefile-wrksrc, because the tarball extracts to iocaine instead of iocaine-2.1.0:

Code:
PORTNAME=       iocaine
DISTVERSION=    2.1.0
CATEGORIES=     www

MAINTAINER=     me@jcpsantiago.xyz
COMMENT=        The deadliest poison known to AI.
WWW=            https://iocaine.madhouse-project.org/

LICENSE=        MIT

USES=           cargo
USE_RC_SUBR=    iocaine

MASTER_SITES=   https://git.madhouse-project.org/${PORTNAME}/${PORTNAME}/archive/

WRKSRC=         ${WRKDIR}/${PORTNAME}

USERS=          www
GROUPS=         www

.include <bsd.port.mk>

I'm assuming the error means it's trying to create the dir, so I looked into bsd.ports.mk, and the only relevant mkdir I see is in https://github.com/freebsd/freebsd-...21289041488bae032c3ccbf6/Mk/bsd.port.mk#L3306, but it should be triggered if HAS_CONFIGURATION is set, which is not the case. I also checked if cargo.mk was overriding the configure phase and I don't see it. If this is not about creating a dir, I don't know where the steps are coded to check what's happening.

I also tried adding

Code:
HAS_CONFIGURE=  yes
CONFIGURE_WRKSRC= ${WRKDIR}/${DISTNAME}

but that did not change the error message (which I feel is strange, because the line I reference above explicitly mkdir the configure_wrksrc.

So I'm lost. I feel this is a trivial thing but I can't see and would appreciate some help in pointing me in the right direction :)
 
The plot thickens a bit and this doesn't make sense to me, so I'm starting from scratch and detailing here step by step what I'm doing.
Here's the barebones, starting point Makefile including some debugging code:

Code:
PORTNAME=    iocaine
DISTVERSION=    2.1.0
CATEGORIES=    www

MAINTAINER=    me@jcpsantiago.xyz
COMMENT=    The deadliest poison known to AI.
WWW=        https://iocaine.madhouse-project.org/

LICENSE=    MIT

USES=        cargo
USE_RC_SUBR=    iocaine

MASTER_SITES=    https://git.madhouse-project.org/${PORTNAME}/${PORTNAME}/archive/

USERS=        www
GROUPS=        www

post-extract:
    @echo "===== DEBUG: post-extract WRKSRC ====="
    @ls -la ${WRKSRC}
    @echo "===== DEBUG: post-extract WRKDIR ====="
    @ls -la ${WRKDIR}
    @echo "===== DEBUG: post-extract WRKDIR/iocaine ====="
    @ls -la ${WRKDIR}/iocaine

.include <bsd.port.mk>

I'm starting clean, so I need a distinfo file which I create with doas make makesum (I'm working from /usr/local/poudriere/ports/default/www/iocaine. The tarball is downloaded
Code:
> doas make makesum
===>  License MIT accepted by the user
===>  License MIT accepted by the user
===>   iocaine-2.1.0 depends on file: /usr/local/sbin/pkg - found
=> iocaine-2.1.0.tar.gz doesn't seem to exist in /usr/local/poudriere/ports/default/distfiles/.
=> Attempting to fetch https://git.madhouse-project.org/iocaine/iocaine/archive/iocaine-2.1.0.tar.gz
iocaine-2.1.0.tar.gz                                    44 kB  542 kBps    00s
===> Fetching all distfiles required by iocaine-2.1.0 for building

and distinfo becomes
Code:
TIMESTAMP = 1747413294
SHA256 (iocaine-2.1.0.tar.gz) = 54ce886b970092d696fe666a05ea498b09fa3046c5a78a197fcfde23ce48bfe9
SIZE (iocaine-2.1.0.tar.gz) = 45512

All good so far. Now onto doas make cargo-crates, which is our first failure:

Code:
> doas make cargo-crates
===>  License MIT accepted by the user
===>   iocaine-2.1.0 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by iocaine-2.1.0 for building
===>  Extracting for iocaine-2.1.0
=> SHA256 Checksum OK for iocaine-2.1.0.tar.gz.
===>  Moving crates to /usr/local/poudriere/ports/default/www/iocaine/work/iocaine-2.1.0/cargo-crates
===== DEBUG: post-extract WRKSRC =====
total 3
drwxr-xr-x  3 root wheel 3 May 16 18:37 .
drwxr-xr-x  4 root wheel 4 May 16 18:37 ..
drwxr-xr-x  2 root wheel 2 May 16 18:37 cargo-crates
===== DEBUG: post-extract WRKDIR =====
total 20
drwxr-xr-x   4 root wheel  4 May 16 18:37 .
drwxr-xr-x   4 root wheel  8 May 16 18:37 ..
drwxr-xr-x  10 root wheel 21 Apr 26 21:42 iocaine
drwxr-xr-x   3 root wheel  3 May 16 18:37 iocaine-2.1.0
===== DEBUG: post-extract WRKDIR/iocaine =====
total 21
drwxr-xr-x  10 root wheel    21 Apr 26 21:42 .
drwxr-xr-x   4 root wheel     4 May 16 18:37 ..
-rw-r--r--   1 root wheel   129 Apr 26 21:42 .envrc
drwxr-xr-x   4 root wheel     4 Apr 26 21:42 .forgejo
-rw-r--r--   1 root wheel   241 Apr 26 21:42 .gitattributes
-rw-r--r--   1 root wheel   188 Apr 26 21:42 .gitignore
-rw-r--r--   1 root wheel  3642 Apr 26 21:42 CHANGELOG.md
-rw-r--r--   1 root wheel 70648 Apr 26 21:42 Cargo.lock
-rw-r--r--   1 root wheel  2106 Apr 26 21:42 Cargo.toml
drwxr-xr-x   2 root wheel     3 Apr 26 21:42 LICENSES
-rw-r--r--   1 root wheel  3045 Apr 26 21:42 README.md
-rw-r--r--   1 root wheel   975 Apr 26 21:42 REUSE.toml
drwxr-xr-x   3 root wheel     4 Apr 26 21:42 benches
-rw-r--r--   1 root wheel   185 Apr 26 21:42 build.rs
drwxr-xr-x   3 root wheel     7 Apr 26 21:42 data
-rw-r--r--   1 root wheel  3140 Apr 26 21:42 flake.lock
-rw-r--r--   1 root wheel  3217 Apr 26 21:42 flake.nix
drwxr-xr-x   2 root wheel     7 Apr 26 21:42 nix
drwxr-xr-x   4 root wheel    14 Apr 26 21:42 src
drwxr-xr-x   2 root wheel     3 Apr 26 21:42 templates
drwxr-xr-x   3 root wheel     4 Apr 26 21:42 tests
===> /usr/local/poudriere/ports/default/www/iocaine/work/iocaine-2.1.0/Cargo.lock not found.  Trying to generate it...
error: manifest path `/usr/local/poudriere/ports/default/www/iocaine/work/iocaine-2.1.0/Cargo.toml` does not exist
*** Error code 101

Stop.
make: stopped in /usr/local/poudriere/ports/default/www/iocaine

We see the tarball extracted into ${WRKDIR}/${PORTNAME} instead the expected/default (as in bsd.ports.mk) ${WRKDIR}/${DISTNAME}. That's ok, the Porter's handbook mentions this exact issue, so we add
Code:
WRKSRC=        ${WRKDIR}/${PORTNAME}

to the Makefile and run doas make cargo-crates again and now a list of crates is printed. I create a
Makefile.crates with this list and run
doas make makesum again. This leads to a flurry of downloads and checksums. Great.

Now, another odd (to me) thing happens: the distinfo file was completely overwritten — there's no more mention of iocaine-2.1.0.tar.gz. Maybe this is normal? I press on, because nowhere online could I find someone complaining about this (it's possible I didn't hit the right keywords).

Next step is to build this with doas poudriere bulk -b latest -j 142amd64 -f ~/pkgs-to-build.
Here's the same debugging statement, which before (running "locally" outside the poudriere jail during the make command) was showing WRKDIR/iocaine full of stuff (this is post-extract):
Code:
===>  Moving crates to /wrkdirs/usr/ports/www/iocaine/work/iocaine/cargo-crates
===== DEBUG: post-extract WRKSRC =====
total 18
drwxr-xr-x    3 nobody wheel    64 May 16 16:48 .
drwxr-xr-x    3 nobody wheel    64 May 16 16:48 ..
drwxr-xr-x  292 nobody wheel 18560 May 16 16:48 cargo-crates
===== DEBUG: post-extract WRKDIR =====
total 0
drwxr-xr-x  3 nobody wheel 64 May 16 16:48 .
drwxr-xr-x  3 nobody wheel 64 May 16 16:48 ..
drwxr-xr-x  3 nobody wheel 64 May 16 16:48 iocaine
===== DEBUG: post-extract WRKDIR/iocaine =====
total 18
drwxr-xr-x    3 nobody wheel    64 May 16 16:48 .
drwxr-xr-x    3 nobody wheel    64 May 16 16:48 ..
drwxr-xr-x  292 nobody wheel 18560 May 16 16:48 cargo-crates

Now it's empty, and after that, in the configuration phase:

Code:
=======================<phase: configure      >============================
===== env: NO_DEPENDS=yes USER=nobody UID=65534 GID=65534
===>  Configuring for iocaine-2.1.0
/bin/sh: cannot create /wrkdirs/usr/ports/www/iocaine/work/iocaine: Is a directory
*** Error code 2

Stop.
make: stopped in /usr/ports/www/iocaine

So:
  • There's no source code at all
  • Something (I still can't figure out what) is trying to write to /wrkdirs/usr/ports/www/iocaine/work/iocaine as if it was a file, but it's in fact a directory. I imagine something from the cargo macros, but I don't know what.
I tried adding
Code:
SHA256 (iocaine-2.1.0.tar.gz) = 54ce886b970092d696fe666a05ea498b09fa3046c5a78a197fcfde23ce48bfe9
SIZE (iocaine-2.1.0.tar.gz) = 45512

by hand to the distinfo file, but that still made no difference: the ls statements still show no files and the "Is a directory" error is still there. Only removing all the crates from the distinfo file and the Makefiles.crates resulted in the tarball being extracted and the iocaine dir being correctly populated inside poudriere.
At this stage it feels like I have 2 problems: why is the tarball not being used? and what command is trying to write to iocaine as if it was a file?
 
Have you succeeded with this?

I also just tried to build iocaine and version 2.0.0 builds fine for me as is by unpacking the tarball and just run cargo build --release.
Versions after 2.0.0 use jemalloc, which is FreeBSDs default memory allocator, yet somehow rust folks managed to make it not build on FreeBSD... After disabling it as a default build option, Version 2.2.0 also builds fine. IIUC, since FreeBSD uses jemalloc anyways, it doesn't matter what cargo/rust uses (???)

To run it one needs some word file (e.g. /usr/share/dict/words) and some random text(s), e.g. by fetch https://www.gutenberg.org/ebooks/`jot -r 1 1 75000`.txt.utf-8 (this could be re-run periodically or on every service startup to always use another random text)


I've never had to deal with rust in a port before (and already regret that I started to...), and I too can't get it to work - as soon as cargo gets involved, the make process only cares about the insane amount of dependencies listed in CARGO_CRATES, but doesn't even fetch/extract the actual thing (iocaine) that the makefile is supposed to build. Hence poudriere testport fails right at the beginning of the configure phase, because there's nothing to configure...

Can someone knowledgeable about rust ports chime in and give me/us a hint in the right direction?

heres my current Makefile:
Code:
PORTNAME=       iocaine
DISTVERSION=    2.2.0
CATEGORIES=     www 

MAINTAINER=     sko@rostwald.de
COMMENT=        The deadliest poison known to AI. 
WWW=            https://iocaine.madhouse-project.org/

LICENSE=        MIT 

USES=           cargo
USE_RC_SUBR=    iocaine


#MASTER_SITES=   https://git.madhouse-project.org/${PORTNAME}/${PORTNAME}/archive/

# rust jemalloc is broken and set as a default feature
CARGO_FEATURES= '--no-default-features'

OPTIONS_DEFINE= JEMALLOC TOKIO

JEMALLOC_DESC?= Use tikv-jemallocator (BROKEN on FreeBSD)
JEMALLOC_VARS= CARGO_FEATURES+=jemalloc
TOKIO_DESC?= Tokio debugger console
TOKIO_VARS= CARGO_FEATURES+=tokio-console

USERS=          www 
GROUPS=         www 

CARGO_CRATES=   addr2line-0.24.2 \
[...] (omitted the >400 dependencies listed here...)

.include <bsd.port.mk>

and here's the tail of the buildlog from poudriere testport:
Code:
===>   Returning to build of iocaine-2.2.0
===========================================================================
=======================<phase: lib-depends    >============================
===== env: DEVELOPER_MODE=yes USE_PACKAGE_DEPENDS_ONLY=1 USER=root UID=0 GID=0
===========================================================================
=>> Recording filesystem state for prebuild... done
=======================<phase: configure      >============================
===== env: DEVELOPER_MODE=yes STRICT_DEPENDS=yes USER=root UID=0 GID=0
===>   iocaine-2.2.0 depends on package: rust>=1.85.0 - found
===>   iocaine-2.2.0 depends on file: /usr/local/bin/ccache - found
===>  Configuring for iocaine-2.2.0
===>   Additional optimization to port applied
===>   Cargo config:
[source.cargo]
directory = '/wrkdirs/usr/ports/www/iocaine/work/iocaine-2.2.0/cargo-crates'
[source.crates-io]
replace-with = 'cargo'
grep: /wrkdirs/usr/ports/www/iocaine/work/iocaine-2.2.0/Cargo.toml: No such file or directory
===>   Updating Cargo.lock
error: failed to parse manifest at `/wrkdirs/usr/ports/www/iocaine/work/iocaine-2.2.0/Cargo.toml`

Caused by:
  manifest is missing either a `[package]` or a `[workspace]`
*** Error code 101

Stop.
make: stopped in /usr/ports/www/iocaine
build of www/iocaine | iocaine-2.2.0 ended at Tue Jun 17 17:09:12 CEST 2025
build time: 00:01:20
!!! build failure encountered !!!
(full log: https://pkg.rostwald.de/data/FreeBS...06-17_17h07m35s/logs/errors/iocaine-2.2.0.log)
 
Hey sko ! Nope, I was stuck, documented the process as best as I could above and then moved on to other software I wanted to write ports for. I'm still very interested in having a port of iocaine but I don't understand what's happening. I was able to build other ports (as explained before with chhoto-url) but here the poudriere is making something weird because of the way the software is packaged. I haven't tried hosting it myself and packaging differently to see if poudriere would be happier — maybe this is indeed the way to go and then kindly request the author to change the packaging structure.
 
I've fiddled with that and fixed the thing that overrides actual source code with cargo crates. Now while building it, build get almost done but then it gives a programming error, i guess some socket feature exist on linux but not on freebsd? Tried the unix_socket without abstract, though but got another problem, like it wants &str?

Makefile:
PORTNAME=    iocaine
DISTVERSION=    2.3.0
CATEGORIES=    www
MASTER_SITES=    https://git.madhouse-project.org/iocaine/iocaine/archive/
# explicit: normally DISTFILES doesn't include the source code tar archive.
DISTFILES+=    ${PORTNAME}-${DISTVERSION}${EXTRACT_SUFX}

MAINTAINER=    nxjoseph@protonmail.com
COMMENT=    Deadliest poison known to AI
WWW=        https://iocaine.madhouse-project.org \
        https://git.madhouse-project.org/iocaine/iocaine

LICENSE=    MIT
LICENSE_FILE=    ${WRKSRC}/LICENSES/MIT.txt

USES=        cargo gmake

# explicit: need to set, otherwise fails to go ahead
WRKSRC=        ${WRKDIR}/${PORTNAME}

.include <bsd.port.mk>

Attached the patch (easter egg in pkg-descr :D).
 

Attachments

  • 2025-06-24-223621_1920x1080_scrot.png
    2025-06-24-223621_1920x1080_scrot.png
    287.3 KB · Views: 43
  • iocaine.patch.txt
    iocaine.patch.txt
    81.5 KB · Views: 27
I've fiddled with that and fixed the thing that overrides actual source code with cargo crates. Now while building it, build get almost done but then it gives a programming error, i guess some socket feature exist on linux but not on freebsd? Tried the unix_socket without abstract, though but got another problem, like it wants &str?

It should build & run fine - at least it did for me when manually building it via cargo build (and disabling jemalloc). I'm currently running it on 2 hosts, one of which seems to attract openai/GPTbot, which of course completely ignores the robots.txt. Within a week Iocaine has already fed over 1GB of garbage to that garbage bot.
I'm also investigating turning it into a tarpit by setting limit_rate to 3 bytes/sec after 20 connections ( limit_rate_after 20) at the angie reverse proxy that sits before iocaine.

I'll have a look at your patch tomorrow and try to get it to build.
 
With this patch, it builds fine (in poudriere testport) and can be ran but i guess iocaine wants to be configured before running for first time.


freebsd:~
% iocaine

thread 'main' panicked at src/bin/iocaine.rs:68:71:
Failed to load configuration from config.toml (and environment variables): missing field `sources`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Abort

freebsd:~
% pkg info -l iocaine
iocaine-2.3.0:
/usr/local/bin/iocaine
/usr/local/bin/iocaine-handler-test
/usr/local/etc/iocaine/config.toml.sample
/usr/local/share/licenses/iocaine-2.3.0/LICENSE
/usr/local/share/licenses/iocaine-2.3.0/MIT
/usr/local/share/licenses/iocaine-2.3.0/catalog.mk

freebsd:~
% cat /usr/local/etc/iocaine/config.toml
# SPDX-FileCopyrightText: 2025 Gergely Nagy
# SPDX-FileContributor: Gergely Nagy
#
# SPDX-License-Identifier: MIT

[server]
bind = "0.0.0.0:42069"

[sources]
words = "/data/wordlist.txt"
markov = ["/data/training-text.txt"]
 

Attachments

After quite a lot of fiddling around, I finally got poudriere to start the build.
However - as soon as I set 'USE_RC_SUBR' (which is mandatory if it should run as a service...), poudriere tries to overwrite the working directory at the configure phase:

Code:
[...]
=======================<phase: configure      >============================
===== env: DEVELOPER_MODE=yes STRICT_DEPENDS=yes USER=root UID=0 GID=0
===>   iocaine-2.2.0 depends on package: rust>=1.85.0 - found
===>   iocaine-2.2.0 depends on package: gmake>=4.4.1 - found
===>   iocaine-2.2.0 depends on file: /usr/local/bin/ccache - found
===>  Configuring for iocaine-2.2.0
/bin/sh: cannot create /wrkdirs/usr/ports/www/iocaine/work/iocaine: Is a directory
*** Error code 2

I've tried various variants for WRKSRC, WRKSRC_SUBDIR, CARGO_TARGET_DIR, CARGO_DIST_SUBDIR but those all don't influence the fact that poudriere wants to overwrite the already existing workdir...

Another headdesk moment was, that CARGO_FEATURES actually needs to be CARGO_BUILD_ARGS, otherwise poudriere claims that iocaine doesn't have an '--no-default-features' option - which it has and the porters handbook explicitily mentions for CARGO_FEATURES...

But at last, with the following Makefile (and the Makefile.crates) poudriere testport finishes the build (on 14.3-RELEASE and quarterly ports tree) and then chokes at the not-yet-existing pkg-plist:
Code:
PORTNAME=       iocaine
DISTVERSION=    2.2.0
CATEGORIES=     www

MAINTAINER=     whoever@somewhere.org
COMMENT=        The deadliest poison known to AI.
WWW=            https://iocaine.madhouse-project.org/

LICENSE=        MIT
LICENSE_FILE=   ${WRKSRC}/LICENSES/MIT.txt

USES=           cargo gmake
## poudriere tries to overwrite the WRKDIR at the configure phase when this is enabled
#USE_RC_SUBR=    iocaine


MASTER_SITES=   https://git.madhouse-project.org/${PORTNAME}/${PORTNAME}/archive/
DISTFILES+=     ${PORTNAME}-${DISTVERSION}${EXTRACT_SUFX}
WRKSRC=         ${WRKDIR}/${PORTNAME}

# rust jemalloc is broken and set as a default feature
CARGO_BUILD_ARGS= '--no-default-features'

OPTIONS_DEFINE= JEMALLOC TOKIO-CONSOLE

JEMALLOC_DESC?= Use tikv-jemallocator (BROKEN on FreeBSD)
JEMALLOC_VARS= CARGO_BUILD_ARGS+=jemalloc
TOKIO-CONSOLE_DESC?= Tokio debugger console
TOKIO-CONSOLE_VARS= CARGO_BUILD_ARGS+=tokio-console

USERS=          www
GROUPS=         www

.include <bsd.port.mk>


So now it's time to generate the plist to pick the few files actually needed (i.e. the binary, config.toml and the template) and of course get poudriere to include the rc-file without nuking the workdir...

I'd also consider not using the www user/group and giving iocaine a separate non-privileged user+group and adding the www user to that group to access the socket. (That's how I currently run it)
 
I don't think that use rc subr knob makes it the override thing. I've already fixed those in my patch, why don't you continue from my patch or at least add missing knobs from my patch to yours and test after that.
 
Sorry, I somehow overlooked your last post and used the Makefile/patch from post #5. I also just realised you are already building version 2.3.0 where they seem to have fixed the jemalloc build error - or the upstream dependency did; at least jemalloc now builds without CARGO_BUILD_ARGS= '--no-default-features'. I'd still add jemalloc and tokio as build options, as they add quite a bit to the build time and resulting binary size.


I don't think that use rc subr knob makes it the override thing.

Adding
Code:
USE_RC_SUBR= iocaine
to your Makefile from the patch in #7 leads to the exact same error:

Code:
===========================================================================
=>> Recording filesystem state for prebuild... done
=======================<phase: configure      >============================
===== env: DEVELOPER_MODE=yes STRICT_DEPENDS=yes USER=root UID=0 GID=0
===>   iocaine-2.3.0 depends on package: rust>=1.85.0 - found
===>   iocaine-2.3.0 depends on package: pkgconf>=1.3.0_1 - found
===>   iocaine-2.3.0 depends on package: gmake>=4.4.1 - found
===>   iocaine-2.3.0 depends on file: /usr/local/bin/ccache - found
===>   iocaine-2.3.0 depends on shared library: libcurl.so - found (/usr/local/lib/libcurl.so)
===>  Configuring for iocaine-2.3.0
/bin/sh: cannot create /wrkdirs/usr/ports/www/iocaine/work/iocaine: Is a directory
*** Error code 2

Stop.
make: stopped in /usr/ports/www/iocaine
[00:00:33] Saving www/iocaine | iocaine-2.3.0 wrkdir

The problem is, that the build process tries to move the rc-file 'iocaine' into ${WRKDIR}, which collides with the name of the ${WRKSRC}. This is why I added '-${DISTVERSION' to the ${WRKSRC} (-> WRKSRC= ${WRKDIR}/${PORTNAME}-${DISTVERSION}) and then tried to get everything extracted into this directory; but the tarball includes the extra parent dir 'iocaine' (which earlier by accident matched the ${WRKSRC} and therefore placed the files correctly).
After only changing the $WRKSRC, the ${WRKDIR} now contains the folders 'iocaine' and 'iocaine-2.3.0' (=${WRKSRC}) when it should only contain the latter, holding the 'cargo-crates' directory and the contents of 'iocaine':
Code:
sko@buildhost1:/usr/local/poudriere/ports/quarterly/www/iocaine $ ll work/
total 10
-rw-r--r--   1 root wheel  0 Jun 25 14:01 .extract_done.iocaine._usr_local
drwxr-xr-x  11 root wheel 24 Jun 22 10:31 iocaine/          <-- the parent directory from the tarball
drwxr-xr-x   3 root wheel  3 Jun 25 14:00 iocaine-2.3.0/       <-- the ${WRKSRC} where everything should end up (already contains 'cargo-crates')

To get the tarball extracted into the ${WRKSRC} *without* the additionall 'iocaine' directory, I tried to leverage 'do-extract' with ${TAR}, but this throws off cargo when it tries to move around files at the end of extract (no idea why - maybe it doesn't like that the ${WRKSRC} isn't empty when it moves 'cargo-crates' there), so I came up with this abomination for now:
Code:
post-extract:
    @${MV} ${WRKSRC}/cargo-crates ${WRKDIR}/${PORTNAME}/
    @${RMDIR} ${WRKSRC}
    @${MV} ${WRKDIR}/${PORTNAME} ${WRKSRC}
(just moving the contents of the extracted 'iocaine' folder wasn't possible in a trivial way, as it contains dotfiles and using a wildcard of 'iocaine/.*' of course leads to an error for '.' - I really hope/am firmly convinced this can be achieved more elegantly)

The ${WRKDIR} then looks as follows after make configure:
Code:
sko@buildhost1:/usr/local/poudriere/ports/quarterly/www/iocaine $ ll work/
total 22
drwxr-xr-x   2 root wheel     3 Jun 25 13:39 .cargo/
-rw-r--r--   1 root wheel     0 Jun 25 13:39 .configure_done.iocaine._usr_local
-rw-r--r--   1 root wheel     0 Jun 25 13:38 .extract_done.iocaine._usr_local
-rw-r--r--   1 root wheel 15881 Jun 25 13:38 .license-catalog.mk
-rw-r--r--   1 root wheel    68 Jun 25 13:38 .license-report
-rw-r--r--   1 root wheel     0 Jun 25 13:38 .license_done.iocaine._usr_local
-rw-r--r--   1 root wheel     0 Jun 25 13:38 .patch_done.iocaine._usr_local
drwxr-xr-x   2 root wheel     4 Jun 25 13:39 cargo-home/
-rwxr-xr-x   1 root wheel 10648 Jun 25 13:39 compat11_canary*
-rw-r--r--   1 root wheel  1751 Jun 25 13:39 iocaine                  <-- rc-file
drwxr-xr-x  12 root wheel    25 Jun 25 13:38 iocaine-2.3.0/          <-- the ${WRKSRC}

i.e. the 'iocaine' rc-file can placed in ${WRKDIR} without colliding with the name of the ${WRKSRC} and the build contains the rc-file
poudriere testport succeeds with those additions to your patch from post #7

I'm currently adding the last few bits to the port, e.g.:
- a working default config file which binds to a unix socket (as recommended by the documentation)
- the templates from the tarball (required to run iocaine)
- pkg-message with hints on initial configuration and using books from project gutenberg (I don't think it's wise to include this as a script due to wildly varying copyright laws and also to respect their Terms of Use)
 
No problems for me but I don't have the courage to complete the port with the additionals as I don't have any interest in this port but can help about ports framework problems as far as i know.

Code:
root@143amd64-default:/usr/ports/www/iocaine # make configure
===>  Patching for iocaine-2.3.0
===>  Applying FreeBSD patches for iocaine-2.3.0 from /usr/ports/www/iocaine/files
===>   iocaine-2.3.0 depends on package: rust>=1.87.0 - found
===>   iocaine-2.3.0 depends on package: pkgconf>=1.3.0_1 - found
===>   iocaine-2.3.0 depends on package: gmake>=4.4.1 - found
===>   iocaine-2.3.0 depends on file: /usr/local/bin/ccache - found
===>   iocaine-2.3.0 depends on shared library: libcurl.so - found (/usr/local/lib/libcurl.so)
===>  Configuring for iocaine-2.3.0
===>   Additional optimization to port applied
===>   Cargo config:
[source.cargo]
directory = '/wrkdirs/usr/ports/www/iocaine/work/iocaine/cargo-crates'
[source.crates-io]
replace-with = 'cargo'
===>   Updating Cargo.lock
     Locking 0 packages to latest Rust 1.85 compatible versions
note: to see how you depend on a package, run `cargo tree --invert --package <dep>@<ver>`
root@143amd64-default:/usr/ports/www/iocaine #


root@143amd64-default:/usr/ports/www/iocaine # ls `make -V WRKSRC`
.cargo         .gitattributes build.rs       Cargo.toml     flake.lock     justfile       README.md      templates
.envrc         .gitignore     cargo-crates   CHANGELOG.md   flake.nix      LICENSES       REUSE.toml     tests
.forgejo       benches        Cargo.lock     data           HACKING.md     nix            src

root@143amd64-default:/usr/ports/www/iocaine # echo `make -V WRKSRC`
/wrkdirs/usr/ports/www/iocaine/work/iocaine

root@143amd64-default:/usr/ports/www/iocaine # ls `make -V WRKSRC`/cargo-crates | head -5
addr2line-0.24.2
adler2-2.0.0
ahash-0.7.8
ahash-0.8.11
aho-corasick-0.7.20

root@143amd64-default:/usr/ports/www/iocaine # ls -1F `make -V WRKDIR`
.cargo/
.ccache@
.configure_done.iocaine._usr_local
.extract_done.iocaine._usr_local
.license_done.iocaine._usr_local
.license-catalog.mk
.license-report
.patch_done.iocaine._usr_local
cargo-home/
compat11_canary*
iocaine/

I think that somehow that main problem arises because the iocaine-${DISTVERSION}.tar.gz source code archive, unusually, isn't included in $DISTFILES by default so that it doesn't get extracted. Adding that archive to DISTFILES and setting $WRKSRC fixes that.

Before adding source code archive to $DISTFILES:
Code:
# make -V DISTFILES | awk '{print $1,$2,$3}'
rust/crates/addr2line-0.24.2.crate:_cargo_1 rust/crates/adler2-2.0.0.crate:_cargo_2 rust/crates/ahash-0.7.8.crate:_cargo_3
After:
Code:
# make -V DISTFILES | awk '{print $1,$2,$3}'
iocaine-2.3.0.tar.gz rust/crates/addr2line-0.24.2.crate:_cargo_1 rust/crates/adler2-2.0.0.crate:_cargo_2

From my Makefile, you need things marked as explicit.
 
I've put everything together and the attached patch is the current state of the port in my local tree (quarterly; but it also built fine on latest yesterday).
I still had to do the ugly post-extract mv/rmdir/mv to get all files into the WRKSRC, but the port builds, runs, includes all necessary files and a brief description how to get started in pkg-message.
The Makefile might still need some cleanup; apart from the post-extract I also couldn't get 'CARGO_FEATURES' to work as advertised in the porters handbook, so it's 'CARGO_BUILD_ARGS' for now.

Huge thanks for all the help nxjoseph !


I think that somehow that main problem arises because the iocaine-${DISTVERSION}.tar.gz source code archive, unusually, isn't included in $DISTFILES by default so that it doesn't get extracted. Adding that archive to DISTFILES and setting $WRKSRC fixes that.

cargo puts everything in $DISTFILES/cargo-crates as it should; but the iocaine-tarball holds that additional 'iocaine' folder, which is extracted in to $WRKDIR - where make tries to move the rc-file which is also named 'iocaine'.
Extracting the tarball into $WRKSRC also fails, because the files within that extra 'iocaine' directory need to be directly under $WRKSRC, where the 'cargo-crates' already are. And cargo complains if there is already something - even completely unrelated - in the CARGO_VENDOR_DIR before it starts to move cargo-crates into that directory.
Setting 'CARGO_VENDOR_DIR' to point into $WRKSRC/iocaine also does not work, as either $TAR won't write into that path afterwards or $MV complains that $WRKSRC isn't empty if I try to 'post/extract; $MV $WRKDIR/iocaine to $WRKSRC/ (the -f flag for mv which would solve this is of course ignored...).

So it seems the only viable option is to first let cargo do its thing with default settings so it doesn't blow up, then let the extract phase do its thing (to the $WRKDIR, which is wrong in that case, but otherwise it won't extract for one reason or another) and THEN move everything around so it can be build...
 

Attachments

[CFT]

I fixed some issues with the variables used in the rc-file (which I missed because I'm an idiot and forgot to remove my local file and never actually used the one from the built port/pkg), added the 'reload' command to it and made some other minor fixes/improvements. Attached is the current version that was also tested for portlint errors and should be fit (I hope?) for requesting it as a new port.

It would be nice if some people can test that diff and give some feedback.


Version 2.4.0 will bring persistent metrics; I'll add that as soon as it's released and I find the time to test it.


nxjoseph:
You mentioned not having any interest in this port; so would it be OK with you if I set myself as a maintainer for the port? Of course I'll give you credit for all your help in the commit message (or how/where is the correct place for that when submitting a new port?)
 

Attachments

It would be nice if some people can test that diff and give some feedback.
I can test the patch in poudriere later.

I fixed some issues with the variables used in the rc-file (which I missed because I'm an idiot and forgot to remove my local file and never actually used the one from the built port/pkg), added the 'reload' command to it and made some other minor fixes/improvements. Attached is the current version that was also tested for portlint errors and should be fit (I hope?) for requesting it as a new port.
Thanks for your work!

nxjoseph:
You mentioned not having any interest in this port; so would it be OK with you if I set myself as a maintainer for the port?
Sure, go ahead. :)

Of course I'll give you credit for all your help in the commit message (or how/where is the correct place for that when submitting a new port?)
To be honest, I don't know, I wanted to do the same for a committer that really helped me through a PR, too.
 
  • Thanks
Reactions: sko
Update:

The maintainer of iocaine, Gergely Nagy, resolved the PR in record time, fixing both issues we earlier needed patches for; so those patches are no longer necessary and have been removed. A new patch version has just been released.
I updated the diff for that new version 2.4.1 and submitted it as a new port: PR 287944

Feel free to grab the diff and test it, any feedback is welcome!
 
Back
Top