Page 1 of 1

stubs: replace useless libs with headers - dbus, dbus-glib..

Posted: Mon 13 Aug 2012, 03:25
by technosaurus
It is common practice to make stub functions that return acceptable values to replace dependencies, but it is also possible in C to use macros to define functions as constants. This allows us to replace entire libraries with just a header (.h) file. I have done a bit of work on dbus and dbus-glib (the pre-alpha headers compress to <10kb and should be much less when compiled) I have an eye on gconf for the future, possibly others as I get annoyed with them.

The general idea is to look through the functions for return values and just define each function as a constant from a working return value... mostly TRUE, FALSE, 0, NULL or ""

Edit: this de-bus pet is only for packagers/developers to build against - it does not replace a runtime of dbus/dbus-glib, for that there is another project called "nobus" ...still needs testing - let me know if you try it.

Posted: Thu 13 Sep 2012, 15:36
by technosaurus
here is a small pet package of the nobus project for non-dev-types
(I built it as a shared library for use with prebuilt binaries)

I won't be updating the package, so here are the url and extra build instructions for a shared library.
https://github.com/clbr/nobus

Code: Select all

cc -shared -Wl,-soname,libdbus-glib-1.so.2,-s -o libdbus-glib-1.so.2  stubs.o
then made a symlink for dbus (see inside package for details)

Now to see if it works with prebuilt mozillas.

Posted: Thu 13 Sep 2012, 23:58
by disciple
Edit: this de-bus pet is only for packagers/developers to build against - it does not replace a runtime of dbus/dbus-glib, for that there is another project called "nobus" ...still needs testing - let me know if you try it.
I'm confused - from reading the nobus readme I thought that it did the same thing, i.e. it does not replace a runtime, it is a compile-time solution to remove the dbus dependency.

Posted: Fri 14 Sep 2012, 02:09
by technosaurus
It _was_ before I got a hold of it. I built it as a shared lib - which nobus lends itself to, since it uses function stubs. Mine couldn't do that, since I use macros to replace the code with constants that compile away (mostly)... it has no functions.

Edit: the reason it probably says that is that it only builds a static lib. Gcc is good at inlining small, constant functions, so it would build the same as mine with the right compiler options (de-bus minimizes the build size regardless of optimization). Note, I may need to add extern to some functions for it to work (if you get a missing symbol for a function that is in the library, it usually just needs extern before the function type declaration)

Posted: Wed 26 Sep 2012, 00:35
by Dewbie
technosaurus wrote:
Now to see if it works with prebuilt mozillas.
Tested SeaMonkey 2.12.1 official build and nobus-0.2-i486.pet with:
Puppy Linux 4.1.2
Puppy Linux 4.3.1
Wary 5.1.4.1.
Works with all of em! :)

Posted: Wed 26 Sep 2012, 21:36
by greengeek
I was recently trialling Gray's WaryNOP 5.1.1 which comes with Opera but I wanted to install Firefox, however FF would not run because the system did not have /usr/lib/libhunspell.so.0 available.

Is this the sort of problem that "nobus" is designed to alleviate?

(I renamed a totally different lib as the missing one and then FF ran ok, so obviously the structure of the lib is not that critical...)

Posted: Wed 26 Sep 2012, 22:04
by technosaurus
the official ff has the hunspell lib builtin iirc, but no you would get no spell checking at best, and at worst it would segfault when it tried (unless maybe you turned it off in settings, then you could just symlink some random lib to where it is looking) - hunspell is useful in other apps too - I recommend just installing it. dbus otoh doesn't do much of anything useful.

or you can make a fake anything in case it looks for the SONAME

gcc -shared -o libdummy.so.3 -Wl,-soname,libdummy.so.3 -s

Posted: Wed 26 Sep 2012, 22:27
by greengeek
technosaurus wrote:or you can make a fake anything in case it looks for the SONAME

gcc -shared -o libdummy.so.3 -Wl,-soname,libdummy.so.3 -s
So does that create a "dummy" lib that can be renamed to temporarily replace the missing one?

I had wondered if it might be possible to make a generic lib (lets say called "safelib"), which, when called by some programme, would bring up a dialog saying "Library safelib has been called by programme xxx" so that there would be some indication that the missing lib had actually been accessed, whether or not the outcome was problematic.

(I have often been concerned about just adding in missing libs, because there's no easy way for me to know if it is guaranteed to be the correct lib for my system - there are so many with similar names.)

The reason for my question about nobus was that I found a forum that had pinpointed the lack of dbus and dbus-glib as being the reason for the missing hunspell
http://answers.yahoo.com/question/index ... 846AAkiY7g

Posted: Wed 26 Sep 2012, 23:12
by technosaurus
oops:
gcc -shared blankfile.c -o libdummy.so.3 -Wl,-soname,libdummy.so.3 -s

IIRC, Barry now includes hunspell in puppy by default because you can compile mozilla products --with-system-hunspell (thus it won't work on older pups without it unless you get the hunspell package) official builds have hunspell inside their directory structure and you may have to futz around with LD_LIBRARY_PATH to find it (the included script should do it for you but puppy haz its own mozilla wrapper that may not) ... same goes for lib{z,png,jpeg,cairo,...} anyhow mozilla's source looks like someone crossed the streams or I would have contributed some fixes long ago

Posted: Thu 25 Apr 2013, 04:11
by session
greengeek wrote:I had wondered if it might be possible to make a generic lib (lets say called "safelib"), which, when called by some programme, would bring up a dialog saying "Library safelib has been called by programme xxx" so that there would be some indication that the missing lib had actually been accessed, whether or not the outcome was problematic.

(I have often been concerned about just adding in missing libs, because there's no easy way for me to know if it is guaranteed to be the correct lib for my system - there are so many with similar names.)
Library identification would be nice; using nobus, recent versions of vanilla Seamonkey would crash on a few sites (ex. Chase Logon) and it was really through trial-and-error and chance that I discovered it was because of missing dbus(-glib) libs...

Thankyou

Posted: Fri 07 Jun 2013, 20:13
by darry1966
Thankyou for this handy No Bus .pet I owe you a Virtual Beer. Works well on my modified 4.12 system.
:D










t