* global'lari context'de toplayalim
* herseyi duzgunce init edelim * global'larin modulunu duzgun bicimde import edelim * fixes #413 * expect major breakage!
This commit is contained in:
@@ -17,7 +17,6 @@ __trans = gettext.translation('pisi', fallback=True)
|
||||
_ = __trans.ugettext
|
||||
|
||||
from pisi.cli.pisicli import PisiCLI
|
||||
from pisi.ui import ui
|
||||
|
||||
def handle_exception(exception, value, tb):
|
||||
import traceback
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE Project SYSTEM "Project-3.7.dtd">
|
||||
<!-- Project file for project pisi -->
|
||||
<!-- Saved: 2005-08-19, 16:42:14 -->
|
||||
<!-- Saved: 2005-08-28, 03:00:42 -->
|
||||
<!-- Copyright (C) 2005 PiSi Development Team, pisi@uludag.org.tr -->
|
||||
<Project version="3.7">
|
||||
<ProgLanguage mixed="0">Python</ProgLanguage>
|
||||
@@ -20,10 +20,6 @@
|
||||
<Dir>tools</Dir>
|
||||
<Name>cat-db.py</Name>
|
||||
</Source>
|
||||
<Source>
|
||||
<Dir>tools</Dir>
|
||||
<Name>list-portage-base.py</Name>
|
||||
</Source>
|
||||
<Source>
|
||||
<Dir>tests</Dir>
|
||||
<Dir>popt</Dir>
|
||||
@@ -307,6 +303,52 @@
|
||||
<Dir>pisi</Dir>
|
||||
<Name>api.py</Name>
|
||||
</Source>
|
||||
<Source>
|
||||
<Dir></Dir>
|
||||
<Dir>home</Dir>
|
||||
<Dir>exa</Dir>
|
||||
<Dir>code</Dir>
|
||||
<Dir>projects</Dir>
|
||||
<Dir>pisi-gurer</Dir>
|
||||
<Name>dependency.py</Name>
|
||||
</Source>
|
||||
<Source>
|
||||
<Dir></Dir>
|
||||
<Dir>home</Dir>
|
||||
<Dir>exa</Dir>
|
||||
<Dir>code</Dir>
|
||||
<Dir>projects</Dir>
|
||||
<Dir>pisi-gurer</Dir>
|
||||
<Name>specfile.py</Name>
|
||||
</Source>
|
||||
<Source>
|
||||
<Dir></Dir>
|
||||
<Dir>home</Dir>
|
||||
<Dir>exa</Dir>
|
||||
<Dir>code</Dir>
|
||||
<Dir>projects</Dir>
|
||||
<Dir>pisi-gurer</Dir>
|
||||
<Name>xmlutil.py</Name>
|
||||
</Source>
|
||||
<Source>
|
||||
<Dir></Dir>
|
||||
<Dir>home</Dir>
|
||||
<Dir>exa</Dir>
|
||||
<Dir>code</Dir>
|
||||
<Dir>projects</Dir>
|
||||
<Dir>pisi-kga</Dir>
|
||||
<Name>setup.py</Name>
|
||||
</Source>
|
||||
<Source>
|
||||
<Dir></Dir>
|
||||
<Dir>home</Dir>
|
||||
<Dir>exa</Dir>
|
||||
<Dir>code</Dir>
|
||||
<Dir>projects</Dir>
|
||||
<Dir>pisi-kga</Dir>
|
||||
<Dir>src</Dir>
|
||||
<Name>pisi_kga.py</Name>
|
||||
</Source>
|
||||
</Sources>
|
||||
<Forms>
|
||||
</Forms>
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
# Please read the COPYING file.
|
||||
#
|
||||
|
||||
# PISI version
|
||||
# PiSi version
|
||||
|
||||
__version__ = "0.3"
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
import os
|
||||
|
||||
# Pisi Modules
|
||||
from pisi.ui import ui
|
||||
import pisi.context as ctx
|
||||
|
||||
# ActionsAPI Modules
|
||||
import pisi.actionsapi
|
||||
@@ -25,21 +25,21 @@ from pisi.actionsapi.libtools import gnuconfig_update
|
||||
|
||||
class ConfigureError(pisi.actionsapi.Error):
|
||||
def __init__(self, Exception):
|
||||
ui.error(Exception)
|
||||
ctx.ui.error(Exception)
|
||||
if can_access_file('config.log'):
|
||||
ui.error('\n!!! Please attach the config.log to your bug report:\n%s/config.log\n' % os.getcwd())
|
||||
ctx.ui.error('\n!!! Please attach the config.log to your bug report:\n%s/config.log\n' % os.getcwd())
|
||||
|
||||
class MakeError(pisi.actionsapi.Error):
|
||||
def __init__(self, Exception):
|
||||
ui.error(Exception)
|
||||
ctx.ui.error(Exception)
|
||||
|
||||
class InstallError(pisi.actionsapi.Error):
|
||||
def __init__(self, Exception):
|
||||
ui.error(Exception)
|
||||
ctx.ui.error(Exception)
|
||||
|
||||
class RunTimeError(pisi.actionsapi.Error):
|
||||
def __init__(self, Exception):
|
||||
ui.error(Exception)
|
||||
ctx.ui.error(Exception)
|
||||
|
||||
def configure(parameters = ''):
|
||||
'''configure source with given parameters = "--with-nls --with-libusb --with-something-usefull"'''
|
||||
|
||||
@@ -15,7 +15,7 @@ import os.path
|
||||
|
||||
# PISI Modules
|
||||
import pisi.actionsapi
|
||||
from pisi.ui import ui
|
||||
import pisi.context as ctx
|
||||
|
||||
# ActionsAPI Modules
|
||||
from variables import glb
|
||||
@@ -115,7 +115,7 @@ def getBinutilsInfo(util):
|
||||
if not exists_binary(util):
|
||||
raise BinutilsError('util %s cannot be found' % util)
|
||||
else:
|
||||
ui.debug('Warning: %s does not exist, using plain name %s' \
|
||||
ctx.ui.debug('Warning: %s does not exist, using plain name %s' \
|
||||
% (cross_build_name, util))
|
||||
return util
|
||||
else:
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
import os
|
||||
|
||||
# Pisi Modules
|
||||
from pisi.ui import ui
|
||||
import pisi.context as ctx
|
||||
|
||||
# ActionsAPI Modules
|
||||
import pisi.actionsapi
|
||||
@@ -23,17 +23,17 @@ from pisi.actionsapi.shelltools import system
|
||||
|
||||
class ConfigureError(pisi.actionsapi.Error):
|
||||
def __init__(self, Exception):
|
||||
ui.error(Exception)
|
||||
ctx.ui.error(Exception)
|
||||
if can_access_file('config.log'):
|
||||
ui.error('\n!!! Please attach the config.log to your bug report:\n%s/config.log\n' % os.getcwd())
|
||||
ctx.ui.error('\n!!! Please attach the config.log to your bug report:\n%s/config.log\n' % os.getcwd())
|
||||
|
||||
class MakeError(pisi.actionsapi.Error):
|
||||
def __init__(self, Exception):
|
||||
ui.error(Exception)
|
||||
ctx.ui.error(Exception)
|
||||
|
||||
class InstallError(pisi.actionsapi.Error):
|
||||
def __init__(self, Exception):
|
||||
ui.error(Exception)
|
||||
ctx.ui.error(Exception)
|
||||
|
||||
def configure(parameters = ''):
|
||||
''' parameters = '--with-nls --with-libusb --with-something-usefull '''
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
import os
|
||||
|
||||
# Pisi-Core Modules
|
||||
from pisi.ui import ui
|
||||
import pisi.context as ctx
|
||||
|
||||
# ActionsAPI Modules
|
||||
import pisi.actionsapi
|
||||
@@ -23,7 +23,7 @@ import pisi.actionsapi.get as get
|
||||
|
||||
class RunTimeError(pisi.actionsapi.Error):
|
||||
def __init__(self, Exception):
|
||||
ui.error(Exception)
|
||||
ctx.ui.error(Exception)
|
||||
|
||||
def preplib(sourceDirectory = '/usr/lib'):
|
||||
sourceDirectory = get.installDIR() + sourceDirectory
|
||||
@@ -40,7 +40,7 @@ def gnuconfig_update():
|
||||
for file in files:
|
||||
if file in ['config.sub', 'config.guess']:
|
||||
copy('/usr/share/gnuconfig/%s' % file, os.path.join(root, file))
|
||||
ui.info('GNU Config Update Finished...\n')
|
||||
ctx.ui.info('GNU Config Update Finished...\n')
|
||||
|
||||
def libtoolize(parameters = ''):
|
||||
if system('/usr/bin/libtoolize %s' % parameters):
|
||||
|
||||
@@ -18,7 +18,7 @@ import fileinput
|
||||
import re
|
||||
|
||||
# Pisi Modules
|
||||
from pisi.ui import ui
|
||||
import pisi.context as ctx
|
||||
|
||||
# ActionsAPI Modules
|
||||
import pisi.actionsapi
|
||||
@@ -125,7 +125,7 @@ def doman(*sourceFiles):
|
||||
pageName, pageDirectory = source[:source.rindex('.')], \
|
||||
source[source.rindex('.')+1:]
|
||||
except ValueError:
|
||||
ui.error('\n!!! ActionsAPI [doman]: Wrong man page file...\n')
|
||||
ctx.ui.error('\n!!! ActionsAPI [doman]: Wrong man page file...\n')
|
||||
|
||||
makedirs(manDIR + '/man%s' % pageDirectory)
|
||||
system('install -m0644 %s %s' % (source, manDIR + '/man%s' % pageDirectory))
|
||||
@@ -186,7 +186,7 @@ def dosym(sourceFile, destinationFile):
|
||||
try:
|
||||
os.symlink(sourceFile, get.installDIR() + destinationFile)
|
||||
except OSError:
|
||||
ui.error('\n!!! ActionsAPI [dosym]: File exists...\n')
|
||||
ctx.ui.error('\n!!! ActionsAPI [dosym]: File exists...\n')
|
||||
|
||||
def insinto(destinationDirectory, sourceFile, destinationFile = ''):
|
||||
'''insert a sourceFile into destinationDirectory as a destinationFile with same uid/guid/permissions'''
|
||||
|
||||
@@ -16,7 +16,7 @@ import glob
|
||||
import shutil
|
||||
|
||||
# Pisi Modules
|
||||
from pisi.ui import ui
|
||||
import pisi.context as ctx
|
||||
|
||||
# ActionsAPI Modules
|
||||
import pisi.actionsapi
|
||||
@@ -44,9 +44,9 @@ def chmod(sourceFile, mode = 0755):
|
||||
try:
|
||||
os.chmod(file, mode)
|
||||
except OSError:
|
||||
ui.error('\n!!! ActionsAPI [chmod]: Operation not permitted...\n')
|
||||
ctx.ui.error('\n!!! ActionsAPI [chmod]: Operation not permitted...\n')
|
||||
else:
|
||||
ui.error('\n!!! ActionsAPI [chmod]: File doesn\'t exists...\n')
|
||||
ctx.ui.error('\n!!! ActionsAPI [chmod]: File doesn\'t exists...\n')
|
||||
|
||||
def chown(sourceFile, uid = 0, gid = 0):
|
||||
'''change the owner and group id of sourceFile to the numeric uid and gid'''
|
||||
@@ -54,16 +54,16 @@ def chown(sourceFile, uid = 0, gid = 0):
|
||||
try:
|
||||
os.chown(sourceFile, uid, gid)
|
||||
except OSError:
|
||||
ui.error('\n!!! ActionsAPI [chown]: Operation not permitted...\n')
|
||||
ctx.ui.error('\n!!! ActionsAPI [chown]: Operation not permitted...\n')
|
||||
else:
|
||||
ui.error('\n!!! ActionsAPI [chown]: File doesn\'t exists...\n')
|
||||
ctx.ui.error('\n!!! ActionsAPI [chown]: File doesn\'t exists...\n')
|
||||
|
||||
def sym(sourceFile, destinationFile):
|
||||
'''creates symbolic link'''
|
||||
try:
|
||||
os.symlink(sourceFile, destinationFile)
|
||||
except OSError:
|
||||
ui.error('\n!!! ActionsAPI [sym]: Permission denied...\n')
|
||||
ctx.ui.error('\n!!! ActionsAPI [sym]: Permission denied...\n')
|
||||
|
||||
def unlink(sourceFile):
|
||||
'''remove the file path'''
|
||||
@@ -71,11 +71,11 @@ def unlink(sourceFile):
|
||||
try:
|
||||
os.unlink(sourceFile)
|
||||
except OSError:
|
||||
ui.error('\n!!! ActionsAPI [unlink]: Permission denied...\n')
|
||||
ctx.ui.error('\n!!! ActionsAPI [unlink]: Permission denied...\n')
|
||||
elif isDirectory(sourceFile):
|
||||
pass
|
||||
else:
|
||||
ui.error('\n!!! ActionsAPI [unlink]: File doesn\'t exists...\n')
|
||||
ctx.ui.error('\n!!! ActionsAPI [unlink]: File doesn\'t exists...\n')
|
||||
|
||||
def unlinkDir(sourceDirectory):
|
||||
'''delete an entire directory tree'''
|
||||
@@ -83,11 +83,11 @@ def unlinkDir(sourceDirectory):
|
||||
try:
|
||||
shutil.rmtree(sourceDirectory)
|
||||
except OSError:
|
||||
ui.error('\n!!! ActionsAPI [unlinkDir]: Operation not permitted...\n')
|
||||
ctx.ui.error('\n!!! ActionsAPI [unlinkDir]: Operation not permitted...\n')
|
||||
elif isFile(sourceDirectory):
|
||||
pass
|
||||
else:
|
||||
ui.error('\n!!! ActionsAPI [unlinkDir]: Directory doesn\'t exists...\n')
|
||||
ctx.ui.error('\n!!! ActionsAPI [unlinkDir]: Directory doesn\'t exists...\n')
|
||||
|
||||
def move(sourceFile, destinationFile):
|
||||
'''recursively move a sourceFile or directory to destinationFile'''
|
||||
@@ -96,9 +96,9 @@ def move(sourceFile, destinationFile):
|
||||
try:
|
||||
shutil.move(file, destinationFile)
|
||||
except OSError:
|
||||
ui.error('\n!!! ActionsAPI [move]: Permission denied...\n')
|
||||
ctx.ui.error('\n!!! ActionsAPI [move]: Permission denied...\n')
|
||||
else:
|
||||
ui.error('\n!!! ActionsAPI [move]: File doesn\'t exists...\n')
|
||||
ctx.ui.error('\n!!! ActionsAPI [move]: File doesn\'t exists...\n')
|
||||
|
||||
def copy(sourceFile, destinationFile):
|
||||
'''recursively copy a sourceFile or directory to destinationFile'''
|
||||
@@ -107,9 +107,9 @@ def copy(sourceFile, destinationFile):
|
||||
try:
|
||||
shutil.copy(file, destinationFile)
|
||||
except IOError:
|
||||
ui.error('\n!!! ActionsAPI [copy]: Permission denied...\n')
|
||||
ctx.ui.error('\n!!! ActionsAPI [copy]: Permission denied...\n')
|
||||
else:
|
||||
ui.error('\n!!! ActionsAPI [copy]: File doesn\'t exists...\n')
|
||||
ctx.ui.error('\n!!! ActionsAPI [copy]: File doesn\'t exists...\n')
|
||||
|
||||
def copytree(source, destination, sym = False):
|
||||
'''recursively copy an entire directory tree rooted at source'''
|
||||
@@ -117,9 +117,9 @@ def copytree(source, destination, sym = False):
|
||||
try:
|
||||
shutil.copytree(source, destination, sym)
|
||||
except OSError:
|
||||
ui.error('\n!!! ActionsAPI [copytree]: Permission denied...\n')
|
||||
ctx.ui.error('\n!!! ActionsAPI [copytree]: Permission denied...\n')
|
||||
else:
|
||||
ui.error('\n!!! ActionsAPI [copytree]: Directory doesn\'t exists...\n')
|
||||
ctx.ui.error('\n!!! ActionsAPI [copytree]: Directory doesn\'t exists...\n')
|
||||
|
||||
def touch(sourceFile):
|
||||
'''changes the access time of the 'sourceFile', or creates it if it is not exist'''
|
||||
@@ -131,7 +131,7 @@ def touch(sourceFile):
|
||||
f = open(sourceFile, 'w')
|
||||
f.close()
|
||||
except IOError:
|
||||
ui.error('\n!!! ActionsAPI [touch]: Permission denied...\n')
|
||||
ctx.ui.error('\n!!! ActionsAPI [touch]: Permission denied...\n')
|
||||
|
||||
def cd(directoryName = ''):
|
||||
'''change directory'''
|
||||
@@ -179,12 +179,12 @@ def dirName(sourceFile):
|
||||
def system(command):
|
||||
#FIXME: String formatting
|
||||
command = command.replace(" ", " ")
|
||||
ui.debug('executing %s\n' % command)
|
||||
ctx.ui.debug('executing %s\n' % command)
|
||||
p = os.popen(command)
|
||||
while 1:
|
||||
line = p.readline()
|
||||
if not line:
|
||||
break
|
||||
ui.debug(line)
|
||||
ctx.ui.debug(line)
|
||||
|
||||
return p.close()
|
||||
|
||||
+53
-47
@@ -19,29 +19,7 @@ if ver[0] <= 2 and ver[1] < 4:
|
||||
|
||||
import pisi
|
||||
|
||||
class Error(pisi.Error):
|
||||
pass
|
||||
|
||||
def init(database = True, options = None, ui = None ):
|
||||
import pisi.config
|
||||
import pisi.ui
|
||||
"""Initialize PiSi subsystem"""
|
||||
pisi.config.config = pisi.config.Config(options)
|
||||
if ui is None:
|
||||
if options:
|
||||
pisi.ui.ui = pisi.ui.CLI(options.debug)
|
||||
else:
|
||||
pisi.ui.ui = pisi.ui.CLI()
|
||||
else:
|
||||
pisi.ui.ui = ui
|
||||
# initialize repository databases
|
||||
if database:
|
||||
from pisi.repodb import repodb
|
||||
repodb.init_dbs()
|
||||
|
||||
from pisi.config import config
|
||||
from pisi.constants import const
|
||||
from pisi.ui import ui
|
||||
import pisi.context as ctx
|
||||
from pisi.uri import URI
|
||||
import pisi.util as util
|
||||
import pisi.dependency as dependency
|
||||
@@ -52,6 +30,34 @@ from pisi.repodb import repodb
|
||||
from pisi.installdb import installdb
|
||||
from pisi.index import Index
|
||||
|
||||
class Error(pisi.Error):
|
||||
pass
|
||||
|
||||
def init(database = True, options = None, ui = None ):
|
||||
"""Initialize PiSi subsystem"""
|
||||
|
||||
import pisi.config
|
||||
ctx.config = pisi.config.Config(options)
|
||||
|
||||
if ui is None:
|
||||
import pisi.ui
|
||||
if options:
|
||||
pisi.context.ui = pisi.ui.CLI(options.debug)
|
||||
else:
|
||||
pisi.context.ui = pisi.ui.CLI()
|
||||
else:
|
||||
pisi.context.ui = ui
|
||||
|
||||
# initialize repository databases
|
||||
if database:
|
||||
import pisi.repodb
|
||||
pisi.repodb.init()
|
||||
import pisi.installdb
|
||||
pisi.installdb.init()
|
||||
import pisi.packagedb
|
||||
pisi.packagedb.init()
|
||||
import pisi.sourcedb
|
||||
pisi.sourcedb.init()
|
||||
|
||||
def install(packages):
|
||||
"""install a list of packages (either files/urls, or names)"""
|
||||
@@ -68,26 +74,26 @@ def install(packages):
|
||||
install_pkg_names(packages)
|
||||
|
||||
except InstallError, e:
|
||||
ui.error("%s\n" % e)
|
||||
ctx.ui.error("%s\n" % e)
|
||||
|
||||
except packagedb.PackageDBError, e:
|
||||
ui.error("PackageDBError: (%s)\n" % e)
|
||||
ui.error("Package is not installable.\n")
|
||||
ctx.ui.error("PackageDBError: (%s)\n" % e)
|
||||
ctx.ui.error("Package is not installable.\n")
|
||||
|
||||
#except Exception, e:
|
||||
# print e
|
||||
# ui.error("Error: %s\n" % e)
|
||||
# ctx.ui.error("Error: %s\n" % e)
|
||||
|
||||
|
||||
def install_pkg_files(package_URIs):
|
||||
"""install a number of pisi package files"""
|
||||
from package import Package
|
||||
|
||||
ui.debug('A = %s\n' % str(package_URIs))
|
||||
ctx.ui.debug('A = %s\n' % str(package_URIs))
|
||||
|
||||
for x in package_URIs:
|
||||
if not x.endswith(const.package_prefix):
|
||||
ui.error('Mixing file names and package names not supported YET.\n')
|
||||
ctx.ui.error('Mixing file names and package names not supported YET.\n')
|
||||
return False
|
||||
|
||||
# read the package information into memory first
|
||||
@@ -136,7 +142,7 @@ def install_pkg_files(package_URIs):
|
||||
A = d_t.keys()
|
||||
|
||||
if len(A)==0:
|
||||
ui.info('No packages to install.\n')
|
||||
ctx.ui.info('No packages to install.\n')
|
||||
return True
|
||||
|
||||
# try to construct a pisi graph of packages to
|
||||
@@ -180,10 +186,10 @@ def install_pkg_names(A):
|
||||
the repository, trying to perform a minimum number of
|
||||
installs"""
|
||||
|
||||
ui.debug('A = %s\n' % str(A))
|
||||
ctx.ui.debug('A = %s\n' % str(A))
|
||||
|
||||
if len(A)==0:
|
||||
ui.info('No packages to install.\n')
|
||||
ctx.ui.info('No packages to install.\n')
|
||||
return True
|
||||
|
||||
# try to construct a pisi graph of packages to
|
||||
@@ -235,7 +241,7 @@ def upgrade_pkg_names(A):
|
||||
Ap = []
|
||||
for x in A:
|
||||
if not installdb.is_installed(x):
|
||||
ui.info('Package %s is not installed.\n' % x)
|
||||
ctx.ui.info('Package %s is not installed.\n' % x)
|
||||
continue
|
||||
(version, release, build) = installdb.get_version(x)
|
||||
pkg = packagedb.get_package(x)
|
||||
@@ -245,17 +251,17 @@ def upgrade_pkg_names(A):
|
||||
elif build < pkg.build:
|
||||
Ap.append(x)
|
||||
else:
|
||||
#ui.info('Package %s cannot be upgraded. ' % x)
|
||||
ui.info('Package %s is already at its latest version %s,\
|
||||
#ctx.ui.info('Package %s cannot be upgraded. ' % x)
|
||||
ctx.ui.info('Package %s is already at its latest version %s,\
|
||||
release %s, build %s.\n'
|
||||
% (x, pkg.version, pkg.release, pkg.build))
|
||||
A = Ap
|
||||
|
||||
if len(A)==0:
|
||||
ui.info('No packages to upgrade.\n')
|
||||
ctx.ui.info('No packages to upgrade.\n')
|
||||
return True
|
||||
|
||||
ui.debug('A = %s\n' % str(A))
|
||||
ctx.ui.debug('A = %s\n' % str(A))
|
||||
|
||||
# try to construct a pisi graph of packages to
|
||||
# install / reinstall
|
||||
@@ -310,11 +316,11 @@ def remove(A):
|
||||
if installdb.is_installed(x):
|
||||
Ap.append(x)
|
||||
else:
|
||||
ui.info('Package %s does not exist. Cannot remove.\n' % x)
|
||||
ctx.ui.info('Package %s does not exist. Cannot remove.\n' % x)
|
||||
A = Ap
|
||||
|
||||
if len(A)==0:
|
||||
ui.info('No packages to remove.\n')
|
||||
ctx.ui.info('No packages to remove.\n')
|
||||
return True
|
||||
|
||||
# try to construct a pisi graph of packages to
|
||||
@@ -350,7 +356,7 @@ def remove(A):
|
||||
if installdb.is_installed(x):
|
||||
operations.remove_single(x)
|
||||
else:
|
||||
ui.info('Package %s is not installed. Cannot remove.\n' % x)
|
||||
ctx.ui.info('Package %s is not installed. Cannot remove.\n' % x)
|
||||
|
||||
return True # everything went OK :)
|
||||
|
||||
@@ -396,11 +402,11 @@ def info_name(package_name):
|
||||
|
||||
def index(repo_dir = '.'):
|
||||
|
||||
ui.info('* Building index of PISI files under %s\n' % repo_dir)
|
||||
ctx.ui.info('* Building index of PISI files under %s\n' % repo_dir)
|
||||
index = Index()
|
||||
index.index(repo_dir)
|
||||
index.write(const.pisi_index)
|
||||
ui.info('* Index file written\n')
|
||||
index.write(ctx.const.pisi_index)
|
||||
ctx.ui.info('* Index file written\n')
|
||||
|
||||
class Repo:
|
||||
def __init__(self, indexuri):
|
||||
@@ -414,16 +420,16 @@ def remove_repo(name):
|
||||
if repodb.has_repo(name):
|
||||
repodb.remove_repo(name)
|
||||
else:
|
||||
ui.error('* Repository %s does not exist. Cannot remove.\n'
|
||||
ctx.ui.error('* Repository %s does not exist. Cannot remove.\n'
|
||||
% name)
|
||||
|
||||
def update_repo(repo):
|
||||
|
||||
ui.info('* Updating repository: %s\n' % repo)
|
||||
ctx.ui.info('* Updating repository: %s\n' % repo)
|
||||
index = Index()
|
||||
index.read(repodb.get_repo(repo).indexuri.get_uri(), repo)
|
||||
index.update_db(repo)
|
||||
ui.info('* Package database updated.\n')
|
||||
ctx.ui.info('* Package database updated.\n')
|
||||
|
||||
|
||||
# build functions...
|
||||
@@ -489,7 +495,7 @@ def build_until(pspecfile, state, authInfo=None):
|
||||
pb.compile_action_script()
|
||||
|
||||
last = pb.get_state()
|
||||
ui.info("Last state was %s\n"%last)
|
||||
ctx.ui.info("Last state was %s\n"%last)
|
||||
|
||||
if not last: last = "none"
|
||||
|
||||
|
||||
+61
-25
@@ -23,9 +23,7 @@ _ = __trans.ugettext
|
||||
|
||||
import pisi
|
||||
import pisi.util as util
|
||||
from pisi.ui import ui
|
||||
from pisi.constants import const
|
||||
from pisi.config import config
|
||||
import pisi.context as ctx
|
||||
from pisi.context import BuildContext
|
||||
from pisi.sourcearchive import SourceArchive
|
||||
from pisi.files import Files, FileInfo
|
||||
@@ -74,10 +72,48 @@ def check_path_collision(package, pkgList):
|
||||
# path.pathname: /usr/share/doc
|
||||
if util.subpath(pinfo.pathname, path.pathname):
|
||||
collisions.append(path.pathname)
|
||||
ui.error(_('Path %s belongs in multiple packages\n') %
|
||||
ctx.ui.error(_('Path %s belongs in multiple packages\n') %
|
||||
path.pathname)
|
||||
return collisions
|
||||
|
||||
# a dynamic build context
|
||||
from pisi.specfile import SpecFile
|
||||
|
||||
|
||||
class BuildContext(object):
|
||||
"""Build Context Singleton"""
|
||||
|
||||
def __init__(self, pspecfile):
|
||||
super(BuildContext, self).__init__()
|
||||
self.set_spec_file(pspecfile)
|
||||
|
||||
def set_spec_file(self, pspecfile):
|
||||
self.pspecfile = pspecfile
|
||||
spec = SpecFile()
|
||||
spec.read(pspecfile)
|
||||
# FIXME: following checks the integrity but does nothing when it is wrong
|
||||
# -gurer
|
||||
#spec.verify() # check pspec integrity
|
||||
self.spec = spec
|
||||
|
||||
# directory accessor functions
|
||||
|
||||
# pkg_x_dir: per package directory for storing info type x
|
||||
|
||||
def pkg_dir(self):
|
||||
"package build directory"
|
||||
packageDir = self.spec.source.name + '-' + \
|
||||
self.spec.source.version + '-' + self.spec.source.release
|
||||
|
||||
return config.destdir + config.values.dirs.tmp_dir \
|
||||
+ '/' + packageDir
|
||||
|
||||
def pkg_work_dir(self):
|
||||
return self.pkg_dir() + const.work_dir_suffix
|
||||
|
||||
def pkg_install_dir(self):
|
||||
return self.pkg_dir() + const.install_dir_suffix
|
||||
|
||||
|
||||
class PisiBuild:
|
||||
"""PisiBuild class, provides the package build and creation routines"""
|
||||
@@ -106,7 +142,7 @@ class PisiBuild:
|
||||
def build(self):
|
||||
"""Build the package in one shot."""
|
||||
|
||||
ui.info(_("Building PISI source package: %s\n") % self.spec.source.name)
|
||||
ctx.ui.info(_("Building PISI source package: %s\n") % self.spec.source.name)
|
||||
util.xterm_title(_("Building PISI source package: %s\n") % self.spec.source.name)
|
||||
|
||||
self.compile_action_script()
|
||||
@@ -140,30 +176,30 @@ class PisiBuild:
|
||||
os.environ.update(evn)
|
||||
|
||||
def fetch_source_archive(self):
|
||||
ui.info(_("Fetching source from: %s\n") % self.spec.source.archiveUri)
|
||||
ctx.ui.info(_("Fetching source from: %s\n") % self.spec.source.archiveUri)
|
||||
self.sourceArchive.fetch()
|
||||
ui.info(_("Source archive is stored: %s/%s\n")
|
||||
ctx.ui.info(_("Source archive is stored: %s/%s\n")
|
||||
%(config.archives_dir(), self.spec.source.archiveName))
|
||||
|
||||
def unpack_source_archive(self):
|
||||
ui.info(_("Unpacking archive..."))
|
||||
ctx.ui.info(_("Unpacking archive..."))
|
||||
self.sourceArchive.unpack()
|
||||
ui.info(_(" unpacked (%s)\n") % self.ctx.pkg_work_dir())
|
||||
ctx.ui.info(_(" unpacked (%s)\n") % self.ctx.pkg_work_dir())
|
||||
self.set_state("unpacked")
|
||||
|
||||
def run_setup_action(self):
|
||||
# Run configure, build and install phase
|
||||
ui.action(_("Setting up source...\n"))
|
||||
ctx.ui.action(_("Setting up source...\n"))
|
||||
self.run_action_function(const.setup_func)
|
||||
self.set_state("setupaction")
|
||||
|
||||
def run_build_action(self):
|
||||
ui.action(_("Building source...\n"))
|
||||
ctx.ui.action(_("Building source...\n"))
|
||||
self.run_action_function(const.build_func)
|
||||
self.set_state("buildaction")
|
||||
|
||||
def run_install_action(self):
|
||||
ui.action(_("Installing...\n"))
|
||||
ctx.ui.action(_("Installing...\n"))
|
||||
|
||||
# Before install make sure install_dir is clean
|
||||
if os.path.exists(self.ctx.pkg_install_dir()):
|
||||
@@ -182,10 +218,10 @@ class PisiBuild:
|
||||
buf = open(scriptfile).read()
|
||||
exec compile(buf, "error", "exec") in localSymbols, globalSymbols
|
||||
except IOError, e:
|
||||
ui.error(_("Unable to read Action Script (%s): %s\n") %(scriptfile,e))
|
||||
ctx.ui.error(_("Unable to read Action Script (%s): %s\n") %(scriptfile,e))
|
||||
sys.exit(1)
|
||||
except SyntaxError, e:
|
||||
ui.error (_("SyntaxError in Action Script (%s): %s\n") %(scriptfile,e))
|
||||
ctx.ui.error (_("SyntaxError in Action Script (%s): %s\n") %(scriptfile,e))
|
||||
sys.exit(1)
|
||||
|
||||
self.actionLocals = localSymbols
|
||||
@@ -236,7 +272,7 @@ class PisiBuild:
|
||||
compressType=patch.compressionType,
|
||||
targetDir=config.tmp_dir())
|
||||
|
||||
ui.action(_("* Applying patch: %s\n") % patch.filename)
|
||||
ctx.ui.action(_("* Applying patch: %s\n") % patch.filename)
|
||||
util.do_patch(self.srcDir, patchFile, level=patch.level, target=patch.target)
|
||||
|
||||
def gen_metadata_xml(self, package):
|
||||
@@ -262,7 +298,7 @@ class PisiBuild:
|
||||
# build no
|
||||
if config.options.ignore_build_no:
|
||||
metadata.package.build = None # means, build no information n/a
|
||||
ui.warning('build number is not available.')
|
||||
ctx.ui.warning('build number is not available.')
|
||||
else:
|
||||
metadata.package.build = self.calc_build_no(metadata.package.name)
|
||||
|
||||
@@ -305,7 +341,7 @@ class PisiBuild:
|
||||
if fn.startswith(package_name + '-') and \
|
||||
fn.endswith(const.package_prefix):
|
||||
old_package_fn = os.path.join(root, fn)
|
||||
ui.info('(found old version %s)' % old_package_fn)
|
||||
ctx.ui.info('(found old version %s)' % old_package_fn)
|
||||
old_pkg = Package(old_package_fn, 'r')
|
||||
from os.path import join
|
||||
old_pkg.read(join(config.tmp_dir(), 'oldpkg'))
|
||||
@@ -313,7 +349,7 @@ class PisiBuild:
|
||||
found.append( (old_package_fn, old_build) )
|
||||
if not found:
|
||||
return 0
|
||||
ui.warning('(no previous build found, setting build no to 0.)')
|
||||
ctx.ui.warning('(no previous build found, setting build no to 0.)')
|
||||
else:
|
||||
a = filter(lambda (x,y): y != None, found)
|
||||
if a:
|
||||
@@ -350,7 +386,7 @@ class PisiBuild:
|
||||
|
||||
# set build number
|
||||
if old_build is None:
|
||||
ui.warning('(old package lacks a build no, setting build no to 0.)')
|
||||
ctx.ui.warning('(old package lacks a build no, setting build no to 0.)')
|
||||
return 0
|
||||
elif changed:
|
||||
return old_build + 1
|
||||
@@ -367,17 +403,17 @@ class PisiBuild:
|
||||
self.spec.source.release)
|
||||
|
||||
|
||||
ui.action(_("** Building package %s\n") % package.name);
|
||||
ctx.ui.action(_("** Building package %s\n") % package.name);
|
||||
|
||||
ui.action(_("Generating %s...") % const.files_xml)
|
||||
ctx.ui.action(_("Generating %s...") % const.files_xml)
|
||||
self.gen_files_xml(package)
|
||||
ui.info(_(" done.\n"))
|
||||
ctx.ui.info(_(" done.\n"))
|
||||
|
||||
ui.action(_("Generating %s...") % const.metadata_xml)
|
||||
ctx.ui.action(_("Generating %s...") % const.metadata_xml)
|
||||
self.gen_metadata_xml(package)
|
||||
ui.info(_(" done.\n"))
|
||||
ctx.ui.info(_(" done.\n"))
|
||||
|
||||
ui.action(_("Creating PISI package %s\n") % name)
|
||||
ctx.ui.action(_("Creating PISI package %s\n") % name)
|
||||
|
||||
pkg = Package(name, 'w')
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ class Command(object):
|
||||
import pisi
|
||||
import pisi.api
|
||||
pisi.api.init(database, self.options)
|
||||
from pisi.ui import ui
|
||||
import pisi.context as ctx
|
||||
|
||||
def finalize(self):
|
||||
"""do cleanup work for PiSi components"""
|
||||
@@ -134,7 +134,7 @@ class Command(object):
|
||||
|
||||
def help(self):
|
||||
"""print help for the command"""
|
||||
pisi.ui.ui.info(self.format_name() + ': ')
|
||||
ctx.ui.info(self.format_name() + ': ')
|
||||
print getattr(self, "__doc__")
|
||||
print self.parser.format_option_help()
|
||||
|
||||
@@ -227,8 +227,7 @@ fetch all necessary files and build the package for you.
|
||||
return
|
||||
|
||||
self.init()
|
||||
from pisi.config import config
|
||||
pisi.ui.ui.info('Output directory: %s\n' % config.options.output_dir)
|
||||
ctx.ui.info('Output directory: %s\n' % config.options.output_dir)
|
||||
for arg in self.args:
|
||||
pisi.api.build(arg, self.authInfo)
|
||||
self.finalize()
|
||||
@@ -254,7 +253,7 @@ class PackageOp(Command):
|
||||
try:
|
||||
pisi.comariface.init()
|
||||
except pisi.comariface.ComarError:
|
||||
pisi.ui.ui.error('Comar error encountered\n')
|
||||
ctx.ui.error('Comar error encountered\n')
|
||||
self.die()
|
||||
|
||||
def finalize(self):
|
||||
@@ -645,7 +644,6 @@ Gives a brief list of PiSi components published in the repository.
|
||||
|
||||
def run(self):
|
||||
from pisi.repodb import repodb
|
||||
from pisi.ui import ui
|
||||
|
||||
self.init(True)
|
||||
|
||||
@@ -655,7 +653,7 @@ Gives a brief list of PiSi components published in the repository.
|
||||
else:
|
||||
# print for all repos
|
||||
for repo in repodb.list():
|
||||
ui.info("Repository : %s\n" % repo)
|
||||
ctx.ui.info("Repository : %s\n" % repo)
|
||||
self.print_packages(repo)
|
||||
self.finalize()
|
||||
|
||||
@@ -681,8 +679,6 @@ class ListPending(Command):
|
||||
|
||||
def run(self):
|
||||
from pisi.installdb import installdb
|
||||
from pisi.ui import ui
|
||||
|
||||
self.init(True)
|
||||
|
||||
list = installdb.list_pending()
|
||||
|
||||
+3
-2
@@ -17,7 +17,7 @@
|
||||
# Eray Ozkural <eray@uludag.org.tr>
|
||||
|
||||
import pisi
|
||||
from pisi.constants import const
|
||||
import pisi.context as ctx
|
||||
from pisi.configfile import ConfigurationFile
|
||||
|
||||
class Config(object):
|
||||
@@ -55,6 +55,7 @@ class Config(object):
|
||||
# kullanılıyor ama /var/tmp/pisi/install gibi bir dizine niye
|
||||
# ihtiyacımız var? (baris)
|
||||
def install_dir(self):
|
||||
return self.tmp_dir() + const.install_dir_suffix
|
||||
return self.tmp_dir() + ctx.const.install_dir_suffix
|
||||
|
||||
#TODO: remove this
|
||||
config = Config()
|
||||
|
||||
@@ -88,6 +88,3 @@ class Constants:
|
||||
|
||||
def __delattr__(self, attr):
|
||||
delattr(self.__c, attr)
|
||||
|
||||
# singleton for easy access here
|
||||
const = Constants()
|
||||
|
||||
+9
-32
@@ -15,40 +15,17 @@
|
||||
# Authors: Baris Metin <baris@uludag.org.tr
|
||||
# Eray Ozkural <eray@uludag.org.tr>
|
||||
|
||||
from pisi.constants import const
|
||||
from pisi.config import config
|
||||
from pisi.specfile import SpecFile
|
||||
# global variables here
|
||||
|
||||
class BuildContext(object):
|
||||
"""Build Context Singleton"""
|
||||
import pisi.constants
|
||||
|
||||
def __init__(self, pspecfile):
|
||||
super(BuildContext, self).__init__()
|
||||
self.set_spec_file(pspecfile)
|
||||
const = pisi.constants.Constants()
|
||||
|
||||
def set_spec_file(self, pspecfile):
|
||||
self.pspecfile = pspecfile
|
||||
spec = SpecFile()
|
||||
spec.read(pspecfile)
|
||||
# FIXME: following checks the integrity but does nothing when it is wrong
|
||||
# -gurer
|
||||
#spec.verify() # check pspec integrity
|
||||
self.spec = spec
|
||||
config = None
|
||||
|
||||
# directory accessor functions
|
||||
|
||||
# pkg_x_dir: per package directory for storing info type x
|
||||
# default UI is CLI
|
||||
ui = None # not now
|
||||
|
||||
def pkg_dir(self):
|
||||
"package build directory"
|
||||
packageDir = self.spec.source.name + '-' + \
|
||||
self.spec.source.version + '-' + self.spec.source.release
|
||||
|
||||
return config.destdir + config.values.dirs.tmp_dir \
|
||||
+ '/' + packageDir
|
||||
|
||||
def pkg_work_dir(self):
|
||||
return self.pkg_dir() + const.work_dir_suffix
|
||||
|
||||
def pkg_install_dir(self):
|
||||
return self.pkg_dir() + const.install_dir_suffix
|
||||
#def register(_impl):
|
||||
# """ Register a UI implementation"""
|
||||
# ui = _impl
|
||||
|
||||
+6
-7
@@ -12,13 +12,12 @@
|
||||
|
||||
# Author: Eray Ozkural <eray@uludag.org.tr>
|
||||
|
||||
from installdb import installdb
|
||||
import packagedb
|
||||
from ui import ui
|
||||
from version import Version
|
||||
from xmlext import *
|
||||
from xmlfile import XmlFile
|
||||
from util import Checks
|
||||
#import pisi.db as db
|
||||
import pisi.context as ctx
|
||||
from pisi.version import Version
|
||||
from pisi.xmlext import *
|
||||
from pisi.xmlfile import XmlFile
|
||||
from pisi.util import Checks
|
||||
|
||||
class DepInfo:
|
||||
def __init__(self, node = None):
|
||||
|
||||
+3
-3
@@ -24,7 +24,7 @@ from base64 import encodestring
|
||||
import pisi
|
||||
import pisi.util as util
|
||||
from pisi.uri import URI
|
||||
from pisi.ui import ui
|
||||
import pisi.context as ctx
|
||||
|
||||
|
||||
class FetchError(pisi.Error):
|
||||
@@ -37,7 +37,7 @@ def fetch_url(url, dest, progress=None):
|
||||
fetch.progress = progress
|
||||
fetch.fetch()
|
||||
if progress:
|
||||
ui.info('\n')
|
||||
ctx.ctx.ui.info('\n')
|
||||
|
||||
|
||||
class Fetcher:
|
||||
@@ -101,7 +101,7 @@ class Fetcher:
|
||||
'percent' : self.percent,
|
||||
'rate': self.rate,
|
||||
'symbol': symbol}
|
||||
ui.display_progress(retval)
|
||||
ctx.ui.display_progress(retval)
|
||||
|
||||
dest.close()
|
||||
|
||||
|
||||
+3
-3
@@ -13,9 +13,9 @@
|
||||
|
||||
# Authors: Eray Ozkural <eray@uludag.org.tr>
|
||||
|
||||
from xmlext import *
|
||||
from xmlfile import XmlFile
|
||||
from util import Checks
|
||||
from pisi.xmlext import *
|
||||
from pisi.xmlfile import XmlFile
|
||||
from pisi.util import Checks
|
||||
|
||||
class FileInfo:
|
||||
"""FileInfo holds the information for a File node/tag in files.xml"""
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (C) 2005, TUBITAK/UEKAE
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Please read the COPYING file.
|
||||
#
|
||||
|
||||
|
||||
config = None
|
||||
ui = None
|
||||
+10
-12
@@ -20,10 +20,8 @@ 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.context as ctx
|
||||
import pisi.util as util
|
||||
from pisi.config import config
|
||||
from pisi.constants import const
|
||||
from pisi.uri import URI
|
||||
|
||||
class Index(XmlFile):
|
||||
@@ -41,10 +39,10 @@ class Index(XmlFile):
|
||||
if url.is_remote_file():
|
||||
from fetcher import fetch_url
|
||||
|
||||
dest = os.path.join(config.index_dir(), repo)
|
||||
dest = os.path.join(ctx.config.index_dir(), repo)
|
||||
if not os.path.exists(dest):
|
||||
os.makedirs(dest)
|
||||
fetch_url(url, dest, ui.Progress)
|
||||
fetch_url(url, dest, ctx.ui.Progress)
|
||||
|
||||
self.filepath = os.path.join(dest, url.filename())
|
||||
|
||||
@@ -68,8 +66,8 @@ class Index(XmlFile):
|
||||
self.repo_dir = repo_uri
|
||||
for root, dirs, files in os.walk(repo_uri):
|
||||
for fn in files:
|
||||
if fn.endswith(const.package_prefix):
|
||||
ui.info('Adding ' + fn + ' to package index\n')
|
||||
if fn.endswith(ctx.const.package_prefix):
|
||||
ctx.ui.info('Adding ' + fn + ' to package index\n')
|
||||
self.add_package(os.path.join(root, fn), repo_uri)
|
||||
|
||||
def update_db(self, repo):
|
||||
@@ -81,12 +79,12 @@ class Index(XmlFile):
|
||||
def add_package(self, path, repo_uri):
|
||||
package = Package(path, 'r')
|
||||
# extract control files
|
||||
util.clean_dir(config.install_dir())
|
||||
package.extract_PISI_files(config.install_dir())
|
||||
util.clean_dir(ctx.config.install_dir())
|
||||
package.extract_PISI_files(ctx.config.install_dir())
|
||||
|
||||
md = metadata.MetaData()
|
||||
md.read(os.path.join(config.install_dir(), const.metadata_xml))
|
||||
if config.options and config.options.absolute_uris:
|
||||
md.read(os.path.join(ctx.config.install_dir(), ctx.const.metadata_xml))
|
||||
if ctx.config.options and ctx.config.options.absolute_uris:
|
||||
md.package.packageURI = os.path.realpath(path)
|
||||
else: # create relative path by default
|
||||
# TODO: in the future we'll do all of this with purl/pfile/&helpers
|
||||
@@ -95,6 +93,6 @@ class Index(XmlFile):
|
||||
md.package.packageURI = util.removepathprefix(repo_uri, path)
|
||||
# check package semantics
|
||||
if md.has_errors():
|
||||
ui.error('Package ' + md.package.name + ': metadata corrupt\n')
|
||||
ctx.ui.error('Package ' + md.package.name + ': metadata corrupt\n')
|
||||
else:
|
||||
self.packages.append(md.package)
|
||||
|
||||
@@ -19,8 +19,6 @@ import os
|
||||
import pisi
|
||||
from pisi.specfile import *
|
||||
from pisi.package import Package
|
||||
from pisi.config import config
|
||||
from pisi.constants import const
|
||||
from pisi.ui import ui
|
||||
from pisi.installdb import installdb
|
||||
import pisi.packagedb as packagedb
|
||||
|
||||
+6
-6
@@ -20,8 +20,8 @@ import fcntl
|
||||
|
||||
# PiSi
|
||||
import pisi
|
||||
import pisi.context as ctx
|
||||
import pisi.lockeddbshelve as shelve
|
||||
from pisi.constants import const
|
||||
from pisi.files import Files
|
||||
import pisi.util as util
|
||||
|
||||
@@ -72,12 +72,10 @@ class InstallDB:
|
||||
from os.path import join
|
||||
self.d = shelve.LockedDBShelf('install')
|
||||
self.dp = shelve.LockedDBShelf('configpending')
|
||||
from pisi.config import config
|
||||
self.files_dir = os.path.join(config.db_dir(), 'files')
|
||||
self.files_dir = os.path.join(ctx.config.db_dir(), 'files')
|
||||
|
||||
def files_name(self, pkg, version, release):
|
||||
from os.path import join
|
||||
from pisi.config import config
|
||||
pkg_dir = join(config.lib_dir(), pkg + '-' + version + '-' + release)
|
||||
return join(pkg_dir, const.files_xml)
|
||||
|
||||
@@ -133,7 +131,6 @@ class InstallDB:
|
||||
def install(self, pkg, version, release, build, distro = ""):
|
||||
"""install package with specific version, release, build"""
|
||||
pkg = str(pkg)
|
||||
from pisi.config import config
|
||||
if self.is_installed(pkg):
|
||||
raise InstallDBError("already installed")
|
||||
if config.options and config.options.ignore_comar:
|
||||
@@ -155,5 +152,8 @@ class InstallDB:
|
||||
if self.d.has_key(pkg):
|
||||
del self.d[pkg]
|
||||
|
||||
installdb = InstallDB()
|
||||
installdb = None
|
||||
|
||||
def init():
|
||||
installdb = InstallDB()
|
||||
|
||||
|
||||
@@ -19,8 +19,7 @@ import bsddb.db as db
|
||||
import os
|
||||
import fcntl
|
||||
|
||||
from pisi.config import config
|
||||
import pisi.util as util
|
||||
import pisi
|
||||
|
||||
class LockedDBShelf(shelve.DBShelf):
|
||||
|
||||
@@ -41,22 +40,20 @@ class LockedDBShelf(shelve.DBShelf):
|
||||
flags = db.DB_TRUNCATE | db.DB_CREATE
|
||||
else:
|
||||
raise error, "flags should be one of 'r', 'w', 'c' or 'n' or use the bsddb.db.DB_* flags"
|
||||
filename = os.path.join( config.db_dir(), dbname + '.bdb')
|
||||
filename = os.path.join( pisi.context.config.db_dir(), dbname + '.bdb')
|
||||
LockedDBShelf.open(self,filename, dbname, filetype, flags, mode)
|
||||
|
||||
def open(self, filename, dbname, filetype, flags, mode):
|
||||
util.check_dir(config.db_dir())
|
||||
pisi.util.check_dir(pisi.context.config.db_dir())
|
||||
self.lockfile = file(filename + '.lock', 'w')
|
||||
try:
|
||||
fcntl.flock(self.lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
except IOError:
|
||||
import sys
|
||||
from ui import ui
|
||||
ui.error("Another instance of PISI is running. Try later!\n")
|
||||
pisi.context.ui.error("Another instance of PISI is running. Try later!\n")
|
||||
sys.exit(1)
|
||||
return self.db.open(filename, dbname, filetype, flags, mode)
|
||||
|
||||
def close(self):
|
||||
self.db.close()
|
||||
self.lockfile.close()
|
||||
|
||||
|
||||
+4
-4
@@ -16,11 +16,11 @@
|
||||
# Authors: Eray Ozkural <eray@uludag.org.tr>
|
||||
# Baris Metin <baris@uludag.org.tr
|
||||
|
||||
from ui import ui
|
||||
import pisi.context as ctx
|
||||
|
||||
from xmlfile import *
|
||||
import specfile
|
||||
from util import Checks
|
||||
from pisi.xmlfile import *
|
||||
import pisi.specfile as specfile
|
||||
from pisi.util import Checks
|
||||
|
||||
class SourceInfo:
|
||||
|
||||
|
||||
+1
-3
@@ -13,9 +13,7 @@
|
||||
import os
|
||||
|
||||
import pisi
|
||||
from pisi.config import config
|
||||
from pisi.constants import const
|
||||
from pisi.ui import ui
|
||||
import pisi.context as ctx
|
||||
from pisi.uri import URI
|
||||
import pisi.util as util
|
||||
import pisi.packagedb as packagedb
|
||||
|
||||
+6
-7
@@ -18,9 +18,8 @@
|
||||
from os.path import join
|
||||
|
||||
import pisi
|
||||
import pisi.context as ctx
|
||||
import pisi.archive as archive
|
||||
from pisi.constants import const
|
||||
from pisi.config import config
|
||||
from pisi.uri import URI
|
||||
from pisi.metadata import MetaData
|
||||
from pisi.files import Files
|
||||
@@ -79,7 +78,7 @@ class Package:
|
||||
def extract_PISI_files(self, outdir):
|
||||
"""Extract PISI control files: metadata.xml, files.xml,
|
||||
action scripts, etc."""
|
||||
self.extract_files([const.metadata_xml, const.files_xml], outdir)
|
||||
self.extract_files([ctx.const.metadata_xml, ctx.const.files_xml], outdir)
|
||||
self.extract_dir('config', outdir)
|
||||
|
||||
def read(self, outdir = None):
|
||||
@@ -90,14 +89,14 @@ class Package:
|
||||
self.extract_PISI_files(outdir)
|
||||
|
||||
self.metadata = MetaData()
|
||||
self.metadata.read( join(outdir, const.metadata_xml) )
|
||||
self.metadata.read( join(outdir, ctx.const.metadata_xml) )
|
||||
if self.metadata.has_errors():
|
||||
raise PackageError, "MetaData format wrong"
|
||||
|
||||
self.files = Files()
|
||||
self.files.read( join(outdir, const.files_xml) )
|
||||
self.files.read( join(outdir, ctx.const.files_xml) )
|
||||
if self.files.has_errors():
|
||||
raise PackageError, "invalid %s" % const.files_xml
|
||||
raise PackageError, "invalid %s" % ctx.const.files_xml
|
||||
|
||||
def pkg_dir(self):
|
||||
packageDir = self.metadata.package.name + '-' \
|
||||
@@ -107,4 +106,4 @@ class Package:
|
||||
return join( config.lib_dir(), packageDir)
|
||||
|
||||
def comar_dir(self):
|
||||
return self.pkg_dir() + const.comar_dir_suffix
|
||||
return self.pkg_dir() + ctx.const.comar_dir_suffix
|
||||
|
||||
+10
-6
@@ -26,7 +26,7 @@ from bsddb import db
|
||||
|
||||
import pisi
|
||||
import pisi.util as util
|
||||
from pisi.config import config
|
||||
import pisi.context as ctx
|
||||
|
||||
class PackageDBError(pisi.Error):
|
||||
pass
|
||||
@@ -35,9 +35,9 @@ class PackageDB(object):
|
||||
"""PackageDB class provides an interface to the package database with
|
||||
a delegated dbshelve object"""
|
||||
def __init__(self, id):
|
||||
util.check_dir(config.db_dir())
|
||||
self.fname = os.path.join(config.db_dir(), 'package-%s.bdb' % id )
|
||||
self.fname2 = os.path.join(config.db_dir(), 'revdep-%s.bdb' % id )
|
||||
util.check_dir(ctx.config.db_dir())
|
||||
self.fname = os.path.join(ctx.config.db_dir(), 'package-%s.bdb' % id )
|
||||
self.fname2 = os.path.join(ctx.config.db_dir(), 'revdep-%s.bdb' % id )
|
||||
self.lockfile = file(self.fname + '.lock', 'w')
|
||||
try:
|
||||
fcntl.flock(self.lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
@@ -147,5 +147,9 @@ def remove_package(name):
|
||||
|
||||
# tracking databases for non-repository information
|
||||
|
||||
thirdparty_packagedb = PackageDB('thirdparty')
|
||||
inst_packagedb = PackageDB('installed')
|
||||
thirdparty_packagedb = None
|
||||
inst_packagedb = None
|
||||
|
||||
def init():
|
||||
thirdparty_packagedb = PackageDB('thirdparty')
|
||||
inst_packagedb = PackageDB('installed')
|
||||
|
||||
+9
-3
@@ -14,7 +14,7 @@ from bsddb import db
|
||||
import bsddb.dbshelve as shelve
|
||||
import os, fcntl
|
||||
|
||||
from pisi.config import config
|
||||
import pisi.context as ctx
|
||||
import pisi.packagedb as packagedb
|
||||
import pisi.util as util
|
||||
from pisi.uri import URI
|
||||
@@ -22,7 +22,7 @@ from pisi.uri import URI
|
||||
class RepoDB(object):
|
||||
"""RepoDB maps repo ids to repository information"""
|
||||
def __init__(self):
|
||||
self.filename = os.path.join(config.db_dir(), 'repo.bdb')
|
||||
self.filename = os.path.join(ctx.config.db_dir(), 'repo.bdb')
|
||||
self.d = shelve.open(self.filename)
|
||||
self.fdummy = open(self.filename + '.lock', 'w')
|
||||
fcntl.flock(self.fdummy, fcntl.LOCK_EX)
|
||||
@@ -59,4 +59,10 @@ class RepoDB(object):
|
||||
name = str(name)
|
||||
del self.d[name]
|
||||
|
||||
repodb = RepoDB()
|
||||
repodb = None
|
||||
|
||||
def init():
|
||||
repodb = RepoDB()
|
||||
repodb.init_dbs()
|
||||
print 'repodb initialized'
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ from os import access, R_OK
|
||||
import pisi
|
||||
from pisi.archive import Archive
|
||||
from pisi.uri import URI
|
||||
from pisi.ui import ui
|
||||
from pisi.config import config
|
||||
from pisi.fetcher import fetch_url
|
||||
import pisi.util as util
|
||||
|
||||
|
||||
+4
-1
@@ -59,5 +59,8 @@ class SourceDB(object):
|
||||
name = str(name)
|
||||
del self.d[name]
|
||||
|
||||
sourcedb = SourceDB()
|
||||
sourcedb = None
|
||||
|
||||
def init():
|
||||
sourcedb = SourceDB()
|
||||
|
||||
|
||||
+1
-2
@@ -22,9 +22,8 @@ from os.path import basename
|
||||
|
||||
# pisi modules
|
||||
from pisi.xmlext import *
|
||||
import pisi.xmlfile as xmlfile
|
||||
from pisi.xmlfile import XmlFile
|
||||
from pisi.ui import ui
|
||||
import pisi
|
||||
from pisi.dependency import DepInfo
|
||||
from pisi.util import Checks
|
||||
|
||||
|
||||
+2
-8
@@ -16,14 +16,11 @@
|
||||
import sys
|
||||
|
||||
from pisi.colors import colorize
|
||||
from pisi.config import config
|
||||
import pisi.context as ctx
|
||||
|
||||
def register(_impl):
|
||||
""" Register a UI implementation"""
|
||||
ui = _impl
|
||||
|
||||
# default UI implementation
|
||||
class CLI:
|
||||
"Command Line Interface"
|
||||
def __init__(self, debuggy = False, verbose = False):
|
||||
self.show_debug = debuggy
|
||||
self.show_verbose = verbose
|
||||
@@ -90,6 +87,3 @@ class CLI:
|
||||
(pd['filename'], pd['percent'], pd['rate'], pd['symbol'])
|
||||
self.info(out)
|
||||
|
||||
# default UI is CLI
|
||||
ui = None
|
||||
#CLI()
|
||||
|
||||
@@ -26,9 +26,6 @@ import statvfs
|
||||
|
||||
# pisi modules
|
||||
import pisi
|
||||
from pisi.ui import ui
|
||||
from pisi.constants import const
|
||||
from pisi.config import config
|
||||
|
||||
class FileError(pisi.Error):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user