* bug 333 fixed
* comar'i ve dep'leri ignore etmek icin option koy
- comar ignore implement et, comariface disaridan init ediliyor
artik
- packageop diye bir abstract komut tanimla
This commit is contained in:
+42
-12
@@ -17,6 +17,7 @@ from pisi.config import config
|
||||
from pisi.purl import PUrl
|
||||
from common import *
|
||||
import pisi.toplevel
|
||||
from pisi.ui import ui
|
||||
|
||||
# helper functions
|
||||
def cmdObject(cmd, fail=False):
|
||||
@@ -100,6 +101,10 @@ class Command(object):
|
||||
def help(self):
|
||||
print getattr(self, "__doc__")
|
||||
|
||||
def die(self):
|
||||
print 'Program terminated abnormally.'
|
||||
sys.exit(-1)
|
||||
|
||||
class Help(Command):
|
||||
"""Prints usage
|
||||
|
||||
@@ -145,7 +150,38 @@ fetch all necessary files and build the package for you.
|
||||
for arg in self.args:
|
||||
pisi.toplevel.build(arg, self.authInfo)
|
||||
|
||||
class Install(Command):
|
||||
class PackageOp(Command):
|
||||
"""Abstract package operation command"""
|
||||
def __init__(self):
|
||||
super(PackageOp, self).__init__()
|
||||
|
||||
def options(self):
|
||||
self.parser.add_option("", "--ignore-comar", action="store_true",
|
||||
default=False, help="xxxx")
|
||||
self.parser.add_option("", "--ignore-dependency",
|
||||
action="store_true",
|
||||
default=False, help="xxxx")
|
||||
|
||||
def init(self):
|
||||
self.init_db()
|
||||
import pisi.comariface
|
||||
if not self.options.ignore_comar:
|
||||
try:
|
||||
pisi.comariface.init()
|
||||
except pisi.comariface.ComarError:
|
||||
ui.error('Comar error encountered\n')
|
||||
self.die()
|
||||
|
||||
def finalize(self):
|
||||
#self.finalize_db()
|
||||
if not self.options.ignore_comar:
|
||||
pass
|
||||
#try:
|
||||
# pisi.comariface.finalize()
|
||||
#except pisi.comariface.ComarError:
|
||||
# ui.error('Comar error encountered\n')
|
||||
|
||||
class Install(PackageOp):
|
||||
"""Install PISI packages
|
||||
|
||||
Usage:
|
||||
@@ -158,19 +194,16 @@ repositories (with add-repo).
|
||||
def __init__(self):
|
||||
super(Install, self).__init__()
|
||||
|
||||
def options(self):
|
||||
self.parser.add_option("", "--test", action="store_true",
|
||||
default=True, help="xxxx")
|
||||
|
||||
def run(self):
|
||||
if not self.args:
|
||||
self.help()
|
||||
return
|
||||
|
||||
self.init_db()
|
||||
self.init()
|
||||
pisi.toplevel.install(self.args)
|
||||
self.finalize()
|
||||
|
||||
class Remove(Command):
|
||||
class Remove(PackageOp):
|
||||
"""Remove PISI packages
|
||||
|
||||
Usage:
|
||||
@@ -181,17 +214,14 @@ Remove a package from your system. Just give the package name to remove.
|
||||
def __init__(self):
|
||||
super(Remove, self).__init__()
|
||||
|
||||
def options(self):
|
||||
self.parser.add_option("", "--test", action="store_true",
|
||||
default=True, help="xxxx")
|
||||
|
||||
def run(self):
|
||||
if not self.args:
|
||||
self.help()
|
||||
return
|
||||
|
||||
self.init_db()
|
||||
self.init()
|
||||
pisi.toplevel.remove(self.args)
|
||||
self.finalize()
|
||||
|
||||
class Info(Command):
|
||||
"""Display information about a package
|
||||
|
||||
+13
-2
@@ -13,6 +13,9 @@
|
||||
import socket
|
||||
import struct
|
||||
|
||||
class ComarError(Exception):
|
||||
pass
|
||||
|
||||
class ComarIface:
|
||||
"""A class for communicating with comard."""
|
||||
RESULT = 0
|
||||
@@ -31,7 +34,7 @@ class ComarIface:
|
||||
self.sock.connect("/tmp/comar")
|
||||
except:
|
||||
# should raise an exception here
|
||||
print "Cannot connect to COMAR"
|
||||
raise ComarError, 'Cannot connect to COMAR daemon'
|
||||
|
||||
def __pack(self, cmd, id, args):
|
||||
size = 0
|
||||
@@ -104,4 +107,12 @@ class ComarIface:
|
||||
"""
|
||||
pass
|
||||
|
||||
comard = ComarIface()
|
||||
comard = None
|
||||
|
||||
def init():
|
||||
comard = ComarIface()
|
||||
|
||||
def finalize():
|
||||
if comard:
|
||||
del comard
|
||||
|
||||
|
||||
+4
-3
@@ -85,9 +85,10 @@ class Installer:
|
||||
ui.info("Registering COMAR script %s\n" % pcomar.script)
|
||||
# FIXME: We must check the result of the command (possibly
|
||||
# with id?)
|
||||
comard.register(pcomar.om,
|
||||
self.metadata.package.name,
|
||||
scriptPath)
|
||||
if comard:
|
||||
comard.register(pcomar.om,
|
||||
self.metadata.package.name,
|
||||
scriptPath)
|
||||
|
||||
def check_requirements(self):
|
||||
"""check system requirements"""
|
||||
|
||||
+3
-2
@@ -44,8 +44,9 @@ def remove_single(package_name):
|
||||
os.unlink(fpath)
|
||||
installdb.remove(package_name)
|
||||
inst_packagedb.remove_package(package_name)
|
||||
# FIXME: (return value)...
|
||||
comard.remove(package_name)
|
||||
if comard:
|
||||
# FIXME: (return value)...
|
||||
comard.remove(package_name)
|
||||
|
||||
def install_single(pkg):
|
||||
"""install a single package from URI or ID"""
|
||||
|
||||
Reference in New Issue
Block a user