WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: A script to check dependencies  (Read 15863 times)

Offline polikuo

  • Hero Member
  • *****
  • Posts: 724
Re: A script to check dependencies
« Reply #15 on: January 06, 2017, 06:18:40 AM »
My comment: Have you seen:
Halma on this forum have the following script thread
http://forum.tinycorelinux.net/index.php/topic,17454.0.html

Hi, thanks for your reply.
I honestly haven't seen the post before.
A great script fetching desired extensions.  :D
Although the script doesn't take care of KERNEL modules...

My goal here is to find dependencies and generate .dep files when creating extensions.
I put the recursive scan function in it to prevent unwanted tczs to be listed in the .dep file.
By unwanted tczs, I'm talking about extensions like gnome-session.

The current dep tree look like this:
gnome-session
 |--gnome-themes-standard -----> redundant, can be removed
 |--gdm-gir
 |   `--gnome-shell-gir
 |        `--gnome-shell
 |             `--gnome-themes-standard -----> already called here
 |--some
 |--other
 `--tczs

Sorry that I didn't made my point clear at my previous post.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14817
Re: A script to check dependencies
« Reply #16 on: January 06, 2017, 07:22:08 AM »
gnome-themes-standard, gnome-desktop-gir and gnome-shell-gir removed from gnome-session dep file - thanks

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14817
Re: A script to check dependencies
« Reply #17 on: January 07, 2017, 04:02:29 AM »
When I run your latest script I get:
Code: [Select]
$ ./dep_check
./dep_check: line 32: syntax error: unexpected "(" (expecting "}")

Offline polikuo

  • Hero Member
  • *****
  • Posts: 724
Re: A script to check dependencies
« Reply #18 on: January 07, 2017, 06:58:25 AM »
When I run your latest script I get:
Code: [Select]
$ ./dep_check
./dep_check: line 32: syntax error: unexpected "(" (expecting "}")
Did you accidentally add/delete anything by chance ?
My script will show help info if there are no arguments
I just copy the script from forum, and this is what I get:
Code: [Select]
tc@box:~$ ./dep_check
Usage: dep_check [-option] your_top_directory [append your list here ...]
  Available Options (Default -ns)
  -c colorful output (same as -cns)
  -d show only detected tczs, without custom extensions (cyan)
  -f show full detected dependencies with ldd (white)
  -h show this helpinfo (yellow)
  -n show dependencies that are not found (red)
  -r show recursively scanned tczs (full)
  -s show detected tczs (short)
tc@box:~$ ./dep_check /tmp/tcloop/firefox/
dbus-glib.tcz
gtk2.tcz
gtk3.tcz
libasound.tcz
tc@box:~$ ./dep_check -c /tmp/tcloop/alsa
These dependencies are missing
libsamplerate.so.0
libasound.tcz
ncurses.tcz
tc@box:~$ tce-load -si libsamplerate
tc@box:~$ ./dep_check -c /tmp/tcloop/alsa
libasound.tcz
libsamplerate.tcz
ncurses.tcz
tc@box:~$ ./dep_check -c /tmp/tcloop/alsa alsa-modules-KERNEL input-joystick-4.2.9-tinycore.tcz
alsa-modules-KERNEL.tcz
libasound.tcz
libsamplerate.tcz
ncurses.tcz
« Last Edit: January 07, 2017, 07:13:49 AM by polikuo »

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: A script to check dependencies
« Reply #19 on: January 07, 2017, 11:40:12 AM »
This is a great idea thanks for the script.

However...  At the risk of sounding dumb,   I'm having difficulty getting past the help menu.  Actually I haven't successfully made it passed the help menu.  There is always some kind of error.

Code: [Select]
/mnt/sda2/tc7-x86/optional $ getDepList
Usage: getDepList [-option] your_top_directory [append your list here ...]
  Available Options (Default -ns)
  -c colorful output (same as -cns)
  -d show only detected tczs, without custom extensions (cyan)
  -f show full detected dependencies with ldd (white)
  -h show this helpinfo (yellow)
  -n show dependencies that are not found (red)
  -r show recursively scanned tczs (full)
  -s show detected tczs (short)
/mnt/sda2/tc7-x86/optional $ getDepList -f *
/usr/local/bin/getDepList: cd: line 120: can't cd to NAS-Connect.tcz
Usage: getDepList [-option] your_top_directory [append your list here ...]
  Available Options (Default -ns)
  -c colorful output (same as -cns)
  -d show only detected tczs, without custom extensions (cyan)
  -f show full detected dependencies with ldd (white)
  -h show this helpinfo (yellow)
  -n show dependencies that are not found (red)
  -r show recursively scanned tczs (full)
  -s show detected tczs (short)
