Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 26 Jul 2014, 03:20
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Options for fixing paths in apps.?
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [30 Posts]   Goto page: 1, 2 Next
Author Message
sunburnt


Joined: 08 Jun 2005
Posts: 5009
Location: Arizona, U.S.A.

PostPosted: Mon 29 Aug 2011, 23:55    Post subject:  Options for fixing paths in apps.?  

I`m experimenting with using squash files mounted only, no union.
I know ChoicePup did this, but I don`t see how this problem was solved.

Executable and library files that`re are found by their paths are easy to fix.
Why not have other paths to other types of files: config., data, etc.? (kernel)

Example: I have an app., xmahjoong, it won`t run because it can`t find the tiles.
Obviously the path to the tile files is coded absolutely.

If app. code had only relative paths to it`s own files this wouldn`t be a problem.
Then the app. could be "installed" anywhere, even in a mounted squash file.

Something to do with how the app. is compiled effects how paths are handled?
Would a static compile put the tile files inside the executable and fix this?

1) I can`t think of an easy fix for this except with lots of links. ( Sucks...)
2) Other than that, it`s possible that recompiling may fix it.
3) Or worse case scenario... rewrite the apps. code with relative paths.

Any ideas to solve this? Maybe something I haven`t thought of here?
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2219

PostPosted: Tue 30 Aug 2011, 02:39    Post subject:  

Links or a slight mod to the sources are your best bet. Some apps code will let you use relative paths, but others may not easily do so.
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5009
Location: Arizona, U.S.A.

PostPosted: Tue 30 Aug 2011, 03:36    Post subject:  

Somehow I knew it would be you to answer amigo...

1) So in the case of xmahjoong, the tile files and etc. can`t be compiled into it?
2) Does a static compile mean only libraries are joined?
3) Or can what`s included in the executable be controlled?

I`ve read much on static compiling, but nothing has explained this very well.

Links are such a mess and still have to be tracked just like the files themselves.
And modding source code is a long treacherous task over thousands of apps...

# You said: "Some apps code will let you use relative paths"
4) You mean: "Some apps. will work no matter where they`re installed." Right?

5) Which begs the Q... Why don`t all apps. use relative paths for all file access?
Back to top
View user's profile Send private message 
jpeps

Joined: 31 May 2008
Posts: 3220

PostPosted: Tue 30 Aug 2011, 04:54    Post subject:  

sunburnt wrote:
Somehow I knew it would be you to answer amigo...

1) So in the case of xmahjoong, the tile files and etc. can`t be compiled into it?
2) Does a static compile mean only libraries are joined?
3) Or can what`s included in the executable be controlled?

I`ve read much on static compiling, but nothing has explained this very well.

Links are such a mess and still have to be tracked just like the files themselves.
And modding source code is a long treacherous task over thousands of apps...

# You said: "Some apps code will let you use relative paths"
4) You mean: "Some apps. will work no matter where they`re installed." Right?

5) Which begs the Q... Why don`t all apps. use relative paths for all file access?


I think static build generally refers to having all the llbs included. The point is that it's not relying on them being present in the distro. For example, it was difficult getting Skype to work until they released a static build. With dynamic builds, links are often necessary anyway when it calls for specific versions of a lib...so it's standard procedure.
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2219

PostPosted: Tue 30 Aug 2011, 16:34    Post subject:  

Ach, you caught me red-faced there, so to speak! LOL

It is common to include pixmaps right in the binary -Xdialog is a good example. But, that is usually for XPM's. I've just had a quick look cause I've had xmahjongg in my collection for ages. It's using those yucky *.gif's and it's all written in that yucky C++. But, you can set the location to install them by setting pkgdatadir or datadir in configure options.Something like this should work:

./configure --prefix=/usr --datadir=/usr/share/xmahjongg

Or, cd into the unpackaged sources and do:
grep -nrH tiles * |less
That should give a clue to this:
grep -nrH pkgdatadir * |less
Which gives a clue to this:
grep -nrH PKGDATADIR * |less

There, you'll see that configure substitues the given or default value of pkgdatadir into the:
#define PKGDATADIR
(in the config.h.in) configure creates config.h from this. If you edit
the config.h.in and change line 73:
#undef PKGDATADIR
to read:
#define relative/path/here

If somehow that is getting clobbered when configure is run (no matter if/what setting pkgdatadir gets), then, before compiling, simply edit the finished config.h file to read like above, compile, strip, compress, check perms, check ownerships, check this, check that -oh wait, I have src2pkg to do all that for me...

(Edit: Actually grepping for PKGDATADIR should also show you that you could edit src/main.cc {line 526} to read like this:
const char *config_dir = "relative/or/absolute/path";
to make all those files go where you like.)

Oh man, I feel like a hero... I did not plan on being nice today, but sometimes nature has her way with me.
Have fun!
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5009
Location: Arizona, U.S.A.

PostPosted: Tue 30 Aug 2011, 21:31    Post subject:  

Thanks jpeps; I made a sfs file from a static build of Skype years ago.

WOW !!!!! ... I`m overwhelmed amigo... ( I copied your post to my tutors dir.)
Now I`m going back and rereading all the compiling tutors again!

I hear you about xmahjongg looking yucky, it`s just the test bed for my idea.
I take it you`re a standard C programmer? None of this fancy object crap?

# More damn Qs.......... Can this be put into a generic script for all apps.?
# Or make a script to run on one or more of these files to edit it as needed?
# Or are the config. files for compiling apps. so different from app. to app.?

# Need to automate this to make a big collection of apps. that`re relocatable.

