From 53baba96fe95073623e145dfa4b0ed4850d71dd3 Mon Sep 17 00:00:00 2001 From: lxnay Date: Mon, 14 Apr 2008 17:32:28 +0000 Subject: [PATCH] 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 --- server/activator | 3 + server/server_activator.py | 117 +++++++++++++++++++++++++++---------- 2 files changed, 90 insertions(+), 30 deletions(-) diff --git a/server/activator b/server/activator index d0f6983f8..e002834b8 100644 --- a/server/activator +++ b/server/activator @@ -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:] diff --git a/server/server_activator.py b/server/server_activator.py index c2e09388f..c0b2bcfa2 100644 --- a/server/server_activator.py +++ b/server/server_activator.py @@ -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):