pisi'yi çalışır hale getirme operasyonu!

- yeni context'in kullanılmasını sağla (kod çalışsın diye, context'i bu şekilde bırakmak güzel bir kod oluşturmuyor).
- düzeltirken hatırlamadığım onlarca hata...
This commit is contained in:
Barış Metin
2005-08-30 18:44:33 +00:00
parent 63c80a12d9
commit 47950a019c
34 changed files with 291 additions and 256 deletions
+4 -1
View File
@@ -21,8 +21,11 @@ from pisi.cli.pisicli import PisiCLI
def handle_exception(exception, value, tb):
import traceback
import exceptions
import pisi.ui
from pisi.xmlext import XmlError
from pisi.ui import ui
ui = pisi.ui.CLI()
if exception == exceptions.KeyboardInterrupt:
ui.error(_("\nKeyboardInterrupt: Exiting...\n"))
+7 -8
View File
@@ -14,8 +14,7 @@
from os import getenv, environ
# Pisi-Core Modules
import pisi.config
import pisi.constants
import pisi.context as ctx
# Set individual information, that are generally needed for ActionsAPI
@@ -24,7 +23,7 @@ def exportFlags():
# Build systems depend on these environment variables. That is why
# we export them instead of using as (instance) variables.
values = pisi.config.config.values
values = ctx.config.values
environ['HOST'] = values.build.host
environ['CFLAGS'] = values.build.cflags
environ['CXXFLAGS'] = values.build.cxxflags
@@ -75,9 +74,9 @@ class Dirs:
kde = '/usr/kde/3.4'
qt = '/usr/qt/3'
class Variables(pisi.config.Config):
const = pisi.constants.const
env = Env()
dirs = Dirs()
def initVariables():
ctx.env = Env()
ctx.dirs = Dirs()
return ctx
glb = Variables()
glb = initVariables()
+27 -29
View File
@@ -26,8 +26,8 @@ import pisi.dependency as dependency
import pisi.pgraph as pgraph
import pisi.operations as operations
import pisi.packagedb as packagedb
from pisi.repodb import repodb
from pisi.installdb import installdb
import pisi.repodb
import pisi.installdb
from pisi.index import Index
class Error(pisi.Error):
@@ -50,14 +50,12 @@ def init(database = True, options = None, ui = None ):
# 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()
ctx.repodb = pisi.repodb.init()
ctx.installdb = pisi.installdb.init()
packagedb.init()
# import pisi.sourcedb
# pisi.sourcedb.init()
def install(packages):
"""install a list of packages (either files/urls, or names)"""
@@ -68,7 +66,7 @@ def install(packages):
try:
# determine if this is a list of files/urls or names
if packages[0].endswith(const.package_prefix): # they all have to!
if packages[0].endswith(ctx.const.package_prefix): # they all have to!
install_pkg_files(packages)
else:
install_pkg_names(packages)
@@ -92,7 +90,7 @@ def install_pkg_files(package_URIs):
ctx.ui.debug('A = %s\n' % str(package_URIs))
for x in package_URIs:
if not x.endswith(const.package_prefix):
if not x.endswith(ctx.const.package_prefix):
ctx.ui.error('Mixing file names and package names not supported YET.\n')
return False
@@ -235,15 +233,15 @@ def upgrade_pkg_names(A):
"""Re-installs packages from the repository, trying to perform
a maximum number of upgrades."""
ignore_build = config.options and config.options.ignore_build_no
ignore_build = ctx.config.options and ctx.config.options.ignore_build_no
# filter packages that are not installed
Ap = []
for x in A:
if not installdb.is_installed(x):
if not ctx.installdb.is_installed(x):
ctx.ui.info('Package %s is not installed.\n' % x)
continue
(version, release, build) = installdb.get_version(x)
(version, release, build) = ctx.installdb.get_version(x)
pkg = packagedb.get_package(x)
if ignore_build or (not build):
if release < pkg.release:
@@ -283,8 +281,8 @@ def upgrade_pkg_names(A):
print 'checking ', dep
# add packages that can be upgraded
if dependency.repo_satisfies_dep(dep):
if installdb.is_installed(dep.package):
(v,r,b) = installdb.get_version(dep.package)
if ctx.installdb.is_installed(dep.package):
(v,r,b) = ctx.installdb.get_version(dep.package)
rep_pkg = packagedb.get_package(dep.package)
(vp,rp,bp) = (rep_pkg.version, rep_pkg.release,
rep_pkg.build)
@@ -313,7 +311,7 @@ def remove(A):
# filter packages that are not installed
Ap = []
for x in A:
if installdb.is_installed(x):
if ctx.installdb.is_installed(x):
Ap.append(x)
else:
ctx.ui.info('Package %s does not exist. Cannot remove.\n' % x)
@@ -328,7 +326,7 @@ def remove(A):
G_f = pgraph.PGraph(packagedb) # construct G_f
# find the "install closure" graph of G_f by package
# find the (install closure) graph of G_f by package
# set A using packagedb
print A
for x in A:
@@ -353,7 +351,7 @@ def remove(A):
order = G_f.topological_sort()
print order
for x in order:
if installdb.is_installed(x):
if ctx.installdb.is_installed(x):
operations.remove_single(x)
else:
ctx.ui.info('Package %s is not installed. Cannot remove.\n' % x)
@@ -367,7 +365,7 @@ def configure_pending():
pass
def info(package):
if package.endswith(const.package_prefix):
if package.endswith(ctx.const.package_prefix):
return info_file(package)
else:
return info_name(package)
@@ -375,10 +373,10 @@ def info(package):
def info_file(package):
from package import Package
if not os.path.exist(package):
if not os.path.exists(package):
raise Error ('File %s not found' % package)
package = Package(package_name)
package = Package(package)
package.read()
return package.metadata, package.files
@@ -392,8 +390,8 @@ def info_name(package_name):
#FIXME: get it from sourcedb
metadata.source = None
#TODO: fetch the files from server if possible
if installdb.is_installed(package.name):
files = installdb.files(package.name)
if ctx.installdb.is_installed(package.name):
files = ctx.installdb.files(package.name)
else:
files = None
return metadata, files
@@ -414,11 +412,11 @@ class Repo:
def add_repo(name, indexuri):
repo = Repo(URI(indexuri))
repodb.add_repo(name, repo)
ctx.repodb.add_repo(name, repo)
def remove_repo(name):
if repodb.has_repo(name):
repodb.remove_repo(name)
if ctx.repodb.has_repo(name):
ctx.repodb.remove_repo(name)
else:
ctx.ui.error('* Repository %s does not exist. Cannot remove.\n'
% name)
@@ -427,7 +425,7 @@ def update_repo(repo):
ctx.ui.info('* Updating repository: %s\n' % repo)
index = Index()
index.read(repodb.get_repo(repo).indexuri.get_uri(), repo)
index.read(ctx.repodb.get_repo(repo).indexuri.get_uri(), repo)
index.update_db(repo)
ctx.ui.info('* Package database updated.\n')
+43 -44
View File
@@ -24,7 +24,6 @@ _ = __trans.ugettext
import pisi
import pisi.util as util
import pisi.context as ctx
from pisi.context import BuildContext
from pisi.sourcearchive import SourceArchive
from pisi.files import Files, FileInfo
from pisi.metadata import MetaData
@@ -105,23 +104,23 @@ class BuildContext(object):
packageDir = self.spec.source.name + '-' + \
self.spec.source.version + '-' + self.spec.source.release
return config.destdir + config.values.dirs.tmp_dir \
return ctx.config.destdir + ctx.config.values.dirs.tmp_dir \
+ '/' + packageDir
def pkg_work_dir(self):
return self.pkg_dir() + const.work_dir_suffix
return self.pkg_dir() + ctx.const.work_dir_suffix
def pkg_install_dir(self):
return self.pkg_dir() + const.install_dir_suffix
return self.pkg_dir() + ctx.const.install_dir_suffix
class PisiBuild:
"""PisiBuild class, provides the package build and creation routines"""
def __init__(self, pspec):
self.ctx = BuildContext(pspec)
self.pspecDir = os.path.dirname(os.path.realpath(self.ctx.pspecfile))
self.spec = self.ctx.spec
self.sourceArchive = SourceArchive(self.ctx)
self.bctx = BuildContext(pspec)
self.pspecDir = os.path.dirname(os.path.realpath(self.bctx.pspecfile))
self.spec = self.bctx.spec
self.sourceArchive = SourceArchive(self.bctx)
self.set_environment_vars()
@@ -166,9 +165,9 @@ class PisiBuild:
def set_environment_vars(self):
"""Sets the environment variables for actions API to use"""
evn = {
"PKG_DIR": self.ctx.pkg_dir(),
"WORK_DIR": self.ctx.pkg_work_dir(),
"INSTALL_DIR": self.ctx.pkg_install_dir(),
"PKG_DIR": self.bctx.pkg_dir(),
"WORK_DIR": self.bctx.pkg_work_dir(),
"INSTALL_DIR": self.bctx.pkg_install_dir(),
"SRC_NAME": self.spec.source.name,
"SRC_VERSION": self.spec.source.version,
"SRC_RELEASE": self.spec.source.release
@@ -179,40 +178,40 @@ class PisiBuild:
ctx.ui.info(_("Fetching source from: %s\n") % self.spec.source.archiveUri)
self.sourceArchive.fetch()
ctx.ui.info(_("Source archive is stored: %s/%s\n")
%(config.archives_dir(), self.spec.source.archiveName))
%(ctx.config.archives_dir(), self.spec.source.archiveName))
def unpack_source_archive(self):
ctx.ui.info(_("Unpacking archive..."))
self.sourceArchive.unpack()
ctx.ui.info(_(" unpacked (%s)\n") % self.ctx.pkg_work_dir())
ctx.ui.info(_(" unpacked (%s)\n") % self.bctx.pkg_work_dir())
self.set_state("unpacked")
def run_setup_action(self):
# Run configure, build and install phase
ctx.ui.action(_("Setting up source...\n"))
self.run_action_function(const.setup_func)
self.run_action_function(ctx.const.setup_func)
self.set_state("setupaction")
def run_build_action(self):
ctx.ui.action(_("Building source...\n"))
self.run_action_function(const.build_func)
self.run_action_function(ctx.const.build_func)
self.set_state("buildaction")
def run_install_action(self):
ctx.ui.action(_("Installing...\n"))
# Before install make sure install_dir is clean
if os.path.exists(self.ctx.pkg_install_dir()):
util.clean_dir(self.ctx.pkg_install_dir())
if os.path.exists(self.bctx.pkg_install_dir()):
util.clean_dir(self.bctx.pkg_install_dir())
# install function is mandatory!
self.run_action_function(const.install_func, True)
self.run_action_function(ctx.const.install_func, True)
self.set_state("installaction")
def compile_action_script(self):
"""Compiles actions.py and sets the actionLocals and actionGlobals"""
specdir = os.path.dirname(self.ctx.pspecfile)
scriptfile = os.path.join(specdir, const.actions_file)
specdir = os.path.dirname(self.bctx.pspecfile)
scriptfile = os.path.join(specdir, ctx.const.actions_file)
try:
localSymbols = globalSymbols = {}
buf = open(scriptfile).read()
@@ -235,7 +234,7 @@ class PisiBuild:
except KeyError:
workdir = self.spec.source.name + "-" + self.spec.source.version
return os.path.join(self.ctx.pkg_work_dir(), workdir)
return os.path.join(self.bctx.pkg_work_dir(), workdir)
def run_action_function(self, func, mandatory=False):
"""Calls the corresponding function in actions.py.
@@ -263,14 +262,14 @@ class PisiBuild:
def apply_patches(self):
files_dir = os.path.abspath(os.path.join(self.pspecDir,
const.files_dir))
ctx.const.files_dir))
for patch in self.spec.source.patches:
patchFile = os.path.join(files_dir, patch.filename)
if patch.compressionType:
patchFile = util.uncompress(patchFile,
compressType=patch.compressionType,
targetDir=config.tmp_dir())
targetDir=ctx.config.tmp_dir())
ctx.ui.action(_("* Applying patch: %s\n") % patch.filename)
util.do_patch(self.srcDir, patchFile, level=patch.level, target=patch.target)
@@ -283,33 +282,33 @@ class PisiBuild:
metadata = MetaData()
metadata.from_spec(self.spec.source, package)
metadata.package.distribution = config.values.general.distribution
metadata.package.distributionRelease = config.values.general.distribution_release
metadata.package.distribution = ctx.config.values.general.distribution
metadata.package.distributionRelease = ctx.config.values.general.distribution_release
metadata.package.architecture = "Any"
# FIXME: Bu hatalı. installsize'ı almak için tüm
# pkg_install_dir()'ın boyutunu hesaplayamayız. Bir source
# birden fazla kaynak üretebilir. package.paths ile
# karşılaştırarak file listesinden boyutları hesaplatmalıyız.
d = self.ctx.pkg_install_dir()
d = self.bctx.pkg_install_dir()
size = util.dir_size(d)
metadata.package.installedSize = str(size)
# build no
if config.options.ignore_build_no:
if ctx.config.options.ignore_build_no:
metadata.package.build = None # means, build no information n/a
ctx.ui.warning('build number is not available.')
else:
metadata.package.build = self.calc_build_no(metadata.package.name)
metadata.write(os.path.join(self.ctx.pkg_dir(), const.metadata_xml))
metadata.write(os.path.join(self.bctx.pkg_dir(), ctx.const.metadata_xml))
self.metadata = metadata
def gen_files_xml(self, package):
"""Generetes files.xml using the path definitions in specfile and
generated files by the build system."""
files = Files()
install_dir = self.ctx.pkg_install_dir()
install_dir = self.bctx.pkg_install_dir()
collisions = check_path_collision(package,
self.spec.packages)
if collisions:
@@ -327,24 +326,24 @@ class PisiBuild:
d[frpath] = FileInfo(frpath, ftype, fsize, fhash)
for (p, fileinfo) in d.iteritems():
files.append(fileinfo)
files.write(os.path.join(self.ctx.pkg_dir(), const.files_xml))
files.write(os.path.join(self.bctx.pkg_dir(), ctx.const.files_xml))
self.files = files
def calc_build_no(self, package_name):
"""Calculate build number"""
# find previous build in config.options.output_dir
# find previous build in ctx.config.options.output_dir
found = []
for root, dirs, files in os.walk(config.options.output_dir):
for root, dirs, files in os.walk(ctx.config.options.output_dir):
for fn in files:
fn = fn.decode('utf-8')
if fn.startswith(package_name + '-') and \
fn.endswith(const.package_prefix):
fn.endswith(ctx.const.package_prefix):
old_package_fn = os.path.join(root, 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'))
old_pkg.read(join(ctx.config.tmp_dir(), 'oldpkg'))
old_build = old_pkg.metadata.package.build
found.append( (old_package_fn, old_build) )
if not found:
@@ -362,7 +361,7 @@ class PisiBuild:
# compare old files.xml with the new one..
old_pkg = Package(old_package_fn, 'r')
from os.path import join
old_pkg.read(join(config.tmp_dir(), 'oldpkg'))
old_pkg.read(join(ctx.config.tmp_dir(), 'oldpkg'))
# FIXME: TAKE INTO ACCOUNT MINOR CHANGES IN METADATA
changed = False
@@ -405,11 +404,11 @@ class PisiBuild:
ctx.ui.action(_("** Building package %s\n") % package.name);
ctx.ui.action(_("Generating %s...") % const.files_xml)
ctx.ui.action(_("Generating %s...") % ctx.const.files_xml)
self.gen_files_xml(package)
ctx.ui.info(_(" done.\n"))
ctx.ui.action(_("Generating %s...") % const.metadata_xml)
ctx.ui.action(_("Generating %s...") % ctx.const.metadata_xml)
self.gen_metadata_xml(package)
ctx.ui.info(_(" done.\n"))
@@ -424,29 +423,29 @@ class PisiBuild:
# add comar files to package
os.chdir(self.pspecDir)
for pcomar in package.providesComar:
fname = os.path.join(const.comar_dir,
fname = os.path.join(ctx.const.comar_dir,
pcomar.script)
pkg.add_to_package(fname)
# store additional files
install_dir = self.ctx.pkg_dir() + const.install_dir_suffix
install_dir = self.bctx.pkg_dir() + ctx.const.install_dir_suffix
for afile in package.additionalFiles:
src = os.path.join(const.files_dir, afile.filename)
src = os.path.join(ctx.const.files_dir, afile.filename)
dest = os.path.join(install_dir + os.path.dirname(afile.target), os.path.basename(afile.target))
util.copy_file(src, dest)
if afile.permission:
os.chmod(dest, int(afile.permission) | 0777)
# add xmls and files
os.chdir(self.ctx.pkg_dir())
os.chdir(self.bctx.pkg_dir())
pkg.add_to_package(const.metadata_xml)
pkg.add_to_package(const.files_xml)
pkg.add_to_package(ctx.const.metadata_xml)
pkg.add_to_package(ctx.const.files_xml)
# Now it is time to add files to the packages using newly
# created files.xml
files = Files()
files.read(const.files_xml)
files.read(ctx.const.files_xml)
for finfo in files.list:
pkg.add_to_package("install/" + finfo.path)
+9 -15
View File
@@ -15,6 +15,7 @@ from optparse import OptionParser
import pisi
import pisi.cli
import pisi.context as ctx
from pisi.uri import URI
@@ -113,10 +114,8 @@ class Command(object):
"""initialize PiSi components"""
# NB: command imports here or in the command class run fxns
import pisi
import pisi.api
pisi.api.init(database, self.options)
import pisi.context as ctx
def finalize(self):
"""do cleanup work for PiSi components"""
@@ -227,7 +226,7 @@ fetch all necessary files and build the package for you.
return
self.init()
ctx.ui.info('Output directory: %s\n' % config.options.output_dir)
ctx.ui.info('Output directory: %s\n' % ctx.config.options.output_dir)
for arg in self.args:
pisi.api.build(arg, self.authInfo)
self.finalize()
@@ -372,8 +371,7 @@ Upgrade the entire system.
return
self.init()
from pisi.installdb import installdb
pisi.api.upgrade(installdb.list_installed())
pisi.api.upgrade(ctx.installdb.list_installed())
self.finalize()
@@ -503,15 +501,14 @@ Usage: list-installed
def run(self):
self.init(True)
from pisi.installdb import installdb
list = installdb.list_installed()
list = ctx.installdb.list_installed()
list.sort()
if self.options.install_info:
print 'Package Name |St| Version| Rel.| Build| Distro| Date'
print '========================================================================'
for pkg in list:
package = pisi.packagedb.inst_packagedb.get_package(pkg)
inst_info = installdb.get_info(pkg)
inst_info = ctx.installdb.get_info(pkg)
if self.options.long:
print package
print inst_info
@@ -621,10 +618,9 @@ Lists currently tracked repositories.
def run(self):
self.init()
from pisi.repodb import repodb
for repo in repodb.list():
for repo in ctx.repodb.list():
print repo
print ' ', repodb.get_repo(repo).indexuri.get_uri()
print ' ', ctx.repodb.get_repo(repo).indexuri.get_uri()
self.finalize()
@@ -643,7 +639,6 @@ Gives a brief list of PiSi components published in the repository.
name = ("list-available", "la")
def run(self):
from pisi.repodb import repodb
self.init(True)
@@ -652,7 +647,7 @@ Gives a brief list of PiSi components published in the repository.
self.print_packages(arg)
else:
# print for all repos
for repo in repodb.list():
for repo in ctx.repodb.list():
ctx.ui.info("Repository : %s\n" % repo)
self.print_packages(repo)
self.finalize()
@@ -678,10 +673,9 @@ class ListPending(Command):
name = ("list-pending", "lp")
def run(self):
from pisi.installdb import installdb
self.init(True)
list = installdb.list_pending()
list = ctx.installdb.list_pending()
list.sort()
for p in list:
print p
+3
View File
@@ -26,6 +26,9 @@ config = None
# default UI is CLI
ui = None # not now
installdb = None
repodb = None
#def register(_impl):
# """ Register a UI implementation"""
# ui = _impl
+2 -1
View File
@@ -14,6 +14,7 @@
#import pisi.db as db
import pisi.context as ctx
import pisi.packagedb as packagedb
from pisi.version import Version
from pisi.xmlext import *
from pisi.xmlfile import XmlFile
@@ -89,7 +90,7 @@ def installed_satisfies_dep(depinfo):
"""determine if a package in *repository* satisfies given
dependency spec"""
pkg_name = depinfo.package
if not installdb.is_installed(pkg_name):
if not ctx.installdb.is_installed(pkg_name):
return False
else:
pkg = packagedb.inst_packagedb.get_package(pkg_name)
+2 -2
View File
@@ -23,8 +23,8 @@ from base64 import encodestring
# pisi modules
import pisi
import pisi.util as util
from pisi.uri import URI
import pisi.context as ctx
from pisi.uri import URI
class FetchError(pisi.Error):
@@ -37,7 +37,7 @@ def fetch_url(url, dest, progress=None):
fetch.progress = progress
fetch.fetch()
if progress:
ctx.ctx.ui.info('\n')
ctx.ui.info('\n')
class Fetcher:
+3 -3
View File
@@ -16,12 +16,12 @@
import os
from pisi.package import Package
from pisi.xmlfile import XmlFile
import pisi.context as ctx
import pisi.metadata as metadata
import pisi.packagedb as packagedb
import pisi.context as ctx
import pisi.util as util
from pisi.package import Package
from pisi.xmlfile import XmlFile
from pisi.uri import URI
class Index(XmlFile):
+27 -28
View File
@@ -17,16 +17,15 @@
import os
import pisi
import pisi.context as ctx
import pisi.packagedb as packagedb
import pisi.dependency as dependency
import pisi.operations as operations
from pisi.specfile import *
from pisi.package import Package
from pisi.ui import ui
from pisi.installdb import installdb
import pisi.packagedb as packagedb
from pisi.packagedb import inst_packagedb
import pisi.dependency as dependency
from pisi.metadata import MetaData
from pisi.comariface import comard
import pisi.operations as operations
#import conflicts
class InstallError(pisi.Error):
@@ -45,7 +44,7 @@ class Installer:
def install(self, ask_reinstall = True):
"entry point"
ui.info('Installing %s, version %s, release %s, build %s\n' %
ctx.ui.info('Installing %s, version %s, release %s, build %s\n' %
(self.pkginfo.name, self.pkginfo.version,
self.pkginfo.release, self.pkginfo.build))
self.ask_reinstall = ask_reinstall
@@ -72,12 +71,12 @@ class Installer:
# check conflicts
for pkg in self.metadata.package.conflicts:
if installdb.is_installed(self.pkginfo):
if ctx.installdb.is_installed(self.pkginfo):
raise InstallError("Package conflicts " + pkg)
# check dependencies
if not dependency.installable(self.pkginfo.name):
ui.error('Dependencies for ' + self.pkginfo.name +
ctx.ui.error('Dependencies for ' + self.pkginfo.name +
' not satisfied\n')
raise InstallError("Package not installable")
@@ -86,12 +85,12 @@ class Installer:
pkg = self.pkginfo
if installdb.is_installed(pkg.name): # is this a reinstallation?
(iversion, irelease, ibuild) = installdb.get_version(pkg.name)
if ctx.installdb.is_installed(pkg.name): # is this a reinstallation?
(iversion, irelease, ibuild) = ctx.installdb.get_version(pkg.name)
# determine if same version
same_ver = False
ignore_build = config.options and config.options.ignore_build_no
ignore_build = ctx.config.options and ctx.config.options.ignore_build_no
if (not ibuild) or (not pkg.build) or ignore_build:
# we don't look at builds to compare two package versions
if pkg.version == iversion and pkg.release == irelease:
@@ -102,21 +101,21 @@ class Installer:
if same_ver:
if self.ask_reinstall:
if not ui.confirm('Re-install same version package?'):
if not ctx.ui.confirm('Re-install same version package?'):
raise InstallError('Package re-install declined')
else:
upgrade = False
# is this an upgrade?
# determine and report the kind of upgrade: version, release, build
if pkg.version > iversion:
ui.info('Upgrading to new upstream version\n')
ctx.ui.info('Upgrading to new upstream version\n')
upgrade = True
elif pkg.release > irelease:
ui.info('Upgrading to new distribution release\n')
ctx.ui.info('Upgrading to new distribution release\n')
upgrade = True
elif ((not ignore_build) and ibuild and pkg.build
and pkg.build > ibuild):
ui.info('Upgrading to new distribution build\n')
ctx.ui.info('Upgrading to new distribution build\n')
upgrade = True
# is this a downgrade? confirm this action.
@@ -127,7 +126,7 @@ class Installer:
x = 'Downgrade to old distribution release?'
else:
x = 'Downgrade to old distribution build?'
if not ui.confirm(x):
if not ctx.ui.confirm(x):
raise InstallError('Package downgrade declined')
# remove old package then
@@ -136,24 +135,24 @@ class Installer:
def extract_install(self):
"unzip package in place"
ui.info('Extracting files,\n')
self.package.extract_dir_flat('install', config.destdir)
ctx.ui.info('Extracting files,\n')
self.package.extract_dir_flat('install', ctx.config.destdir)
def store_pisi_files(self):
"""put files.xml, metadata.xml, actions.py and COMAR scripts
somewhere in the file system. We'll need these in future..."""
ui.info('Storing %s, ' % const.files_xml)
self.package.extract_file(const.files_xml, self.package.pkg_dir())
ctx.ui.info('Storing %s, ' % ctx.const.files_xml)
self.package.extract_file(ctx.const.files_xml, self.package.pkg_dir())
ui.info('%s.\n' % const.metadata_xml)
self.package.extract_file(const.metadata_xml, self.package.pkg_dir())
ctx.ui.info('%s.\n' % ctx.const.metadata_xml)
self.package.extract_file(ctx.const.metadata_xml, self.package.pkg_dir())
for pcomar in self.metadata.package.providesComar:
fpath = os.path.join(const.comar_dir, pcomar.script)
fpath = os.path.join(ctx.const.comar_dir, pcomar.script)
# comar prefix is added to the pkg_dir while extracting comar
# script file. so we'll use pkg_dir as destination.
ui.info('Storing %s\n' % fpath)
ctx.ui.info('Storing %s\n' % fpath)
self.package.extract_file(fpath, self.package.pkg_dir())
def register_comar_scripts(self):
@@ -161,7 +160,7 @@ class Installer:
for pcomar in self.metadata.package.providesComar:
scriptPath = os.path.join(self.package.comar_dir(),pcomar.script)
ui.info("Registering COMAR script %s\n" % pcomar.script)
ctx.ui.info("Registering COMAR script %s\n" % pcomar.script)
# FIXME: We must check the result of the command (possibly
# with id?)
if comard:
@@ -174,11 +173,11 @@ class Installer:
"update databases"
# installdb
installdb.install(self.metadata.package.name,
ctx.installdb.install(self.metadata.package.name,
self.metadata.package.version,
self.metadata.package.release,
self.metadata.package.build,
self.metadata.package.distribution)
# installed packages
inst_packagedb.add_package(self.pkginfo)
packagedb.inst_packagedb.add_package(self.pkginfo)
+11 -5
View File
@@ -76,8 +76,8 @@ class InstallDB:
def files_name(self, pkg, version, release):
from os.path import join
pkg_dir = join(config.lib_dir(), pkg + '-' + version + '-' + release)
return join(pkg_dir, const.files_xml)
pkg_dir = join(ctx.config.lib_dir(), pkg + '-' + version + '-' + release)
return join(pkg_dir, ctx.const.files_xml)
def files(self, pkg):
pkg = str(pkg)
@@ -133,7 +133,7 @@ class InstallDB:
pkg = str(pkg)
if self.is_installed(pkg):
raise InstallDBError("already installed")
if config.options and config.options.ignore_comar:
if ctx.config.options and ctx.config.options.ignore_comar:
state = 'ip'
self.dp[pkg] = True
else:
@@ -152,8 +152,14 @@ class InstallDB:
if self.d.has_key(pkg):
del self.d[pkg]
installdb = None
db = None
def init():
installdb = InstallDB()
global db
if db:
return db
db = InstallDB()
return db
+2 -1
View File
@@ -20,6 +20,7 @@ import os
import fcntl
import pisi
import pisi.context
class LockedDBShelf(shelve.DBShelf):
@@ -41,7 +42,7 @@ class LockedDBShelf(shelve.DBShelf):
else:
raise error, "flags should be one of 'r', 'w', 'c' or 'n' or use the bsddb.db.DB_* flags"
filename = os.path.join( pisi.context.config.db_dir(), dbname + '.bdb')
LockedDBShelf.open(self,filename, dbname, filetype, flags, mode)
self.open(filename, dbname, filetype, flags, mode)
def open(self, filename, dbname, filetype, flags, mode):
pisi.util.check_dir(pisi.context.config.db_dir())
+1 -2
View File
@@ -17,9 +17,8 @@
# Baris Metin <baris@uludag.org.tr
import pisi.context as ctx
from pisi.xmlfile import *
import pisi.specfile as specfile
from pisi.xmlfile import *
from pisi.util import Checks
class SourceInfo:
+11 -13
View File
@@ -14,40 +14,39 @@ import os
import pisi
import pisi.context as ctx
from pisi.uri import URI
import pisi.util as util
import pisi.packagedb as packagedb
from pisi.uri import URI
# single package operations
def remove_single(package_name):
"""Remove a single package"""
from installdb import installdb
from comariface import comard
inst_packagedb = packagedb.inst_packagedb
#TODO: check dependencies
ui.info('Removing package %s' % package_name)
if not installdb.is_installed(package_name):
ctx.ui.info('Removing package %s' % package_name)
if not ctx.installdb.is_installed(package_name):
raise Exception('Trying to remove nonexistent package '
+ package_name)
for fileinfo in installdb.files(package_name).list:
fpath = os.path.join(config.destdir, fileinfo.path)
for fileinfo in ctx.installdb.files(package_name).list:
fpath = os.path.join(ctx.config.destdir, fileinfo.path)
# TODO: We have to store configuration files for futher
# usage. Currently we'are doing it like rpm does, saving
# with a prefix and leaving the user to edit it. In the future
# we'll have a plan for these configuration files.
if fileinfo.type == const.conf:
if fileinfo.type == ctx.const.conf:
os.rename(fpath, fpath + ".pisi")
else:
os.unlink(fpath)
installdb.remove(package_name)
ctx.installdb.remove(package_name)
packagedb.remove_package(package_name)
if comard:
# FIXME: (return value)...
comard.remove(package_name)
ui.info('.\n')
ctx.ui.info('.\n')
def install_single(pkg, upgrade = False):
"""install a single package from URI or ID"""
@@ -71,8 +70,7 @@ def install_single_name(name, upgrade = False):
# find package in repository
repo = packagedb.which_repo(name)
if repo:
from repodb import repodb
repo = repodb.get_repo(repo)
repo = ctx.repodb.get_repo(repo)
pkg = packagedb.get_package(name)
# FIXME: let pkg.packageURI be stored as URI type rather than string
@@ -83,12 +81,12 @@ def install_single_name(name, upgrade = False):
pkg_path = os.path.join(os.path.dirname(repo.indexuri.get_uri()),
str(pkg_uri.path()))
ui.debug("Package URI: %s\n" % pkg_path)
ctx.ui.debug("Package URI: %s\n" % pkg_path)
# Package will handle remote file for us!
install_single_file(pkg_path, upgrade)
else:
ui.error("Package %s not found in any active repository.\n" % pkg)
ctx.ui.error("Package %s not found in any active repository.\n" % pkg)
# deneme, don't remove ulan
class AtomicOperation(object):
+3 -3
View File
@@ -38,7 +38,7 @@ class Package:
if url.is_remote_file():
from fetcher import fetch_url
from ui import ui
dest = config.packages_dir()
dest = ctx.config.packages_dir()
fetch_url(url, dest, ui.Progress)
self.filepath = join(dest, url.filename())
@@ -83,7 +83,7 @@ class Package:
def read(self, outdir = None):
if not outdir:
outdir = config.tmp_dir()
outdir = ctx.config.tmp_dir()
# extract control files
self.extract_PISI_files(outdir)
@@ -103,7 +103,7 @@ class Package:
+ self.metadata.package.version + '-' \
+ self.metadata.package.release
return join( config.lib_dir(), packageDir)
return join( ctx.config.lib_dir(), packageDir)
def comar_dir(self):
return self.pkg_dir() + ctx.const.comar_dir_suffix
+8 -4
View File
@@ -43,8 +43,7 @@ class PackageDB(object):
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")
ctx.ui.error("Another instance of PISI is running. Try later!\n")
sys.exit(1)
self.d = shelve.open(self.fname)
self.dr = shelve.open(self.fname2)
@@ -151,5 +150,10 @@ thirdparty_packagedb = None
inst_packagedb = None
def init():
thirdparty_packagedb = PackageDB('thirdparty')
inst_packagedb = PackageDB('installed')
global thirdparty_packagedb
global inst_packagedb
if not thirdparty_packagedb:
thirdparty_packagedb = PackageDB('thirdparty')
if not inst_packagedb:
inst_packagedb = PackageDB('installed')
+11 -12
View File
@@ -11,9 +11,9 @@
# Author: Eray Ozkural
from bsddb import db
import bsddb.dbshelve as shelve
import os, fcntl
import pisi.lockeddbshelve as shelve
import pisi.context as ctx
import pisi.packagedb as packagedb
import pisi.util as util
@@ -22,10 +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(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)
self.d = shelve.LockedDBShelf("repo")
def init_dbs(self):
# initialize package/source dbs
@@ -33,9 +30,7 @@ class RepoDB(object):
packagedb.add_db(x)
def __del__(self):
#fcntl.flock(self.fdummy, fcntl.LOCK_UN)
self.fdummy.close()
#os.unlink(self.filename + '.lock')
self.d.close()
def has_repo(self, name):
name = str(name)
@@ -59,10 +54,14 @@ class RepoDB(object):
name = str(name)
del self.d[name]
repodb = None
db = None
def init():
repodb = RepoDB()
repodb.init_dbs()
print 'repodb initialized'
global db
if db:
return db
db = RepoDB()
db.init_dbs()
return db
+13 -11
View File
@@ -21,10 +21,11 @@ from os import access, R_OK
# pisi modules
import pisi
import pisi.util as util
import pisi.context as ctx
from pisi.archive import Archive
from pisi.uri import URI
from pisi.fetcher import fetch_url
import pisi.util as util
class SourceArchiveError(pisi.Error):
pass
@@ -32,19 +33,20 @@ class SourceArchiveError(pisi.Error):
class SourceArchive:
"""source archive. this is a class responsible for fetching
and unpacking a source archive"""
def __init__(self, ctx):
self.ctx = ctx
self.url = URI(self.ctx.spec.source.archiveUri)
self.archiveFile = join(config.archives_dir(), self.url.filename())
self.archiveType = self.ctx.spec.source.archiveType
self.archiveSHA1 = self.ctx.spec.source.archiveSHA1
def __init__(self, bctx):
self.url = URI(bctx.spec.source.archiveUri)
self.archiveFile = join(ctx.config.archives_dir(), self.url.filename())
self.archiveName = bctx.spec.source.archiveName
self.archiveType = bctx.spec.source.archiveType
self.archiveSHA1 = bctx.spec.source.archiveSHA1
self.bctx = bctx
def fetch(self, interactive=True):
if not self.is_cached(interactive):
if interactive:
progress = ui.Progress
progress = ctx.ui.Progress
else: progress = None
fetch_url(self.url, config.archives_dir(), progress)
fetch_url(self.url, ctx.config.archives_dir(), progress)
def is_cached(self, interactive=True):
if not access(self.archiveFile, R_OK):
@@ -53,7 +55,7 @@ class SourceArchive:
# check hash
if util.check_file_hash(self.archiveFile, self.archiveSHA1):
if interactive:
ui.info('%s [cached]\n' % self.ctx.spec.source.archiveName)
ctx.ui.info('%s [cached]\n' % self.archiveName)
return True
return False
@@ -65,4 +67,4 @@ class SourceArchive:
raise SourceArchiveError, "unpack: check_file_hash failed"
archive = Archive(self.archiveFile, self.archiveType)
archive.unpack(self.ctx.pkg_work_dir(), cleanDir)
archive.unpack(self.bctx.pkg_work_dir(), cleanDir)
+8 -3
View File
@@ -24,13 +24,13 @@ import fcntl
from bsddb import db
import pisi.util as util
from pisi.config import config
import pisi.context as ctx
class SourceDB(object):
def __init__(self):
util.check_dir(config.db_dir())
self.filename = os.path.join(config.db_dir(), 'source.bdb')
util.check_dir(ctx.config.db_dir())
self.filename = os.path.join(ctx.config.db_dir(), 'source.bdb')
self.d = shelve.open(self.filename)
self.fdummy = file(self.filename + '.lock', 'w')
fcntl.flock(self.fdummy, fcntl.LOCK_EX)
@@ -62,5 +62,10 @@ class SourceDB(object):
sourcedb = None
def init():
global sourcedb
if sourcedb:
return sourcedb
sourcedb = SourceDB()
return sourcedb
+9 -10
View File
@@ -12,9 +12,8 @@
from os.path import basename, dirname, join
import pisi.context as ctx
from pisi.ui import ui
from pisi.config import config
from pisi.constants import const
from pisi.uri import URI
from pisi.specfile import SpecFile
@@ -26,7 +25,7 @@ class SourceFetcher(object):
self.location = dirname(self.url.uri)
pkgname = basename(dirname(self.url.path()))
self.dest = join(config.tmp_dir(), pkgname)
self.dest = join(ctx.config.tmp_dir(), pkgname)
def fetch_all(self):
# fetch pspec file
@@ -43,7 +42,7 @@ class SourceFetcher(object):
return pspec
def fetch_actionsfile(self):
actionsuri = join(self.location, const.actions_file)
actionsuri = join(self.location, ctx.const.actions_file)
self.url.uri = actionsuri
self.fetch()
@@ -51,27 +50,27 @@ class SourceFetcher(object):
spec = self.spec
for patch in spec.source.patches:
patchuri = join(self.location,
const.files_dir, patch.filename)
ctx.const.files_dir, patch.filename)
self.url.uri = patchuri
self.fetch(const.files_dir)
self.fetch(ctx.const.files_dir)
def fetch_comarfiles(self):
spec = self.spec
for package in spec.packages:
for pcomar in package.providesComar:
comaruri = join(self.location,
const.comar_dir, pcomar.script)
ctx.const.comar_dir, pcomar.script)
self.url.uri = comaruri
self.fetch(const.comar_dir)
self.fetch(ctx.const.comar_dir)
def fetch_additionalFiles(self):
spec = self.spec
for pkg in spec.packages:
for afile in pkg.additionalFiles:
afileuri = join(self.location,
const.files_dir, afile.filename)
ctx.const.files_dir, afile.filename)
self.url.uri = afileuri
self.fetch(const.files_dir)
self.fetch(ctx.const.files_dir)
def fetch(self, appendDest=""):
from fetcher import fetch_url
+1 -1
View File
@@ -21,9 +21,9 @@
from os.path import basename
# pisi modules
import pisi
from pisi.xmlext import *
from pisi.xmlfile import XmlFile
import pisi
from pisi.dependency import DepInfo
from pisi.util import Checks
-1
View File
@@ -16,7 +16,6 @@
import sys
from pisi.colors import colorize
import pisi.context as ctx
class CLI:
+2 -1
View File
@@ -26,6 +26,7 @@ import statvfs
# pisi modules
import pisi
import pisi.context as ctx
class FileError(pisi.Error):
pass
@@ -357,4 +358,4 @@ def partition_freespace(directory):
########################################
def package_name(name, version, release):
return name + '-' + version + '-' + release + const.package_prefix
return name + '-' + version + '-' + release + ctx.const.package_prefix
+1 -1
View File
@@ -12,7 +12,7 @@
# Authors: Eray Ozkural <eray@uludag.org.tr>
import util
import pisi.util as util
class Version:
def __init__(self, verstring):
+24 -22
View File
@@ -13,32 +13,34 @@ import os
from os.path import exists as pathexists
from os.path import basename, islink, join
import pisi.context as ctx
import pisi.api
from pisi import archive
from pisi import sourcearchive
from pisi import fetcher
from pisi import util
from pisi import context
from pisi.build import BuildContext
from pisi.config import config
from pisi import uri
class ArchiveFileTestCase(unittest.TestCase):
# def setUp(self):
# pass
def setUp(self):
pisi.api.init()
def testUnpackTar(self):
ctx = context.BuildContext("tests/popt/pspec.xml")
bctx = BuildContext("tests/popt/pspec.xml")
achv = sourcearchive.SourceArchive(ctx)
achv = sourcearchive.SourceArchive(bctx)
assert ctx.spec.source.archiveType == "targz"
assert bctx.spec.source.archiveType == "targz"
# skip fetching and directly unpack the previously fetched (by
# fetchertests) archive
if not achv.isCached(interactive=False):
if not achv.is_cached(interactive=False):
achv.fetch(interactive=False)
achv.unpack()
targetDir = ctx.pkg_work_dir()
targetDir = bctx.pkg_work_dir()
# but testing is hard
# "var/tmp/pisi/popt-1.7-3/work" (targetDir)
assert pathexists(targetDir + "/popt-1.7")
@@ -51,15 +53,15 @@ class ArchiveFileTestCase(unittest.TestCase):
"5af9dd7d754f788cf511c57ce0af3d555fed009d")
def testUnpackZip(self):
ctx = context.BuildContext("tests/sandbox/pspec.xml")
bctx = BuildContext("tests/sandbox/pspec.xml")
assert ctx.spec.source.archiveType == "zip"
assert bctx.spec.source.archiveType == "zip"
achv = sourcearchive.SourceArchive(ctx)
achv = sourcearchive.SourceArchive(bctx)
achv.fetch(interactive=False)
achv.unpack(cleanDir=True)
targetDir = ctx.pkg_work_dir()
targetDir = bctx.pkg_work_dir()
assert pathexists(targetDir + "/sandbox")
testfile = targetDir + "/sandbox/loremipsum.txt"
@@ -75,9 +77,9 @@ class ArchiveFileTestCase(unittest.TestCase):
def testMakeZip(self):
# first unpack our dear sandbox.zip
ctx = context.BuildContext("tests/sandbox/pspec.xml")
targetDir = ctx.pkg_work_dir()
achv = sourcearchive.SourceArchive(ctx)
bctx = BuildContext("tests/sandbox/pspec.xml")
targetDir = bctx.pkg_work_dir()
achv = sourcearchive.SourceArchive(bctx)
achv.fetch(interactive=False)
achv.unpack(cleanDir=True)
del achv
@@ -92,18 +94,18 @@ class ArchiveFileTestCase(unittest.TestCase):
def testUnpackZipCond(self):
ctx = context.BuildContext("tests/sandbox/pspec.xml")
url = uri.URI(ctx.spec.source.archiveUri)
targetDir = ctx.pkg_work_dir()
bctx = BuildContext("tests/sandbox/pspec.xml")
url = uri.URI(bctx.spec.source.archiveUri)
targetDir = bctx.pkg_work_dir()
filePath = join(config.archives_dir(), url.filename())
# check cached
if util.sha1_file(filePath) != ctx.spec.source.archiveSHA1:
fetch = fetcher.Fetcher(ctx.spec.source.archiveUri, targetDir)
if util.sha1_file(filePath) != bctx.spec.source.archiveSHA1:
fetch = fetcher.Fetcher(bctx.spec.source.archiveUri, targetDir)
fetch.fetch()
assert ctx.spec.source.archiveType == "zip"
assert bctx.spec.source.archiveType == "zip"
achv = archive.Archive(filePath, ctx.spec.source.archiveType)
achv = archive.Archive(filePath, bctx.spec.source.archiveType)
achv.unpack_files(["sandbox/loremipsum.txt"], targetDir)
assert pathexists(targetDir + "/sandbox")
testfile = targetDir + "/sandbox/loremipsum.txt"
+6 -1
View File
@@ -10,11 +10,13 @@
import unittest
from pisi.constants import const
import pisi.context as ctx
class ContextTestCase(unittest.TestCase):
def testConstness(self):
const = ctx.const
# test if we can get a const attribute?
try:
test = const.package_prefix
@@ -46,6 +48,8 @@ class ContextTestCase(unittest.TestCase):
pass
def testConstValues(self):
const = ctx.const
constDict = {
"actions_file": "actions.py",
"setup_func": "setup",
@@ -59,4 +63,5 @@ class ContextTestCase(unittest.TestCase):
else:
self.fail("Constants does not have an attribute named %s" % k)
suite = unittest.makeSuite(ContextTestCase)
+10 -6
View File
@@ -11,17 +11,21 @@
import unittest
import os
import pisi.context as ctx
import pisi.api
from pisi.specfile import SpecFile
from pisi import fetcher
from pisi import util
from pisi import context
from pisi import config
from pisi import uri
class FetcherTestCase(unittest.TestCase):
def setUp(self):
self.ctx = context.BuildContext("tests/popt/pspec.xml")
self.url = uri.URI(self.ctx.spec.source.archiveUri)
self.destpath = config.config.archives_dir()
pisi.api.init()
self.spec = SpecFile()
self.spec.read("tests/popt/pspec.xml")
self.url = uri.URI(self.spec.source.archiveUri)
self.destpath = ctx.config.archives_dir()
self.fetch = fetcher.Fetcher(self.url, self.destpath)
def testFetch(self):
@@ -29,6 +33,6 @@ class FetcherTestCase(unittest.TestCase):
fetchedFile = os.path.join(self.destpath, self.url.filename())
if os.access(fetchedFile, os.R_OK):
self.assertEqual(util.sha1_file(fetchedFile),
self.ctx.spec.source.archiveSHA1)
self.spec.source.archiveSHA1)
suite = unittest.makeSuite(FetcherTestCase)
+2 -2
View File
@@ -16,10 +16,10 @@ from pisi.config import config
class GraphTestCase(unittest.TestCase):
def setUp(self):
self.g0 = graph.digraph()
self.g0 = graph.Digraph()
self.g0.from_list([ (1,2), (1,3), (2,3), (3,4), (4, 5), (4,1)])
self.g1 = graph.digraph()
self.g1 = graph.Digraph()
self.g1.from_list([ (0,2), (0,3), (3,4), (2,4), (0,5), (5,4) ])
def testCycle(self):
+15 -13
View File
@@ -11,29 +11,31 @@
import unittest
import os
from pisi.installdb import installdb
import pisi.context as ctx
import pisi.api
import pisi.installdb
from pisi import util
from pisi.config import config
class InstallDBTestCase(unittest.TestCase):
def setUp(self):
pass
pisi.api.init()
self.installdb = ctx.installdb
def testRemoveDummy(self):
installdb.remove('installtest')
self.assert_(not installdb.is_installed('installtest'))
self.installdb.remove('installtest')
self.assert_(not self.installdb.is_installed('installtest'))
def testInstall(self):
installdb.purge('installtest')
installdb.install('installtest', '0.1', '2', '3')
self.installdb.purge('installtest')
self.installdb.install('installtest', '0.1', '2', '3')
def testRemovePurge(self):
installdb.install('installtest', '0.1', '2', '3')
self.assert_(installdb.is_installed('installtest'))
installdb.remove('installtest')
self.assert_(installdb.is_removed('installtest'))
installdb.purge('installtest')
self.assert_(not installdb.is_recorded('installtest'))
self.installdb.install('installtest', '0.1', '2', '3')
self.assert_(self.installdb.is_installed('installtest'))
self.installdb.remove('installtest')
self.assert_(self.installdb.is_removed('installtest'))
self.installdb.purge('installtest')
self.assert_(not self.installdb.is_recorded('installtest'))
suite = unittest.makeSuite(InstallDBTestCase)
+1 -1
View File
@@ -36,7 +36,7 @@ class MetaDataTestCase(unittest.TestCase):
def testVerify(self):
md = self.testRead()
if not md.verify():
if md.has_errors():
self.fail("Couldn't verify!")
+9 -3
View File
@@ -11,19 +11,25 @@
import unittest
import os
import pisi.context as ctx
import pisi.api
from pisi.packagedb import PackageDB
from pisi import util
from pisi import context
from pisi.specfile import SpecFile
class PackageDBTestCase(unittest.TestCase):
def setUp(self):
# setUp will be called for each test individually
self.ctx = context.BuildContext('tests/popt/pspec.xml')
pisi.api.init()
self.spec = SpecFile()
self.spec.read('tests/popt/pspec.xml')
self.pdb = PackageDB('testdb')
def testAdd(self):
self.pdb.add_package(self.ctx.spec.packages[0])
self.pdb.add_package(self.spec.packages[0])
self.assert_(self.pdb.has_package('popt-libs'))
# close the database and remove lock
del self.pdb
+1 -1
View File
@@ -21,7 +21,7 @@ runTestSuite = lambda(x): unittest.TextTestRunner(verbosity=2).run(x)
def run_all():
import utiltests
import xmlfile
import xmlfiletests
import specfiletests
import metadatatests
import constantstests
+2 -1
View File
@@ -8,6 +8,8 @@
<Source>
<Name>sandbox</Name>
<Homepage>http://cekirdek.uludag.org.tr/</Homepage>
<Summary lang="tr">Test packati</Summary>
<Description lang="tr">Sandbox: Test paketi...</Description>
<Packager>
<Name>A. Murat Eren</Name>
<Email>meren@uludag.org.tr</Email>
@@ -27,7 +29,6 @@
<Package>
<Name>sandbox</Name>
<Summary lang="tr">Bla</Summary>
<Category>temprorary:zip</Category>
<Files>
<File>
+13 -7
View File
@@ -11,22 +11,28 @@
import unittest
import os
from pisi.sourcedb import sourcedb
import pisi.context as ctx
import pisi.api
import pisi.sourcedb
from pisi import util
from pisi import context
from pisi.specfile import SpecFile
class SourceDBTestCase(unittest.TestCase):
def setUp(self):
self.ctx = context.BuildContext("tests/popt/pspec.xml")
pisi.api.init()
self.sourcedb = pisi.sourcedb.init()
self.spec = SpecFile()
self.spec.read("tests/popt/pspec.xml")
def testAdd(self):
sourcedb.add_source(self.ctx.spec.source)
self.assert_(sourcedb.has_source("popt"))
self.sourcedb.add_source(self.spec.source)
self.assert_(self.sourcedb.has_source("popt"))
def testRemove(self):
self.testAdd()
sourcedb.remove_source("popt")
self.assert_(not sourcedb.has_source("popt"))
self.sourcedb.remove_source("popt")
self.assert_(not self.sourcedb.has_source("popt"))
suite = unittest.makeSuite(SourceDBTestCase)