1 |
commit: b728ae2804796599b7f18056a9e135a4c809fc25 |
2 |
Author: Magnus Granberg <zorry <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Oct 29 00:12:57 2011 +0000 |
4 |
Commit: Magnus Granberg <zorry <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Oct 29 00:12:57 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=dev/zorry.git;a=commit;h=b728ae28 |
7 |
|
8 |
Add gobs_setup_profile |
9 |
|
10 |
--- |
11 |
gobs/bin/gobs_setup_profile | 12 ++++++ |
12 |
gobs/pym/build_log.py | 10 +++-- |
13 |
gobs/pym/build_queru.py | 2 +- |
14 |
gobs/pym/check_setup.py | 7 ++++ |
15 |
gobs/pym/init_setup_profile.py | 79 ++++++++++++++++++++++++++++++++++++++++ |
16 |
gobs/pym/package.py | 11 +----- |
17 |
gobs/pym/pgsql.py | 7 ++++ |
18 |
7 files changed, 114 insertions(+), 14 deletions(-) |
19 |
|
20 |
diff --git a/gobs/bin/gobs_setup_profile b/gobs/bin/gobs_setup_profile |
21 |
new file mode 100755 |
22 |
index 0000000..902ffe8 |
23 |
--- /dev/null |
24 |
+++ b/gobs/bin/gobs_setup_profile |
25 |
@@ -0,0 +1,12 @@ |
26 |
+#!/usr/bin/python |
27 |
+# Copyright 2006-2011 Gentoo Foundation |
28 |
+# Distributed under the terms of the GNU General Public License v2 |
29 |
+ |
30 |
+from gobs.init_setup_profile import setup_profile_main |
31 |
+ |
32 |
+def main(): |
33 |
+ # Main |
34 |
+ setup_profile_main(args=None) |
35 |
+ |
36 |
+if __name__ == "__main__": |
37 |
+ main() |
38 |
\ No newline at end of file |
39 |
|
40 |
diff --git a/gobs/pym/build_log.py b/gobs/pym/build_log.py |
41 |
index 354e8d3..80a186a 100644 |
42 |
--- a/gobs/pym/build_log.py |
43 |
+++ b/gobs/pym/build_log.py |
44 |
@@ -562,9 +562,11 @@ class gobs_buildlog(object): |
45 |
os.chmod(emerge_info_logfilename, 0664) |
46 |
print("Package: ", pkg.cpv, "logged to db.") |
47 |
else: |
48 |
- try: |
49 |
- os.remove(settings.get("PORTAGE_LOG_FILE")) |
50 |
- except: |
51 |
- pass |
52 |
+ # FIXME Remove the log some way so |
53 |
+ # mergetask._locate_failure_log(x) works in action_build() |
54 |
+ #try: |
55 |
+ # os.remove(settings.get("PORTAGE_LOG_FILE")) |
56 |
+ #except: |
57 |
+ # pass |
58 |
print("Package: ", pkg.cpv, "NOT logged to db.") |
59 |
CM.putConnection(conn) |
60 |
|
61 |
diff --git a/gobs/pym/build_queru.py b/gobs/pym/build_queru.py |
62 |
index 9794bbd..3f0bde8 100644 |
63 |
--- a/gobs/pym/build_queru.py |
64 |
+++ b/gobs/pym/build_queru.py |
65 |
@@ -670,7 +670,7 @@ class queruaction(object): |
66 |
build_fail = self.emerge_main(argscmd, build_dict) |
67 |
# Run depclean |
68 |
print('build_fail', build_fail) |
69 |
- if not "clean" in build_dict['post_message']: |
70 |
+ if not "noclean" in build_dict['post_message']: |
71 |
depclean_fail = main_depclean() |
72 |
try: |
73 |
os.remove("/etc/portage/package.use/gobs.use") |
74 |
|
75 |
diff --git a/gobs/pym/check_setup.py b/gobs/pym/check_setup.py |
76 |
index cc9b55b..b5f612b 100644 |
77 |
--- a/gobs/pym/check_setup.py |
78 |
+++ b/gobs/pym/check_setup.py |
79 |
@@ -14,6 +14,13 @@ CM=connectionManager(gobs_settings_dict) |
80 |
if CM.getName()=='pgsql': |
81 |
from gobs.pgsql import * |
82 |
|
83 |
+def git_pull(): |
84 |
+ repo = Repo("/var/lib/gobs/" + gobs_settings_dict['gobs_gitreponame'] + "/") |
85 |
+ repo_remote = repo.remotes.origin |
86 |
+ repo_remote.pull() |
87 |
+ master = repo.head.reference |
88 |
+ print(master.log()) |
89 |
+ |
90 |
def check_make_conf(): |
91 |
# FIXME: mark any config updating true in the db when updating the configs |
92 |
# Get the config list |
93 |
|
94 |
diff --git a/gobs/pym/init_setup_profile.py b/gobs/pym/init_setup_profile.py |
95 |
new file mode 100644 |
96 |
index 0000000..6f640d9 |
97 |
--- /dev/null |
98 |
+++ b/gobs/pym/init_setup_profile.py |
99 |
@@ -0,0 +1,79 @@ |
100 |
+#!/usr/bin/python |
101 |
+# Copyright 2006-2011 Gentoo Foundation |
102 |
+# Distributed under the terms of the GNU General Public License v2 |
103 |
+ |
104 |
+""" This code will update the sql backend with needed info for |
105 |
+ the Frontend and the Guest deamon. """ |
106 |
+ |
107 |
+import sys |
108 |
+import os |
109 |
+ |
110 |
+# Get the options from the config file set in gobs.readconf |
111 |
+from gobs.readconf import get_conf_settings |
112 |
+reader=get_conf_settings() |
113 |
+gobs_settings_dict=reader.read_gobs_settings_all() |
114 |
+# make a CM |
115 |
+from gobs.ConnectionManager import connectionManager |
116 |
+CM=connectionManager(gobs_settings_dict) |
117 |
+#selectively import the pgsql/mysql querys |
118 |
+if CM.getName()=='pgsql': |
119 |
+ from gobs.pgsql import * |
120 |
+ |
121 |
+from gobs.check_setup import check_make_conf, git_pull |
122 |
+from gobs.arch import gobs_arch |
123 |
+from gobs.package import gobs_package |
124 |
+from gobs.categories import gobs_categories |
125 |
+from gobs.old_cpv import gobs_old_cpv |
126 |
+from gobs.categories import gobs_categories |
127 |
+import portage |
128 |
+ |
129 |
+def setup_profile_main(args=None): |
130 |
+ """ |
131 |
+ @param args: command arguments (default: sys.argv[1:]) |
132 |
+ @type args: list |
133 |
+ """ |
134 |
+ conn=CM.getConnection() |
135 |
+ if args is None: |
136 |
+ args = sys.argv[1:] |
137 |
+ if args[0] is "-add": |
138 |
+ git_pull() |
139 |
+ check_make_conf() |
140 |
+ print "Check configs done" |
141 |
+ # Get default config from the configs table and default_config=1 |
142 |
+ config_id = args[1] |
143 |
+ default_config_root = "/var/lib/gobs/" + gobs_settings_dict['gobs_gitreponame'] + "/" + config_id + "/" |
144 |
+ # Set config_root (PORTAGE_CONFIGROOT) to default_config_root |
145 |
+ mysettings = portage.config(config_root = default_config_root) |
146 |
+ myportdb = portage.portdbapi(mysettings=mysettings) |
147 |
+ init_package = gobs_package |
148 |
+ # get the cp list |
149 |
+ package_list_tree = package_list_tree = myportdb.cp_all()(mysettings, myportdb) |
150 |
+ print "Setting default config to:", config_id |
151 |
+ for package_line in sorted(package_list_tree): |
152 |
+ build_dict = {} |
153 |
+ packageDict = {} |
154 |
+ ebuild_id_list = [] |
155 |
+ # split the cp to categories and package |
156 |
+ element = package_line.split('/') |
157 |
+ categories = element[0] |
158 |
+ package = element[1] |
159 |
+ print "C", categories + "/" + package # C = Checking |
160 |
+ pkgdir = mysettings['PORTDIR'] + "/" + categories + "/" + package |
161 |
+ config_cpv_listDict = gobs_package.config_match_cp(categories, package, config_id) |
162 |
+ packageDict['ebuild_version_tree'] = config_cpv_listDict['ebuild_version'] |
163 |
+ build_dict['checksum'] = portage.checksum.sha256hash(pkgdir + "/" + package + "-" + config_cpv_listDict['ebuild_version'] + ".ebuild")[0] |
164 |
+ build_dict['package_id'] = have_package_db(categories, package) |
165 |
+ build_dict['ebuild_version'] = config_cpv_listDict['ebuild_version'] |
166 |
+ ebuild_id = get_ebuild_id_db_checksum(connection, build_dict) |
167 |
+ if ebuild_id is not None: |
168 |
+ ebuild_id_list.append(ebuild_id) |
169 |
+ gobs_package.add_new_ebuild_buildquery_db(ebuild_id_list, packageDict, config_cpv_listDict) |
170 |
+ if args[0] is "-del": |
171 |
+ config_id = args[1] |
172 |
+ querue_id_list = get_queue_id_list_config(conn, config_id) |
173 |
+ if querue_id_list is not None: |
174 |
+ for querue_id in querue_id_list: |
175 |
+ del_old_queue(conn, queue_id) |
176 |
+ CM.putConnection(conn) |
177 |
+ |
178 |
+ |
179 |
\ No newline at end of file |
180 |
|
181 |
diff --git a/gobs/pym/package.py b/gobs/pym/package.py |
182 |
index 884ce7c..bbd5998 100644 |
183 |
--- a/gobs/pym/package.py |
184 |
+++ b/gobs/pym/package.py |
185 |
@@ -68,20 +68,16 @@ class gobs_package(object): |
186 |
return config_cpv_listDict |
187 |
|
188 |
def config_match_cp(self, categories, package, config_id): |
189 |
- conn=CM.getConnection() |
190 |
config_cpv_listDict ={} |
191 |
- # Change config/setup |
192 |
- mysettings_setup = self.change_config(config_id) |
193 |
- myportdb_setup = portage.portdbapi(mysettings=mysettings_setup) |
194 |
# Get latest cpv from portage with the config |
195 |
- latest_ebuild = myportdb_setup.xmatch('bestmatch-visible', categories + "/" + package) |
196 |
+ latest_ebuild = self._myportdb_setup.xmatch('bestmatch-visible', categories + "/" + package) |
197 |
latest_ebuild_version = unicode("") |
198 |
# Check if could get cpv from portage |
199 |
if latest_ebuild != "": |
200 |
# Get the version of cpv |
201 |
latest_ebuild_version = portage.versions.cpv_getversion(latest_ebuild) |
202 |
# Get the iuse and use flags for that config/setup |
203 |
- init_useflags = gobs_use_flags(mysettings_setup, myportdb_setup, latest_ebuild) |
204 |
+ init_useflags = gobs_use_flags(self._mysettings, self._myportdb, latest_ebuild) |
205 |
iuse_flags_list, final_use_list = init_useflags.get_flags() |
206 |
iuse_flags_list2 = [] |
207 |
for iuse_line in iuse_flags_list: |
208 |
@@ -95,9 +91,6 @@ class gobs_package(object): |
209 |
attDict['categories'] = categories |
210 |
config_cpv_listDict[config_id] = attDict |
211 |
# Clean some cache |
212 |
- myportdb_setup.close_caches() |
213 |
- portage.portdbapi.portdbapi_instances.remove(myportdb_setup) |
214 |
- CM.putConnection(conn) |
215 |
return config_cpv_listDict |
216 |
|
217 |
def get_ebuild_metadata(self, ebuild_line): |
218 |
|
219 |
diff --git a/gobs/pym/pgsql.py b/gobs/pym/pgsql.py |
220 |
index 9e7d3f5..b241d1b 100644 |
221 |
--- a/gobs/pym/pgsql.py |
222 |
+++ b/gobs/pym/pgsql.py |
223 |
@@ -322,6 +322,13 @@ def have_package_buildqueue(connection, ebuild_id, config_id): |
224 |
entries = cursor.fetchone() |
225 |
return entries |
226 |
|
227 |
+def get queue_id_list_config(connection, config_id) |
228 |
+ cursor = connection.cursor() |
229 |
+ sqlQ = 'SELECT queue_id FROM buildqueue WHERE config_id = %s' |
230 |
+ cursor.execute(sqlQ, (config_id,)) |
231 |
+ entries = cursor.fetchoall() |
232 |
+ return entries |
233 |
+ |
234 |
def add_new_package_buildqueue(connection, ebuild_id, config_id, iuse_flags_list, use_enable, message): |
235 |
cursor = connection.cursor() |
236 |
sqlQ="SELECT insert_buildqueue( %s, %s, %s, %s, %s )" |