Files
entropy/server/reagent
2007-08-13 16:44:41 +00:00

129 lines
5.0 KiB
Python

#!/usr/bin/python
'''
# DESCRIPTION:
# this application gets a .tbz2 file as input and creates a database entry
# with all the information needed by the Entropy client
Copyright (C) 2007 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
import sys
import string
sys.path.append('../libraries')
from outputTools import *
# CONSTANTS
APPNAME = "reagent"
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(" --nocolor\t\tdisable colorized output")
print_info(entropyTools.blue("Tools available: "))
print_info(" \t"+green("enzyme")+yellow("\t\t to analyze enzyme store directory"))
print_info(" \t\t"+red("--force-bump")+"\t\t\t\t to force the revision bumping of the package entries")
print_info(" \t\t"+red("--branch=[stable,unstable]")+"\t\t to force a specific branch")
print_info(" \t"+green(bold("database"))+yellow("\t Entropy database tool manager"))
print_info(" \t\t"+red("--initialize")+"\t\t\t\t (Re)Initialize the Entropy packages database [DO NOT USE THIS]")
print_info(" \t\t"+red("statistics")+"\t\t\t\t Show Entropy database statistics.")
print_info(" \t\t"+green("search")+"\t\t\t\t\t Search a package inside the Entropy packages database")
print_info(" \t\t"+green("restore-package-info")+"\t\t\t Reinitialize a package entry looking at the current install")
print_info(" \t\t"+green(bold("remove"))+"\t\t\t\t\t Remove a package or a list of packages")
print_info(" \t\t\t"+red("--branch=[stable,unstable]")+"\t Choose which branch of the package to remove")
print_info(" \t\t"+green("create-empty-database")+"\t\t\t Create an empty Entropy database file in the specified <path>")
print_info(" \t\t"+green("stabilize")+"\t\t\t\t Mark as stable a package, a list of packages, world")
print_info(" \t\t"+green("unstabilize")+"\t\t\t\t Mark as unstable a package, a list of packages, world")
print_info(" \t\t"+green("md5check")+"\t\t\t\t Check digest of a package, a list of packages, world")
#print_info(" \t\t"+green(bold("orphans"))+"\t\t\t Dump the list of files that don't belong on any installed package")
print_info(" \t\t"+green(bold("sanity-check"))+"\t\t\t\t Do a quick check on the database to assure data integrity")
print_info(" \t"+green(bold("deptest"))+yellow("\t\t Look for unsatisfied dependencies inside database"))
print_info(" \t\t"+red("--quiet")+"\t\t\t\t\t just print the dependencies list")
print_info(" \t"+green(bold("smartapps"))+yellow("\t Entropy application tool to create self-dependant applications [EXPERIMENTAL]"))
print_info(" \t\t"+green(bold("create"))+"\t\t\t\t\t Create a smartapp package using the package names provided")
print_info(" \t"+green(bold("cleanup"))+yellow("\t\t to clean temporary files"))
options = sys.argv[1:]
# print version
if (string.join(options).find("--version") != -1) or (string.join(options).find(" -V") != -1):
print_generic(APPNAME+": "+APPVERSION)
sys.exit(0)
# print help
if len(options) < 1 or string.join(options).find("--help") != -1 or string.join(options).find(" -h") != -1:
print_help()
if len(options) < 1:
print_error("not enough parameters")
sys.exit(1)
import entropyTools
import reagentTools
import databaseTools
from entropyConstants import *
from serverConstants import *
# preliminary options parsing
_options = []
for opt in options:
if (opt == "--nocolor"):
entropyTools.nocolor()
elif (opt == "--debug"):
entropyTools.enableDebug()
else:
_options.append(opt)
options = _options
if (not entropyTools.isRoot()):
print_error("you must be root in order to run "+APPNAME)
elif (options[0] == "generator"):
reagentTools.generator(options[1:])
sys.exit(0)
elif (options[0] == "enzyme"):
reagentTools.enzyme(options[1:])
sys.exit(0)
# database tool
elif (options[0] == "database"):
databaseTools.database(options[1:])
sys.exit(0)
# smartapps tool
elif (options[0] == "smartapps"):
reagentTools.smartapps(options[1:])
sys.exit(0)
# smartapps tool
elif (options[0] == "deptest"):
reagentTools.dependenciesTest(options[1:])
sys.exit(0)
# cleanup
if (options[0] == "cleanup"):
entropyTools.cleanup()
sys.exit(0)