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