#!/usr/bin/python ''' # DESCRIPTION: # Entropy Package Manager 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 ''' import sys import string import equoTools import entropyTools from entropyConstants import * from clientConstants import * from outputTools import * # CONSTANTS APPNAME = "Equo" APPVERSION = "0.1" def print_help(): print_info("Sabayon Linux "+darkred(APPNAME+" Package Manager")+" (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(red("Tools available: ")) #print_info(" \t"+blue(bold("repo"))+brown("\t\t to handle package repositories")) print_info(" \t"+blue("update")+brown("\t\t update repositories (download new data)")) print_info(" \t\t"+red("--force")+"\t\t\t force the sync even if the database is already up to date") print_info(" \t"+blue("repoinfo")+brown("\t show enabled repositories")) print_info(" \t"+blue("status")+brown("\t\t show respositories status")) #print_info(" \t"+darkgreen(bold("package"))+brown("\t\t to handle packages")) print_info(" \t"+blue("search")+brown("\t\t search a package trough repositories")) print_info(" \t"+blue("install")+brown("\t\t install a package")) print_info(" \t\t"+red("--ask")+"\t\t\t ask before making any changes") print_info(" \t\t"+red("--pretend")+"\t\t just show what would be done") print_info(" \t\t"+red("--fetch")+"\t\t\t just download packages without doing the install") print_info(" \t\t"+red("--nodeps")+"\t\t do not manage any dependency") print_info(" \t\t"+red("--empty")+"\t\t\t also include already installed packages") print_info(" \t\t"+red("--verbose")+"\t\t show more details about what's going on") print_info(" \t"+blue("remove")+brown("\t\t remove a package")) print_info(" \t"+blue("deptest")+brown("\t\t look for unsatisfied dependencies")) print_info(" \t\t"+red("--quiet")+"\t\t\t show less details (useful for scripting)") print_info(" \t\t"+red("--ask")+"\t\t\t ask before making any changes") print_info(" \t\t"+red("--pretend")+"\t\t just show what would be done") print_info(" \t"+blue(bold("query"))+brown("\t\t do misc queries on repository and local databases")) print_info(" \t\t"+darkgreen("installed")+red("\t\t search a package into the local database")) print_info(" \t\t"+darkgreen("belongs")+red("\t\t\t search from what package a file belongs")) print_info(" \t\t"+darkgreen("depends")+red("\t\t\t search which packages depend on the provided atoms")) print_info(" \t\t"+darkgreen("files")+red("\t\t\t search files owned by the provided atoms")) print_info(" \t\t"+darkgreen("description")+red("\t\t search a package description")) print_info(" \t\t"+red("--verbose")+"\t\t show more details about what's going on") print_info(" \t\t"+red("--quiet")+"\t\t\t show less details (useful for scripting)") print_info(" \t"+blue("database")+brown("\t handle installed packages database")) print_info(" \t\t"+darkgreen("generate")+red("\t\t generate installed packages database")) print_info(" \t\t"+red("--exact")+"\t\t only install packages whose version match exactly") print_info(" \t"+blue("cleanup")+brown("\t\t remove downloaded packages and clean temporary directories")) options = sys.argv[1:] # preliminary options parsing _options = [] for opt in options: if (opt == "--nocolor"): entropyTools.nocolor() elif (opt == "--debug"): entropyTools.enableDebug() else: _options.append(opt) options = _options # print version if (string.join(options).find("--version") != -1) or (string.join(options).find(" -V") != -1): entropyTools.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: entropyTools.print_error("not enough parameters") sys.exit(1) try: # sync mirrors tool if (options[0] == "update") or (options[0] == "repoinfo") or (options[0] == "status"): if options[0] == "update": entropyTools.applicationLockCheck("update") rc = equoTools.repositories(options) sys.exit(rc) elif (options[0] == "search") or (options[0] == "install") or (options[0] == "remove") or (options[0] == "deptest"): if options[0] == "install": entropyTools.applicationLockCheck("install") elif options[0] == "remove": entropyTools.applicationLockCheck("remove") rc = equoTools.package(options) sys.exit(rc) elif (options[0] == "query"): rc = equoTools.query(options[1:]) sys.exit(rc) elif (options[0] == "database"): entropyTools.applicationLockCheck("database") rc = equoTools.database(options[1:]) sys.exit(rc) elif (options[0] == "cleanup"): entropyTools.applicationLockCheck("cleanup") entropyTools.cleanup([ etpConst['packagestmpdir'], etpConst['logdir'], etpConst['entropyunpackdir'], etpConst['packagesbindir'] ]) sys.exit(0) except SystemExit: pass except KeyboardInterrupt: pass except: from entropyTools import askquestion from remoteTools import getOnlineContent, reportApplicationError import string print_error(darkred("Hi. My name is Bug Reporter. I am sorry to inform you that Equo crashed. Well, you know, shit happens.")) print_error(darkred("But there's something you could do to help Equo to be a better application.")) print_error(darkgreen("Now I am showing you what happened. Don't panic, I'm here to help you. Suddenly happened:")) print import traceback traceback.print_exc() try: ferror = open("/tmp/equoerror.txt","w") traceback.print_exc(file = ferror) ferror.flush() ferror.close() f = open("/tmp/equoerror.txt","r") errorText = f.readlines() f.close() errorText = string.join(errorText," ") except: print print_error(darkred("Oh well, I cannot even write to /tmp. So, please copy the error and mail lxnay@sabayonlinux.org.")) sys.exit(1) print print_error(blue("Ok, back here. Let me see if you are connected to the Internet. Yes, I am blue now, so?")) conntest = getOnlineContent("http://svn.sabayonlinux.org") if (conntest != False): print_error(darkgreen("Of course you are on the Internet...")) rc = askquestion(" Erm... Can I send the error to my creators so they can fix me?") if rc == "No": print_error(darkgreen("Ok, ok ok ok... Sorry!")) sys.exit(2) else: print_error(darkgreen("Gosh, you aren't! Well, I wrote the error to /tmp/equoerror.txt. When you want, mail the file to lxnay@sabayonlinux.org.")) sys.exit(3) # ok, come on! result = reportApplicationError(errorText) if (result != False): print_error(darkgreen("Thank you very much. The error has been reported and hopefully, the problem will be solved as soon as possible.")) else: print_error(darkred("Ugh. Cannot send the report. I saved the error to /tmp/equoerror.txt. When you want, mail the file to lxnay@sabayonlinux.org.")) sys.exit(4)