~ubuntu-branches/ubuntu/wily/tupi/wily-proposed

« back to all changes in this revision

Viewing changes to .pc/ruby_to_1.9.patch/qonf/test.rb

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2013-06-23 12:48:05 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130623124805-9xq9kggclxvli7r9
Tags: 0.2+git02-1
* New upstream release [June 2013].
  + ready for "libav9" transition.
* Build-Depends:
  + libquazip-dev
* Packaging updates:
  + added ugly override for broken upstream libav detection;
    "pkg-config" is added to Build-Depends for that matter.
  + rules simplified as upstream introduced support for $(DESTDIR).
  + re-build translations after configure.
  + re-build/re-compress man page.
  + dropped all patches.
  + updated lintian-overrides, new overrides for
    "library-not-linked-against-libc" in private libs.
  + ship all icons and docs in -data package.
  + data de-duplication in -data package.
  + debian/watch to check for tags at github as well.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
require 'qonf/qmake'
3
 
require 'qonf/detectos'
4
 
require 'rexml/parsers/sax2parser'
5
 
require 'rexml/sax2listener'
6
 
 
7
 
require 'qonf/info'
8
 
 
9
 
module RQonf
10
 
 
11
 
class Test
12
 
    include REXML
13
 
    
14
 
    attr_reader :rules
15
 
    attr_reader :optional
16
 
    
17
 
    def initialize(rulesPath, qmake)
18
 
        @rules = rulesPath
19
 
        @qmake = qmake
20
 
        
21
 
        @optional = false
22
 
    end
23
 
    
24
 
    def run(config, conf, debug, isLucid)
25
 
 
26
 
        parser = Parser.new
27
 
        parser.os = DetectOS::OS[DetectOS.whatOS].to_s.downcase
28
 
        
29
 
        return false if not parser.parse(@rules) or parser.name.empty?
30
 
        
31
 
        @optional = parser.optional
32
 
        
33
 
        Info.info << "Checking for " << parser.name << "... "
34
 
        
35
 
        dir = "#{File.dirname(@rules)}/#{parser.dir}"
36
 
 
37
 
        if $DEBUG
38
 
            Info.warn << "Running in " << dir << $endl
39
 
        end
40
 
        
41
 
        cwd = Dir.getwd
42
 
 
43
 
        if File.exists?(dir)
44
 
            if File.stat(dir).directory?
45
 
                Dir.chdir(dir)
46
 
 
47
 
                extraLib = ""
48
 
                extraInclude = ""
49
 
                if RUBY_PLATFORM == "x86_64-linux"
50
 
                   extraLib = "-L/usr/lib64 "
51
 
                end
52
 
 
53
 
                if File.dirname(@rules).end_with?("ffmpeg")  
54
 
                   if conf.hasArgument?("with-ffmpeg")
55
 
                      ffmpegLib = conf.argumentValue("with-ffmpeg") + "/lib"
56
 
                      extraLib += "-L#{ffmpegLib}"
57
 
                      extraInclude = conf.argumentValue("with-ffmpeg") + "/include"
58
 
                   end
59
 
                end
60
 
 
61
 
                qmakeLine = ""
62
 
                 
63
 
                if extraLib.length > 0 
64
 
                   qmakeLine = "'LIBS += #{extraLib} #{parser.libs.join(" ")}'";
65
 
                end
66
 
 
67
 
                if extraInclude.length > 0    
68
 
                   qmakeLine += " 'INCLUDEPATH += #{extraInclude} #{parser.includes.join(" ")}'";
69
 
                end
70
 
 
71
 
                if isLucid
72
 
                   qmakeLine = "'DEFINES += K_LUCID' " + qmakeLine
73
 
                end
74
 
 
75
 
                @qmake.run(qmakeLine, true)
76
 
 
77
 
                if not @qmake.compile(debug)
78
 
                    Dir.chdir(cwd)
79
 
                    
80
 
                    print "[ \033[91mFAILED\033[0m ]\n"
81
 
 
82
 
                    priority = "\033[92moptional\033[0m"
83
 
                    flag = "\033[92mCOULD\033[0m"
84
 
                    if @optional == false
85
 
                       priority = "\033[91mrequired\033[0m"
86
 
                       flag = "\033[91mMUST\033[0m"
87
 
                    end
88
 
 
89
 
                    Info.info << "Priority: " << priority << "\n"
90
 
 
91
 
                    
92
 
                    # Provide solution
93
 
                    solution = parser.solution
94
 
                    
95
 
                    Info.warn << "Seems like you are running " << parser.os << "..." << $endl
96
 
                    Info.warn << "You " << flag << " install these dependencies: " << solution[:package] << $endl
97
 
                    Info.warn << "URL: " << solution[:url] << $endl
98
 
                    Info.warn << solution[:comment] << $endl
99
 
                    
100
 
                    return false
101
 
                end
102
 
            else
103
 
                Dir.chdir(cwd)
104
 
                raise QonfException.new("'#{dir}' isn't a directory!")
105
 
                return false
106
 
            end
107
 
        else
108
 
            Dir.chdir(cwd)
109
 
            raise QonfException.new("'#{dir}' doesn't exists!")
110
 
            return false
111
 
        end
112
 
        
113
 
        Dir.chdir(cwd)
114
 
 
115
 
        parser.includes.each { |inc|
116
 
            config.addIncludePath(inc)
117
 
        }
118
 
        
119
 
        parser.libs.each { |lib|
120
 
            config.addLib(lib)
121
 
        }
