aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/hooks
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2013-07-11 22:44:06 -0400
committerJoas Schilling <nickvergessen@gmx.de>2013-07-11 22:44:06 -0400
commit1911285b77fa791ca202f810e4ba40c822aa5ae9 (patch)
tree84f6b4b62c9644099aad58826640ec6afe32c0c7 /phpBB/includes/hooks
parent003a104f931201704998f5c00c5cf982896b470b (diff)
downloadforums-1911285b77fa791ca202f810e4ba40c822aa5ae9.tar
forums-1911285b77fa791ca202f810e4ba40c822aa5ae9.tar.gz
forums-1911285b77fa791ca202f810e4ba40c822aa5ae9.tar.bz2
forums-1911285b77fa791ca202f810e4ba40c822aa5ae9.tar.xz
forums-1911285b77fa791ca202f810e4ba40c822aa5ae9.zip
[ticket/9657] Notifications do not require emails or jabber anymore
PHPBB3-9657
Diffstat (limited to 'phpBB/includes/hooks')
0 files changed, 0 insertions, 0 deletions
7' href='#n117'>117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
#!/usr/bin/ruby

require 'fileutils'
require 'rubygems'
require 'sqlite3'
require_relative 'bugscan'

def create_tables(db)
    #db.execute "CREATE TABLE IF NOT EXISTS Packages(Id INTEGER PRIMARY KEY, Name TEXT, Version TEXT, Release TEXT, UNIQUE (Name, Version, Release))"
    db.execute "CREATE TABLE IF NOT EXISTS Packages(Id INTEGER PRIMARY KEY, Name TEXT, UNIQUE (Name))"
    db.execute "CREATE TABLE IF NOT EXISTS Runs(Id INTEGER PRIMARY KEY, Start INTEGER, End INTEGER, UNIQUE(Start))"
    db.execute "CREATE TABLE IF NOT EXISTS ResultValues(Id INTEGER PRIMARY KEY, Name TEXT, UNIQUE(Name))"
    db.execute "CREATE TABLE IF NOT EXISTS Results(Id INTEGER PRIMARY KEY, Package INTEGER, Run INTEGER, Result INTEGER,
		FOREIGN KEY(Package) REFERENCES Packages(Id),
		FOREIGN KEY(Run) REFERENCES Run(Id),
		FOREIGN KEY(Result) REFERENCES ResultValues(Id),
                UNIQUE(Package, Run, Result))"
    db.execute "CREATE TABLE IF NOT EXISTS Diffs(Run INTEGER PRIMARY KEY, New INTEGER, Fixed INTEGER, NotFixed INTEGER)"
    db.execute "CREATE TABLE IF NOT EXISTS Attributes(Id INTEGER PRIMARY KEY, Package INTEGER, Run INTEGER, Attr TEXT,
        FOREIGN KEY(Package) REFERENCES Packages(Id),
        FOREIGN KEY(Run) REFERENCES Run(Id),
        UNIQUE(Package, Run))"
end

def get_or_add_resultvalue(db, result)
    db.execute "INSERT OR IGNORE INTO ResultValues(Name) VALUES('#{result}')"
    return db.execute("SELECT Id FROM ResultValues WHERE Name = '#{result}'")[0][0]
end

def get_or_add_package(db, name, version, release)
    #db.execute "INSERT OR IGNORE INTO Packages(Name, Version, Release) VALUES('#{name}','#{version}','#{release}')"
    #return db.execute("SELECT Id FROM Packages WHERE Name = '#{name}' AND Version = '#{version}' AND Release = '#{release}'")[0][0]
    db.execute "INSERT OR IGNORE INTO Packages(Name) VALUES('#{name}')"
    return db.execute("SELECT Id FROM Packages WHERE Name = '#{name}'")[0][0]
end

