| 1 |
# Singleton class to access package.mask |
| 2 |
class Pdotmask |
| 3 |
def initialize |
| 4 |
end |
| 5 |
|
| 6 |
def initialize(file = "#{ENV["PORTDIR"]}/profiles/package.mask") |
| 7 |
@masks = Array.new |
| 8 |
|
| 9 |
IO.foreach(file) do |line| # For each line in p.mask |
| 10 |
line =~ /^([^\#]*)(#.*)?\n$/ |
| 11 |
@masks << $1 if $1 != nil and $1 != "" |
| 12 |
end |
| 13 |
end |
| 14 |
|
| 15 |
# gets the mask for a given package |
| 16 |
def masksfor(package) |
| 17 |
package_re=package.gsub('+', "[+]") |
| 18 |
pmasks = Array.new |
| 19 |
masks.each do |mask| |
| 20 |
pmasks << mask if mask =~ /^(>|>=|=|<=|<)?(#{package_re}-[^a-zA-Z*][^*]*$|#{package_re}$)/ |
| 21 |
end |
| 22 |
|
| 23 |
return pmasks |
| 24 |
end |
| 25 |
|
| 26 |
attr_reader :masks |
| 27 |
end |
| 28 |
|
| 29 |
## Kate modeline: leave at the end |
| 30 |
# kate: indent-width 2; replace-trailing-space-save 1; space-indent 1; backspace-indents 1; |