Gentoo Archives: gentoo-commits

From: Magnus Granberg <zorry@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] dev/zorry:master commit in: gobs/bin/, ebuild/dev-python/gobs/, ebuild/dev-python/gobs/files/, gobs/pym/
Date: Sun, 29 Apr 2012 16:32:11
Message-Id: 1335717102.058f9eb48cedcf6ce1cf193c753a0f34b98cb5a4.zorry@gentoo
1 commit: 058f9eb48cedcf6ce1cf193c753a0f34b98cb5a4
2 Author: Magnus Granberg <zorry <AT> gentoo <DOT> org>
3 AuthorDate: Sun Apr 29 16:31:42 2012 +0000
4 Commit: Magnus Granberg <zorry <AT> gentoo <DOT> org>
5 CommitDate: Sun Apr 29 16:31:42 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=dev/zorry.git;a=commit;h=058f9eb4
7
8 adding add/del build querys for configs
9
10 ---
11 ebuild/dev-python/gobs/files/gobs.conf | 2 +-
12 ebuild/dev-python/gobs/gobs-9999.ebuild | 1 -
13 gobs/bin/gobs_host_jobs | 21 +++++
14 gobs/bin/gobs_setup_profile | 20 -----
15 .../pym/{init_setup_profile.py => buildquerydb.py} | 79 +++++++++-----------
16 5 files changed, 57 insertions(+), 66 deletions(-)
17
18 diff --git a/ebuild/dev-python/gobs/files/gobs.conf b/ebuild/dev-python/gobs/files/gobs.conf
19 index 5650449..9ed7a41 100644
20 --- a/ebuild/dev-python/gobs/files/gobs.conf
21 +++ b/ebuild/dev-python/gobs/files/gobs.conf
22 @@ -10,6 +10,6 @@ SQLUSER=buildhost
23 SQLPASSWD=buildhost
24 # Gobs git repo name for the setups/configs
25 GOBSGITREPONAME=tinderboxs_configs
26 -GOBSCONFIG=jasmin.ume.nu/hardened
27 +GOBSCONFIG=localhost/base
28 # Main logfile
29 LOGFILE=/var/log/gobs
30
31 diff --git a/ebuild/dev-python/gobs/gobs-9999.ebuild b/ebuild/dev-python/gobs/gobs-9999.ebuild
32 index 1a6fc3d..808e491 100644
33 --- a/ebuild/dev-python/gobs/gobs-9999.ebuild
34 +++ b/ebuild/dev-python/gobs/gobs-9999.ebuild
35 @@ -35,7 +35,6 @@ src_install() {
36 insinto /etc/gobs
37 doins ${FILESDIR}/gobs.conf || die
38 dobin ${S}/gobs/sbin/gobs_host_jobs || die
39 - dobin ${S}/gobs/bin/gobs_setup_profile || die
40 dosbin ${S}/gobs/sbin/gobs_buildquerys || die
41 dodoc ${S}/gobs/sql/pgdump.sql.gz || die
42 dodoc ${S}/gobs/doc/Setup.txt || die
43
44 diff --git a/gobs/bin/gobs_host_jobs b/gobs/bin/gobs_host_jobs
45 index 0cd5396..09189d7 100755
46 --- a/gobs/bin/gobs_host_jobs
47 +++ b/gobs/bin/gobs_host_jobs
48 @@ -7,6 +7,7 @@ from __future__ import print_function
49 from gobs.init_setup_profile import setup_profile_main
50 from gobs.readconf import get_conf_settings
51 from gobs.updatedb import update_db_main
52 +from gobs.buildquerydb import add_buildquery_main, del_buildquery_main
53
54 reader = get_conf_settings()
55 gobs_settings_dict=reader.read_gobs_settings_all()
56 @@ -49,6 +50,26 @@ def main():
57 else:
58 update_job_list(conn, "Fail", job[1])
59 logging.info("Job %s did fail. Config: %s", job[0], config_profile)
60 + elif job[0] == "addbuildquery":
61 + update_job_list(conn, "Runing", job[1])
62 + logging.info("Job %s is runing. Config: %s", job[0], config_profile)
63 + result = add_buildquery_main(config_profile)
64 + if result is True:
65 + update_job_list(conn, "Done", job[1])
66 + logging.info("Job %s is done. Config: %s", job[0], config_profile)
67 + else:
68 + update_job_list(conn, "Fail", job[1])
69 + logging.info("Job %s did fail. Config: %s", job[0], config_profile)
70 + elif job[0] == "delbuildquery":
71 + update_job_list(conn, "Runing", job[1])
72 + logging.info("Job %s is runing. Config: %s", job[0], config_profile)
73 + result = del_buildquery_main(config_profile)
74 + if result is True:
75 + update_job_list(conn, "Done", job[1])
76 + logging.info("Job %s is done. Config: %s", job[0], config_profile)
77 + else:
78 + update_job_list(conn, "Fail", job[1])
79 + logging.info("Job %s did fail. Config: %s", job[0], config_profile)
80 repeat = False
81 CM.putConnection(conn)
82 time.sleep(60)
83
84 diff --git a/gobs/bin/gobs_setup_profile b/gobs/bin/gobs_setup_profile
85 deleted file mode 100755
86 index 9a1dd04..0000000
87 --- a/gobs/bin/gobs_setup_profile
88 +++ /dev/null
89 @@ -1,20 +0,0 @@
90 -#!/usr/bin/python
91 -# Copyright 2006-2011 Gentoo Foundation
92 -# Distributed under the terms of the GNU General Public License v2
93 -
94 -from gobs.init_setup_profile import setup_profile_main
95 -from gobs.readconf import get_conf_settings
96 -reader = get_conf_settings()
97 -gobs_settings_dict=reader.read_gobs_settings_all()
98 -
99 -import logging
100 -
101 -def main():
102 - # Main
103 - # Logging
104 - logging.basicConfig(filename=gobs_settings_dict['gobs_logfile'], \
105 - format='%(levelname)s: %(asctime)s %(message)s', level=logging.INFO)
106 - setup_profile_main(args=None)
107 -
108 -if __name__ == "__main__":
109 - main()
110 \ No newline at end of file
111
112 diff --git a/gobs/pym/init_setup_profile.py b/gobs/pym/buildquerydb.py
113 similarity index 57%
114 rename from gobs/pym/init_setup_profile.py
115 rename to gobs/pym/buildquerydb.py
116 index 8d19c0b..d383fbc 100644
117 --- a/gobs/pym/init_setup_profile.py
118 +++ b/gobs/pym/buildquerydb.py
119 @@ -1,5 +1,3 @@
120 -#!/usr/bin/python
121 -# Copyright 2006-2011 Gentoo Foundation
122 # Distributed under the terms of the GNU General Public License v2
123
124 """ This code will update the sql backend with needed info for
125 @@ -60,48 +58,41 @@ def add_cpv_query_pool(mysettings, init_package, config_id, package_line):
126 CM.putConnection(conn)
127 return
128
129 -def setup_profile_main(args=None):
130 - """
131 - @param args: command arguments (default: sys.argv[1:])
132 - @type args: list
133 - """
134 +def add_buildquery_main(config_id):
135 conn=CM.getConnection()
136 - if args is None:
137 - args = sys.argv[1:]
138 - if args[0] == "-add":
139 - config_id = args[1]
140 - logging.info("Adding build querys for: %s", config_id)
141 - git_pull()
142 - check_make_conf()
143 - logging.info("Check configs done")
144 - # Get default config from the configs table and default_config=1
145 - default_config_root = "/var/lib/gobs/" + gobs_settings_dict['gobs_gitreponame'] + "/" + config_id + "/"
146 - # Set config_root (PORTAGE_CONFIGROOT) to default_config_root
147 - mysettings = portage.config(config_root = default_config_root)
148 - myportdb = portage.portdbapi(mysettings=mysettings)
149 - init_package = gobs_package(mysettings, myportdb)
150 - # get the cp list
151 - package_list_tree = package_list_tree = myportdb.cp_all()
152 - logging.info("Setting default config to: %s", config_id)
153 - # Use all exept 2 cores when multiprocessing
154 - pool_cores= multiprocessing.cpu_count()
155 - if pool_cores >= 3:
156 - use_pool_cores = pool_cores - 2
157 - else:
158 - use_pool_cores = 1
159 - pool = multiprocessing.Pool(processes=use_pool_cores)
160 - for package_line in sorted(package_list_tree):
161 - pool.apply_async(add_cpv_query_pool, (mysettings, init_package, config_id, package_line,))
162 - pool.close()
163 - pool.join()
164 - logging.info("Adding build querys for: %s ... Done.", config_id)
165 + logging.info("Adding build querys for: %s", config_id)
166 + git_pull()
167 + check_make_conf()
168 + logging.info("Check configs done")
169 + # Get default config from the configs table and default_config=1
170 + default_config_root = "/var/lib/gobs/" + gobs_settings_dict['gobs_gitreponame'] + "/" + config_id + "/"
171 + # Set config_root (PORTAGE_CONFIGROOT) to default_config_root
172 + mysettings = portage.config(config_root = default_config_root)
173 + myportdb = portage.portdbapi(mysettings=mysettings)
174 + init_package = gobs_package(mysettings, myportdb)
175 + # get the cp list
176 + package_list_tree = package_list_tree = myportdb.cp_all()
177 + logging.info("Setting default config to: %s", config_id)
178 + # Use all exept 2 cores when multiprocessing
179 + pool_cores= multiprocessing.cpu_count()
180 + if pool_cores >= 3:
181 + use_pool_cores = pool_cores - 2
182 + else:
183 + use_pool_cores = 1
184 + pool = multiprocessing.Pool(processes=use_pool_cores)
185 + for package_line in sorted(package_list_tree):
186 + pool.apply_async(add_cpv_query_pool, (mysettings, init_package, config_id, package_line,))
187 + pool.close()
188 + pool.join()
189 + logging.info("Adding build querys for: %s ... Done.", config_id)
190 + return True
191
192 - if args[0] == "-del":
193 - config_id = args[1]
194 - logging.info("Removeing build querys for: %s", config_id)
195 - querue_id_list = get_queue_id_list_config(conn, config_id)
196 - if querue_id_list is not None:
197 - for querue_id in querue_id_list:
198 - del_old_queue(conn, querue_id)
199 - logging.info("Removeing build querys for: %s ... Done.", config_id)
200 +def del_buildquery_main(config_id):
201 + logging.info("Removeing build querys for: %s", config_id)
202 + querue_id_list = get_queue_id_list_config(conn, config_id)
203 + if querue_id_list is not None:
204 + for querue_id in querue_id_list:
205 + del_old_queue(conn, querue_id)
206 + logging.info("Removeing build querys for: %s ... Done.", config_id)
207 CM.putConnection(conn)
208 + return True