3 # @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
4 ##############################################################################
5 # Copyright (c) 2014, 2015 The Linux Foundation and others.
7 # All rights reserved. This program and the accompanying materials
8 # are made available under the terms of the Eclipse Public License v1.0
9 # which accompanies this distribution, and is available at
10 # http://www.eclipse.org/legal/epl-v10.html
13 # Thanh Ha (The Linux Foundation) - Initial implementation
14 ##############################################################################
18 from jjblib import Project
21 def _is_project(jjb_dir, project):
22 """Returns true if project is a project that should be auto-generated"""
25 template = os.path.join(jjb_dir, project, "%s.yaml" % p.project)
27 template = os.path.join(jjb_dir, p.project, "%s.yaml" % p.project)
29 if os.path.isfile(template): # Project found
30 with open(template, 'r') as f:
31 first_line = f.readline()
32 if first_line.startswith("# REMOVE THIS LINE IF"):
37 def get_autoupdate_projects(jjb_dir):
38 """Get list of projects that should be auto-updated."""
41 for root, dirs, files in os.walk(jjb_dir):
42 project = root.replace("%s/" % jjb_dir, '')
44 if _is_project(jjb_dir, project):
45 project_list.append(project)
50 def update_templates(projects):
51 for project in projects:
52 print("Updating... %s" % project)
54 if p.meta_project: # Meta project
55 cfg_file = "jjb/%s/%s.cfg" % (project, p.project)
57 cfg_file = "jjb/%s/%s.cfg" % (p.project, p.project)
58 os.system("python scripts/jjb-init-project.py %s -c %s" %
66 all_projects = [d for d in os.listdir(jjb_dir)
67 if os.path.isdir(os.path.join(jjb_dir, d))]
68 auto_update_projects = get_autoupdate_projects(jjb_dir)
69 update_templates(auto_update_projects)