sysdeps 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README +4 -2
- data/bin/sysdeps +6 -4
- data/changelog +8 -2
- data/lib/sysdeps.rb +15 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5386157b88a33cb1a4359d6485f5b68128c9b806889f9b166a695816e956f5f
|
4
|
+
data.tar.gz: 9298fea6f53fcef3e4fb6c87bd1ca7fc450769591553cbbcb8521332eed4e629
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63dcd649f63fac64679fc086e06490f0df979cdae0424f1c349debe2bc81ce2b40c507ab441eb66cd4d1f560d7cce858e8df67512eb4aa0a8d61d75cdda55b5b
|
7
|
+
data.tar.gz: b10993d0b7dd121134c5c9af5324618a64fd84a7a7c7459d91beb08b7bbd808c3f71c45f0f7b11e2fb2ace49d85846708dc682208a25f6ca7eb3ed32d5ae6eaf
|
data/README
CHANGED
@@ -7,13 +7,15 @@ A little script to find missing libraries on a Linux system
|
|
7
7
|
-----------------------------------------------------------
|
8
8
|
|
9
9
|
|
10
|
-
Usage: sysdeps [ -u ][ -p <program name | path> ][ -d <pattern> ][ -j ][ -h ]
|
10
|
+
Usage: sysdeps [ -u ][ -p <program name | path> ][ -d <pattern> ][ -j ][ -v ][ -h ]
|
11
11
|
no args detects missing libraries
|
12
12
|
-u build or update dapendencies cache
|
13
13
|
-p <program name | path> prints program dependencies
|
14
14
|
-d <pattern> prints programs which depends on <pattern> (regex)
|
15
15
|
-j get results in JSON
|
16
|
+
-v print program version
|
16
17
|
-h guess
|
17
18
|
|
18
|
-
|
19
19
|
The dependencies cache must be built before. (sysdeps -u)
|
20
|
+
|
21
|
+
Ex usage: 'sysdeps -p dd -p tar -d dbus'
|
data/bin/sysdeps
CHANGED
@@ -19,7 +19,7 @@ require 'json'
|
|
19
19
|
|
20
20
|
include SysDeps
|
21
21
|
|
22
|
-
|
22
|
+
VERSION = '0.0.4'
|
23
23
|
CACHE_PATH = ENV['HOME'] + '/.sysdeps_cache.json'
|
24
24
|
|
25
25
|
KDEPENDENCIES = 'dependencies'.freeze
|
@@ -35,12 +35,13 @@ trap('INT') {
|
|
35
35
|
|
36
36
|
help = ->() {
|
37
37
|
STDERR.puts <<-EOF.gsub(/^\x20+/, '').gsub(/\x09/, ' ')
|
38
|
-
Usage: #{File.basename $0} [ -u ][ -p <program name | path> ][ -d <pattern> ][ -j ][ -h ]
|
38
|
+
Usage: #{File.basename $0} [ -u ][ -p <program name | path> ][ -d <pattern> ][ -j ][ -v ][ -h ]
|
39
39
|
\t\tno args detects missing libraries
|
40
40
|
\t\t-u build or update dapendencies cache
|
41
41
|
\t\t-p <program name | path> prints program dependencies
|
42
42
|
\t\t-d <pattern> prints programs which depends on <pattern> (regex)
|
43
43
|
\t\t-j get results in JSON
|
44
|
+
\t\t-v print program version
|
44
45
|
\t\t-h guess
|
45
46
|
EOF
|
46
47
|
}
|
@@ -48,7 +49,7 @@ help = ->() {
|
|
48
49
|
|
49
50
|
build_cache = ->() {
|
50
51
|
STDERR.print 'Collecting system libs infos ... '
|
51
|
-
syslibs = SysDeps.get_syslibs
|
52
|
+
syslibs = SysDeps.get_syslibs
|
52
53
|
STDERR.puts 'done'
|
53
54
|
|
54
55
|
STDERR.print 'Collecting dependencies of programs ... '
|
@@ -156,7 +157,8 @@ main = ->{
|
|
156
157
|
'-p' => ->{ ((arg = ARGV.shift) && !arg[/^-/]) ? prog_procs.push(arg) : (help.call ; exit 1) },
|
157
158
|
'-d' => ->{ ((arg = ARGV.shift) && !arg[/^-/]) ? deps_procs.push(arg) : (help.call ; exit 1) },
|
158
159
|
'-j' => ->{ $to_json = true },
|
159
|
-
'-h' => ->{ help.call ; exit },
|
160
|
+
'-h' => ->{ help.call ; exit },
|
161
|
+
'-v' => ->{ puts VERSION ; exit },}
|
160
162
|
|
161
163
|
opts.default = ->{ help.call ; exit 1 }
|
162
164
|
|
data/changelog
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
0.0.2:
|
2
|
-
|
3
|
-
|
2
|
+
- fixed -p and -d argument passing
|
3
|
+
- fixed -p and -d printing
|
4
4
|
|
5
5
|
0.0.3:
|
6
6
|
- added dependency detection for libraries to -d option too
|
7
7
|
- fixed set of path libraries when ld.so.conf is not a file
|
8
|
+
|
9
|
+
0.0.4:
|
10
|
+
- fixed dead links
|
11
|
+
- added -v option
|
12
|
+
- scan the entire system for libraries instead of restricting search to specific
|
13
|
+
paths, to support a wide set of linux distros
|
data/lib/sysdeps.rb
CHANGED
@@ -11,8 +11,6 @@
|
|
11
11
|
# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
12
12
|
|
13
13
|
|
14
|
-
LDCONFPATH = '/etc/ld.so.conf'
|
15
|
-
|
16
14
|
DEPMARK = 'NEEDED'.freeze
|
17
15
|
ELF = 'ELF'.freeze
|
18
16
|
SYM = 'symbolic'.freeze
|
@@ -23,23 +21,27 @@ EMPTY = ''.freeze
|
|
23
21
|
readlink_absolute = ->(path) {
|
24
22
|
curdir = Dir.getwd
|
25
23
|
Dir.chdir(File.dirname path)
|
26
|
-
|
24
|
+
fp = File.readlink(File.basename path)
|
25
|
+
abs = File.exist?(fp) ? File.absolute_path(fp) : nil
|
27
26
|
Dir.chdir curdir
|
28
27
|
abs }
|
29
28
|
|
30
29
|
|
31
|
-
get_syslibs = ->
|
32
|
-
ldconf_paths = File.file?(LDCONFPATH) && File.readable?(LDCONFPATH) ? File.read(LDCONFPATH).split : []
|
33
|
-
ldpaths = ldconf_paths.union(paths).join ' '
|
30
|
+
get_syslibs = -> {
|
34
31
|
sopat = /\.so\.?/
|
35
32
|
|
36
|
-
%x(find
|
33
|
+
%x(find / \\( -type f -o -type l \\) 2>/dev/null)
|
37
34
|
.split
|
38
|
-
.select { |l|
|
39
|
-
l[sopat] }
|
35
|
+
.select { |l| l[sopat] }
|
40
36
|
.map { |l|
|
41
|
-
File.ftype(l) == LINK
|
42
|
-
|
37
|
+
if File.ftype(l) == LINK
|
38
|
+
fp = readlink_absolute(l)
|
39
|
+
fp ? [l, fp] : nil
|
40
|
+
else
|
41
|
+
l
|
42
|
+
end }
|
43
|
+
.flatten
|
44
|
+
.select { |l| l }}
|
43
45
|
|
44
46
|
|
45
47
|
get_program_dependencies = ->(prg) {
|
@@ -52,6 +54,7 @@ get_program_dependencies = ->(prg) {
|
|
52
54
|
|
53
55
|
prgpath = readlink_absolute(prgpath) if File.ftype(prgpath) == LINK
|
54
56
|
|
57
|
+
return nil unless prgpath
|
55
58
|
return nil if %x(file #{prgpath}).split[1] != ELF
|
56
59
|
|
57
60
|
deppat = /\s+#{DEPMARK}\s+/
|
@@ -83,6 +86,7 @@ get_libraries_dependencies = ->(syslibs) {
|
|
83
86
|
syslibs.each_with_object({}) { |sl, o|
|
84
87
|
sl = readlink_absolute(sl) if File.ftype(sl) == LINK
|
85
88
|
|
89
|
+
next unless sl
|
86
90
|
next if %x{file #{sl}}.split[1] != ELF
|
87
91
|
|
88
92
|
o[sl.chomp] =
|