Entropy/ServerInterface:
- change server.conf specs adding http handlers URL to it - added multirepository support to all server-side functions (not yet done) git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@1681 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
# Project Entropy 1.0 Remote handlers configuration file
|
||||
|
||||
handler|svn.sabayonlinux.org|http://svn.sabayonlinux.org/entropy
|
||||
|
||||
@@ -18,9 +18,9 @@ branches|3.5 2008
|
||||
#
|
||||
# repository: server-side repositories configuration
|
||||
# note: default repository setting is in repositories.conf (officialrepositoryid)
|
||||
#| repository|repository_id|repository description|<ftp upload URI 1> <ftp upload URI 2> <ftp upload URI 3> ...
|
||||
#| repository|repository_id|repository description|<ftp upload URI 1> <2>|<http handlers uri>
|
||||
#
|
||||
# example:
|
||||
#| repository|sabayonlinux.org|Sabayon Linux Official Repository|ftp://user:pass@111.111.111.111/ ... ...
|
||||
#| repository|sabayonlinux.org|Sabayon Linux Official Repository|ftp://user:pass@111.111.111.111/|http://svn.sabayonlinux.org/entropy
|
||||
#
|
||||
# repository|
|
||||
+38
-34
@@ -60,12 +60,14 @@ class etpDatabase:
|
||||
self.indexing = False
|
||||
self.dbFile = dbFile
|
||||
self.dbclosed = False
|
||||
self.server_repo = None
|
||||
|
||||
if not self.clientDatabase:
|
||||
self.server_repo = self.dbname[len(etpConst['serverdbid']):]
|
||||
self.create_dbstatus_data()
|
||||
|
||||
# no caching for non root and server connections
|
||||
if (self.dbname == etpConst['serverdbid']) or (not self.entropyTools.is_user_in_entropy_group()):
|
||||
if (self.dbname.startswith(etpConst['serverdbid'])) or (not self.entropyTools.is_user_in_entropy_group()):
|
||||
self.xcache = False
|
||||
self.live_cache = {}
|
||||
|
||||
@@ -91,7 +93,7 @@ class etpDatabase:
|
||||
self.closeDB()
|
||||
|
||||
def create_dbstatus_data(self):
|
||||
taint_file = self.ServiceInterface.get_local_database_taint_file()
|
||||
taint_file = self.ServiceInterface.get_local_database_taint_file(self.server_repo)
|
||||
if not etpDbStatus.has_key(self.dbFile):
|
||||
etpDbStatus[self.dbFile] = {}
|
||||
etpDbStatus[self.dbFile]['tainted'] = False
|
||||
@@ -103,7 +105,8 @@ class etpDatabase:
|
||||
def doServerDatabaseSyncLock(self, noUpload):
|
||||
|
||||
# check if the database is locked locally
|
||||
lock_file = self.ServiceInterface.MirrorsService.get_database_lockfile()
|
||||
# self.server_repo
|
||||
lock_file = self.ServiceInterface.MirrorsService.get_database_lockfile(self.server_repo)
|
||||
if os.path.isfile(lock_file):
|
||||
self.updateProgress(
|
||||
red("Entropy database is already locked by you :-)"),
|
||||
@@ -120,8 +123,8 @@ class etpDatabase:
|
||||
header = red(" * "),
|
||||
back = True
|
||||
)
|
||||
for uri in self.ServiceInterface.get_remote_mirrors():
|
||||
given_up = self.ServiceInterface.MirrorsService.mirror_lock_check(uri)
|
||||
for uri in self.ServiceInterface.get_remote_mirrors(self.server_repo):
|
||||
given_up = self.ServiceInterface.MirrorsService.mirror_lock_check(uri, repo = self.server_repo)
|
||||
if given_up:
|
||||
crippled_uri = self.entropyTools.extractFTPHostFromUri(uri)
|
||||
self.updateProgress(
|
||||
@@ -130,7 +133,7 @@ class etpDatabase:
|
||||
type = "info",
|
||||
header = brown(" * ")
|
||||
)
|
||||
dbstatus = self.ServiceInterface.MirrorsService.get_mirrors_lock()
|
||||
dbstatus = self.ServiceInterface.MirrorsService.get_mirrors_lock(repo = self.server_repo)
|
||||
for db in dbstatus:
|
||||
db[1] = green("Unlocked")
|
||||
if (db[1]):
|
||||
@@ -150,8 +153,8 @@ class etpDatabase:
|
||||
raise exceptionTools.OnlineMirrorError("OnlineMirrorError: cannot lock mirror %s" % (crippled_uri,))
|
||||
|
||||
# if we arrive here, it is because all the mirrors are unlocked
|
||||
self.ServiceInterface.MirrorsService.lock_mirrors(True)
|
||||
self.ServiceInterface.MirrorsService.sync_databases(noUpload)
|
||||
self.ServiceInterface.MirrorsService.lock_mirrors(True, repo = self.server_repo)
|
||||
self.ServiceInterface.MirrorsService.sync_databases(noUpload, repo = repo)
|
||||
|
||||
def closeDB(self):
|
||||
|
||||
@@ -171,7 +174,7 @@ class etpDatabase:
|
||||
|
||||
if not etpDbStatus[self.dbFile]['tainted']:
|
||||
# we can unlock it, no changes were made
|
||||
self.ServiceInterface.MirrorsService.lock_mirrors(False)
|
||||
self.ServiceInterface.MirrorsService.lock_mirrors(False, repo = self.server_repo)
|
||||
else:
|
||||
self.updateProgress(
|
||||
darkgreen("Mirrors have not been unlocked. Run activator."),
|
||||
@@ -211,7 +214,7 @@ class etpDatabase:
|
||||
if self.clientDatabase:
|
||||
return
|
||||
# taint the database status
|
||||
taint_file = self.ServiceInterface.get_local_database_taint_file()
|
||||
taint_file = self.ServiceInterface.get_local_database_taint_file(repo = self.server_repo)
|
||||
f = open(taint_file,"w")
|
||||
f.write(etpConst['currentarch']+" database tainted\n")
|
||||
f.flush()
|
||||
@@ -223,12 +226,12 @@ class etpDatabase:
|
||||
return
|
||||
etpDbStatus[self.dbFile]['tainted'] = False
|
||||
# untaint the database status
|
||||
taint_file = self.ServiceInterface.get_local_database_taint_file()
|
||||
taint_file = self.ServiceInterface.get_local_database_taint_file(repo = self.server_repo)
|
||||
if os.path.isfile(taint_file):
|
||||
os.remove(taint_file)
|
||||
|
||||
def revisionBump(self):
|
||||
revision_file = self.ServiceInterface.get_local_database_revision_file()
|
||||
revision_file = self.ServiceInterface.get_local_database_revision_file(repo = self.server_repo)
|
||||
if not os.path.isfile(revision_file):
|
||||
revision = 0
|
||||
else:
|
||||
@@ -242,7 +245,7 @@ class etpDatabase:
|
||||
f.close()
|
||||
|
||||
def isDatabaseTainted(self):
|
||||
taint_file = self.ServiceInterface.get_local_database_taint_file()
|
||||
taint_file = self.ServiceInterface.get_local_database_taint_file(repo = self.server_repo)
|
||||
if os.path.isfile(taint_file):
|
||||
return True
|
||||
return False
|
||||
@@ -263,17 +266,17 @@ class etpDatabase:
|
||||
def serverUpdatePackagesData(self):
|
||||
|
||||
etpConst['treeupdatescalled'] = True
|
||||
repository = etpConst['officialrepositoryid']
|
||||
|
||||
repo_updates_file = self.ServiceInterface.get_local_database_treeupdates_file()
|
||||
repository = self.server_repo
|
||||
|
||||
repo_updates_file = self.ServiceInterface.get_local_database_treeupdates_file(self.server_repo)
|
||||
doRescan = False
|
||||
|
||||
if repositoryUpdatesDigestCache_db.has_key(repository):
|
||||
stored_digest = repositoryUpdatesDigestCache_db.get(repository)
|
||||
if repositoryUpdatesDigestCache_db.has_key(self.server_repo):
|
||||
stored_digest = repositoryUpdatesDigestCache_db.get(self.server_repo)
|
||||
else:
|
||||
# check database digest
|
||||
stored_digest = self.retrieveRepositoryUpdatesDigest(repository)
|
||||
repositoryUpdatesDigestCache_db[repository] = stored_digest
|
||||
stored_digest = self.retrieveRepositoryUpdatesDigest(self.server_repo)
|
||||
repositoryUpdatesDigestCache_db[self.server_repo] = stored_digest
|
||||
if stored_digest == -1:
|
||||
doRescan = True
|
||||
|
||||
@@ -281,8 +284,8 @@ class etpDatabase:
|
||||
portage_dirs_digest = "0"
|
||||
if not doRescan:
|
||||
|
||||
if repositoryUpdatesDigestCache_disk.has_key(repository):
|
||||
portage_dirs_digest = repositoryUpdatesDigestCache_disk.get(repository)
|
||||
if repositoryUpdatesDigestCache_disk.has_key(self.server_repo):
|
||||
portage_dirs_digest = repositoryUpdatesDigestCache_disk.get(self.server_repo)
|
||||
else:
|
||||
from entropy import SpmInterface
|
||||
SpmIntf = SpmInterface(self.OutputInterface)
|
||||
@@ -301,7 +304,7 @@ class etpDatabase:
|
||||
block = f.read(1024)
|
||||
f.close()
|
||||
portage_dirs_digest = mdigest.hexdigest()
|
||||
repositoryUpdatesDigestCache_disk[repository] = portage_dirs_digest
|
||||
repositoryUpdatesDigestCache_disk[self.server_repo] = portage_dirs_digest
|
||||
del updates_dir
|
||||
|
||||
if doRescan or (str(stored_digest) != str(portage_dirs_digest)):
|
||||
@@ -311,7 +314,7 @@ class etpDatabase:
|
||||
self.noUpload = True
|
||||
|
||||
# reset database tables
|
||||
self.clearTreeupdatesEntries(repository)
|
||||
self.clearTreeupdatesEntries(self.server_repo)
|
||||
|
||||
from entropy import SpmInterface
|
||||
SpmIntf = SpmInterface(self.OutputInterface)
|
||||
@@ -351,10 +354,10 @@ class etpDatabase:
|
||||
self.runTreeUpdatesActions(update_actions)
|
||||
|
||||
# store new actions
|
||||
self.addRepositoryUpdatesActions(repository,update_actions)
|
||||
self.addRepositoryUpdatesActions(self.server_repo,update_actions)
|
||||
|
||||
# store new digest into database
|
||||
self.setRepositoryUpdatesDigest(repository, portage_dirs_digest)
|
||||
self.setRepositoryUpdatesDigest(self.server_repo, portage_dirs_digest)
|
||||
|
||||
# client side, no portage dependency
|
||||
# lxnay: it is indeed very similar to serverUpdatePackagesData() but I prefer keeping both separate
|
||||
@@ -638,7 +641,7 @@ class etpDatabase:
|
||||
)
|
||||
continue
|
||||
# ask to confirm
|
||||
rc = self.askQuestion(" Confirm %s ?" % (branch,))
|
||||
rc = self.askQuestion("Confirm %s ?" % (branch,))
|
||||
if rc == "Yes":
|
||||
break
|
||||
|
||||
@@ -660,10 +663,10 @@ class etpDatabase:
|
||||
type = "warning",
|
||||
header = blue(" # ")
|
||||
)
|
||||
mypath = self.ServiceInterface.quickpkg(myatom,self.ServiceInterface.get_local_store_directory())
|
||||
mypath = self.ServiceInterface.quickpkg(myatom,self.ServiceInterface.get_local_store_directory(self.server_repo))
|
||||
package_paths.add(mypath)
|
||||
packages_data = [(x,branch,False) for x in package_paths]
|
||||
idpackages = self.ServiceInterface.add_packages_to_repository(packages_data)
|
||||
idpackages = self.ServiceInterface.add_packages_to_repository(packages_data, repo = self.server_repo)
|
||||
|
||||
if not idpackages:
|
||||
self.updateProgress(
|
||||
@@ -844,7 +847,7 @@ class etpDatabase:
|
||||
etpData['branch'],
|
||||
)
|
||||
)
|
||||
elif self.dbname == etpConst['serverdbid']:
|
||||
elif self.dbname.startswith(etpConst['serverdbid']):
|
||||
raise
|
||||
|
||||
# on disk size
|
||||
@@ -1172,7 +1175,7 @@ class etpDatabase:
|
||||
# counter
|
||||
self.cursor.execute('DELETE FROM counters WHERE idpackage = '+idpackage)
|
||||
except:
|
||||
if self.dbname in [etpConst['clientdbid'],etpConst['serverdbid']]:
|
||||
if (self.dbname == etpConst['clientdbid']) or self.dbname.startswith(etpConst['serverdbid']):
|
||||
raise
|
||||
try:
|
||||
# on disk sizes
|
||||
@@ -3527,9 +3530,10 @@ class etpDatabase:
|
||||
idpackage,
|
||||
)
|
||||
)
|
||||
if (self.entropyTools.is_user_in_entropy_group()) and (self.dbname == etpConst['serverdbid']):
|
||||
# force commit even if readonly, this will allow to automagically fix dependstable server side
|
||||
self.connection.commit() # we don't care much about syncing the database since it's quite trivial
|
||||
if (self.entropyTools.is_user_in_entropy_group()) and \
|
||||
(self.dbname.startswith(etpConst['serverdbid'])):
|
||||
# force commit even if readonly, this will allow to automagically fix dependstable server side
|
||||
self.connection.commit() # we don't care much about syncing the database since it's quite trivial
|
||||
|
||||
'''
|
||||
@description: recreate dependstable table in the chosen database, it's used for caching searchDepends requests
|
||||
|
||||
+523
-407
File diff suppressed because it is too large
Load Diff
@@ -424,7 +424,6 @@ etpRepositoriesExcluded = {}
|
||||
etpRepositoriesOrder = []
|
||||
|
||||
# remote section
|
||||
etpRemoteSupport = {}
|
||||
etpRemoteFailures = {} # dict of excluded mirrors due to failures,
|
||||
# it contains mirror name and failure count | > 5 == ignore mirror
|
||||
|
||||
@@ -456,7 +455,6 @@ def initConfig_entropyConstants(rootdir):
|
||||
const_setupEntropyPid()
|
||||
const_readEntropySettings()
|
||||
const_readRepositoriesSettings()
|
||||
const_readRemoteSettings()
|
||||
const_readSocketSettings()
|
||||
const_configureLockPaths()
|
||||
initConfig_clientConstants()
|
||||
@@ -520,7 +518,6 @@ def const_defaultSettings(rootdir):
|
||||
'activatorconf': ETP_CONF_DIR+"/activator.conf", # activator.conf file
|
||||
'serverconf': ETP_CONF_DIR+"/server.conf", # server.conf file (generic server side settings)
|
||||
'reagentconf': ETP_CONF_DIR+"/reagent.conf", # reagent.conf file
|
||||
'remoteconf': ETP_CONF_DIR+"/remote.conf", # remote.conf file
|
||||
'equoconf': ETP_CONF_DIR+"/equo.conf", # equo.conf file
|
||||
'socketconf': ETP_CONF_DIR+"/socket.conf", # socket.conf file
|
||||
'packagesrelativepath': "packages/"+ETP_ARCH_CONST+"/", # user by client interfaces
|
||||
@@ -699,7 +696,7 @@ def const_defaultSettings(rootdir):
|
||||
},
|
||||
|
||||
'clientdbid': "client",
|
||||
'serverdbid': "etpdb",
|
||||
'serverdbid': "etpdb:",
|
||||
'systemreleasefile': "/etc/sabayon-release",
|
||||
|
||||
'socket_service': {
|
||||
@@ -819,6 +816,9 @@ def const_readRepositoriesSettings():
|
||||
elif (line.find("officialrepositoryid|") != -1) and (not line.startswith("#")) and (len(line.split("|")) == 2):
|
||||
officialreponame = line.split("|")[1]
|
||||
etpConst['officialrepositoryid'] = officialreponame
|
||||
shell_repoid = os.getenv('ETP_REPO')
|
||||
if shell_repoid:
|
||||
etpConst['officialrepositoryid'] = shell_repoid
|
||||
|
||||
elif (line.find("conntestlink|") != -1) and (not line.startswith("#")) and (len(line.split("|")) == 2):
|
||||
conntestlink = line.split("|")[1]
|
||||
@@ -921,22 +921,6 @@ def const_readEntropySettings():
|
||||
elif line.startswith("system-name|") and (len(line.split("|")) == 2):
|
||||
etpConst['systemname'] = line.split("|")[1].strip()
|
||||
|
||||
def const_readRemoteSettings():
|
||||
etpRemoteSupport.clear()
|
||||
etpRemoteFailures.clear()
|
||||
if (os.path.isfile(etpConst['remoteconf'])):
|
||||
f = open(etpConst['remoteconf'],"r")
|
||||
remoteconf = f.readlines()
|
||||
f.close()
|
||||
for line in remoteconf:
|
||||
if line.startswith("handler|") and (len(line.split("|")) > 2):
|
||||
servername = line.split("|")[1].strip()
|
||||
url = line.split("|")[2].strip()
|
||||
if not url.endswith("/"):
|
||||
url = url+"/"
|
||||
url += etpConst['product']+"/handlers/"
|
||||
etpRemoteSupport[servername] = url
|
||||
|
||||
def const_readEntropyRelease():
|
||||
# handle Entropy Version
|
||||
ETP_REVISION_FILE = "../libraries/revision"
|
||||
@@ -1187,11 +1171,12 @@ def const_readServerSettings():
|
||||
if etpConst['branch'] not in etpConst['branches']:
|
||||
etpConst['branches'].append(etpConst['branch'])
|
||||
|
||||
elif (line.find("repository|") != -1) and (len(line.split("|")) == 4):
|
||||
elif (line.find("repository|") != -1) and (len(line.split("|")) == 5):
|
||||
|
||||
repoid = line.split("|")[1].strip()
|
||||
repodesc = line.split("|")[2].strip()
|
||||
repouris = line.split("|")[3].strip()
|
||||
repohandlers = line.split("|")[4].strip()
|
||||
|
||||
if repouris.startswith("ftp://"):
|
||||
|
||||
@@ -1199,6 +1184,9 @@ def const_readServerSettings():
|
||||
etpConst['server_repositories'][repoid] = {}
|
||||
etpConst['server_repositories'][repoid]['description'] = repodesc
|
||||
etpConst['server_repositories'][repoid]['mirrors'] = []
|
||||
if repohandlers:
|
||||
repohandlers = os.path.join(repohandlers,etpConst['product'],repoid,"handlers")
|
||||
etpConst['server_repositories'][repoid]['handler'] = repohandlers
|
||||
|
||||
uris = repouris.split()
|
||||
for uri in uris:
|
||||
|
||||
Reference in New Issue
Block a user