Bug 273495 - [NEW PORT] devel/reposilite: repository manager for Maven based artifacts in JVM ecosystem
Summary: [NEW PORT] devel/reposilite: repository manager for Maven based artifacts in ...
Status: In Progress
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Michael Osipov
URL: https://reposilite.com
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-01 09:09 UTC by Einar Bjarni Halldórsson
Modified: 2025-05-11 20:31 UTC (History)
4 users (show)

See Also:


Attachments
Adds new port, devel/reposilite (6.29 KB, application/mbox)
2023-09-01 09:09 UTC, Einar Bjarni Halldórsson
no flags Details
Add new port devel/reposilite, fixed portlint issues (6.12 KB, patch)
2023-09-01 11:15 UTC, Einar Bjarni Halldórsson
no flags Details | Diff
Patch adding devel/reposilite (9.22 KB, patch)
2025-01-24 13:32 UTC, Þorsteinn
no flags Details | Diff
Updated (139.76 KB, patch)
2025-05-09 13:09 UTC, Einar Bjarni Halldórsson
einar: maintainer-approval+
Details | Diff
New patch, now includes diff for UIDs and GIDs (9.75 KB, patch)
2025-05-09 13:52 UTC, Einar Bjarni Halldórsson
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Einar Bjarni Halldórsson 2023-09-01 09:09:43 UTC
Created attachment 244554 [details]
Adds new port, devel/reposilite

