mirror of
https://git.FreeBSD.org/ports.git
synced 2024-10-31 21:57:12 +00:00
65 lines
1.4 KiB
Ruby
Executable File
65 lines
1.4 KiB
Ruby
Executable File
#!/usr/local/bin/ruby
|
|
class Plist
|
|
def initialize(no_manpages = true, excl = nil)
|
|
@no_manpages = no_manpages
|
|
self.excludes = excl
|
|
self
|
|
end
|
|
def excludes
|
|
@excludes.dup
|
|
end
|
|
def excludes=(excl)
|
|
if !excl
|
|
@excludes = [
|
|
/^(bin|etc|include|info|lib|libexec|man|sbin|share)$/,
|
|
'etc/rc.d',
|
|
/^lib\/perl5?(\/.*site_perl\/[[:digit:]]\.[[:digit:]]+)?$/,
|
|
/^lib\/xemacs(\/site-lisp)?$/,
|
|
/^man\//,
|
|
/^share\/(dict|doc|emacs|emacs\/site-lisp|examples|misc|skel)$/,
|
|
/^share\/nls($|\/)/
|
|
]
|
|
else
|
|
@excludes = excl.to_a
|
|
end
|
|
|
|
end
|
|
def make(dir)
|
|
@root = dir.to_s + '/'
|
|
imake('', 0, '')
|
|
end
|
|
private
|
|
def imake(dir, level, prevwd)
|
|
thiswd = prevwd + dir # always ends in '/'
|
|
rootedwd = @root + thiswd
|
|
subs = []
|
|
Dir.foreach(rootedwd) {|dirent|
|
|
next if dirent =~ /^\.\.?$/
|
|
if test(?d, rootedwd + dirent)
|
|
subs.concat(imake(dirent + '/', level + 1, thiswd))
|
|
else
|
|
if thiswd !~ /^man\// || !@no_manpages
|
|
subs.push(thiswd + dirent)
|
|
end
|
|
end
|
|
}
|
|
thiswd.chop!
|
|
if level > 0 && !@excludes.find {|x| x === thiswd}
|
|
subs.push('@dirrm ' + thiswd)
|
|
end
|
|
return subs
|
|
end
|
|
end
|
|
|
|
if __FILE__ == $0
|
|
if ARGV.size != 1
|
|
$stderr.print <<-USAGE_EOF
|
|
usage: #{$0} somepath
|
|
Generate a pkg-plist to stdout given a previously empty somepath which
|
|
a port has been installed into (PREFIX=somepath).
|
|
USAGE_EOF
|
|
exit 1
|
|
end
|
|
puts Plist.new.make(ARGV[0]).join("\n")
|
|
end
|