Your last paragraph seems to indicate that this may be possible:
Quote:
edit src/main.cc {line 526} to read like this:
const char *config_dir = "relative/or/absolute/path";

In xmahjongg`s case "relative/path" would be "../share/xmahjongg"?

I`m a beginner at this, I have no clue as to what`s going on ( Duh...).
Believe me... I have read, but concept wise it`s not helping.

Years ago I asked my friend a M$ Access and SQL dev. what a table was.
He chuckled and explained a table as records and fields... I knew instantly.

Thank you very much for indulging me amigo... Terry B.
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2219

PostPosted: Wed 31 Aug 2011, 04:10    Post subject:  

Remember that grep command and use it every time you want to know where something is located or getting called from.

# More damn Qs.......... Can this be put into a generic script for all apps.?
# Or make a script to run on one or more of these files to edit it as needed?
I have a simple and pretty good way of dealing that -I create things as rox AppDirs, but they can then be linked into a normal path if you like. It's an AppDir 'framework of sorts which is either a wrapper around mostl-elsewhere installed programs, using normal shell commands. But the same framework can be used to build AppDirs from source. It includes a couple of example diffs which can be adapted to different kinds of sources:
http://distro.ibiblio.org/pub/linux/distributions/amigolinux/download/AppDirs/AppBuilder-0.4.tbz
The concept is easiest to implement by choosing a main location under which all apps can be managed. Then you just compile each one using the prefix /main/app-location/this-app -or if the user compiles it himself then it will 'locate itself' wherever it is compiled from.

# Or are the config. files for compiling apps. so different from app. to app.?
This is the big problem with build systems. There are a whole bunch of systems for configuring sources. Quite a few can be built with no special options other than prefix, using the standard './configure ;make; make install'. But there are jillions of sources which need something else or more. My src2pkg is probably the most independent among the automated build systems, and knows about lots of configure/build methods. It can build several types of packages, including *.pet.

# Need to automate this to make a big collection of apps. that`re relocatable.
You can only repeatable, orderly builds by scripting everything -src2pkg writes the scripts for you -at least the basic one. You then add any code lines needed for any extra items or actions. For changes to code, you need to have clean diffs -src2pkg applies them automatically or you can use a list.

# In xmahjongg`s case "relative/path" would be "../share/xmahjongg"
Yeah, that works assuming the binary is in an adjacent directory where one directoty up there is a dir named 'share'. That fits the dir structure under /usr and /usr/local. But, if you want the thing with all in one dir(AppDir or 'bundle' style), then you'd use:
"share/xmahjongg"
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5009
Location: Arizona, U.S.A.

PostPosted: Thu 01 Sep 2011, 00:03    Post subject:  

Wanted to try it before replying.
I`m posting a file with the compile and make output.

# The source file dir. is at: /usr/local/src/xmahjongg-3.7

I modified the file: main.cc as you said.
I assume there`s no normal files until you run install?

Need the finished files in an empty dir so I can make a squash file.
I don`t think your src2pkg utility will make squash file packages?

I still don`t see how that one line tells it how to include everything.
I hope I can get this to work on lots of the packages out there.
comp-make.txt.gz
Description 
gz

 Download 
Filename  comp-make.txt.gz 
Filesize  2.46 KB 
Downloaded  161 Time(s) 
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4279

PostPosted: Thu 01 Sep 2011, 12:39    Post subject:  

