LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   smart way for caching libraries with ldconfig (https://www.linuxquestions.org/questions/linux-software-2/smart-way-for-caching-libraries-with-ldconfig-924323/)

entz 01-17-2012 07:40 PM

smart way for caching libraries with ldconfig
 
hi ,

i'm looking for a smart way to have ldconfig recursively search and cache all libraries that it finds in a particular directory.

this is because not all libraries are set in previously known locations .

for instance , libraries might be in /usr/lib/<application-name>/libxxx
that are not known prior to installation , and i want this to be automated which means i can't afforf manually editing ld.so.conf for each and every library or app that's being installed

i want for instance ldconfig to cache all libraries in /usr/lib/* INCLUDING SUBDIRECTORIES !!!
is there a special syntax for ld.so.conf files ?


thanks in advance

unSpawn 02-18-2012 03:50 AM

Should you really?..
 
Quote:

Originally Posted by entz (Post 4577396)
i want for instance ldconfig to cache all libraries in /usr/lib/* INCLUDING SUBDIRECTORIES !!!
is there a special syntax for ld.so.conf files ?

See 'man ldconfig': the part about "trusted directories".


Quote:

Originally Posted by entz (Post 4577396)
for instance , libraries might be in /usr/lib/<application-name>/libxxx that are not known prior to installation , and i want this to be automated which means i can't afforf manually editing ld.so.conf for each and every library or app that's being installed

The preferred way is to drop a configuration file in /etc/ld.so.conf.d/ containing just the name of the subdirectory. It doesn't mean you should cache each and every library found in /usr/lib subdirectories though.


Should you want to do it anyway (*shrug*, your fault, not mine) you can use something like:
Code:

find /usr/lib -type f | while read LIBFILE; do
 file "${LIBFILE}"|grep -q 'shared object' && ( ldconfig -p|grep -q $(basename "${LIBFILE}")||echo $(dirname "${LIBFILE}") )
done | sort -u > /etc/ld.so.conf.d/IDoWhateverIwantEvenIfNotAdvisable


//NTLB


All times are GMT -5. The time now is 05:37 PM.