After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 665672 - New tool: g-ir-dep-scanner
New tool: g-ir-dep-scanner
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
2.31.x
Other Linux
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2011-12-06 15:11 UTC by Dominique Leuenberger
Modified: 2016-04-29 14:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add g-ir-dep-scanner tool (3.55 KB, patch)
2011-12-06 15:13 UTC, Dominique Leuenberger
needs-work Details | Review
Patch version 2 (3.76 KB, patch)
2011-12-06 16:16 UTC, Dominique Leuenberger
none Details | Review
Patch version 3 (3.94 KB, patch)
2011-12-08 21:40 UTC, Dominique Leuenberger
none Details | Review
for reference: this is the rpm script we use in openSUSE to create the dependencies. (3.39 KB, text/plain)
2012-10-16 09:58 UTC, Dominique Leuenberger
  Details
rework as per earlier comments (5.38 KB, patch)
2016-01-18 11:26 UTC, Dominique Leuenberger
reviewed Details | Review
g-ir-dep-scanner: Scan dependencies of a typelib and give information (5.03 KB, patch)
2016-04-29 08:05 UTC, Igor Gnatenko
rejected Details | Review
g-ir-readtypelib: new tool (5.52 KB, patch)
2016-04-29 08:28 UTC, Igor Gnatenko
none Details | Review
g-ir-readtypelib: new tool (5.50 KB, patch)
2016-04-29 08:38 UTC, Igor Gnatenko
none Details | Review
g-ir-inspect: Inspect GI typelibs (5.48 KB, patch)
2016-04-29 08:49 UTC, Igor Gnatenko
none Details | Review
g-ir-inspect: Inspect GI typelibs (5.72 KB, patch)
2016-04-29 14:04 UTC, Igor Gnatenko
accepted-commit_now Details | Review

Description Dominique Leuenberger 2011-12-06 15:11:45 UTC
In order to add automatic dependency generation between rpm packages (openSUSE, others are likely to join), I created a g-ir-dep-scanner that loads a .typelib file, checks for depending other typelibs and shared libraries and outputs this inormation. Based on this output and rpm hooks, automated dependencies can be created.

This goes in large way together with my other works for automatic dependency resolution in rpm / g-i, See bug #654156
Comment 1 Dominique Leuenberger 2011-12-06 15:13:03 UTC
Created attachment 202913 [details] [review]
Add g-ir-dep-scanner tool

Patch version 1 - Currently fail to build git master, but even without this patch. The .c source is tested, just the integration in the build system is not sure to work (yet)
Comment 2 Johan (not receiving bugmail) Dahlin 2011-12-06 15:19:13 UTC
Review of attachment 202913 [details] [review]:

Use /* */ comments.

Scanner suffix is confusing, better to call it tool.

You need to add it to noinst_PROGRAMS.
Comment 3 Dominique Leuenberger 2011-12-06 16:16:23 UTC
Created attachment 202916 [details] [review]
Patch version 2

Reworked patch, taken your comments (and some other I received in the meantime) into account.

Even have made test builds and integration into the build system is fine with this patch.
Comment 4 Dominique Leuenberger 2011-12-08 21:40:57 UTC
Created attachment 203121 [details] [review]
Patch version 3

Sorry for the noise. But I just came across the fact that shared libraries can actually be a comma separated list, so I now split the returned string in pieces in an array and return one library per line (thus giving the same output as with the typelib based dependencies).

Example with Gkbd-3.0:
> g-ir-dep-tool Gkbd
typelib: xlib-2.0
typelib: cairo-1.0
typelib: Pango-1.0
typelib: Gtk-3.0
typelib: Gio-2.0
typelib: GdkPixbuf-2.0
typelib: Gdk-3.0
typelib: GObject-2.0
typelib: GModule-2.0
typelib: GLib-2.0
typelib: Atk-1.0
shlib: libgnomekbd.so.7
shlib: libgnomekbdui.so.7
Comment 5 Dominique Leuenberger 2012-08-27 17:55:17 UTC
FYI: openSUSE has had this patch in for since the patch existed and served a great deal already in not having too many broken deps for this...
Comment 6 Dominique Leuenberger 2012-10-16 09:58:35 UTC
Created attachment 226537 [details]
for reference: this is the rpm script we use in openSUSE to create the dependencies.
Comment 7 Colin Guthrie 2013-01-22 15:04:24 UTC
Can I add a "me too" to this patch.

