* fix: make destdir work

* fix: we have to use a fixx0red copy of os.path.join at places
This commit is contained in:
Eray Özkural
2005-10-09 16:42:37 +00:00
parent 9de9ad4da9
commit ded712dc74
7 changed files with 32 additions and 16 deletions
+3 -3
View File
@@ -103,9 +103,9 @@ class BuildContext(object):
"package build directory" "package build directory"
packageDir = self.spec.source.name + '-' + \ packageDir = self.spec.source.name + '-' + \
self.spec.source.version + '-' + self.spec.source.release self.spec.source.version + '-' + self.spec.source.release
from pisi.util import join_path as join
return ctx.config.destdir + ctx.config.values.dirs.tmp_dir \ return join( ctx.config.destdir(), ctx.config.values.dirs.tmp_dir,
+ '/' + packageDir packageDir )
def pkg_work_dir(self): def pkg_work_dir(self):
return self.pkg_dir() + ctx.const.work_dir_suffix return self.pkg_dir() + ctx.const.work_dir_suffix
+13 -7
View File
@@ -24,6 +24,7 @@ _ = __trans.ugettext
import pisi import pisi
import pisi.context as ctx import pisi.context as ctx
from pisi.configfile import ConfigurationFile from pisi.configfile import ConfigurationFile
from pisi.util import join_path as join
class Config(object): class Config(object):
"""Config Singleton""" """Config Singleton"""
@@ -31,7 +32,6 @@ class Config(object):
def __init__(self, options = None): def __init__(self, options = None):
self.options = options self.options = options
self.values = ConfigurationFile("/etc/pisi/pisi.conf") self.values = ConfigurationFile("/etc/pisi/pisi.conf")
self.destdir = self.values.general.destinationdirectory
def get_option(self, opt): def get_option(self, opt):
if self.options: if self.options:
@@ -44,23 +44,29 @@ class Config(object):
# x_dir: system wide directory for storing info type x # x_dir: system wide directory for storing info type x
# pkg_x_dir: per package directory for storing info type x # pkg_x_dir: per package directory for storing info type x
def destdir(self):
dir = str(self.get_option('destdir'))
if not dir:
dir = self.values.general.destinationdirectory
return dir
def lib_dir(self): def lib_dir(self):
return self.destdir + self.values.dirs.lib_dir return join(self.destdir(), self.values.dirs.lib_dir)
def db_dir(self): def db_dir(self):
return self.destdir + self.values.dirs.db_dir return join(self.destdir(), self.values.dirs.db_dir)
def archives_dir(self): def archives_dir(self):
return self.destdir + self.values.dirs.archives_dir return join(self.destdir(), self.values.dirs.archives_dir)
def packages_dir(self): def packages_dir(self):
return self.destdir + self.values.dirs.packages_dir return join(self.destdir(), self.values.dirs.packages_dir)
def index_dir(self): def index_dir(self):
return self.destdir + self.values.dirs.index_dir return join(self.destdir(), self.values.dirs.index_dir)
def tmp_dir(self): def tmp_dir(self):
return self.destdir + self.values.dirs.tmp_dir return join(self.destdir(), self.values.dirs.tmp_dir)
# bu dizini neden kullanıyoruz? Yalnızca index.py içerisinde # bu dizini neden kullanıyoruz? Yalnızca index.py içerisinde
# kullanılıyor ama /var/tmp/pisi/install gibi bir dizine niye # kullanılıyor ama /var/tmp/pisi/install gibi bir dizine niye
+1 -1
View File
@@ -153,7 +153,7 @@ class Installer:
"unzip package in place" "unzip package in place"
ctx.ui.info(_('Extracting files')) ctx.ui.info(_('Extracting files'))
self.package.extract_dir_flat('install', ctx.config.destdir) self.package.extract_dir_flat('install', ctx.config.destdir())
if self.reinstall: if self.reinstall:
# remove left over files # remove left over files
+2 -3
View File
@@ -73,13 +73,12 @@ class InstallInfo:
class InstallDB: class InstallDB:
def __init__(self): def __init__(self):
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')
self.files_dir = os.path.join(ctx.config.db_dir(), 'files') self.files_dir = pisi.util.join_path(ctx.config.db_dir(), 'files')
def files_name(self, pkg, version, release): def files_name(self, pkg, version, release):
from os.path import join from pisi.util import join_path as join
pkg_dir = join(ctx.config.lib_dir(), pkg + '-' + version + '-' + release) pkg_dir = join(ctx.config.lib_dir(), pkg + '-' + version + '-' + release)
return join(pkg_dir, ctx.const.files_xml) return join(pkg_dir, ctx.const.files_xml)
+1 -1
View File
@@ -29,7 +29,7 @@ import pisi.comariface as comariface
# remove stuff # remove stuff
def remove_file(fileinfo): def remove_file(fileinfo):
fpath = os.path.join(ctx.config.destdir, fileinfo.path) fpath = pisi.util.join_path(ctx.config.destdir(), fileinfo.path)
# TODO: We have to store configuration files for futher # TODO: We have to store configuration files for futher
# usage. Currently we'are doing it like rpm does, saving # usage. Currently we'are doing it like rpm does, saving
# with a prefix and leaving the user to edit it. In the future # with a prefix and leaving the user to edit it. In the future
+1 -1
View File
@@ -115,4 +115,4 @@ class Package:
return join( ctx.config.lib_dir(), packageDir) return join( ctx.config.lib_dir(), packageDir)
def comar_dir(self): def comar_dir(self):
return self.pkg_dir() + ctx.const.comar_dir_suffix return join(self.pkg_dir(), ctx.const.comar_dir_suffix)
+11
View File
@@ -191,6 +191,17 @@ def absolute_path(path):
comps = splitpath(path) comps = splitpath(path)
return comps[0] == '' return comps[0] == ''
def join_path(a, *p):
"""Join two or more pathname components, inserting '/' as needed"""
"""The python original version has a silly logic"""
path = a
for b in p:
if path == '' or path.endswith('/'):
path += b
else:
path += '/' + b
return path
#################################### ####################################
# File/Directory Related Functions # # File/Directory Related Functions #
#################################### ####################################