import os
import sys
import datetime
+import re
from time import sleep
from common import buildmonitor_db
query_data = ('F', curr_sr_status_id, info_stage_id, curr_build_project_id)
buildmonitor_db.do_query(query, query_data)
+def num_failed_packages_except_aggregate(build_project_id):
+ query = "SELECT bt.repository, bt.arch, ipa.package_name, bpa.build_status "\
+ "FROM build_project bp, build_target bt, build_package bpa, info_package ipa "\
+ "WHERE bp.id = bt.build_project_id " \
+ "AND bt.id = bpa.build_target_id " \
+ "AND ipa.id = bpa.info_package_id " \
+ "AND bp.id = %s " \
+ "ORDER BY bpa.id "
+ query_data = build_project_id
+ multi_build_status = buildmonitor_db.get_multi_values_from_query_data(query, query_data)
+
+ build_status = {}
+ # Save the final build status for each package.
+ # This is required because a package can be build several times and
+ # only the last build status is meaningful in this case.
+ for each_build_status in multi_build_status:
+ repo = each_build_status[0]
+ arch = each_build_status[1]
+ pkg = each_build_status[2]
+ status = each_build_status[3]
+
+ if repo not in build_status:
+ build_status[repo] = {}
+ if arch not in build_status[repo]:
+ build_status[repo][arch] = {}
+ build_status[repo][arch][pkg] = status.lower()
+
+ failed_packages_cnt = 0
+ # Count the number of failed packages except *_aggregate packages.
+ for repo in build_status.keys():
+ for arch in build_status[repo].keys():
+ for pkg in build_status[repo][arch].keys():
+ if not re.match(".*_aggregate", pkg):
+ if build_status[repo][arch][pkg] == 'failed':
+ failed_packages_cnt += 1
+
+
+ # return the number of failed packages except *_aggregate packages.
+ return failed_packages_cnt
+
def start_pre_create_snapshot_for_sr_stage(project, bm_git_tag, bm_start_datetime):
print '[%s] enter start_pre_create_snapshot_for_sr_stage\n' % (__file__)
# [16_1208] change the build fail check method from build_target status to build_project status
if curr_build_project_status == 'F':
info_stage_status = 'F'
+
+ # if only *_aggregate packages are failed, make it 'S'
+ if num_failed_packages_except_aggregate(curr_build_project_id) == 0:
+ print
+ print ('[%s] The build status is determined as failed, ' % (__file__)),
+ print 'but only _aggregate packages are failed.'
+ print '[%s] So, final build status is corrected to S!' % (__file__)
+ info_stage_status = 'S'
+
else:
info_stage_status = 'S'
build = BuildService(obs_api, obs_user, obs_passwd)
ret = 0
-
+
# home:prerelease:Tizen:Mobile:submit:tizen:20161025.103628
prerelease_proj=get_prerelease_project_name(obs_project, sr_tag)
- if not check_permission(build, obs_project, repa_user):
- raise LocalError("User %s does not have permission for OBS project %s" % (repa_user, obs_project))
+ if os.getenv("REPA_CHECK_PERMISSION", 0):
+ if not check_permission(build, obs_project, repa_user):
+ raise LocalError("User %s does not have permission for OBS project %s" % (repa_user, obs_project))
if repa_decision == "accept":
repa_accept(build, prerelease_proj, sr_tag, repa_comment)
else:
repa_reject(build, prerelease_proj, sr_tag, repa_comment)
- return 0
+ return 0
if __name__ == '__main__':
try: