Bug 259809 - cad/ngspice_rework: Eliminate conflict between flavors
Summary: cad/ngspice_rework: Eliminate conflict between flavors
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: Yuri Victorovich
URL: https://sourceforge.net/p/ngspice/bug...
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-13 04:13 UTC by Yuri Victorovich
Modified: 2022-08-06 21:01 UTC (History)
2 users (show)

See Also:
kevinz5000: maintainer-feedback+


Attachments
patch (2.45 KB, patch)
2021-11-13 04:13 UTC, Yuri Victorovich
no flags Details | Diff
ngspice_rework-36.log.gz (poudriere bulk with -t) (87.15 KB, application/octet-stream)
2022-07-26 09:18 UTC, Tomoyuki Sakurai
no flags Details
Patch WIP (3.38 KB, patch)
2022-07-26 19:33 UTC, Kevin Zheng
no flags Details | Diff
Patch (3.89 KB, patch)
2022-07-28 22:42 UTC, Kevin Zheng
kevinz5000: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Victorovich freebsd_committer freebsd_triage 2021-11-13 04:13:29 UTC
Created attachment 229462 [details]
patch

Currently both flavors install headers and .cm files.

This makes them to conflict each other.

The attached patch removes conflicting files from the @x11 flavor allowing the executable to be installed in parallel with libraries.

The executable seems to work in a standalone mode fine, but if it ever needs headers or .cm files the @shlib flavor can always be installed.
Comment 1 Kevin Zheng 2021-11-13 19:54:27 UTC
Approved, thank you for the investigation and fix.
Comment 2 Yuri Victorovich freebsd_committer freebsd_triage 2021-11-13 21:59:11 UTC
Committed.

Thanks for the quick approval!
Comment 3 commit-hook freebsd_committer freebsd_triage 2021-11-13 22:00:05 UTC
A commit in branch main references this bug:

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

commit e3cf001d007c4aa6ed7ac45b7bf14982e2ecb3ce
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2021-11-13 21:49:26 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2021-11-13 21:59:25 +0000

    cad/ngspice_rework: Eliminate conflict between flavors

    Before both flavors installed headers and .cm files.
    This caused them to conflict with each other.

    This commit removes conflicting files from the @x11 flavor
    allowing the executable to be installed in parallel with libraries.

    The executable seems to work in a standalone mode fine, but if it ever
    needs headers or .cm files the @shlib flavor can always be installed.

    PR:             259809
    Tested by:      kevinz5000@gmail.com

 cad/ngspice_rework/Makefile                       | 19 ++++++++++++-------
 cad/ngspice_rework/{pkg-plist => pkg-plist-shlib} | 10 ++++------
 2 files changed, 16 insertions(+), 13 deletions(-)
Comment 4 Tomoyuki Sakurai 2022-07-23 21:00:36 UTC
a question:

