Bug 282593 - devel/rubygem-rugged: No support for ssh
Summary: devel/rubygem-rugged: No support for ssh
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Matthias Fechner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-06 22:57 UTC by Einar Bjarni Halldórsson
Modified: 2024-11-15 15:59 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (mfechner)


Attachments
v0: bundle libgit2 (2.58 KB, patch)
2024-11-07 10:42 UTC, Nuno Teixeira
no flags Details | Diff
v1: bundled libgit2 + cleanup cmake build (2.26 KB, patch)
2024-11-07 12:28 UTC, Nuno Teixeira
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 2024-11-06 22:57:23 UTC
I just discovered that oxidized hasn't been pushing commits to the remote repo for 2 weeks.

The error in the logs is:

Hook push_to_remote (#<GithubRepo:0x00001e2179a94968>) failed (#<Rugged::NetworkError: unsupported URL protocol>) for event :post_store

I found https://github.com/ytti/oxidized/issues/3132 and tried patching the port to add `--with-ssh` to CONFIGURE_ARGS but that didn't help.
Comment 1 Einar Bjarni Halldórsson 2024-11-06 23:23:28 UTC
Looks to have been caused by https://cgit.freebsd.org/ports/commit/?id=782c642c8a10cdaeff59df09f00990e76d0392d5
Comment 2 Einar Bjarni Halldórsson 2024-11-06 23:41:54 UTC
Reverting to rubygem-rugged-1.7.2 and libgit2-1.7.2 fixed the error
Comment 3 Nuno Teixeira freebsd_committer freebsd_triage 2024-11-07 08:42:26 UTC
(In reply to Einar Bjarni Halldórsson from comment #2)

> Reverting to rubygem-rugged-1.7.2 and libgit2-1.7.2 fixed the error

Patch from 782c642 fixes liggit2 detection >1.7.0 and in fact rubygem-rugged builds fine with libgit2 1.8.*:

=>> Checking shared library dependencies
 0x0000000000000001 NEEDED               Shared library: [libc.so.7]
 0x0000000000000001 NEEDED               Shared library: [libgit2.so.1.8]
 0x0000000000000001 NEEDED               Shared library: [libm.so.5]
 0x0000000000000001 NEEDED               Shared library: [libruby32.so.32]
 0x0000000000000001 NEEDED               Shared library: [libthr.so.3]


Could you take a look at following PR and check if it is related?
https://github.com/ytti/oxidized/pull/3298

Is there a way of testing git/ssh connection with this port so a upstream PR could be submited?

Thanks
Comment 4 Einar Bjarni Halldórsson 2024-11-07 08:55:36 UTC
(In reply to Nuno Teixeira from comment #3)

Yes, it builds fine, but rugged, which oxidized uses for git operations, apparently doesn't have ssh support.
Oxidized starts, and can ssh into switches to fetch the configrations, it then commits the configs to the git repo. What fails is that I have a hook on 'post_store' which pushes commits to another git repo. For that, oxidized uses rugged, and that is the operation that fails.

The relevant part of the oxidized config looks like this:

hooks:
  push_to_remote:
    type: githubrepo
    events: [post_store]
    remote_repo: git@gitlab.isnic.is:is/nic/network-configs.git
    publickey: /var/db/oxidized/.ssh/id_rsa.pub
    privatekey: /var/db/oxidized/.ssh/id_rsa
Comment 5 Nuno Teixeira freebsd_committer freebsd_triage 2024-11-07 09:01:13 UTC
(In reply to Einar Bjarni Halldórsson from comment #4)

Digging a bit more I found that:

https://github.com/libgit2/rugged#use-the-system-provided-libgit2

"However, note that Rugged does only support specific versions of libgit2."

Port is using CONFIGURE_ARGS= --use-system-libraries.

Could you give a try building with bundled libgit2?
Comment 6 Einar Bjarni Halldórsson 2024-11-07 09:02:20 UTC
With rubygem-rugged-1.7.2_3 and libgit2-1.8.4:

$ ruby -e 'require "rugged"; puts Rugged.features'
threads
https

With rubygem-rugged-1.7.2 and libgit2-1.7.2:

$ ruby -e 'require "rugged"; puts Rugged.features'
threads
https
ssh
Comment 7 Nuno Teixeira freebsd_committer freebsd_triage 2024-11-07 09:27:05 UTC
(In reply to Nuno Teixeira from comment #5)

Before we should try building bundled libgit2 we should try first using:

CONFIGURE_ARGS= --use-system-libraries --with-ssh

I'm away from my PC to check this. I will took a look in a few hours
Comment 8 Nuno Teixeira freebsd_committer freebsd_triage 2024-11-07 10:42:54 UTC
Created attachment 254997 [details]
v0: bundle libgit2

root@rpi4:/usr/ports/devel/rubygem-rugged # ruby -e 'require "rugged"; puts Rugged.features'
threads
https
ssh

NOTES: bundled libgit2
- ssh is enabled
- adicional files added, check pkg-plist file

Please test this port revision 3 and share results.

I will continue to try toadd ssh support to original (unbundled) port.
Comment 9 Einar Bjarni Halldórsson 2024-11-07 11:29:20 UTC
(In reply to Nuno Teixeira from comment #8)

> Please test this port revision 3 and share results.

Tested and confirm that it works.

I see you added cmake:indirect to 'USES', but I don't see 'indirect' in the docs at https://docs.freebsd.org/en/books/porters-handbook/uses/#uses-cmake
Is it just missing from the docs?
Comment 10 Einar Bjarni Halldórsson 2024-11-07 11:32:37 UTC
(In reply to Einar Bjarni Halldórsson from comment #9)

> Is it just missing from the docs?

Looked through Mk/Uses/cmake.mk and I see it there. That's exactly the arg
I was looking for when I was trying to build it, but I hadn't thought of going to the makefile itself.
Comment 11 Nuno Teixeira freebsd_committer freebsd_triage 2024-11-07 11:40:23 UTC
(In reply to Einar Bjarni Halldórsson from comment #10)

My opinion is to use bundled version until upstream add support for higher libgit2 versions and then switch back to system lib build.

Any clues if we need a cleanup of aditional files? Some binaries seems not stripped...
Comment 12 Nuno Teixeira freebsd_committer freebsd_triage 2024-11-07 12:01:25 UTC
(In reply to Nuno Teixeira from comment #11)

I've checked pkg plist from original port and this one adds files to:

@dir %%GEM_LIB_DIR%%/vendor/libgit2/build/CMakeFiles/...

I will give a try to $RM -rf %%GEM_LIB_DIR%%/vendor/libgit2/build since .../build/* shouldn't be installed and update patch.
Comment 13 Einar Bjarni Halldórsson 2024-11-07 12:03:38 UTC
(In reply to Nuno Teixeira from comment #11)

> My opinion is to use bundled version until upstream add support for higher libgit2 versions and then switch back to system lib build.

I agree, but I found this deeper in the rugged readme:

> if you want to build with the system libgit2 rather than the vendored version. In this case, note that the major and minor versions of libgit2 and rugged must match.

Seeing as rugged is now lagging behind libgit2, I have a feeling this will be a regular occurrence if we keep switching to system lib build.
Comment 14 Nuno Teixeira freebsd_committer freebsd_triage 2024-11-07 12:28:15 UTC
Created attachment 254999 [details]
v1: bundled libgit2 + cleanup cmake build

- port revision 4
- cleaned build dir from cmake

NOTE: gitlab depends on this port, exp-run and run-test recommended
Comment 15 Nuno Teixeira freebsd_committer freebsd_triage 2024-11-07 12:33:37 UTC
(In reply to Einar Bjarni Halldórsson from comment #13)

I agreed with you but in a technical point of view we should use system libs when possible and avoid bundled ones.

Lets @mfechner do some tests and decide.

Cheers
Comment 16 Matthias Fechner freebsd_committer freebsd_triage 2024-11-07 12:45:14 UTC
(In reply to Nuno Teixeira from comment #15)
could you please make clear which patch I should test?
Comment 17 Nuno Teixeira freebsd_committer freebsd_triage 2024-11-07 12:50:03 UTC
(In reply to Matthias Fechner from comment #16)

v1: bundled libgit2 + cleanup cmake build
https://bugs.freebsd.org/bugzilla/attachment.cgi?id=254999

While at it it may be worth to remove dep:
"Warning: you might not need LIB_DEPENDS on libgmp.so"

As it seems that its not linked to it in bundled port.
Comment 18 commit-hook freebsd_committer freebsd_triage 2024-11-07 16:26:20 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e72515028ca9a44595cc728401c341e4858699de

commit e72515028ca9a44595cc728401c341e4858699de
Author:     Nuno Teixeira <eduardo@FreeBSD.org>
AuthorDate: 2024-11-07 16:23:01 +0000
Commit:     Matthias Fechner <mfechner@FreeBSD.org>
CommitDate: 2024-11-07 16:25:16 +0000

    devel/rubygem-rugged: use bundled ligbit2

    the current libgit2 (1.8.x) is not compatible with rugged and is
    causing problem with ssh support.

    PR:             282593
    Reported by:    einar@isnic.is

 devel/rubygem-rugged/Makefile                      | 19 +++++++----
 .../files/patch-ext_rugged_extconf.rb (gone)       | 37 ----------------------
 2 files changed, 13 insertions(+), 43 deletions(-)
Comment 19 Matthias Fechner freebsd_committer freebsd_triage 2024-11-07 16:28:16 UTC
Thanks a lot for the report, the analysis and the provided patch.
I switched to bundled libgit, I hope that fixes your problem.

Gitlab showed no problem using this version while I did some tests.
Comment 20 commit-hook freebsd_committer freebsd_triage 2024-11-15 15:59:05 UTC
A commit in branch 2024Q4 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=8f668fba0d28f6faef186bfdc1e9d233c559e237

commit 8f668fba0d28f6faef186bfdc1e9d233c559e237
Author:     Nuno Teixeira <eduardo@FreeBSD.org>
AuthorDate: 2024-11-07 16:23:01 +0000
Commit:     Matthias Fechner <mfechner@FreeBSD.org>
CommitDate: 2024-11-15 15:56:44 +0000

    devel/rubygem-rugged: use bundled ligbit2

    the current libgit2 (1.8.x) is not compatible with rugged and is
    causing problem with ssh support.

    PR:             282593
    Reported by:    einar@isnic.is

    (cherry picked from commit e72515028ca9a44595cc728401c341e4858699de)

 devel/rubygem-rugged/Makefile                      | 18 ++++++++---
 .../files/patch-ext_rugged_extconf.rb (gone)       | 37 ----------------------
 2 files changed, 13 insertions(+), 42 deletions(-)