We (Mageia) use a different mechanism to extract deps automatically, but it would certainly help reduce pointless distribution variations if this was available in an upstream package.
Comment 8 Colin Walters 2013-01-22 15:23:11 UTC
Sorry for not replying earlier, didn't see this patch go by.  So I see the generic desire for a tool to output data from typelibs is an easily readable form.

Typelibs are a bit like ELF files, so maybe what we want is something a bit more generic like "eu-readelf".  What about calling the tool g-ir-readtypelib, and adding options like:

--print-shlibs
--print-typelibs

Then it'd be a bit more future proof, we could add:

--print-symbols

etc.

Note of course that unlike ELF, girepository also ships with a public library to consume the typelibs, so it's also an option to maintain such a tool inside RPM or whatever.
Comment 9 Dominique Leuenberger 2013-01-22 15:35:20 UTC
As the original author of that, and seeing that there is demand by distributions (which is great motivation of course to do more out of this), I am certainly willing to work towards a solution that can be integrated into the upstream code base...

Makes everybodys life easier and we can (better) profit from bugs found by each other (we realized that multiple dists already use this scanner / rpm dep but they obviously drifted apart).

Your suggestion of g-ir-readtype is acceptable to me (what's in the name :) )

the option parsing is also an option (so far we did not care for it, as we need everything... but it's surely an option).

Would you say that stating the tool without --print* gives the output as it does now? Or only the 'help'? 

Of course, 'combination' of --print-typelibs --print-shlib should be possible (which would be what the tool does now).

I'll try to work on something like this in the next few days.
Comment 10 André Klapper 2015-02-07 17:17:57 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]
Comment 11 Thierry Vignaud 2015-09-07 13:46:24 UTC
Any progress on this?
Comment 12 Dominique Leuenberger 2016-01-18 11:26:02 UTC
Created attachment 319247 [details] [review]
rework as per earlier comments

The tool is now named g-ir-readtypelib and uses parameters

--print-shlibs
--print-typelibs

 to print as requested
Comment 13 Emmanuele Bassi (:ebassi) 2016-04-18 14:46:32 UTC
Review of attachment 319247 [details] [review]:

Looks generally good to me; I'm not sure on the rules for coding style in gobject-introspection tools, but the code is so small that I don't think it makes much of a difference.
Comment 14 Igor Gnatenko 2016-04-29 08:05:08 UTC
Created attachment 326990 [details] [review]
g-ir-dep-scanner: Scan dependencies of a typelib and give information

This allows distributions to create automatic dependency tracking coming
from .typelib files.

The dependencies identified at this time are:
typelib - based dependencies
shared library - dependencies

Reference: https://bugzilla.gnome.org/show_bug.cgi?id=665672
Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
Comment 15 Igor Gnatenko 2016-04-29 08:28:28 UTC
Created attachment 326994 [details] [review]
g-ir-readtypelib: new tool

Various distributions (mainly RPM based so far) make use of automatic
dependencies extracted from typelib files (they can require other typelibs
and also shared libraries)

g-ir-readtypelib inspects a .typelib file and prints the dependencies.

Reference: https://bugzilla.gnome.org/show_bug.cgi?id=665672
Signed-off-by: Dominique Leuenberger <dimstar@opensuse.org>
Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
Comment 16 Igor Gnatenko 2016-04-29 08:38:20 UTC
Created attachment 326995 [details] [review]
g-ir-readtypelib: new tool

Various distributions (mainly RPM based so far) make use of automatic
dependencies extracted from typelib files (they can require other typelibs
and also shared libraries)

g-ir-readtypelib inspects a typelib and prints the dependencies.

Reference: https://bugzilla.gnome.org/show_bug.cgi?id=665672
Signed-off-by: Dominique Leuenberger <dimstar@opensuse.org>
Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
Comment 17 Igor Gnatenko 2016-04-29 08:49:54 UTC
Created attachment 326996 [details] [review]
g-ir-inspect: Inspect GI typelibs

Various distributions (mainly RPM based so far) make use of automatic
dependencies extracted from typelib files (they can require other typelibs
and also shared libraries)

Current features
* Print used shared libraries
* Print used typelib dependencies

Reference: https://bugzilla.gnome.org/show_bug.cgi?id=665672
Signed-off-by: Dominique Leuenberger <dimstar@opensuse.org>
Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
Comment 18 Colin Walters 2016-04-29 12:43:40 UTC
Dominique, you're okay with Igor taking over this series?
Comment 19 Colin Walters 2016-04-29 12:45:37 UTC
I'm confused, why do we have two patches for the tool with different names?
Comment 20 Dominique Leuenberger 2016-04-29 12:46:41 UTC
(In reply to Colin Walters from comment #18)
> Dominique, you're okay with Igor taking over this series?

I'm fine with Igor doing the work - his patch is based on top of mine, apparently with cleanups people seem to care for
Comment 21 Colin Walters 2016-04-29 12:49:53 UTC
Review of attachment 326996 [details] [review]:

::: tools/g-ir-inspect.c
@@ +31,3 @@
+    /* Finding the shared library we depend on (if any) */
+    const gchar *shlibs = g_irepository_get_shared_library (NULL, namespace);
+    if (shlibs && shlibs[0] != '\0') {

Brace on new line.

@@ +44,3 @@
+    /* Finding all the typelib-based Requires */
+    g_auto(GStrv) deps = g_irepository_get_dependencies (NULL, namespace);
+    if (deps) {

g-i is GNU style, brace on new line.

@@ +54,3 @@
+      gchar *argv[])
+{
+    g_autoptr(GError) error = NULL;

Sadly, we need to support MSVC builds of g-i.  So we can't use g_auto here.

@@ +83,3 @@
+        return EXIT_FAILURE;
+    }
+    const gchar *namespace = namespaces[0];

I'd also prefer being conservative with declaration-after-statement here.  Most of the rest of the code doesn't do that yet.
Comment 22 Colin Walters 2016-04-29 12:51:21 UTC
(In reply to Dominique Leuenberger from comment #20)
> (In reply to Colin Walters from comment #18)
> > Dominique, you're okay with Igor taking over this series?
> 
> I'm fine with Igor doing the work - his patch is based on top of mine,
> apparently with cleanups people seem to care for

One thing I'm quite sensitive to personally is attribution.  I'd have at least added a:

"Based on a patch by: "
Comment 23 Igor Gnatenko 2016-04-29 14:04:49 UTC
Created attachment 327025 [details] [review]
g-ir-inspect: Inspect GI typelibs

Various distributions (mainly RPM based so far) make use of automatic
dependencies extracted from typelib files (they can require other typelibs
and also shared libraries)

Current features
* Print used shared libraries
* Print used typelib dependencies

Based-on-patch-by: Dominique Leuenberger <dimstar@opensuse.org>
Reference: https://bugzilla.gnome.org/show_bug.cgi?id=665672
Signed-off-by: Dominique Leuenberger <dimstar@opensuse.org>
Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
Comment 24 Colin Walters 2016-04-29 14:06:23 UTC
Review of attachment 327025 [details] [review]:

Ok, LGTM.
Comment 25 Igor Gnatenko 2016-04-29 14:08:32 UTC
(In reply to Colin Walters from comment #24)
> Review of attachment 327025 [details] [review] [review]:
> 
> Ok, LGTM.

pushed as 43597c9