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