Class: QtRebuild

Inherits:
Object
  • Object
show all
Defined in:
lib/qt-rebuild/qt-rebuild.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeQtRebuild

Returns a new instance of QtRebuild.



10
11
12
13
# File 'lib/qt-rebuild/qt-rebuild.rb', line 10

def initialize
  @pkgs_to_build_keys = {}
  @build_keys_to_pkgs = {}
end

Instance Attribute Details

#build_keys_to_pkgsObject (readonly)

Returns the value of attribute build_keys_to_pkgs.



4
5
6
# File 'lib/qt-rebuild/qt-rebuild.rb', line 4

def build_keys_to_pkgs
  @build_keys_to_pkgs
end

#pkgs_to_build_keysObject (readonly)

Returns the value of attribute pkgs_to_build_keys.



4
5
6
# File 'lib/qt-rebuild/qt-rebuild.rb', line 4

def pkgs_to_build_keys
  @pkgs_to_build_keys
end

Class Method Details

.versionObject



6
7
8
# File 'lib/qt-rebuild/qt-rebuild.rb', line 6

def self.version
  IO.read(File.join(File.dirname(__FILE__), '../../VERSION')).strip
end

Instance Method Details

#build_keysObject



79
80
81
# File 'lib/qt-rebuild/qt-rebuild.rb', line 79

def build_keys
  @build_keys_to_pkgs.keys
end

#emerge(pretend, nocolor) ⇒ Object



57
58
59
60
61
62
63
64
65
# File 'lib/qt-rebuild/qt-rebuild.rb', line 57

def emerge(pretend, nocolor)
  buf = []
  buf << 'emerge'
  buf << '--oneshot'
  buf << '--pretend' if pretend
  buf << '--nocolor' if nocolor
  buf += to_set
  puts `#{buf.join(' ')}`
end

#scanObject

scan the installed packages looking for qt dependents that have build keys. These are the files than should be rebuilt whenever qt’s API changes.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/qt-rebuild/qt-rebuild.rb', line 18

def scan
  qt_packages = `qlist -IC x11-libs/qt:4`.split("\n")

  dependents = []
  qt_packages.each do |pkg|
    dependents += `equery -q depends \"#{pkg}\"`.split("\n")
  end
  dependents = dependents.uniq.compact.sort

  dependents.each do |pkg|
    build_keys = []
    so_files = `qlist -Co #{pkg}`.split("\n").select{|file| file =~ /\.so(\..+|)$/}
    so_files.each do |file|
      if `strings #{file} | grep buildkey` =~ /^build\s*key[=:\s]\s*(\S.*)\s*$/i
        build_keys << $1
      end
    end
    build_keys = build_keys.compact.uniq
    unless build_keys.empty?
      @pkgs_to_build_keys[pkg] = build_keys
      build_keys.each do |key|
        @build_keys_to_pkgs[key] ||= []
        @build_keys_to_pkgs[key] << pkg
      end
    end
  end
end

#to_sObject



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/qt-rebuild/qt-rebuild.rb', line 67

def to_s
  buf = []
  @build_keys_to_pkgs.keys.sort.each do |key|
    buf << "# Build key:  #{key}"
    pkgs = @build_keys_to_pkgs[key]
    pkgs.each do |pkg|
      buf << pkg
    end
  end
  buf.compact.uniq.sort.join("\n")
end

#to_setObject



46
47
48
49
50
51
52
53
54
55
# File 'lib/qt-rebuild/qt-rebuild.rb', line 46

def to_set
  buf = []
  @build_keys_to_pkgs.keys.sort.each do |key|
    pkgs = @build_keys_to_pkgs[key]
    pkgs.each do |pkg|
      buf << '=' + pkg
    end
  end
  buf.compact.uniq
end