1 |
commit: 4e044fc62205c73300cd1ab942f7f235f5ea0acc |
2 |
Author: Magnus Granberg <zorry <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Oct 29 22:23:54 2011 +0000 |
4 |
Commit: Magnus Granberg <zorry <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Oct 29 22:23:54 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=dev/zorry.git;a=commit;h=4e044fc6 |
7 |
|
8 |
fix bugs in setup_profile |
9 |
|
10 |
--- |
11 |
gobs/pym/init_setup_profile.py | 10 ++++++---- |
12 |
gobs/pym/package.py | 36 ++++++------------------------------ |
13 |
gobs/pym/pgsql.py | 6 +++++- |
14 |
3 files changed, 17 insertions(+), 35 deletions(-) |
15 |
|
16 |
diff --git a/gobs/pym/init_setup_profile.py b/gobs/pym/init_setup_profile.py |
17 |
index 6f640d9..23a2056 100644 |
18 |
--- a/gobs/pym/init_setup_profile.py |
19 |
+++ b/gobs/pym/init_setup_profile.py |
20 |
@@ -45,10 +45,12 @@ def setup_profile_main(args=None): |
21 |
# Set config_root (PORTAGE_CONFIGROOT) to default_config_root |
22 |
mysettings = portage.config(config_root = default_config_root) |
23 |
myportdb = portage.portdbapi(mysettings=mysettings) |
24 |
- init_package = gobs_package |
25 |
+ init_package = gobs_package(mysettings, myportdb) |
26 |
# get the cp list |
27 |
- package_list_tree = package_list_tree = myportdb.cp_all()(mysettings, myportdb) |
28 |
+ package_list_tree = package_list_tree = myportdb.cp_all() |
29 |
print "Setting default config to:", config_id |
30 |
+ config_id_list = [] |
31 |
+ config_id_list.append(config_id) |
32 |
for package_line in sorted(package_list_tree): |
33 |
build_dict = {} |
34 |
packageDict = {} |
35 |
@@ -59,7 +61,7 @@ def setup_profile_main(args=None): |
36 |
package = element[1] |
37 |
print "C", categories + "/" + package # C = Checking |
38 |
pkgdir = mysettings['PORTDIR'] + "/" + categories + "/" + package |
39 |
- config_cpv_listDict = gobs_package.config_match_cp(categories, package, config_id) |
40 |
+ config_cpv_listDict = init_package.config_match_cp(categories, package, config_id_list) |
41 |
packageDict['ebuild_version_tree'] = config_cpv_listDict['ebuild_version'] |
42 |
build_dict['checksum'] = portage.checksum.sha256hash(pkgdir + "/" + package + "-" + config_cpv_listDict['ebuild_version'] + ".ebuild")[0] |
43 |
build_dict['package_id'] = have_package_db(categories, package) |
44 |
@@ -67,7 +69,7 @@ def setup_profile_main(args=None): |
45 |
ebuild_id = get_ebuild_id_db_checksum(connection, build_dict) |
46 |
if ebuild_id is not None: |
47 |
ebuild_id_list.append(ebuild_id) |
48 |
- gobs_package.add_new_ebuild_buildquery_db(ebuild_id_list, packageDict, config_cpv_listDict) |
49 |
+ init_package.add_new_ebuild_buildquery_db(ebuild_id_list, packageDict, config_cpv_listDict) |
50 |
if args[0] is "-del": |
51 |
config_id = args[1] |
52 |
querue_id_list = get_queue_id_list_config(conn, config_id) |
53 |
|
54 |
diff --git a/gobs/pym/package.py b/gobs/pym/package.py |
55 |
index bbd5998..3bd614e 100644 |
56 |
--- a/gobs/pym/package.py |
57 |
+++ b/gobs/pym/package.py |
58 |
@@ -28,7 +28,7 @@ class gobs_package(object): |
59 |
mysettings_setup = portage.config(config_root = my_new_setup) |
60 |
return mysettings_setup |
61 |
|
62 |
- def config_match_ebuild(self, categories, package): |
63 |
+ def config_match_ebuild(self, categories, package, config_list_all): |
64 |
conn=CM.getConnection() |
65 |
config_cpv_listDict ={} |
66 |
# Get a list from table configs/setups with default_config=Fales and active = True |
67 |
@@ -67,32 +67,6 @@ class gobs_package(object): |
68 |
CM.putConnection(conn) |
69 |
return config_cpv_listDict |
70 |
|
71 |
- def config_match_cp(self, categories, package, config_id): |
72 |
- config_cpv_listDict ={} |
73 |
- # Get latest cpv from portage with the config |
74 |
- latest_ebuild = self._myportdb_setup.xmatch('bestmatch-visible', categories + "/" + package) |
75 |
- latest_ebuild_version = unicode("") |
76 |
- # Check if could get cpv from portage |
77 |
- if latest_ebuild != "": |
78 |
- # Get the version of cpv |
79 |
- latest_ebuild_version = portage.versions.cpv_getversion(latest_ebuild) |
80 |
- # Get the iuse and use flags for that config/setup |
81 |
- init_useflags = gobs_use_flags(self._mysettings, self._myportdb, latest_ebuild) |
82 |
- iuse_flags_list, final_use_list = init_useflags.get_flags() |
83 |
- iuse_flags_list2 = [] |
84 |
- for iuse_line in iuse_flags_list: |
85 |
- iuse_flags_list2.append( init_useflags.reduce_flag(iuse_line)) |
86 |
- # Dic the needed info |
87 |
- attDict = {} |
88 |
- attDict['ebuild_version'] = latest_ebuild_version |
89 |
- attDict['useflags'] = final_use_list |
90 |
- attDict['iuse'] = iuse_flags_list2 |
91 |
- attDict['package'] = package |
92 |
- attDict['categories'] = categories |
93 |
- config_cpv_listDict[config_id] = attDict |
94 |
- # Clean some cache |
95 |
- return config_cpv_listDict |
96 |
- |
97 |
def get_ebuild_metadata(self, ebuild_line): |
98 |
# Get the auxdbkeys infos for the ebuild |
99 |
try: |
100 |
@@ -156,7 +130,7 @@ class gobs_package(object): |
101 |
conn=CM.getConnection() |
102 |
# Get the needed info from packageDict and config_cpv_listDict and put that in buildqueue |
103 |
# Only add it if ebuild_version in packageDict and config_cpv_listDict match |
104 |
- if config_cpv_listDict != {}: |
105 |
+ if config_cpv_listDict not None: |
106 |
message = None |
107 |
# Unpack config_cpv_listDict |
108 |
for k, v in config_cpv_listDict.iteritems(): |
109 |
@@ -212,7 +186,8 @@ class gobs_package(object): |
110 |
ebuild_list_tree = self._myportdb.cp_list((categories + "/" + package), use_cache=1, mytree=None) |
111 |
if ebuild_list_tree == []: |
112 |
return None |
113 |
- config_cpv_listDict = self.config_match_ebuild(categories, package) |
114 |
+ config_list_all = get_config_list(conn) |
115 |
+ config_cpv_listDict = self.config_match_ebuild(categories, package, config_list_all) |
116 |
config_id = get_default_config(conn) |
117 |
packageDict ={} |
118 |
for ebuild_line in sorted(ebuild_list_tree): |
119 |
@@ -262,7 +237,8 @@ class gobs_package(object): |
120 |
package_metadataDict = self.get_package_metadataDict(pkgdir, package) |
121 |
update_new_package_metadata(conn,package_id, package_metadataDict) |
122 |
# Get config_cpv_listDict |
123 |
- config_cpv_listDict = self.config_match_ebuild(categories, package) |
124 |
+ config_list_all = get_config_list(conn) |
125 |
+ config_cpv_listDict = self.config_match_ebuild(categories, package, config_list_all) |
126 |
config_id = get_default_config(conn) |
127 |
packageDict ={} |
128 |
for ebuild_line in sorted(ebuild_list_tree): |
129 |
|
130 |
diff --git a/gobs/pym/pgsql.py b/gobs/pym/pgsql.py |
131 |
index 606c624..1d7ee48 100644 |
132 |
--- a/gobs/pym/pgsql.py |
133 |
+++ b/gobs/pym/pgsql.py |
134 |
@@ -84,7 +84,11 @@ def get_config_list(connection): |
135 |
cursor = connection.cursor() |
136 |
sqlQ = 'SELECT id FROM configs WHERE default_config = False AND active = True' |
137 |
cursor.execute(sqlQ) |
138 |
- return cursor.fetchall() |
139 |
+ entries = cursor.fetchall() |
140 |
+ if entries == (): |
141 |
+ return None |
142 |
+ else: |
143 |
+ return entries |
144 |
|
145 |
def get_config_list_all(connection): |
146 |
cursor = connection.cursor() |