# Find interesting attributes about the package. Right now, this is just interesting
# dependencies.
def find_attributes(build_dir)
    attr = {}
    rpm_list_files = Dir.glob(build_dir + '/rpm_qa.*.log')
    rpm_list_file = rpm_list_files[0]
    if rpm_list_file then
        File.open(rpm_list_file, 'r') {|f|
            f.each_line{|l|
                if l !~ /^(.*)-([^-]*)-([^-]*)/ then
                    puts "Skipping " + l
                    next
                end
                name = $1
                if name =~ /^((bwbasic)|(yabasic)|(mono-basic))$/ then
                    attr[:lang_basic] = true
                end
                if name =~ /^mono$/ then
                    attr[:lang_dotnet] = true
                end
                if name =~ /^(erlang)-compiler$/ then
                    attr[:lang_erlang] = true
                end
                if name =~ /^gcc-g(fortran)$/ then
                    attr[:lang_fortran] = true
                end
                if name =~ /^golang$/ then
                    attr[:lang_go] = true
                end
                if name =~ /^groovy$/ then
                    attr[:lang_groovy] = true
                end
                if name =~ /^ghc$/ then
                    attr[:lang_haskell] = true
                end
                if name =~ /^(java)|(gcc-java)/ then
                    attr[:lang_java] = true
                end
                if name =~ /^c(lisp)-devel$/ then
                    attr[:lang_lisp] = true
                end
                if name =~ /^lib(64)?lua-devel$/ then
                    attr[:lang_lua] = true
                end
                if name =~ /^gcc-objc$/ then
                    attr[:lang_objc] = true
                end
                if name =~ /^(ocaml)-compiler$/ then
                    attr[:lang_ocaml] = true
                end
                if name =~ /^(nodejs)|(uglify-js)|(slimit)|(yuicompressor)$/ then
                    attr[:lang_javascript] = true
                end
                if name =~ /^fpc(-src)?$/ then
                    attr[:lang_pascal] = true
                end
                if name =~ /^(perl)/ then
                    # A bunch of perl modules are installed in every installation,
                    # so ignore those.
                    # A few are also pretty common and are ignored because of
                    # too many false positives:
                    #   perl-libintl-perl
                    #   perl-WWW-Curl (required by openssl)
                    if name !~ /^((perl)|(perl-base)|(perl-Config-IniFiles)|(perl-Exporter-Tiny)|(perl-File-Slurp)|(perl-File-Sync)|(perl-Filesys-Df)|(perl-IO-stringy)|(perl-JSON)|(perl-libintl-perl)|(perl-List-MoreUtils)|(perl-List-MoreUtils-XS)|(perl-Locale-gettext)|(perl-MDK-Common)|(perl-MDV-Distribconf)|(perl-MDV-Packdrakeng)|(perl-Module-ScanDeps)|(perl-srpm-macros)|(perl-Time-ZoneInfo)|(perl-URPM)|(perl-WWW-Curl)|(perl-XML-LibXML)|(perl-XML-NamespaceSupport)|(perl-XML-SAX)|(perl-XML-SAX-Base)|(perl-YAML)|(perl-YAML-Tiny))$/ then
                        attr[:lang_perl] = true
                    end
                end
                if name =~ /^((php)-devel)|(lib(64)?php_common)/ then
                    attr[:lang_php] = true
                end
                if name =~ /^((python3?-setuptools)|(lib(64)?python3?-devel))$/ then
                    attr[:lang_python] = true
                end
                if name =~ /^((ruby)-devel)|(lib(64)?ruby[0-9])/ then
                    attr[:lang_ruby] = true
                end
                if name =~ /^tcl$/ then
                    attr[:lang_tcl] = true
                end
                if name =~ /^vala$/ then
                    attr[:lang_vala] = true
                end

                # Check for a few build systems, too
                if name =~ /^ant$/ then
                    attr[:build_ant] = true
                end
                if name =~ /^bazel$/ then
                    attr[:build_bazel] = true
                end
                if name =~ /^cmake$/ then
                    attr[:build_cmake] = true
                end
                if name =~ /^maven$/ then
                    attr[:build_maven] = true
                end
                if name =~ /^scons$/ then
                    attr[:build_scons] = true
                end
            }
        }
    end

    attr_line = ''
    attr.keys.map{|key| key.to_s}.sort.each do |key|
        attr_line = attr_line + ' ' + key
    end
    attr_line = attr_line.strip()
    return attr_line
end

# Find interesting things about the build, indicating a known bug
def find_bug_matches(build_dir)
    build_files = Dir.glob(build_dir + '/build.*.log')
    build_file = build_files[0]
    if build_file then
        # Big regex that matches everything we're looking for
        # Regexp.union doesn't work as it doesn't bracket each regex
        any_bug_re = Regexp.new('(' + $bug_matches.keys.join(')|(') + ')')
        regex_list = $bug_matches.keys.map{|key| key.to_s}

        # loop over file
        File.open(build_file).each_line do |li|
            if any_bug_re.match(li) then
                # loop over individual regexes to find the matching one
                regex_list.each do |regex|
                   return $bug_matches[regex] if (/#{regex}/.match(li))
                end
            end
        end
        return ''
    end
end

def insert_run(db, status_file)
    t_start = Date.parse(File.basename(File.dirname(status_file))).strftime('%s')
    puts "Inserting data for run #{t_start} (#{status_file})"
    t_end = File.mtime(status_file).to_i
    db.execute "INSERT INTO Runs(Start, End) VALUES(#{t_start}, #{t_end})"
    run_id = db.last_insert_row_id
    File.open(status_file, 'r') {|f|
        db.transaction
        f.each_line{|l|
            if l !~ /^(.*)-([^-]*)-([^-]*).src.rpm: (.*)$/ then
                puts l
                next
            end
            name = $1
            version = $2
            release = $3
            result = $4
            if result == 'rejected' then
                next
            end
            result_id = get_or_add_resultvalue(db, result)
            package_id = get_or_add_package(db, name, version, release)
            begin