Community Repositories: make it back working.

Community Repositories support was broken due to codebase changes
and introduction of SystemSettings, which now overwrites any
overridden setting. This commit fixes all the issues and also
improves the current support.
This commit is contained in:
Fabio Erculiani
2009-04-25 23:21:30 +02:00
parent 6cf7bd9ed1
commit 2deebc2ab6
3 changed files with 44 additions and 26 deletions
+1
View File
@@ -342,6 +342,7 @@ def branchHop(branch):
status = False
if status:
Equo.clientDbconn.moveCountersToBranch(branch)
mytxt = "%s %s: %s" % (red(" @@ "),
darkgreen(_("Succesfully switched to branch")), purple(branch),)
print_info(mytxt)
+16 -15
View File
@@ -183,6 +183,15 @@ class ServerSystemSettingsPlugin(SystemSettingsPlugin):
except (ValueError, IndexError,):
continue
# add system database if community repository mode is enabled
if self._helper.community_repo:
data['repositories'][etpConst['clientserverrepoid']] = {}
mydata = {}
mydata['description'] = "Community Repositories System Database"
mydata['mirrors'] = []
mydata['community'] = False
data['repositories'][etpConst['clientserverrepoid']].update(mydata)
# expand paths
for repoid in data['repositories']:
data['repositories'][repoid]['packages_dir'] = \
@@ -257,6 +266,11 @@ class ServerFatscopeSystemSettingsPlugin(SystemSettingsPlugin):
# get expiration-based packages removal data from config files
for repoid in srv_parser_data['repositories']:
# filter out system repository if community repository
# mode is enabled
if repoid == etpConst['clientserverrepoid']:
continue
idpackages = set()
exp_fp = self._helper.get_local_exp_based_pkgs_rm_whitelist_file(
repo = repoid)
@@ -360,15 +374,13 @@ class Server(Singleton,TextInterface):
_("repository not configured"),
)
)
if etpConst['clientserverrepoid'] in self.SystemSettings[self.sys_settings_plugin_id]['server']['repositories']:
if etpConst['clientserverrepoid'] == self.default_repository:
raise PermissionDenied("PermissionDenied: %s %s" % (
etpConst['clientserverrepoid'],
_("protected repository id, can't use this, sorry dude..."),
)
)
if self.community_repo:
self.add_client_database_to_repositories()
self.switch_default_repository(self.default_repository)
def destroy(self):
@@ -453,15 +465,6 @@ class Server(Singleton,TextInterface):
f.flush()
f.close()
def add_client_database_to_repositories(self):
self.SystemSettings[self.sys_settings_plugin_id]['server']['repositories'][etpConst['clientserverrepoid']] = {}
mydata = {}
mydata['description'] = "Community Repositories System Database"
mydata['mirrors'] = []
mydata['community'] = False
self.SystemSettings[self.sys_settings_plugin_id]['server']['repositories'][etpConst['clientserverrepoid']].update(mydata)
print self.SystemSettings[self.sys_settings_plugin_id]['server']['repositories'].keys()
def setup_services(self):
self.setup_entropy_settings()
cs_name = 'ClientService'
@@ -2067,15 +2070,13 @@ class Server(Singleton,TextInterface):
for server_repo in server_repos:
installed_counters.add(spm_counter)
server_dbconn = self.open_server_repository(read_only = True, no_upload = True, repo = server_repo)
counter = server_dbconn.isCounterAvailable(spm_counter, branch = self.SystemSettings['repositories']['branch'])
counter = server_dbconn.isCounterAvailable(spm_counter)
if counter:
found = True
break
if not found:
toBeAdded.add((spm_atom,spm_counter,))
import pdb; pdb.set_trace()
# packages to be removed from the database
database_counters = {}
for server_repo in server_repos:
+27 -11
View File
@@ -458,21 +458,37 @@ def database(options):
from_branch = options[1]
to_branch = options[2]
print_info(darkgreen(" * ")+red(_("Switching branch, be sure to have your packages in sync.")))
print_info(darkgreen(" * ")+red("%s %s..." % (_("Collecting packages that would be marked"),to_branch,) ), back = True)
dbconn = Entropy.open_server_repository(read_only = True, no_upload = True)
pkglist = dbconn.listAllIdpackages(branch = from_branch)
#myatoms = options[3:]
sys_settings_plugin_id = \
etpConst['system_settings_plugins_ids']['server_plugin']
for repoid in Entropy.SystemSettings[sys_settings_plugin_id]['server']['repositories']:
print_info(darkgreen(" * ")+red("%s %s: %s %s" % (_("These are the packages that would be marked"),to_branch,len(pkglist),_("packages"),)))
print_info(darkgreen(" * ")+"%s %s %s: %s" % (
blue(_("Collecting packages that would be marked")),
bold(to_branch),blue(_("on")),purple(repoid),) )
rc = Entropy.askQuestion(_("Would you like to continue ?"))
if rc == "No":
return 4
dbconn = Entropy.open_server_repository(read_only = True,
no_upload = True, repo = repo)
pkglist = dbconn.listAllIdpackages(branch = from_branch)
print_info(darkgreen(" * ")+"%s %s: %s %s" % (
blue(_("These are the packages that would be marked")),
bold(to_branch), len(pkglist), darkgreen(_("packages")),))
rc = Entropy.askQuestion(_("Would you like to continue ?"))
if rc == "No":
return 4
# XXX remove this in future
dbconn = Entropy.open_server_repository(read_only = False,
no_upload = True, repo = repoid, lock_remote = False)
dbconn.moveCountersToBranch(to_branch)
# XXX remove this in future, not needed
status = Entropy.switch_packages_branch(pkglist, from_branch, to_branch)
if status == None:
return 1
status = Entropy.switch_packages_branch(pkglist, from_branch, to_branch)
if status == None:
return 1
switched, already_switched, ignored, not_found, no_checksum = status
if not_found or no_checksum:
return 1