/mnt/sda2/tc7-x86/optional $ getDepList -f /tmp/tcloop/*
WARNING! copy2fs.lst found in /mnt/sda2/tc7-x86, please disable it and reboot
/mnt/sda2/tc7-x86/optional $ getDepList -f /mnt/sda2/tc7-x86/optional/*
/usr/local/bin/getDepList: cd: line 120: can't cd to /mnt/sda2/tc7-x86/optional/NAS-Connect.tcz
Usage: getDepList [-option] your_top_directory [append your list here ...]
  Available Options (Default -ns)
  -c colorful output (same as -cns)
  -d show only detected tczs, without custom extensions (cyan)
  -f show full detected dependencies with ldd (white)
  -h show this helpinfo (yellow)
  -n show dependencies that are not found (red)
  -r show recursively scanned tczs (full)
  -s show detected tczs (short)
/mnt/sda2/tc7-x86/optional $ getDepList -f *
/usr/local/bin/getDepList: cd: line 120: can't cd to NAS-Connect.tcz
Usage: getDepList [-option] your_top_directory [append your list here ...]
  Available Options (Default -ns)
  -c colorful output (same as -cns)
  -d show only detected tczs, without custom extensions (cyan)
  -f show full detected dependencies with ldd (white)
  -h show this helpinfo (yellow)
  -n show dependencies that are not found (red)
  -r show recursively scanned tczs (full)
  -s show detected tczs (short)
/mnt/sda2/tc7-x86/optional $ getDepList -r /tmp/tcloop/*
Xdialog.tcz
Xlibs.tcz
...
xz.tcz
zsync.tcz
/usr/local/bin/getDepList: line 204: Feedbacks: not found
/mnt/sda2/tc7-x86/optional $ getDepList -f /tmp/tcloop/*

/usr/local/bin/getDepList: line 204: Feedbacks: not found
/mnt/sda2/tc7-x86/optional $
/mnt/sda2/tc7-x86/optional/oss $ getDepList -r *
usr.tcz not found or size is zero
If you load it elsewhere, please move it and the dep file into your
/mnt/sda2/tc7-x86/optional/
/tmp/tcloop/firefox/usr/local/firefox $ getDepList -f *
/usr/local/bin/getDepList: cd: line 120: can't cd to Throbber-small.gif
Usage: getDepList [-option] your_top_directory [append your list here ...]
  Available Options (Default -ns)
  -c colorful output (same as -cns)
  -d show only detected tczs, without custom extensions (cyan)
  -f show full detected dependencies with ldd (white)
  -h show this helpinfo (yellow)
  -n show dependencies that are not found (red)
  -r show recursively scanned tczs (full)
  -s show detected tczs (short)
/tmp/tcloop/firefox/usr/local/firefox $
/tmp/tcloop/firefox/usr/local/firefox $ getDepList -f ./firefox
/usr/local/bin/getDepList: cd: line 120: can't cd to ./firefox
Usage: getDepList [-option] your_top_directory [append your list here ...]
  Available Options (Default -ns)
  -c colorful output (same as -cns)
  -d show only detected tczs, without custom extensions (cyan)
  -f show full detected dependencies with ldd (white)
  -h show this helpinfo (yellow)
  -n show dependencies that are not found (red)
  -r show recursively scanned tczs (full)
  -s show detected tczs (short)
/tmp/tcloop/firefox/usr/local/firefox $

closest I've been to success but still not without error is:
Code: [Select]
/tmp/tcloop/firefox/usr/local/firefox $ getDepList /tmp/tcloop/firefox/
dbus-glib.tcz
gtk3.tcz
libasound.tcz
nvidia-352.63-KERNEL.tcz
/usr/local/bin/getDepList: line 204: Feedbacks: not found
/tmp/tcloop/firefox/usr/local/firefox $

Ok lets examine this.
  • nvidia-352.63-KERNEL.tcz is also not a dep of firefox
  • libasound.tcz is an optional dep of firefox
yet firefox will not run without these deps loaded
cairo.tcz
gamin.tcz

The only list I've been able to show is what looks like a partial list of extensions in my tcz store.
So far I've not been able to show a list of missing (or otherwise) deps of any installed extensions

Maybe I misunderstand the intention of the script??
Maybe I misunderstand the usage?

Speaking of usage,
Code: [Select]
Usage: getDepList [-option] your_top_directory [append your list here ...]Why not set a default option if no option is given?
The default directory appears to be /tmp/tcloop where all extensions are loop mounted too, in which case why not use it as the default if none is specified?
When you say "your_top_directory" you mean " / "  ?
When you say "[append your list here ...]" please explain, list of what?  Extensions? executables ?



To sum up, the usage isn't exactly intuitive and I receive an error indicating how the usage is incorrect at every attempt without a correct usage example.

AIUI the script will check for missing dependencies.  However, if deps are missing the extension will refuse to load.  so how exactly am I supposed to load the extension..?  A catch 22?

Maybe I'm doing this all wrong?
« Last Edit: January 07, 2017, 12:11:48 PM by coreplayer2 »

Offline polikuo

  • Hero Member
  • *****
  • Posts: 724
Re: A script to check dependencies
« Reply #20 on: January 07, 2017, 02:11:37 PM »
To sum up, the usage isn't exactly intuitive and I receive an error indicating how the usage is incorrect at every attempt without a correct usage example.

Sorry about that, not exactly an English speaker here.  :-[
I'll try to re-explain my idea.

Let's say today I get bored, and feel like making a new extension. (for instance: ibus.tcz)

First, we compile it from source.
./configure ~~ make ~~ make install DESTDIR=/tmp/ibus-base

After all the stripping, we end up with a "top_directory" (/tmp/ibus-base),
which contains some libraries and some python scripts, make sense  :D

The main idea of the script is to find all the "shared libraries" required by the program.
To do that with my script, just type /path/to/the/script /tmp/ibus-base
Code: [Select]
tc@box:~/ $ get-dep-list /tmp/ibus-base
dconf.tcz
libnotify.tcz
You can have a colorful output by passing "-c", by the way.  :)

My script first validate that the first argument it gets is a directory, and cd to it.
No, I never use /tmp/tcloop as the default directory.
There never was a "default directory" to begin with.  ::)

That's why you get  :-\
/mnt/sda2/tc7-x86/optional $ getDepList -f *
/usr/local/bin/getDepList: cd: line 120: can't cd to NAS-Connect.tcz
/mnt/sda2/tc7-x86/optional $ getDepList -f /mnt/sda2/tc7-x86/optional/*
/usr/local/bin/getDepList: cd: line 120: can't cd to /mnt/sda2/tc7-x86/optional/NAS-Connect.tcz
/tmp/tcloop/firefox/usr/local/firefox $ getDepList -f *
/usr/local/bin/getDepList: cd: line 120: can't cd to Throbber-small.gif
/tmp/tcloop/firefox/usr/local/firefox $ getDepList -f ./firefox
/usr/local/bin/getDepList: cd: line 120: can't cd to ./firefox
Apparently you don't have a directory named "firefox" in your "/tmp/tcloop/firefox/usr/local/firefox"  ;)

In order to scan all the "shared libraries", I use "find -exec ldd {} +" to do the trick.
Thanks andyj who point out that
1. Not all dependencies are libraries, just as not all extensions are libraries. Be careful when you say extensions seem to have unneeded dependecies.
2. Watch out for circular (mutual) dependencies. Freetype <-> harfbuzz and cyrus-sasl <-> openldap are two that I know of off the top of my head.
3. Many dependencies are optional. This is particularly true for programs that use plugins / extensions / modules like Apache, PHP, LDAP, rsyslog, Postgresql, etc.
4. This requires that copy2fs.flg or copy2fs.lst not be used. Might be a problem in some cases.

Due to the copy2fs feature, the contents in a extension get copied to the RAM.
That extension will be dismissed because I check /tmp/tcloop/extension_name to figure out which tcz contains the library.
That's why you get  :-\
WARNING! copy2fs.lst found in /mnt/sda2/tc7-x86, please disable it and reboot

Since ibus depends on iso-codes and python, I need to add that to the "list-to-scan".  8)
I can append the list by typing /path/to/the/script /tmp/ibus-base iso-codes python (with or without ".tcz")
Code: [Select]
tc@box:~/ $ get-dep-list /tmp/ibus-base iso-codes python
dconf.tcz
iso-codes.tcz
libnotify.tcz
python.tcz
Actually I'm considering merging ibus.tcz and ibus-gir.tcz since they depends on each other.

I can redirect the list to a file and move on packing the extension.
Code: [Select]
tc@box:~/ $ get-dep-list /tmp/ibus-base iso-codes python > /tmp/ibus.tcz.dep

In your case, you should do /path/to/the/script /tmp/tcloop/firefox cairo.tcz gamin.tcz hicolor-icon-theme.tcz
Or you can be lazy and do /path/to/the/script /tmp/tcloop/firefox `cat firefox.dep`
(When I do this test, I boot with bootcode "base", and then only load firfox)
Code: [Select]
These dependencies are missing
libXt.so.6
libgdk-x11-2.0.so.0
libgtk-x11-2.0.so.0
dbus-glib.tcz
gamin.tcz
gtk3.tcz
hicolor-icon-theme.tcz
libasound.tcz

In fact, my script also suggest adding gtk2.tcz to the dep file.
Althought, we all know that firefox goes well without it  :P
Anyway~, after loading gtk2 you'll see
Code: [Select]
dbus-glib.tcz
gamin.tcz
gtk2.tcz
gtk3.tcz
hicolor-icon-theme.tcz
libasound.tcz
cairo.tcz is already a dependence of gtk3.tcz, that's why it's not on the list.
If you expand the dependence tree, you'll see it.  ;)
My script take care of that by looping (not a good idea for big extensions).  :'(

As for nvidia-352.63-KERNEL.tcz (renamed cause the script, but tce-load can detect that as well)  :D
Somehow ldd links these files to /usr/lib/libnvidia-glsi.so.352.63 (I knew that long ago, just couldn't figure out why) ???
  crashreporter
  libmozgk.so
  libxul.so
  updater

Finally, I have absolutely no clue where does the "Feedbacks" comes from, I never put such string in it.  :o
/mnt/sda2/tc7-x86/optional $ getDepList -f /tmp/tcloop/*
/usr/local/bin/getDepList: line 204: Feedbacks: not found
/tmp/tcloop/firefox/usr/local/firefox $ getDepList /tmp/tcloop/firefox/
dbus-glib.tcz
gtk3.tcz
libasound.tcz
nvidia-352.63-KERNEL.tcz
/usr/local/bin/getDepList: line 204: Feedbacks: not found

I hope that answers most of the questions, let me know if I miss something.  8)

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: A script to check dependencies
« Reply #21 on: January 07, 2017, 06:28:02 PM »
Thanks polikuo for the info, I'm getting used to this script.   
Although am sure I'll have forgot by next time, which is why I like default settings
Another reason for defaults in usage is that it makes you feel comfortable when there's no immediate error.
I hate a script/program which I initiated telling me I'm stupid for not providing any argument, even if I am!! 
I'd much prefer to have a default option, then if the output needs tweaking I know I can run -h option to modify the results.

FYI 
Code: [Select]
tc@box:/tmp/tcloop/firefox/usr/local/firefox$ getDepList -n .*
These dependencies are missing
libgdk-x11-2.0.so.0
libgtk-x11-2.0.so.0
/usr/local/bin/getDepList: line 204: Feedbacks: not found
tc@box:/tmp/tcloop/firefox/usr/local/firefox$
I'm guessing this is one of the limitations of the script. 
Because latest firefox is gtk3 now.
Code: [Select]
tc@box:/tmp/tcloop/firefox/usr/local/firefox$ ldd libmozgtk.so | grep 'gtk'
        libgtk-3.so.0 => /usr/local/lib/libgtk-3.so.0 (0xb728a000)
tc@box:/tmp/tcloop/firefox/usr/local/firefox$

AIUI firefox is built with lib's offering backwards compatibly for gtk2 plugins (specifically flashplayer) 
gtk2 is a dep of flash.tcz and is therefore not required to be loaded by firefox.


I also found that
Code: [Select]
/usr/local/bin/getDepList: line 204: Feedbacks: not foundcomes from libxul.so (a firefox lib)
another erroneous item to disregard..

The script attempts to process non related files like *.pdf and some text files which throws errors..

« Last Edit: January 07, 2017, 06:30:00 PM by coreplayer2 »

Offline polikuo

  • Hero Member
  • *****
  • Posts: 724
Re: A script to check dependencies
« Reply #22 on: January 07, 2017, 10:55:27 PM »
Hi coreplayer2
/usr/local/bin/getDepList: line 204: Feedbacks: not found
I can't replicate it, which version of firefox your're using ?  ???
I use getfirefox_Latest.sh on both 32&64 platform, bootcode lang=zh_TW, version 50.1.0

The script attempts to process non related files like *.pdf and some text files which throws errors..
In my script, I have
Code: [Select]
LDD_OUT="$(find . -not -type d -exec ldd {} + 2> /dev/null)"That shouldn't throw any error messages.
I can't replicate the "Feebacks error" and fix the script.  :P

P.S.
Don't use wildcard character (*) for directory.
If you create a script getARGS with 'echo "$@"' in it, you'll see:
Code: [Select]
/tmp/tcloop/firefox/usr/local/firefox$ /tmp/getARGS .*
. ..
What will happen here is that you'll cd to . (i.e. /tmp/tcloop/firefox/usr/local/firefox)
Anything after the first ARG, the script will assume it's an tcz extension.
Usually, you'll get "...tcz not found" message, but since you pass "-n" to the script,
it just ignore all the none-necessary looping and print out:
Code: [Select]
These dependencies are missing
libgdk-x11-2.0.so.0
libgtk-x11-2.0.so.0

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
A script to check dependencies
« Reply #23 on: January 07, 2017, 11:04:40 PM »
Ah ha!! It just clicked [emoji12]

The path to file under test ends in a directory, not a file !!

I knew I was doing this all wrong



Sent from my iPhone using Tapatalk
« Last Edit: January 07, 2017, 11:06:27 PM by coreplayer2 »

Offline polikuo

  • Hero Member
  • *****
  • Posts: 724
Re: A script to check dependencies
« Reply #24 on: January 07, 2017, 11:13:34 PM »
Ah ha!! It just clicked [emoji12]

The path to file under test ends in a directory, not a file !!

I knew I was doing this all wrong



Sent from my iPhone using Tapatalk

Glad that we're on the same wavelength  :)

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: A script to check dependencies
« Reply #25 on: January 07, 2017, 11:51:44 PM »
Well...   whether I'll be able to change habits is another matter..

Code: [Select]
/tmp/tcloop/alsa $ getDepList -n $PWD
These dependencies are missing
libsamplerate.so.0
/usr/local/bin/getDepList: line 204: Feedbacks: not found
/tmp/tcloop/alsa $

yet the "Feedbacks" is still present
:p

Offline polikuo

  • Hero Member
  • *****
  • Posts: 724
Re: A script to check dependencies
« Reply #26 on: January 08, 2017, 12:04:05 AM »
Well...   whether I'll be able to change habits is another matter..

Code: [Select]
/tmp/tcloop/alsa $ getDepList -n $PWD
These dependencies are missing
libsamplerate.so.0
/usr/local/bin/getDepList: line 204: Feedbacks: not found
/tmp/tcloop/alsa $

yet the "Feedbacks" is still present
:p

My script only has 201 lines
Did you accidentally copied "Feedbacks are welcomed  :D" from my previous post ?
If that's the case, delete it ~
« Last Edit: January 08, 2017, 12:05:56 AM by polikuo »

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: A script to check dependencies
« Reply #27 on: January 08, 2017, 12:15:41 AM »
That is it exactly, and there is no "exit"

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11628
Re: A script to check dependencies
« Reply #28 on: January 08, 2017, 12:26:09 AM »
Hi coreplayer2
That's what the  [Select]  to the right of where it says  Code:  is for. Click the  [Select]  and it highlights what's inside the
code tags. Then just  Ctrl-C  to copy it to the clipboard.

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: A script to check dependencies
« Reply #29 on: January 08, 2017, 01:26:09 AM »
OkI think we have figured this out

Code: [Select]
tc@box:~$ depList -n /tmp/tcloop/alsa
These dependencies are missing
libsamplerate.so.0
tc@box:~$

replaced FeedBacks with a successful exit status
Code: [Select]
exit 0
The more I look at this, the more I'm convinced the default arguments if none given should be -cdn
Code: [Select]
tc@box:~$ depList -cdn /tmp/tcloop/alsa
libasound.tcz
ncurses.tcz
These dependencies are missing
libsamplerate.so.0
tc@box:~$

For me, I find typing the path to top level directory for the build goes against the grain.  It's more intuitive and natural to enter the directory in question then run the script.

this is considerably harder
Code: [Select]
tc@box:~$ depList -cdn /tmp/tcloop/alsa
libasound.tcz
ncurses.tcz
These dependencies are missing
libsamplerate.so.0
tc@box:~$

than
Code: [Select]
/tmp/tcloop/alsa $ depList -cdn *
libasound.tcz
ncurses.tcz
These dependencies are missing
libsamplerate.so.0
/tmp/tcloop/alsa $

The latter works fine however :)
« Last Edit: January 08, 2017, 01:29:07 AM by coreplayer2 »