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

Under development: PCMCIA, wireless, etc.
Post Reply
Message
Author
User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

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

#1 Post 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.
Attachments
de-bus-0.0.pet
(9.42 KiB) Downloaded 727 times
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#2 Post 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.
Attachments
nobus-0.2-i486.pet
(5.18 KiB) Downloaded 959 times
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#3 Post 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.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#4 Post 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)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

Dewbie

#5 Post 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! :)

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#6 Post 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...)

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#7 Post 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
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#8 Post 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

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#9 Post 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
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
session
Posts: 89
Joined: Mon 07 Feb 2011, 23:11
Location: Valley of the Sun

#10 Post 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...
[color=green]Primary[/color] - Intel Pentium 4 2.40GHz, 571MB RAM, ATI Radeon 7000. Linux Mint 17 Qiana installed.
[color=blue]Secondary[/color] - Pentium 3 533MHz, 385MB RAM, ATI Rage 128 Pro ULTRA TF. Precise Puppy 5.7.1 Retro full install.

darry1966

Thankyou

#11 Post 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

Post Reply