Is There a Way to Know Full Dependencies?
Simon Ruderich
simon at ruderich.com
Wed Aug 29 16:52:22 PDT 2007
Xin Liu wrote:
> Hi,
>
> I'm just wondering, is there an easy way to know the full dependencies
> for installing a package? For instance, gnuplot depends on tetex, and
> tetex further depends on texinfo, then is it possible for me to know
> that gnuplot indirectly depends on texinfo before the actual
> downloading and compiling start? I ask this because I want to easily
> find out the full dependencies of installing a package before
> installing anything, so that if I don't like a particular dependency,
> I can edit the portfile to bypass it.
>
> Best
> Regards,
>
> Xin Liu
Hi,
sorry for the late reply, but I didn't came across this problem until now.
I don't know of any direct way within macports but I created a small
ruby script which does what you want. I'm not sure if it uses a very
good way, because it's a bit slow, but it works for me.
Just use "./alldeps.rb <your portname here>" with it and it should give
you all decencies.
I attached it to this mail.
But it would be really nice if this could be integrated in macports (or
if it's already there, said to me :-) )
Hope this helps,
Simon
--
+ privacy is necessary
+ using http://gnupg.org
+ public key id: 0x6115F804EFB33229
-------------- next part --------------
#!/usr/bin/env ruby
puts "Usage: ./alldeps.rb <port name>" if ARGV[0].nil?
# gets all dependencies:
def port_deps( port )
# get the dependencies of this port:
result = `port deps "#{port}" 2>&1`
# abort with false if the port couldn't be found:
( puts result; exit ) if result =~ /Error: No port .+ found\./
# return an empty array if the port doesn't have any dependencies:
return [] if result =~ /.+ has no dependencies/
# array to store the dependencies:
deps = []
# add each dependency of this port:
result.each do |line|
deps << line.strip if line =~ /^\s+\S+/
end
# add the dependencies of each dependency to deps to get all:
deps.each do |dep|
# add the dependency only if it doesn't exist already:
port_deps( dep ).each { |dep| deps << dep unless deps.include? dep }
end
# return the collect dependencies:
deps
end
# output all dependencies:
port_deps( ARGV[0] ).sort.each { |dep| puts "- #{dep}" }
More information about the macports-users
mailing list