New port for reposilite [https://reposilite.com], a lightweight repository manager for Maven based artifacts.

Very useful since artifactory is now FORBIDDEN.
Comment 1 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2023-09-01 09:23:59 UTC
As you have mentioned that this is your first port, have you ran portlint -abct, portfmt, portclippy?
Have you tested this port in poudriere specially on 12.4 i386, 12.4 amd64, 13.2, amd64 and preferably 14.0 SNAPSHOT amd64?
Have you tried make index after adding the ports tree?

These are the basic checklist any committer will go through before committing so if you can do that before hand it definitely reduces the time required to commit.
Comment 2 Einar Bjarni Halldórsson 2023-09-01 09:25:56 UTC
(In reply to Muhammad Moinur Rahman from comment #1)

No, I've only tested building in poudriere on 13.2.

I'll go through the list and fix any problems I might find
Comment 3 Einar Bjarni Halldórsson 2023-09-01 11:15:54 UTC
Created attachment 244556 [details]
Add new port devel/reposilite, fixed portlint issues

Fixed issues discovered by portlint
Comment 4 Einar Bjarni Halldórsson 2023-09-01 11:32:24 UTC
Ran `port test` and fixed all warnings and errors.

I get a warning about dependecy not being declared on /usr/local/openjdk11/bin/java, but I'm not sure I need it if I have USE_JAVA and JAVA_VERSION in Makefile?

It builds in Poudriere 13.2. It just fetches the jar from upstream, so it's very unlikely that any port specific issues are found on other releases or archs
Comment 5 Michael Osipov 2023-09-04 19:36:01 UTC
Will review in the next couple of days if you leave the time for it.

Please note that there is also Nexus 2 OSS in the tree for years now.
Comment 6 Michael Osipov 2023-09-05 07:40:13 UTC
A few issues:

* Makefile:
** Should have:
NO_ARCH=	yes
NO_BUILD=	yes
NO_TEST=	yes
** Empty STRIP isn't necessary
** USE_RC_SUBR=${PORTNAME}
** REPOSILITEUSER?=${PORTNAME}
** I was once told that one should supply the DISTVERSION only and the framework will derive the PORTVERSION automatically
* reposilite.in:
** reposilite_run_dir => reposilite_rundir (similar to etcdir=
** reposilite_rundir: should be filtered from the Makefile
** reposilite_user: should be filtered from the Makefile
** reposilite_dir: does not make sense because the JAR cannot be moved, it is mandated by the Makefile (convention) especially because you have hardcoded the JAR name
** Beat me, but where does daemon(8) receive user/group to drop privs?
** Who needs this "export JAVA_HOME=${reposilite_java_home}"?
** reposilite_java_home is not used at all! reposilite_cmd completely ignores it. Totally defeats the purpose
** required_files: Does not make sense to me. Java presence is during build/installation; ${reposilite_config} is never created by you at installation time
** I believe that this is redundant: reposilite_precmd. All required trees should be created at installation time: See https://github.com/michael-o/freebsd-ports/blob/c44ab5af99444359c6baab54143f2ddf8d21d999/devel/nexus2-oss/Makefile#L106-L108 and added to pkg-plist
** This is logically wrong: ${reposilite_dir:="%%DATADIR%%"}. DATADIR is in share for static (!) files installed and used read-only at runtime. It is not a work directory. What you need is ${reposilite_workdir:="%%WORKDIR%%"} where WORKDIR points to /var/reposilite. 
** The header comment are partially inconsistent, e.g. rundir.
** folder ==> directory
** reposilite_flags or reposilite_args? Sould be args...
** reposilite_max_mem should be generalized to reposilite_java_opts. Why 32M? Leave it empty since this should be user-configured unless you know better.
** reposilite_cmd: This should not be overwritable, no?

Yes, I am picky, but the later you address the issues the more expensive it is going to be.

Please have a look at by Nexus 2 port, it separates between etcdir/rundir/workdir and datadir. Should be here as well: https://github.com/michael-o/freebsd-ports/tree/master/devel/nexus2-oss
Comment 7 Þorsteinn 2025-01-24 13:32:13 UTC
Created attachment 256953 [details]
Patch adding devel/reposilite

(In reply to Michael Osipov from comment #6)
Hello!

I'm hoping to pick this up, I've added an attachment with a patch that I think addresses the issues you pointed out if you would be available to review it.

It builds and subsequently runs on 14.2-RELEASE.

Cheers,
Þorsteinn
Comment 8 Michael Osipov freebsd_committer freebsd_triage 2025-01-24 13:43:56 UTC
(In reply to Þorsteinn from comment #7)

Noted, will try to review next week for you. This is a good alternative to fully fledged Nexus server.
Comment 9 Þorsteinn 2025-01-24 14:14:12 UTC
(In reply to Michael Osipov from comment #8)

Thanks mate!

I also have poudriere logs of the build if you'd like.
Comment 10 Michael Osipov freebsd_committer freebsd_triage 2025-01-27 11:28:28 UTC
Going through, first issue:
The JAR contains shared objects which are loaded at runtime:
* libsqlitejdbc
* libjansi
* libjnidispatch (JNA)

libsqlitejdbc contains a bundled SQLite library which is not desired because only external dependencies guarantee security issues to be addressed in time. Here we need to revive java/sqlitejdbc first, depend on it and strip the .so files from the JARs. A couple of years ago I have upstreamed all necessary changes to libsqlitejdbc to properly dynamically link with FreeBSD. It just works.
libjansi.so: In theory we can compile ourselves and I have upstreamed here as well, but since this is a small library and I know the author I am fine with it being bundled.
libjnidispatch: We have devel/jna, basically same as for libsqlitejdbc: strip the JAR and runtime depend
Comment 11 Michael Osipov freebsd_committer freebsd_triage 2025-01-27 11:38:39 UTC
I forgot, libconscrypt could also be a problem.

Reference:
$ tar tzf reposilite-3.5.20-all.jar | grep .so\$
org/sqlite/native/Linux/armv7/libsqlitejdbc.so
org/sqlite/native/Linux/arm/libsqlitejdbc.so
org/sqlite/native/Linux/x86_64/libsqlitejdbc.so
org/sqlite/native/Linux/riscv64/libsqlitejdbc.so
org/sqlite/native/Linux/x86/libsqlitejdbc.so
org/sqlite/native/Linux/ppc64/libsqlitejdbc.so
org/sqlite/native/Linux/armv6/libsqlitejdbc.so
org/sqlite/native/Linux/aarch64/libsqlitejdbc.so
org/sqlite/native/Linux-Musl/x86_64/libsqlitejdbc.so
org/sqlite/native/Linux-Musl/x86/libsqlitejdbc.so
org/sqlite/native/Linux-Musl/aarch64/libsqlitejdbc.so
org/sqlite/native/FreeBSD/x86_64/libsqlitejdbc.so
org/sqlite/native/FreeBSD/x86/libsqlitejdbc.so
org/sqlite/native/FreeBSD/aarch64/libsqlitejdbc.so
org/sqlite/native/Linux-Android/arm/libsqlitejdbc.so
org/sqlite/native/Linux-Android/x86_64/libsqlitejdbc.so
org/sqlite/native/Linux-Android/x86/libsqlitejdbc.so
org/sqlite/native/Linux-Android/aarch64/libsqlitejdbc.so
org/fusesource/jansi/internal/native/FreeBSD/x86/libjansi.so
org/fusesource/jansi/internal/native/FreeBSD/x86_64/libjansi.so
org/fusesource/jansi/internal/native/Linux/arm/libjansi.so
org/fusesource/jansi/internal/native/Linux/arm64/libjansi.so
org/fusesource/jansi/internal/native/Linux/armv6/libjansi.so
org/fusesource/jansi/internal/native/Linux/armv7/libjansi.so
org/fusesource/jansi/internal/native/Linux/ppc64/libjansi.so
org/fusesource/jansi/internal/native/Linux/x86/libjansi.so
org/fusesource/jansi/internal/native/Linux/x86_64/libjansi.so
org/fusesource/jansi/internal/native/Windows/arm64/libjansi.so
META-INF/native/libconscrypt_openjdk_jni-linux-x86_64.so
com/sun/jna/linux-x86/libjnidispatch.so
com/sun/jna/linux-x86-64/libjnidispatch.so
com/sun/jna/linux-arm/libjnidispatch.so
com/sun/jna/linux-armel/libjnidispatch.so
com/sun/jna/linux-aarch64/libjnidispatch.so
com/sun/jna/linux-ppc/libjnidispatch.so
com/sun/jna/linux-ppc64le/libjnidispatch.so
com/sun/jna/linux-mips64el/libjnidispatch.so
com/sun/jna/linux-loongarch64/libjnidispatch.so
com/sun/jna/linux-s390x/libjnidispatch.so
com/sun/jna/linux-riscv64/libjnidispatch.so
com/sun/jna/sunos-x86/libjnidispatch.so
com/sun/jna/sunos-x86-64/libjnidispatch.so
com/sun/jna/sunos-sparc/libjnidispatch.so
com/sun/jna/sunos-sparcv9/libjnidispatch.so
com/sun/jna/freebsd-x86/libjnidispatch.so
com/sun/jna/freebsd-x86-64/libjnidispatch.so
com/sun/jna/openbsd-x86/libjnidispatch.so
com/sun/jna/openbsd-x86-64/libjnidispatch.so
Comment 12 Michael Osipov freebsd_committer freebsd_triage 2025-01-27 12:10:06 UTC
Some new points:
* The configuration.cdn.sample is never provided/marked as real file (without .sample), thus cannot be handled by the pkg system properly during update/deinstall
* The JAR should be part of the pkg-plist
* The work/rundir should be likely protected, e.g., https://github.com/freebsd/freebsd-ports/blob/11dc3fd02ee2fb8de91ca0e88e0a5c0fe15575a5/devel/nexus2-oss/pkg-plist#L345-L348 and https://github.com/freebsd/freebsd-ports/blob/11dc3fd02ee2fb8de91ca0e88e0a5c0fe15575a5/devel/nexus2-oss/pkg-plist#L1-L15
* ${reposilite_rundir}/${reposilite_workdir} in reposilite.in are never declared/initialized
* reposilite.in: has user hardcoded

They are likely others as soon as you have patched these.
Comment 13 Þorsteinn 2025-01-27 15:44:50 UTC
(In reply to Michael Osipov from comment #10)

By stripping the JAR file would we just delete jnidispatch.so and libsqlitejdbc.so, re-pack the JAR file and LIB_DEPEND on devel/jna and java/sqlitejdb?

What's involved in reviving java/sqlitejdb and how would we handle that?

(In reply to Michael Osipov from comment #11)

If we're not bundling libconscrypt, wouldn't it need to be ported as well?
Comment 14 Þorsteinn 2025-01-27 15:45:39 UTC
(In reply to Michael Osipov from comment #12)

* The configuration.cdn.sample is never provided/marked as real file (without .sample), thus cannot be handled by the pkg system properly during update/deinstall

  The config file is set up as outlined in the porter's handbook here:
  https://docs.freebsd.org/en/books/porters-handbook/plist/#plist-config

  and the @sample macro here:
  https://docs.freebsd.org/en/books/porters-handbook/plist/#plist-keywords-sample

  from which I understand that only the .sample file could be given and then it would copy it to the actual config file if one doesn't exist, in a way that doesn't wipe the config on deinstall/update. Am I misunderstanding something and should I be creating it somewhere?

* The JAR should be part of the pkg-plist

  I'll move the JAR from PLIST_FILES+= to the actual pkg-plist file and update the permissions on the directories.

* The work/rundir should be likely protected

  I'll update the permissions accordingly.

* ${reposilite_rundir}/${reposilite_workdir} in reposilite.in are never declared/initialized
* reposilite.in: has user hardcoded

  My bad, they were supposed to be %%WORKDIR%% and %%REPOSILITE_USER%%, i'll update that.
Comment 15 Michael Osipov freebsd_committer freebsd_triage 2025-02-26 09:28:18 UTC
(In reply to Þorsteinn from comment #14)

Can you provide an updated patch? I'd like to finalize this one next month.
Comment 16 Ivan 2025-05-08 13:32:49 UTC
I believe, --token option with some random password should be provided and printed if workdir is empty. Reposilite starts without any users and requires interactive steps.

I hope this port will be finished, because artifactory will expire soon.
Comment 17 Michael Osipov freebsd_committer freebsd_triage 2025-05-08 14:53:59 UTC
(In reply to Ivan from comment #16)

As said, I waiting for the potential maintainer to address open issues. I need to think about devel/nexus2-oss. Whether I will migrate off or introduce a devel/nexus3-oss port.
Comment 18 Einar Bjarni Halldórsson 2025-05-08 20:35:00 UTC
I tried stripping the .so files from the jar and running it. It wouldn't start with the version of sqlitejdbc in ports, but I fetched the jar from https://github.com/xerial/sqlite-jdbc and extracted libsqlitejdbc.so and with that reposilite at least starts up.

xerial/sqlite-jdbc is in part based on the old sqlitejdbc, but it's not the same project. Is it kosher to migrate java/sqlitejdbc to new upstream, or should we create a new port?
Comment 19 Michael Osipov freebsd_committer freebsd_triage 2025-05-09 05:21:05 UTC
(In reply to Einar Bjarni Halldórsson from comment #18)

It is fine to upgrade the port. Please file an issue and wait for the maintainer to react.
Comment 20 Einar Bjarni Halldórsson 2025-05-09 13:09:42 UTC
Created attachment 260289 [details]
Updated

This addresses most of the comments from Michael, but not stripping the jar and linking with dynamic libraries from ports. I got it running, but only with sqlite-jdbc .so from github. The current version of sqlitejdbc in ports is too old and updating that port is not something we can spend time on.

We can either commit the port as-is or someone else can do the work to strip the jar and link with libraries from ports.
Comment 21 Michael Osipov freebsd_committer freebsd_triage 2025-05-09 13:25:18 UTC
(In reply to Einar Bjarni Halldórsson from comment #20)

* Why are the UIDs and GIDs files included? It should only contain a diff.
* Let's keep SQLite as-is and add a comment in the Makefile. Honestly, I do not understand at all why they use SQLite instead of H2, HSQLDB or anything else in pure Java to avoid that pain. The problem of the bundled so is that is contains an amalgamation of SQLite instead of using the port...
Comment 22 Einar Bjarni Halldórsson 2025-05-09 13:26:38 UTC
(In reply to Ivan from comment #16)

> I believe, --token option with some random password should be provided and printed if workdir is empty. Reposilite starts without any users and requires interactive steps.

Except --token option creates a *TEMPORARY* password. It's deleted as soon as the server shuts down.
Comment 23 Einar Bjarni Halldórsson 2025-05-09 13:33:12 UTC
(In reply to Michael Osipov from comment #21)

> Why are the UIDs and GIDs files included? It should only contain a diff.

UIDs and GIDs files are included becuse we're building and running this in production in poudriere using a ports overlay.

I'll create another patch that doesn't include the files but has a patch for /UIDs and /GIDs

> Let's keep SQLite as-is and add a comment in the Makefile. Honestly, I do not understand at all why they use SQLite instead of H2, HSQLDB or anything else in pure Java to avoid that pain. The problem of the bundled so is that is contains an amalgamation of SQLite instead of using the port...

From the sample config:

# Database configuration. Supported storage providers:
# - mysql localhost:3306 database user password
# - sqlite reposilite.db
# - sqlite --temporary
# Experimental providers (not covered with tests):
# - postgresql localhost:5432 database user password
# - h2 reposilite
Comment 24 Einar Bjarni Halldórsson 2025-05-09 13:52:36 UTC
Created attachment 260291 [details]
New patch, now includes diff for UIDs and GIDs