1 |
commit: 082e83c77c4368bb1c63c2fdf7e07167cea6b435 |
2 |
Author: Magnus Granberg <zorry <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Jul 31 13:43:09 2011 +0000 |
4 |
Commit: Magnus Granberg <zorry <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Jul 31 13:43:09 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=dev/zorry.git;a=commit;h=082e83c7 |
7 |
|
8 |
fix and clean code for gobs_updatedb |
9 |
|
10 |
--- |
11 |
gobs/bin/gobs_updatedb | 6 +++--- |
12 |
gobs/pym/arch.py | 25 +++++++++++++------------ |
13 |
gobs/pym/categories.py | 26 +++++++++++++++----------- |
14 |
gobs/pym/old_cpv.py | 29 ++++++++++++++++++----------- |
15 |
gobs/pym/package.py | 18 +++++++----------- |
16 |
5 files changed, 56 insertions(+), 48 deletions(-) |
17 |
|
18 |
diff --git a/gobs/bin/gobs_updatedb b/gobs/bin/gobs_updatedb |
19 |
index a9c8e4a..36b26bd 100755 |
20 |
--- a/gobs/bin/gobs_updatedb |
21 |
+++ b/gobs/bin/gobs_updatedb |
22 |
@@ -28,7 +28,7 @@ from gobs.old_cpv import gobs_old_cpv |
23 |
from gobs.categories import gobs_categories |
24 |
import portage |
25 |
|
26 |
-def init_portage_settings(CM, gobs_settings_dict): |
27 |
+def init_portage_settings(gobs_settings_dict): |
28 |
|
29 |
""" Get the BASE Setup/Config for portage.settings |
30 |
@type: module |
31 |
@@ -101,8 +101,8 @@ def update_cpv_db(mysettings, gobs_settings_dict): |
32 |
def main(): |
33 |
# Main |
34 |
# Init settings for the default config |
35 |
- mysettings = init_portage_settings(CM,gobs_settings_dict) |
36 |
- init_arch = gobs_arch(CM) |
37 |
+ mysettings = init_portage_settings(gobs_settings_dict) |
38 |
+ init_arch = gobs_arch() |
39 |
init_arch.update_arch_db() |
40 |
# Update the cpv db |
41 |
update_cpv_db(mysettings, gobs_settings_dict) |
42 |
|
43 |
diff --git a/gobs/pym/arch.py b/gobs/pym/arch.py |
44 |
index 7e11041..1a26083 100644 |
45 |
--- a/gobs/pym/arch.py |
46 |
+++ b/gobs/pym/arch.py |
47 |
@@ -1,24 +1,25 @@ |
48 |
import portage |
49 |
+from gobs.readconf import get_conf_settings |
50 |
+reader=get_conf_settings() |
51 |
+gobs_settings_dict=reader.read_gobs_settings_all() |
52 |
+# make a CM |
53 |
+from gobs.ConnectionManager import connectionManager |
54 |
+CM=connectionManager(gobs_settings_dict) |
55 |
+#selectively import the pgsql/mysql querys |
56 |
+if CM.getName()=='pgsql': |
57 |
+ from gobs.pgsql import * |
58 |
|
59 |
class gobs_arch(object): |
60 |
|
61 |
- def __init__(self, CM): |
62 |
- #selective import the pgsql/mysql queries |
63 |
- if CM.getName() is 'pgsql': |
64 |
- from gobs.pgsql import * |
65 |
- self._CM = CM |
66 |
- self._conn = CM.getConnection() |
67 |
- |
68 |
- def __del__(self): |
69 |
- self._CM.putConnection(self._conn) |
70 |
- |
71 |
def update_arch_db(self): |
72 |
+ conn = CM.getConnection() |
73 |
# FIXME: check for new keyword |
74 |
# Add arch db (keywords) |
75 |
- if get_arch_db(self._conn) is None: |
76 |
+ if get_arch_db(conn) is None: |
77 |
arch_list = portage.archlist |
78 |
for arch in arch_list: |
79 |
if arch[0] not in ["~","-"]: |
80 |
arch_list.append("-" + arch) |
81 |
arch_list.append("-*") |
82 |
- add_new_arch_db(self._conn,arch_list) |
83 |
\ No newline at end of file |
84 |
+ add_new_arch_db(conn,arch_list) |
85 |
+ CM.putConnection(conn) |
86 |
\ No newline at end of file |
87 |
|
88 |
diff --git a/gobs/pym/categories.py b/gobs/pym/categories.py |
89 |
index f9f4367..dae1207 100644 |
90 |
--- a/gobs/pym/categories.py |
91 |
+++ b/gobs/pym/categories.py |
92 |
@@ -1,26 +1,30 @@ |
93 |
#from gobs.text import gobs_text |
94 |
from gobs.text import get_file_text |
95 |
import portage |
96 |
+from gobs.readconf import get_conf_settings |
97 |
+reader=get_conf_settings() |
98 |
+gobs_settings_dict=reader.read_gobs_settings_all() |
99 |
+# make a CM |
100 |
+from gobs.ConnectionManager import connectionManager |
101 |
+CM=connectionManager(gobs_settings_dict) |
102 |
+#selectively import the pgsql/mysql querys |
103 |
+if CM.getName()=='pgsql': |
104 |
+ from gobs.pgsql import * |
105 |
|
106 |
class gobs_categories(object): |
107 |
|
108 |
- def __init__(self, CM, mysettings): |
109 |
- self._CM = CM |
110 |
- self._conn=CM.getConnection() |
111 |
+ def __init__(self, mysettings): |
112 |
self._mysettings = mysettings |
113 |
- if CM.getName() is 'pgsql': |
114 |
- from gobs.pgsql import * |
115 |
- |
116 |
- def __del__(self): |
117 |
- self._CM.putConnection(self._conn) |
118 |
|
119 |
def update_categories_db(self, categories): |
120 |
+ conn=CM.getConnection() |
121 |
# Update categories_meta in the db |
122 |
categories_dir = self._mysettings['PORTDIR'] + "/" + categories + "/" |
123 |
categories_metadata_xml_checksum_tree = portage.checksum.sha256hash(categories_dir + "metadata.xml")[0] |
124 |
categories_metadata_xml_text_tree = get_file_text(categories_dir + "metadata.xml") |
125 |
- categories_metadata_xml_checksum_db = get_categories_checksum_db(self._conn, categories) |
126 |
+ categories_metadata_xml_checksum_db = get_categories_checksum_db(conn, categories) |
127 |
if categories_metadata_xml_checksum_db is None: |
128 |
- add_new_categories_meta_sql(self._conn,categories, categories_metadata_xml_checksum_tree, categories_metadata_xml_text_tree) |
129 |
+ add_new_categories_meta_sql(conn,categories, categories_metadata_xml_checksum_tree, categories_metadata_xml_text_tree) |
130 |
elif categories_metadata_xml_checksum_db != categories_metadata_xml_checksum_tree: |
131 |
- update_categories_meta_sql(self._conn,categories, categories_metadata_xml_checksum_tree, categories_metadata_xml_text_tree) |
132 |
+ update_categories_meta_sql(conn,categories, categories_metadata_xml_checksum_tree, categories_metadata_xml_text_tree) |
133 |
+ CM.putConnection(conn) |
134 |
|
135 |
diff --git a/gobs/pym/old_cpv.py b/gobs/pym/old_cpv.py |
136 |
index c577033..4923bf7 100644 |
137 |
--- a/gobs/pym/old_cpv.py |
138 |
+++ b/gobs/pym/old_cpv.py |
139 |
@@ -1,15 +1,22 @@ |
140 |
from __future__ import print_function |
141 |
+from gobs.readconf import get_conf_settings |
142 |
+reader=get_conf_settings() |
143 |
+gobs_settings_dict=reader.read_gobs_settings_all() |
144 |
+# make a CM |
145 |
+from gobs.ConnectionManager import connectionManager |
146 |
+CM=connectionManager(gobs_settings_dict) |
147 |
+#selectively import the pgsql/mysql querys |
148 |
+if CM.getName()=='pgsql': |
149 |
+ from gobs.pgsql import * |
150 |
+ |
151 |
class gobs_old_cpv(object): |
152 |
|
153 |
- def __init__(self, CM, myportdb, mysettings): |
154 |
- self._CM = CM |
155 |
+ def __init__(self, myportdb, mysettings): |
156 |
self._mysettings = mysettings |
157 |
self._myportdb = myportdb |
158 |
- if CM.getName() is 'pgsql': |
159 |
- from gobs.pgsql import * |
160 |
|
161 |
def mark_old_ebuild_db(self, categories, package, package_id): |
162 |
- conn=self._CM.getConnection() |
163 |
+ conn=CM.getConnection() |
164 |
ebuild_list_tree = sorted(self._myportdb.cp_list((categories + "/" + package), use_cache=1, mytree=None)) |
165 |
# Get ebuild list on categories, package in the db |
166 |
ebuild_list_db = cp_list_db(conn,package_id) |
167 |
@@ -24,7 +31,7 @@ class gobs_old_cpv(object): |
168 |
if old_ebuild_list != []: |
169 |
for old_ebuild in old_ebuild_list: |
170 |
print("O", categories + "/" + package + "-" + old_ebuild[0]) |
171 |
- self.dbquerys.add_old_ebuild(conn,package_id, old_ebuild_list) |
172 |
+ add_old_ebuild(conn,package_id, old_ebuild_list) |
173 |
# Check if we have older no activ ebuilds then 60 days |
174 |
ebuild_old_list_db = cp_list_old_db(conn,package_id) |
175 |
# Delete older ebuilds in the db |
176 |
@@ -32,10 +39,10 @@ class gobs_old_cpv(object): |
177 |
for del_ebuild_old in ebuild_old_list_db: |
178 |
print("D", categories + "/" + package + "-" + del_ebuild_old[1]) |
179 |
del_old_ebuild(conn,ebuild_old_list_db) |
180 |
- self._CM.putConnection(conn) |
181 |
+ CM.putConnection(conn) |
182 |
|
183 |
def mark_old_package_db(self, package_id_list_tree): |
184 |
- conn=self._CM.getConnection() |
185 |
+ conn=CM.getConnection() |
186 |
# Get categories/package list from db |
187 |
package_list_db = cp_all_db(conn) |
188 |
old_package_id_list = [] |
189 |
@@ -59,10 +66,10 @@ class gobs_old_cpv(object): |
190 |
element = get_cp_from_package_id(conn,i) |
191 |
print("D", element) |
192 |
del_old_package(conn,del_package_id_old_list) |
193 |
- self._CM.putConnection(conn) |
194 |
+ CM.putConnection(conn) |
195 |
|
196 |
def mark_old_categories_db(self): |
197 |
- conn=self._CM.getConnection() |
198 |
+ conn=CM.getConnection() |
199 |
# Get categories list from the tree and db |
200 |
categories_list_tree = self._mysettings.categories |
201 |
categories_list_db =get_categories_db(conn) |
202 |
@@ -79,4 +86,4 @@ class gobs_old_cpv(object): |
203 |
for real_old_categories in categories_old_list: |
204 |
del_old_categories(conn,real_old_categoriess) |
205 |
print("D", real_old_categories) |
206 |
- self._CM.putConnection(conn) |
207 |
\ No newline at end of file |
208 |
+ CM.putConnection(conn) |
209 |
\ No newline at end of file |
210 |
|
211 |
diff --git a/gobs/pym/package.py b/gobs/pym/package.py |
212 |
index f240e4e..8d94936 100644 |
213 |
--- a/gobs/pym/package.py |
214 |
+++ b/gobs/pym/package.py |
215 |
@@ -18,7 +18,7 @@ if CM.getName()=='pgsql': |
216 |
|
217 |
class gobs_package(object): |
218 |
|
219 |
- def __init__(self, mysettings, CM, myportdb, gobs_settings_dict): |
220 |
+ def __init__(self, mysettings, myportdb, gobs_settings_dict): |
221 |
self._mysettings = mysettings |
222 |
self._gobs_settings_dict = gobs_settings_dict |
223 |
self._myportdb = myportdb |
224 |
@@ -41,16 +41,12 @@ class gobs_package(object): |
225 |
# Change config/setup |
226 |
mysettings_setup = self.change_config(config_id) |
227 |
myportdb_setup = portage.portdbapi(mysettings=mysettings_setup) |
228 |
- # Get cpv from portage with the config |
229 |
- ebuild_match_list = myportdb_setup.match(categories + "/" + package, use_cache=1) |
230 |
- latest_ebuild = "" |
231 |
+ # Get latest cpv from portage with the config |
232 |
+ latest_ebuild = myportdb_setup.xmatch('bestmatch-visible', categories + "/" + package) |
233 |
latest_ebuild_version = unicode("") |
234 |
# Check if could get cpv from portage |
235 |
- # and get the lastes ebuild on that config/setup |
236 |
- if ebuild_match_list != []: |
237 |
- for ebuild_match_line in ebuild_match_list: |
238 |
- latest_ebuild = ebuild_match_line |
239 |
- # Get the version of cpv |
240 |
+ if latest_ebuild != "": |
241 |
+ # Get the version of cpv |
242 |
latest_ebuild_version = portage.versions.cpv_getversion(latest_ebuild) |
243 |
# Get the iuse and use flags for that config/setup |
244 |
init_useflags = gobs_use_flags(mysettings_setup, myportdb_setup, latest_ebuild) |
245 |
@@ -268,7 +264,7 @@ class gobs_package(object): |
246 |
add_new_metadata(conn,metadataDict) |
247 |
# Get the text in Manifest and update it |
248 |
get_manifest_text = get_file_text(pkgdir + "/Manifest") |
249 |
- self._dbquerys.update_manifest_sql(conn,package_id, get_manifest_text, manifest_checksum_tree) |
250 |
+ update_manifest_sql(conn,package_id, get_manifest_text, manifest_checksum_tree) |
251 |
# Add any qa and repoman erros to buildlog |
252 |
qa_error = [] |
253 |
init_manifest = gobs_manifest(self._mysettings, pkgdir) |
254 |
@@ -280,7 +276,7 @@ class gobs_package(object): |
255 |
# Add the ebuild to the buildqueru table if needed |
256 |
self.add_new_ebuild_buildquery_db(ebuild_id_list, packageDict, config_cpv_listDict) |
257 |
# Mark or remove any old ebuilds |
258 |
- init_old_cpv = gobs_old_cpv(self._CM, self._myportdb, self._mysettings) |
259 |
+ init_old_cpv = gobs_old_cpv(self._myportdb, self._mysettings) |
260 |
init_old_cpv.mark_old_ebuild_db(categories, package, package_id) |
261 |
CM.putConnection(conn) |