the biggest commit, ever git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@982 cd1c1023-2f26-0410-ae45-c471fc1f0318
121 lines
4.4 KiB
Python
121 lines
4.4 KiB
Python
#!/usr/bin/python
|
|
'''
|
|
# DESCRIPTION:
|
|
# Entropy mirrors syncing manager
|
|
|
|
Copyright (C) 2007-2008 Fabio Erculiani
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
'''
|
|
|
|
# Never do "import portage" here, please use entropyTools binding
|
|
|
|
import os
|
|
from sys import path, exit, argv
|
|
|
|
path.append('../libraries')
|
|
path.append('../client')
|
|
from outputTools import *
|
|
|
|
# CONSTANTS
|
|
APPNAME = "activator"
|
|
APPVERSION = "1.0"
|
|
def print_help():
|
|
print_info("Sabayon Linux "+APPNAME+" (C - 2007)")
|
|
print_info("General Options:")
|
|
print_info(" --help\t\tthis output")
|
|
print_info(" --version\t\tprint version")
|
|
print_info(" --verbose\t\tbe more verbose")
|
|
print_info(" --nocolor\t\tdisable colorized output")
|
|
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"+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("--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"))
|
|
print_info(" \t\t"+green("lock")+red("\t\t\t to lock the database(s) status ["+brown("DANGEROUS")+red("]")))
|
|
print_info(" \t\t"+green("unlock")+red("\t\t\t to unlock the database(s) status ["+brown("DANGEROUS")+red("]")))
|
|
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"))
|
|
|
|
options = argv[1:]
|
|
|
|
from entropyConstants import *
|
|
from serverConstants import *
|
|
|
|
# print version
|
|
if (' '.join(options).find("--version") != -1) or (' '.join(options).find(" -V") != -1):
|
|
print_generic(APPNAME+": "+APPVERSION)
|
|
exit(0)
|
|
|
|
# print help
|
|
if len(options) < 1 or ' '.join(options).find("--help") != -1 or ' '.join(options).find(" -h") != -1:
|
|
print_help()
|
|
if len(options) < 1:
|
|
print_error("not enough parameters")
|
|
exit(1)
|
|
|
|
import entropyTools
|
|
import activatorTools
|
|
|
|
# preliminary options parsing
|
|
_options = []
|
|
for opt in options:
|
|
if (opt == "--nocolor"):
|
|
nocolor()
|
|
elif (opt == "--debug"):
|
|
entropyTools.enableDebug()
|
|
else:
|
|
if (opt == "--quiet"):
|
|
etpUi['quiet'] = True
|
|
elif (opt == "--verbose"):
|
|
etpUi['verbose'] = True
|
|
elif (opt == "--ask"):
|
|
etpUi['ask'] = True
|
|
elif (opt == "--pretend"):
|
|
etpUi['pretend'] = True
|
|
else:
|
|
_options.append(opt)
|
|
options = _options
|
|
|
|
if (not entropyTools.isRoot()):
|
|
print_error("you must be root in order to run "+APPNAME)
|
|
exit(2)
|
|
|
|
# sync mirrors tool
|
|
elif (options[0] == "sync"):
|
|
activatorTools.sync(options[1:])
|
|
exit(0)
|
|
# tidy tool
|
|
elif (options[0] == "tidy"):
|
|
activatorTools.sync(options[1:], justTidy = True)
|
|
exit(0)
|
|
|
|
# database tool
|
|
elif (options[0] == "database"):
|
|
activatorTools.database(options[1:])
|
|
exit(0)
|
|
|
|
# database tool
|
|
elif (options[0] == "packages"):
|
|
activatorTools.packages(options[1:])
|
|
exit(0)
|