* upgrade test'ini duzelt
* python import kurallarina uy - global degistirdigimiz yerde init order'ina dikkat et - her import statement'i tek satirda - global adlari kullan * yes-all diye bir common option ekle * install_files'in cagirdigi install_names'i eger bossa hic cagirma * fix: olmayan repo'yu kaldirma * fix: info ln'ler * commands: yeni init/finalize olayi ekle - import'u dogru yerde cagirmak icin ornegin gerekti
This commit is contained in:
+61
-17
@@ -16,8 +16,6 @@ from optparse import OptionParser
|
||||
import pisi
|
||||
from pisi.purl import PUrl
|
||||
from pisi.cli.common import *
|
||||
import pisi.toplevel
|
||||
from pisi.ui import ui
|
||||
|
||||
|
||||
def commandsString():
|
||||
@@ -48,18 +46,21 @@ class Command(object):
|
||||
|
||||
def __init__(self):
|
||||
# now for the real parser
|
||||
import pisi
|
||||
self.parser = OptionParser(usage=usage_text,
|
||||
version="%prog " + pisi.__version__)
|
||||
self.options()
|
||||
self.parser = commonopts(self.parser)
|
||||
(self.options, self.args) = self.parser.parse_args()
|
||||
#print 'opts,args = ', self.options, self.args
|
||||
self.args.pop(0) # exclude command arg
|
||||
|
||||
import pisi
|
||||
#from pisi.ui import ui
|
||||
|
||||
# initialize PiSi
|
||||
#print '**** running cmd'
|
||||
pisi.config.config = pisi.config.Config(self.options)
|
||||
cli = pisi.ui.CLI(self.options.debug)
|
||||
pisi.ui.ui = cli
|
||||
pisi.ui.ui = pisi.ui.CLI(self.options.debug)
|
||||
|
||||
self.checkAuthInfo()
|
||||
|
||||
@@ -91,9 +92,17 @@ class Command(object):
|
||||
else:
|
||||
self.authInfo = None
|
||||
|
||||
def init_db(self):
|
||||
from pisi.repodb import repodb
|
||||
repodb.init_dbs()
|
||||
def init(self, database = False):
|
||||
"""initialize PiSi components"""
|
||||
|
||||
# IMPORTANT: command imports here or in the command class run fxns
|
||||
import pisi.toplevel
|
||||
if database:
|
||||
from pisi.repodb import repodb
|
||||
repodb.init_dbs()
|
||||
|
||||
def finalize(self):
|
||||
pass
|
||||
|
||||
def help(self):
|
||||
print getattr(self, "__doc__")
|
||||
@@ -121,12 +130,17 @@ for that command.
|
||||
if not self.args:
|
||||
self.parser.print_help()
|
||||
return
|
||||
|
||||
self.init()
|
||||
|
||||
for arg in self.args:
|
||||
print
|
||||
pisi.ui.ui.info("%s: " % arg)
|
||||
obj = cmdObject(arg, True)
|
||||
obj.help()
|
||||
# print "\n",self.parser.format_option_help()
|
||||
|
||||
|
||||
self.finalize()
|
||||
|
||||
|
||||
class Build(Command):
|
||||
"""Build a PISI package using a pspec.xml file
|
||||
@@ -145,8 +159,10 @@ fetch all necessary files and build the package for you.
|
||||
self.help()
|
||||
return
|
||||
|
||||
self.init()
|
||||
for arg in self.args:
|
||||
pisi.toplevel.build(arg, self.authInfo)
|
||||
self.finalize()
|
||||
|
||||
|
||||
class PackageOp(Command):
|
||||
@@ -162,7 +178,7 @@ class PackageOp(Command):
|
||||
## default=False, help="xxxx")
|
||||
|
||||
def init(self):
|
||||
self.init_db()
|
||||
super(PackageOp, self).init(True)
|
||||
import pisi.comariface
|
||||
if not self.options.ignore_comar:
|
||||
try:
|
||||
@@ -170,6 +186,7 @@ class PackageOp(Command):
|
||||
except pisi.comariface.ComarError:
|
||||
ui.error('Comar error encountered\n')
|
||||
self.die()
|
||||
self.finalize()
|
||||
|
||||
def finalize(self):
|
||||
#self.finalize_db()
|
||||
@@ -278,8 +295,10 @@ TODO: Some description...
|
||||
self.help()
|
||||
return
|
||||
|
||||
self.init()
|
||||
for arg in self.args:
|
||||
self.printinfo(arg)
|
||||
self.finalize()
|
||||
|
||||
def printinfo(self, arg):
|
||||
import os.path
|
||||
@@ -301,7 +320,8 @@ TODO: Some description...
|
||||
super(Index, self).__init__()
|
||||
|
||||
def run(self):
|
||||
|
||||
|
||||
self.init()
|
||||
from pisi.toplevel import index
|
||||
if len(self.args)==1:
|
||||
index(self.args[0])
|
||||
@@ -311,7 +331,7 @@ TODO: Some description...
|
||||
else:
|
||||
print 'Indexing only a single directory supported.'
|
||||
return
|
||||
|
||||
self.finalize()
|
||||
|
||||
class ListInstalled(Command):
|
||||
"""Print the list of all installed packages
|
||||
@@ -330,7 +350,7 @@ TODO: Some description...
|
||||
default=False, help="show in long format")
|
||||
|
||||
def run(self):
|
||||
self.init_db()
|
||||
self.init(True)
|
||||
from pisi.installdb import installdb
|
||||
for pkg in installdb.list_installed():
|
||||
package = pisi.packagedb.get_package(pkg)
|
||||
@@ -338,6 +358,7 @@ TODO: Some description...
|
||||
print package.name, '-', package.summary
|
||||
else:
|
||||
print package
|
||||
self.finalize()
|
||||
|
||||
|
||||
class UpdateRepo(Command):
|
||||
@@ -359,7 +380,7 @@ TODO: Some description...
|
||||
self.init_db()
|
||||
for repo in self.args:
|
||||
pisi.toplevel.update_repo(repo)
|
||||
|
||||
self.finalize()
|
||||
|
||||
class AddRepo(Command):
|
||||
"""Add a repository
|
||||
@@ -375,9 +396,11 @@ TODO: Some description...
|
||||
def run(self):
|
||||
|
||||
if len(self.args)>=2:
|
||||
self.init()
|
||||
name = self.args[0]
|
||||
indexuri = self.args[1]
|
||||
pisi.toplevel.add_repo(name, indexuri)
|
||||
self.init()
|
||||
else:
|
||||
self.help()
|
||||
return
|
||||
@@ -397,8 +420,10 @@ TODO: Some description...
|
||||
def run(self):
|
||||
|
||||
if len(self.args)>=1:
|
||||
self.init()
|
||||
name = self.args[0]
|
||||
pisi.toplevel.remove_repo(name)
|
||||
self.finalize()
|
||||
else:
|
||||
self.help()
|
||||
return
|
||||
@@ -417,10 +442,12 @@ TODO: Some description...
|
||||
|
||||
def run(self):
|
||||
|
||||
self.init()
|
||||
from pisi.repodb import repodb
|
||||
for repo in repodb.list():
|
||||
print repo
|
||||
print ' ', repodb.get_repo(repo).indexuri.getUri()
|
||||
self.finalize()
|
||||
|
||||
|
||||
class ListAvailable(Command):
|
||||
@@ -448,6 +475,7 @@ TODO: desc...
|
||||
for repo in repodb.list():
|
||||
ui.info("Repository : %s\n" % repo)
|
||||
self.print_packages(repo)
|
||||
self.finalize()
|
||||
|
||||
def print_packages(self, repo):
|
||||
from pisi import packagedb
|
||||
@@ -472,6 +500,7 @@ class ListPending(Command):
|
||||
for p in installdb.list_pending():
|
||||
print p
|
||||
|
||||
self.finalize()
|
||||
|
||||
class SearchAvailable(Command):
|
||||
"""Search in available packages
|
||||
@@ -506,14 +535,17 @@ for you.
|
||||
self.parser.add_option("-s", action="store", dest="state")
|
||||
|
||||
def run(self):
|
||||
|
||||
if not self.args:
|
||||
self.help()
|
||||
return
|
||||
|
||||
self.init()
|
||||
state = self.options.state
|
||||
|
||||
for arg in self.args:
|
||||
pisi.toplevel.build_until(arg, state, self.authInfo)
|
||||
self.finalize()
|
||||
|
||||
|
||||
class BuildUnpack(Command):
|
||||
@@ -532,8 +564,10 @@ TODO: desc.
|
||||
self.help()
|
||||
return
|
||||
|
||||
self.init()
|
||||
for arg in self.args:
|
||||
pisi.toplevel.build_until(arg, "unpack", self.authInfo)
|
||||
self.finalize()
|
||||
|
||||
|
||||
class BuildSetup(Command):
|
||||
@@ -552,8 +586,11 @@ TODO: desc.
|
||||
self.help()
|
||||
return
|
||||
|
||||
self.init()
|
||||
for arg in self.args:
|
||||
pisi.toplevel.build_until(arg, "setupaction", self.authInfo)
|
||||
pisi.toplevel.build_until(arg, "setupaction",
|
||||
self.authInfo)
|
||||
self.finalize()
|
||||
|
||||
|
||||
class BuildBuild(Command):
|
||||
@@ -572,8 +609,10 @@ TODO: desc.
|
||||
self.help()
|
||||
return
|
||||
|
||||
self.init()
|
||||
for arg in self.args:
|
||||
pisi.toplevel.build_until(arg, "buildaction", self.authInfo)
|
||||
self.finalize()
|
||||
|
||||
|
||||
class BuildInstall(Command):
|
||||
@@ -592,8 +631,11 @@ TODO: desc.
|
||||
self.help()
|
||||
return
|
||||
|
||||
self.init()
|
||||
for arg in self.args:
|
||||
pisi.toplevel.build_until(arg, "installaction", self.authInfo)
|
||||
pisi.toplevel.build_until(arg, "installaction",
|
||||
self.authInfo)
|
||||
self.finalize()
|
||||
|
||||
|
||||
class BuildPackage(Command):
|
||||
@@ -612,8 +654,10 @@ TODO: desc.
|
||||
self.help()
|
||||
return
|
||||
|
||||
self.init()
|
||||
for arg in self.args:
|
||||
pisi.toplevel.build_until(arg, "buildpackages", self.authInfo)
|
||||
self.finalize()
|
||||
|
||||
# command dictionary
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ PISI Package Manager
|
||||
def commonopts(parser):
|
||||
p = parser
|
||||
p.add_option("-D", "--destdir", action="store")
|
||||
p.add_option("", "--yes-all", action="store_true",
|
||||
default=False, help = "assume yes in all yes/no queries")
|
||||
p.add_option("-u", "--username", action="store")
|
||||
p.add_option("-p", "--password", action="store")
|
||||
p.add_option("-P", action="store_true", dest="getpass", default=False,
|
||||
|
||||
@@ -14,7 +14,6 @@ import sys
|
||||
from optparse import OptionParser
|
||||
|
||||
import pisi
|
||||
import pisi.operations
|
||||
from pisi.purl import PUrl
|
||||
from pisi.cli.common import *
|
||||
from pisi.cli.commands import *
|
||||
|
||||
+3
-3
@@ -15,9 +15,9 @@
|
||||
# Authors: Baris Metin <baris@uludag.org.tr
|
||||
# Eray Ozkural <eray@uludag.org.tr>
|
||||
|
||||
from constants import const
|
||||
from config import config
|
||||
from specfile import SpecFile
|
||||
from pisi.constants import const
|
||||
from pisi.config import config
|
||||
from pisi.specfile import SpecFile
|
||||
|
||||
class BuildContext(object):
|
||||
"""Build Context Singleton"""
|
||||
|
||||
+9
-9
@@ -16,15 +16,15 @@
|
||||
|
||||
import os
|
||||
|
||||
from package import Package
|
||||
from xmlfile import XmlFile
|
||||
import metadata
|
||||
import packagedb
|
||||
from ui import ui
|
||||
import util
|
||||
from config import config
|
||||
from constants import const
|
||||
from purl import PUrl
|
||||
from pisi.package import Package
|
||||
from pisi.xmlfile import XmlFile
|
||||
import pisi.metadata as metadata
|
||||
import pisi.packagedb as packagedb
|
||||
from pisi.ui import ui
|
||||
import pisi.util as util
|
||||
from pisi.config import config
|
||||
from pisi.constants import const
|
||||
from pisi.purl import PUrl
|
||||
|
||||
class Index(XmlFile):
|
||||
|
||||
|
||||
+2
-2
@@ -101,10 +101,10 @@ class Installer:
|
||||
# is this an upgrade?
|
||||
# determine and report the kind of upgrade: version, release, build
|
||||
if pkg.version > iversion:
|
||||
ui.info('Upgrading to new upstream version')
|
||||
ui.info('Upgrading to new upstream version\n')
|
||||
upgrade = True
|
||||
elif pkg.release > irelease:
|
||||
ui.info('Upgrading to new distribution release')
|
||||
ui.info('Upgrading to new distribution release\n')
|
||||
upgrade = True
|
||||
|
||||
# is this a downgrade? confirm this action.
|
||||
|
||||
+3
-3
@@ -36,12 +36,12 @@ class InstallDB:
|
||||
from os.path import join
|
||||
self.d = shelve.LockedDBShelf('install')
|
||||
self.dp = shelve.LockedDBShelf('configpending')
|
||||
from config import config
|
||||
from pisi.config import config
|
||||
self.files_dir = os.path.join(config.db_dir(), 'files')
|
||||
|
||||
def files_name(self, pkg, version, release):
|
||||
from os.path import join
|
||||
from config import config
|
||||
from pisi.config import config
|
||||
pkg_dir = join(config.lib_dir(), pkg + '-' + version + '-' + release)
|
||||
return join(pkg_dir, const.files_xml)
|
||||
|
||||
@@ -93,7 +93,7 @@ class InstallDB:
|
||||
def install(self, pkg, version, release):
|
||||
"""install package with specific version and release"""
|
||||
pkg = str(pkg)
|
||||
from config import config
|
||||
from pisi.config import config
|
||||
if self.is_installed(pkg):
|
||||
raise InstallDBError("already installed")
|
||||
if config.options and config.options.ignore_comar:
|
||||
|
||||
@@ -19,8 +19,8 @@ import bsddb.db as db
|
||||
import os
|
||||
import fcntl
|
||||
|
||||
from config import config
|
||||
import util
|
||||
from pisi.config import config
|
||||
import pisi.util as util
|
||||
|
||||
class LockedDBShelf(shelve.DBShelf):
|
||||
|
||||
|
||||
+3
-2
@@ -14,8 +14,9 @@ from bsddb import db
|
||||
import bsddb.dbshelve as shelve
|
||||
import os, fcntl
|
||||
|
||||
from config import config
|
||||
import packagedb, util
|
||||
from pisi.config import config
|
||||
import pisi.packagedb as packagedb
|
||||
import pisi.util as util
|
||||
from pisi.purl import PUrl
|
||||
|
||||
class RepoDB(object):
|
||||
|
||||
+5
-4
@@ -19,12 +19,13 @@
|
||||
# yes, we are cheap
|
||||
|
||||
import bsddb.dbshelve as shelve
|
||||
import os, fcntl
|
||||
|
||||
import util
|
||||
from config import config
|
||||
import os
|
||||
import fcntl
|
||||
from bsddb import db
|
||||
|
||||
import pisi.util as util
|
||||
from pisi.config import config
|
||||
|
||||
class SourceDB(object):
|
||||
|
||||
def __init__(self):
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
|
||||
from os.path import basename, dirname, join
|
||||
|
||||
from ui import ui
|
||||
from config import config
|
||||
from constants import const
|
||||
from purl import PUrl
|
||||
from specfile import SpecFile
|
||||
from pisi.ui import ui
|
||||
from pisi.config import config
|
||||
from pisi.constants import const
|
||||
from pisi.purl import PUrl
|
||||
from pisi.specfile import SpecFile
|
||||
|
||||
class SourceFetcher(object):
|
||||
def __init__(self, url, authInfo=None):
|
||||
|
||||
+8
-2
@@ -92,7 +92,9 @@ def install_pkg_files(packages):
|
||||
# be satisfied by installing packages from the repo
|
||||
|
||||
# if so, then invoke install_pkg_names
|
||||
if install_pkg_names([x.package for x in dep_unsatis]):
|
||||
extra_packages = [x.package for x in dep_unsatis]
|
||||
if (extra_packages and install_pkg_names(extra_packages)) or \
|
||||
(not extra_packages):
|
||||
for x in packages:
|
||||
operations.install_single_file(x)
|
||||
|
||||
@@ -291,7 +293,11 @@ def add_repo(name, indexuri):
|
||||
repodb.add_repo(name, repo)
|
||||
|
||||
def remove_repo(name):
|
||||
repodb.remove_repo(name)
|
||||
if repodb.has_repo(name):
|
||||
repodb.remove_repo(name)
|
||||
else:
|
||||
ui.error('* Repository %s does not exist. Cannot remove.\n'
|
||||
% name)
|
||||
|
||||
def update_repo(repo):
|
||||
|
||||
|
||||
+8
-2
@@ -14,7 +14,9 @@
|
||||
# Murat Eren <meren@uludag.org.tr>
|
||||
|
||||
import sys
|
||||
from colors import colorize
|
||||
|
||||
from pisi.colors import colorize
|
||||
from pisi.config import config
|
||||
|
||||
def register(_impl):
|
||||
""" Register a UI implementation"""
|
||||
@@ -53,6 +55,9 @@ class CLI:
|
||||
sys.stdout.flush()
|
||||
|
||||
def confirm(self, msg):
|
||||
from pisi.config import config
|
||||
if config.options and config.options.yes_all:
|
||||
return True
|
||||
while True:
|
||||
s = raw_input(msg + colorize('(yes/no)', 'red'))
|
||||
if s.startswith('y') or s.startswith('Y'):
|
||||
@@ -82,4 +87,5 @@ class CLI:
|
||||
self.info(out)
|
||||
|
||||
# default UI is CLI
|
||||
ui = CLI()
|
||||
ui = None
|
||||
#CLI()
|
||||
|
||||
+11
-11
@@ -4,18 +4,18 @@ pwd
|
||||
PATH=$PATH:.
|
||||
set -x -e
|
||||
|
||||
pisi-cli --ignore-comar remove unzip zip
|
||||
pisi-cli build tests/zip/pspec.xml tests/unzip/pspec.xml
|
||||
pisi-cli --ignore-comar install unzip-5.50-1.pisi zip-2.3-1.pisi
|
||||
pisi-cli --yes-all --ignore-comar install unzip-5.50-1.pisi zip-2.3-1.pisi
|
||||
|
||||
rm -rf myrepo
|
||||
mkdir myrepo
|
||||
mkdir -p myrepo
|
||||
cd myrepo
|
||||
../pisi-cli build ../tests/zip2/pspec.xml ../tests/unzip2/pspec.xml
|
||||
../pisi-cli index .
|
||||
../pisi-cli add-repo repo1 pisi-index.xml
|
||||
../pisi-cli list-repo
|
||||
../pisi-cli update-repo repo1
|
||||
../pisi-cli list-available
|
||||
../pisi-cli --ignore-comar upgrade zip
|
||||
../pisi-cli list-installed
|
||||
cd ..
|
||||
pisi-cli index myrepo
|
||||
pisi-cli remove-repo myrepo
|
||||
pisi-cli add-repo myrepo pisi-index.xml
|
||||
pisi-cli list-repo
|
||||
pisi-cli update-repo myrepo
|
||||
pisi-cli list-available
|
||||
pisi-cli --ignore-comar upgrade zip
|
||||
pisi-cli list-installed
|
||||
|
||||
Reference in New Issue
Block a user