Entropy/ServerInterface:

- added --syncall option to activator to allow syncing of all the repositories without too much hassle


git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@1738 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
lxnay
2008-04-14 17:32:28 +00:00
parent 261e97c69c
commit 53baba96fe
2 changed files with 90 additions and 30 deletions
+3
View File
@@ -45,11 +45,13 @@ def print_help():
print_info(blue("Tools available: "))
print_info(" \t"+green(bold("sync"))+brown("\t\t to sync packages, database and also do some tidy"))
print_info(" \t\t"+red("--noask")+"\t\t\t do not make any question")
print_info(" \t\t"+red("--syncall")+"\t\t sync all the configured repositories")
print_info(" \t"+green(bold("tidy"))+brown("\t\t to just remove binary packages that are not in database and are expired"))
print_info(" \t"+green(bold("packages"))+brown("\t to manage binary packages"))
print_info(" \t\t"+green("sync")+red("\t\t\t to sync the binary packages across primary mirrors"))
print_info(" \t\t\t"+red("--ask")+"\t\t\t ask before making any changes")
print_info(" \t\t\t"+red("--pretend")+"\t\t just show what would be done")
print_info(" \t\t\t"+red("--syncall")+"\t\t sync all the configured repositories")
print_info(" \t\t\t"+red("--do-packages-check")+"\t after the syncronization, also check packages checksum")
print_info(" \t"+green(bold("database"))+brown("\t to manage database status and settings [")+bold("database content won't be touched")+brown("]"))
print_info(" \t\t"+green("sync")+red("\t\t\t to sync the database across primary mirrors"))
@@ -58,6 +60,7 @@ def print_help():
print_info(" \t\t"+green("download-lock")+red("\t\t to lock the download mirror status"))
print_info(" \t\t"+green("download-unlock")+red("\t\t to unlock the download mirror status"))
print_info(" \t\t"+green("lock-status")+red("\t\t to show the current locks status of the mirrors"))
print_info(" \t\t\t"+red("--syncall")+"\t\t sync all the configured repositories")
options = sys.argv[1:]
+87 -30
View File
@@ -28,59 +28,100 @@ Entropy = ServerInterface()
def sync(options, justTidy = False):
do_noask = False
sync_all = False
myopts = []
for opt in options:
if opt == "--noask":
do_noask = True
elif opt == "--syncall":
sync_all = True
else:
myopts.append(opt)
options = myopts
print_info(green(" * ")+red("Starting to sync data across mirrors (packages/database) ..."))
if not justTidy:
repos = [Entropy.default_repository]
if sync_all:
repos = etpConst['server_repositories'].keys()
repos.sort()
old_default = Entropy.default_repository
mirrors_tainted, mirrors_errors, successfull_mirrors, broken_mirrors, check_data = Entropy.MirrorsService.sync_packages(ask = not do_noask, pretend = etpUi['pretend'])
if not mirrors_errors:
if mirrors_tainted:
if (not do_noask) and etpConst['rss-feed']:
etpRSSMessages['commitmessage'] = readtext(">> Please insert a commit message: ")
elif etpConst['rss-feed']:
etpRSSMessages['commitmessage'] = "Autodriven Update"
rc = database(["sync"])
if not rc:
Entropy.MirrorsService.lock_mirrors(lock = False)
if not rc and not do_noask:
rc = Entropy.askQuestion("Should I continue with the tidy procedure ?")
if rc == "No":
sys.exit(0)
elif rc:
print_error(darkred(" !!! ")+red("Aborting !"))
sys.exit(1)
for repo in repos:
Entropy.MirrorsService.tidy_mirrors(ask = not do_noask, pretend = etpUi['pretend'])
if repo != Entropy.default_repository:
Entropy.switch_default_repository(repo)
errors = False
if not justTidy:
mirrors_tainted, mirrors_errors, successfull_mirrors, broken_mirrors, check_data = Entropy.MirrorsService.sync_packages(ask = not do_noask, pretend = etpUi['pretend'])
if not mirrors_errors:
if mirrors_tainted:
if (not do_noask) and etpConst['rss-feed']:
etpRSSMessages['commitmessage'] = readtext(">> Please insert a commit message: ")
elif etpConst['rss-feed']:
etpRSSMessages['commitmessage'] = "Autodriven Update"
errors, fine, broken = sync_remote_databases()
if not errors:
Entropy.MirrorsService.lock_mirrors(lock = False)
if not errors and not do_noask:
rc = Entropy.askQuestion("Should I continue with the tidy procedure ?")
if rc == "No":
continue
elif errors:
print_error(darkred(" !!! ")+red("Aborting !"))
continue
if not errors:
Entropy.MirrorsService.tidy_mirrors(ask = not do_noask, pretend = etpUi['pretend'])
if old_default != Entropy.default_repository:
Entropy.switch_default_repository(old_default)
def packages(options):
sync_all = False
do_pkg_check = False
for opt in options:
if (opt == "--do-packages-check"):
if opt == "--do-packages-check":
do_pkg_check = True
elif opt == "--syncall":
sync_all = True
if not options:
return
if options[0] == "sync":
return Entropy.MirrorsService.sync_packages( ask = etpUi['ask'],
pretend = etpUi['pretend'],
packages_check = do_pkg_check
)
repos = [Entropy.default_repository]
if sync_all:
repos = etpConst['server_repositories'].keys()
repos.sort()
old_default = Entropy.default_repository
for repo in repos:
if repo != Entropy.default_repository:
Entropy.switch_default_repository(repo)
Entropy.MirrorsService.sync_packages( ask = etpUi['ask'],
pretend = etpUi['pretend'],
packages_check = do_pkg_check
)
if old_default != Entropy.default_repository:
Entropy.switch_default_repository(old_default)
return 0
def database(options):
cmd = options[0]
sync_all = False
for opt in options:
if opt == "--syncall":
sync_all = True
if cmd == "lock":
@@ -140,12 +181,28 @@ def database(options):
elif cmd == "sync":
print_info(green(" * ")+red("Syncing databases ..."))
errors, fine, broken = sync_remote_databases()
if errors:
print_error(darkred(" !!! ")+green("Database sync errors, cannot continue."))
return 1
return 0
repos = [Entropy.default_repository]
if sync_all:
repos = etpConst['server_repositories'].keys()
repos.sort()
old_default = Entropy.default_repository
problems = 0
for repo in repos:
if repo != Entropy.default_repository:
Entropy.switch_default_repository(repo)
print_info(green(" * ")+red("Syncing databases ..."))
errors, fine, broken = sync_remote_databases()
if errors:
print_error(darkred(" !!! ")+green("Database sync errors, cannot continue."))
problems = 1
if old_default != Entropy.default_repository:
Entropy.switch_default_repository(old_default)
return problems
def sync_remote_databases(noUpload = False, justStats = False):