when @x11 and @shlib do not conflict each other, why is FLAVORS needed? why not removing FLAVORS, and installing the binary and the shared libs?
Comment 5 Yuri Victorovich freebsd_committer freebsd_triage 2022-07-23 21:05:59 UTC
FLAVORS might not be needed here.
Comment 6 Kevin Zheng 2022-07-23 21:07:17 UTC
(In reply to Tomoyuki Sakurai from comment #4)
Because ngspice's configure script lets you pick either shlib or x11, but not both. When building x11, it will not build shlib, and vice versa.
Comment 7 Yuri Victorovich freebsd_committer freebsd_triage 2022-07-23 21:10:52 UTC
(In reply to Tomoyuki Sakurai from comment #4)

In light of Kevin's answer it looks like your question is for ngspice upstream. They should allow to build everything in one shot.
Comment 8 Tomoyuki Sakurai 2022-07-24 05:19:05 UTC
just an idea:

1. run ./configure with_ngshared in do-configure
2. save config.status for shlib
3. run ./configure for x11
4. build with x11 in do-build
5. restore config.status for shlib
6. build again
7. manually install all the files in stage (not make install)
Comment 9 Kevin Zheng 2022-07-26 06:53:08 UTC
(In reply to Tomoyuki Sakurai from comment #8)
That's a good suggestion. I could see making such a change to the FreeBSD port to support this. If you're familiar with the ports system, perhaps you could take a look first. Otherwise, I'll try to see what I can do about this soon (TM).
Comment 11 Tomoyuki Sakurai 2022-07-26 09:18:47 UTC
Created attachment 235477 [details]
ngspice_rework-36.log.gz (poudriere bulk with -t)
Comment 12 Yuri Victorovich freebsd_committer freebsd_triage 2022-07-26 16:45:44 UTC
Thank you.
Comment 13 Kevin Zheng 2022-07-26 19:33:20 UTC
Created attachment 235496 [details]
Patch WIP

I've updated your suggested patch here. The main change was to rename pkg-plst-shlib to pkg-plist, because without the FLAVOR it was using the (empty) pkg-plist file.

I'm currently debugging why the resulting shared library from this hack no longer loads with kicad:

Failed to load shared library... Undefined symbol "g_mif_info"
Comment 14 Tomoyuki Sakurai 2022-07-27 00:18:42 UTC
sounds like LD_CONFIG issue. I haven't tested the port with Kicad yet.
Comment 15 Tomoyuki Sakurai 2022-07-27 11:20:51 UTC
building shlib first fixed it.

fixed in:

https://github.com/trombik/freebsd-ports-ngspice_rework/commit/9768ffdf5df10a0063c973f4c6882227cad366b4
Comment 16 Kevin Zheng 2022-07-27 18:13:43 UTC
(In reply to Tomoyuki Sakurai from comment #15)
Thanks for investigating and writing up the fix. Do you know why changing the build order fixed it? I'll probably also do some testing on the CLI version to make sure that hasn't suddenly broken due to the build order...
Comment 17 Tomoyuki Sakurai 2022-07-27 20:09:49 UTC
the hint was a comment in PKGBUILD.

"shared lib sets flags and modifies headers, needs dedicated pass"
https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=ngspice-git#n37
Comment 18 Kevin Zheng 2022-07-28 01:00:21 UTC
(In reply to Tomoyuki Sakurai from comment #17)
You were missing a change from 36 to 37:

diff --git a/cad/ngspice_rework/Makefile b/cad/ngspice_rework/Makefile
index e1ff6bc6b0ff..18b3ea1767f8 100644
--- a/cad/ngspice_rework/Makefile
+++ b/cad/ngspice_rework/Makefile
@@ -56,7 +56,7 @@ post-install:
        ${INSTALL} -d ${STAGEDIR}${PREFIX}/include/ngspice
        ${INSTALL_LIB} ${WRKSRC}/src/.libs/libngspice.so ${STAGEDIR}${PREFIX}/lib/
        ${INSTALL_LIB} ${WRKSRC}/src/.libs/libngspice.so.0 ${STAGEDIR}${PREFIX}/lib/
-       ${INSTALL_LIB} ${WRKSRC}/src/.libs/libngspice.so.0.0.2 ${STAGEDIR}${PREFIX}/lib/
+       ${INSTALL_LIB} ${WRKSRC}/src/.libs/libngspice.so.0.0.4 ${STAGEDIR}${PREFIX}/lib/
        ${INSTALL_DATA} ${WRKSRC}/src/include/ngspice/sharedspice.h ${STAGEDIR}${PREFIX}/include/ngspice/
        ${INSTALL_DATA} ${WRKSRC}/ngspice.pc ${STAGEDIR}${PREFIX}/libdata/pkgconfig/

Other than that, I can confirm that the shared library and executable both work.

Tomoyuki, the man page install location is now technically incorrect, because FreeBSD wants man pages in ${LOCALBASE}/man and not ${LOCALBASE}/share/man (Yuri could you confirm that?)

Yuri, what's the procedure for poking the consumers of the shlib flavor? Should we suggest a patch to fix all dependent ports?
Comment 19 Yuri Victorovich freebsd_committer freebsd_triage 2022-07-28 01:39:34 UTC
(In reply to Kevin Zheng from comment #18)

Hi Kevin,

> [...] FreeBSD wants man pages in ${LOCALBASE}/man and not ${LOCALBASE}/share/man [...]

FreeBSD now recommends share/man for manpages actually. They changed the location not long ago. But both are acceptable at the moment.

> [...] what's the procedure for poking the consumers of the shlib flavor? [...]

I can just flatten the flavors in dependency lines, no worries.


Yuri
Comment 20 Kevin Zheng 2022-07-28 22:42:42 UTC
Created attachment 235535 [details]
Patch

Here is the final patch with all the proposed changes squashed. I approve it, and if Yuri can give it a look-over and update the dependent ports, I think it's ready.
Comment 21 Yuri Victorovich freebsd_committer freebsd_triage 2022-07-29 00:35:57 UTC
(In reply to Kevin Zheng from comment #20)

Thanks, Kevin.

Will look at it today.


Yuri
Comment 22 Yuri Victorovich freebsd_committer freebsd_triage 2022-07-29 07:38:31 UTC
I added the suggestion for the upstream to allow to build in one shot (the URL field).

Let's wait for them to comment on it on the off chance that this is already implemented and we just couldn't see it.


Yuri
Comment 23 Yuri Victorovich freebsd_committer freebsd_triage 2022-07-29 20:07:55 UTC
The answer that the upstream gave supports the idea that libngspice and ngspice are two separate invocations of the simulator and should be kept as separate flavors. Perhaps flavors should be renamed.

See https://sourceforge.net/p/ngspice/bugs/599/
Comment 24 Tomoyuki Sakurai 2022-07-29 21:14:08 UTC
the justification sounds like a historical design flaw to me. if they don't depend each other, they should have a different name of their own. anyway, i don't need x11 version in practical usages. just thought usage of FLAVORS seemed wrong. it's up to the maintainer.
Comment 25 Kevin Zheng 2022-08-03 00:32:33 UTC
I'm on the fence, so I'd like to hear everyone's thoughts. We don't necessarily have to do what upstream insists on doing.

Pros to flavors:

- Can install library without TUI application (which requires X11)

Cons to flavors:

- Conflicts in headers and .cm files. We technically don't need to install the headers in the TUI mode, but the .cm files are needed for code models to work (in both modes?)

An alternative would be to make yet another flavor, e.g. ngspice_rework-shared, with the header files and code models.
Comment 26 Tomoyuki Sakurai 2022-08-03 11:10:02 UTC
i'm a kicad user. i guess, most of users are, too. i need a simulator in kicad. kicad requires x11. the port is required by kicad only the last time i checked. there might be users who do not need x11, but just the shared library. i cannot think of any use case, but theologically, there might be.

to me, as a kicad user, the fact that the default ngspice_rework package does not provide shared lib was a surprise. the conflict was also a surprise.

every change breaks someone's workflow. if you think backward compatibility is more important, keep the port in the ports tree. it will not surprise anyone.
Comment 27 Yuri Victorovich freebsd_committer freebsd_triage 2022-08-03 16:05:14 UTC
There is a new and very promising Qucs-S (cad/qucs-s) circuit simulator GUI and it uses ngspice as a default simulator backend. Qucs-S doesn't require x11 in ngspice.
Comment 28 Kevin Zheng 2022-08-06 21:01:37 UTC
Let's go ahead and commit this patch to remove flavors and install the TUI and shared library in one port. We can add an OPTION to remove X11 if someone reports that there is a need.