summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorAlex Legler <alex@a3li.li>2015-07-03 11:41:10 +0200
committerAlex Legler <alex@a3li.li>2015-07-03 11:41:10 +0200
commit3d0ecf32542ece3ab4893694e1a83028d043a75f (patch)
tree517668a15ea6dcbf9904dc5ae94c96b4b85acf8e /bin
parentAdd myself to the gnome herd (diff)
downloadapi-3d0ecf32542ece3ab4893694e1a83028d043a75f.tar.gz
api-3d0ecf32542ece3ab4893694e1a83028d043a75f.tar.bz2
api-3d0ecf32542ece3ab4893694e1a83028d043a75f.zip
Add USE flag list generator, ignore result file
Diffstat (limited to 'bin')
-rwxr-xr-xbin/use-index.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/bin/use-index.rb b/bin/use-index.rb
new file mode 100755
index 0000000..c0a968b
--- /dev/null
+++ b/bin/use-index.rb
@@ -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