I used to sometimes mod the sources to include the icons in /usr/share/pixmaps or /usr/share/mini-icons (depending on the type of icon) ... until an app was looking for a specific image that got overwritten and caused it to segfault. The symlink method is much safer, but I think it is gobolinux that does exactly what you speak of (I think by setting the prefix to something like /mnt/appname and the mount script adds :/mnt/appname/bin:/mnt/appname/sbin to $PATH and other such things)
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2219

PostPosted: Thu 01 Sep 2011, 13:11    Post subject:  

mount script adds PATH -the trouble with that is that you wind up with a new PATH element for each program. get's very messy looking an dit adds time needed for startup because the sehll must search through each PATH element until it finds the app you are calling.
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5009
Location: Arizona, U.S.A.

PostPosted: Thu 01 Sep 2011, 14:38    Post subject:  

Thanks technosaurus; Did configure option and make install placed the files correctly.
The app. works! The apps. files aren`t merged, but it works from here:
# /tmp/apps.sq/mnt/xmahjongg.tcz.sfs/bin/xmahjongg
With it`s other dirs.:
# /tmp/apps.sq/mnt/xmahjongg.tcz.sfs/share/xmahjongg

NO original dirs. or files exist where they normally are! ( So no cheating...)

If it all was compiled into one exec. file, it would be nice, no sq. file needed !
Imagine all apps. this way! But it`s not critical, making sq. files is easy to do.

Thanks again amigo; Some of your mods to the files failed to make.
A few did make install, but the tiles etc. are still separate. Most failed to run.
#This ran, but did not merge anything:
./configure --prefix=/usr/local --datadir=/usr/local/share

# The configure option: "--datadir=" sets what`s merged into the exec. file?
..... It seems like what`s needed`s an option to include everything in /src/(app.)
..... Then just copy to /src/(app.) all images, icons, libraries, etc. and they`re in...

### I do now understand how to set the placement of the install files.

### And most importantly, it seems to fix the app`s. path-to-its-files problem.
......... More testing on other source packages will tell how well this works.
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4279

PostPosted: Thu 01 Sep 2011, 23:11    Post subject:  

magic ermine can do what you are wanting (all in 1 binary)- I have tried it before and have permission to distribute any open source apps.
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5009
Location: Arizona, U.S.A.

PostPosted: Fri 02 Sep 2011, 01:05    Post subject:  

technosaurus; Went to the web site and there`s only a 15 day trial.
It does sound exactly like what I spoke of, but I`ve had good luck so far.
I`ve gotten several apps working with you and amigo`s help, many thanks!

A lot of apps. have dependencies that Puppy doesn`t have, so they grow big.
It`s time consuming searching, downloading, compile, and find they need more...

Same for the Panel I`m looking for, downloaded lots, but most are task bars +.
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4279

PostPosted: Fri 02 Sep 2011, 09:33    Post subject:  

i'm getting a bit off topic here, but related.

If you are build something with a new library dependency, add -ffunction-sections and -fdata-sections to the lib when you compile it statically & add the same CFLAGS to your program too along with -Wl,--gc-sections to your LDFLAGS.
If you want to get a picture of how much space it saves you you can use -Wl,--print-gc-sections

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5009
Location: Arizona, U.S.A.

PostPosted: Fri 02 Sep 2011, 14:25    Post subject:  

Now I`m going to have to read more on this. I know nothing of which you speak.
One by one here...

# add -ffunction-sections and -fdata-sections to the lib when you compile it statically
Add these to one or more of the files in the extracted source package?

# add the same CFLAGS to your program too along with -Wl,--gc-sections to your LDFLAGS
Same here I assume? CFLAGS and LDFLAGS are variables in source config. files?

# -Wl,--print-gc-sections
And this last one shows the space savings for having used the previous instructions?

If the difference in the savings is closer to the non-static build it`d be great.

# All this I assume is for static builds? I need more clarification...
A static build seems to be mainly libs. included? Or other data files as well?

I think keeping most of the libs. separate is good for saving space.
Unique ones to the app. should go in it. This demands a statistical analysis.
What libs. are most common? This Q is a monster as there`s thousands of libs.

An added dir. to LD_LIBRARY_PATH will make it possible to add new libs.
So not a problem. Puppy already has one of course: /root/my-applications/lib
I usually add libs. there if I`m doing things manually. Easy to find and delete them.

Is there a quick way to know what libs. a distro. has? ( cat ld.so.conf | find )
"ldd" shows what`s needed. The two could be compared for a missing list.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 2 [30 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0954s ][ Queries: 12 (0.0053s) ][ GZIP on ]