libnetconf2 icon indicating copy to clipboard operation
libnetconf2 copied to clipboard

Add homebrew tap

Open plajjan opened this issue 3 years ago • 9 comments

Please implement a Homebrew tap for installing libnetconf!

I would like to get libnetconf2 on my Mac and would prefer if I could do that in a convenient manner through Homebrew, which is my package manager of choice.

The use case is to use it for development of a netconf module for the standard library in Acton, a programming language we are developing which in turn is developed both on Linux and Mac!

I'm opening it here but I suppose I really want libyang too, since that's a dependency.

plajjan avatar Aug 11 '22 14:08 plajjan

Have you actually tried it? libyang should be fully supported on Mac but libnetconf2 is not. Specifically, there were serious problems with both SSH and TLS support so the only working setup probably is the raw NETCONF communication and SSH/TLS encryption handled by an external tool.

michalvasko avatar Aug 18 '22 08:08 michalvasko

No, I have not tried compiling libnetconf2 on mac... Started doing my development on Linux but I'm hoping to run it on mac as well, once my code is written. Tried to get ahead by ensuring that libnetconf2 is available on mac so I can easily test once I'm happy with my code :)

Do you have some extra info on the difficulties with libnetconf2 on mac? I mean libssh (which I really care about) is in homebrew for mac, as is openssl.. is there something in particular that poses a problem?

plajjan avatar Aug 18 '22 14:08 plajjan

Seems I've been able to build libnetconf2 on mac... I mean, it compiled, though I dunno if it works ;) I think it was just a single tweak, beyond setting some paths... but that tweak does indicate to me that I might be the first person attempting this. Though realizing as I type this that I did this on the master branch whereas perhaps devel is ahead...

Anyway, is there an interest at all from your side in maintaining homebrew formulas for libyang and libnetconf2? I might be able to help write the initial formulas, but would you guys be willing to host and maintain that stuff?

plajjan avatar Aug 18 '22 20:08 plajjan

How exactly did you manage that? You had to disable SSH support, did you not? SSH uses local system users to check authenticated users, which is using the Linux API and that obviously refused to be compiled on Mac.

As for TLS, the last time I tested it (years ago), I have encountered critical issues but do not remember them exactly. What I do remember is the cause, which is that OpenSSL on Mac was actually not OpenSSL but some Apple-maintained library with similar API "pretending" to be OpenSSL but behaving differently in some cases. After learning this I completely gave up having any Mac support for libnetconf2 and am not keen on getting into all this again when you have to expect the weirdest kinds of problems. Unfortunately, the same goes for the homebrew formulas. Creating them should not be a problem but maintenance is another thing. Their existence would imply official Mac support which would lead to what I have just talked about.

So I am sorry, but I do not think we will have an official formula. On the other hand, you are free to create one yourself in a forked project. I would also be willing to merge PRs and provide help with any problems to a reasonable extent.

michalvasko avatar Aug 19 '22 06:08 michalvasko

No, I did not disable SSH but again, I haven't actually gotten to run any code with this yet... I'm not sure what part it is that you are expecting to fail around SSH. At least libssh is available on Mac via Homebrew, so surely something works!? :) Is this local system users check a libnetconf2 thing or a libssh thing? i.e. when can I expect something to fail? You say compilation should fail, but I am past that!?

Indeed, Mac does not run OpenSSL (I think it's LibreSSL) per default and Homebrew generally prefers to use the OS version of things, or at the very least not contaminate / collide with the OS on things, which is why OpenSSL is "keg only" in Homebrew speak. It is installed but not reachable system wide. Other applications built / installed with Homebrew can use OpenSSL as Homebrew manages the include & lib prefixes. So if you've tried to get things working on Mac and have failed, I think it might be worthwhile trying again with the help of Homebrew since it deals with some of the nastier areas for you.

I'll try to shape up my formulas and push it to a git repo so you can have a look at it too!

plajjan avatar Aug 19 '22 09:08 plajjan

The one thing I have to change in libnetconf2 is to remove -lcrypt. It is required on Linux but AFAIU it is not required on MacOS. I got it working simply be removing those lines from the cmake config. Naturally, it should be fixed by another condition on macos (or perhaps only using -lcrypt on Linux?! do BSDs need it?)...

plajjan avatar Aug 19 '22 09:08 plajjan

I'm not sure what part it is that you are expecting to fail around SSH.

The last time I tried it, the header pwd.h was not available as weren't any of those functions.

Mac does not run OpenSSL (I think it's LibreSSL)

So I had some problems with that but I have probably not tried to install OpenSSL using homebrew.

The one thing I have to change in libnetconf2 is to remove -lcrypt.

I see, a Mac switch to not link it should be fine. It actually seems to be a part of BSD specs (based on my man page).

I'll try to shape up my formulas and push it to a git repo so you can have a look at it too!

Okay, that is a good start. Once everything is working we will see.

michalvasko avatar Aug 19 '22 09:08 michalvasko

Right, -lcrypt seems part of BSD so available out of box on macos etc. I'm really not a cmake guy so I'd rather not try to fix it but if necessary I'll take a stab at it.

I have pushed my libyang & libnetconf2 Homebrew formulae to https://github.com/plajjan/homebrew-plajjan

What is a good test case to ensure that the libraries are properly installed? For example, in the libssh Homebrew formula, they have this little small program that they test compiling to ensure the library is properly installed: https://github.com/Homebrew/homebrew-core/blob/master/Formula/libssh.rb#L34

plajjan avatar Aug 22 '22 10:08 plajjan

The libcrypt problem should be fixed but you will have to wait for another release if you want a tag. Other than that, libnetconf2 depends also on libpam. As for the test, you could write a similar small app with just server and client init and destroy functions, for example. Or compile the examples.

michalvasko avatar Aug 22 '22 13:08 michalvasko