Skip to content

Commit

Permalink
Add USE flag list generator, ignore result file
Browse files Browse the repository at this point in the history
  • Loading branch information
a3li committed Jul 3, 2015
1 parent 0ae522b commit 3d0ecf3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
files/packages/use.json
29 changes: 29 additions & 0 deletions bin/use-index.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env ruby

require 'json'

GLOBAL = '/usr/portage/profiles/use.desc'
LOCAL = '/usr/portage/profiles/use.local.desc'

output = { 'global' => {}, 'local' => {} }

File.readlines(GLOBAL).each do |line|
next if line =~ /^(|#.*)$/

flag, desc = line.strip.split(' - ', 2)
output['global'][flag] = desc
end

File.readlines(LOCAL).each do |line|
next if line =~ /^(|#.*)$/

atom_flag, desc = line.strip.split(' - ', 2)
atom, flag = atom_flag.split(':', 2)
cat, pkg = atom.split('/', 2)

output['local'][cat] ||= {}
output['local'][cat][pkg] ||= {}
output['local'][cat][pkg][flag] = desc
end

puts output.to_json

0 comments on commit 3d0ecf3

Please sign in to comment.