122
 
        
123
 
        parser.defines.each { |define|
124
 
            config.addDefine(define)
125
 
        }
126
 
 
127
 
        parser.modules.each { |mod|
128
 
            config.addModule(mod)
129
 
        }
130
 
        
131
 
        print "[ \033[92mOK\033[0m ]\n"
132
 
 
133
 
        priority = "\033[92moptional\033[0m"
134
 
        if @optional == false 
135
 
           priority = "\033[91mrequired\033[0m" 
136
 
        end
137
 
 
138
 
        Info.info << "Priority: " << priority << "\n"
139
 
        
140
 
        return true
141
 
    end
142
 
    
143
 
    def to_s
144
 
        @rules
145
 
    end
146
 
    
147
 
    private
148
 
    class Parser
149
 
        include REXML::SAX2Listener
150
 
        
151
 
        attr_reader :name
152
 
        attr_reader :dir
153
 
        attr_reader :defines
154
 
        attr_reader :includes
155
 
        attr_reader :libs
156
 
        attr_reader :modules
157
 
        attr_accessor :os
158
 
        attr_reader :solution
159
 
        attr_reader :optional
160
 
        
161
 
        def initialize
162
 
            @name = ""
163
 
            @current_tag = ""
164
 
            @section = ""
165
 
            @dir = ""
166
 
            @defines = []
167
 
            @includes = []
168
 
            @libs = []
169
 
            @modules = []
170
 
            @solution = {}
171
 
            @os = ""
172
 
            @optional = false
173
 
        end
174
 
        
175
 
        def start_document
176
 
        end
177
 
        
178
 
        def end_document
179
 
        end
180
 
        
181
 
        def start_element( uri, localname, qname, attributes)
182
 
            case qname
183
 
                when "qonf"
184
 
                    @optional = (attributes["optional"] == "true")
185
 
                when "test"
186
 
                    @section = qname
187
 
                    @name = attributes["name"].to_s
188
 
                when "dir"
189
 
                    if @section == "test"
190
 
                        @dir = attributes["path"]
191
 
                    end
192
 
                when "provide"
193
 
                    @section = qname
194
 
                when "define"
195
 
                    if @section  == "provide"
196
 
                        @defines << attributes["value"]
197
 
                    end
198
 
                when "include"
199
 
                    if @section  == "provide"
200
 
                        @includes << attributes["path"]
201
 
                    end
202
 
                when "lib"
203
 
                    if @section  == "provide"
204
 
                        @libs << attributes["path"]
205
 
                    end
206
 
                when "module"
207
 
                    if @section == "provide"
208
 
                        @modules << attributes["value"]
209
 
                    end
210
 
                when "command"
211
 
                    if @section == "provide"
212
 
                        if @current_tag == "includes"
213
 
                            IO.popen(attributes["value"]) { |c|
214
 
                                output = c.readlines.join("").split(" ")
215
 
                                
216
 
                                output.each { |i|
217
 
                                    if i =~ /-I(.*)/
218
 
                                        @includes << $1.chomp
219
 
                                    elsif not i =~ /-.*/
220
 
                                        @includes << i
221
 
                                    end
222
 
                                }
223
 
                            }
224
 
                        elsif @current_tag == "libs"
225
 
                            IO.popen(attributes["value"]) { |c|
226
 
                                output = c.readlines.join("").split(" ")
227
 
                                
228
 
                                output.each { |lib|
229
 
                                    if lib =~ /-l(.*)/
230
 
                                        @libs << lib
231
 
                                    elsif lib[0].chr != "-"
232
 
                                        @libs << lib
233
 
                                    end
234
 
                                }
235
 
                                @libs.concat(output)
236
 
                            }
237
 
                        end
238
 
                    end
239
 
                when "solution"
240
 
                    @section = "solution"
241
 
                when "windows"
242
 
                    if @os == qname and @solution.size == 0
243
 
                        fillSolution(attributes)
244
 
                    end
245
 
                when "macosx"
246
 
                    if @os == qname and @solution.size == 0
247
 
                        fillSolution(attributes)
248
 
                    end
249
 
                when "linux"
250
 
                    if @os == qname and @solution.size == 0
251
 
                        fillSolution(attributes)
252
 
                    end
253
 
                when "distribution"
254
 
                    if @os == attributes["name"].to_s.downcase and @solution.size == 0
255
 
                        fillSolution(attributes)
256
 
                    end
257
 
            end
258
 
            
259
 
            @current_tag = qname
260
 
        end
261
 
        
262
 
        def end_element(uri, localname, qname)
263
 
            case qname
264
 
                when ""
265
 
            end
266
 
            
267
 
        end
268
 
        
269
 
        def characters(text)
270
 
            text = text.strip
271
 
            if not text.empty?
272
 
            end
273
 
        end
274
 
        
275
 
        def parse(path)
276
 
            sax2 = REXML::Parsers::SAX2Parser.new( File.new( path ) )
277
 
            sax2.listen(self)
278
 
            
279
 
            begin
280
 
                sax2.parse
281
 
            rescue
282
 
                return false
283
 
            end
284
 
            
285
 
            return true
286
 
        end
287
 
        
288
 
        private
289
 
        def fillSolution(attributes)
290
 
            @solution[:package] = attributes["package"]
291
 
            @solution[:url] = attributes["url"]
292
 
            @solution[:comment] = attributes["comment"]
293
 
        end
294
 
    end
295
 
end
296
 
 
297
 
end #module
298