config: Let --destdir= parameter work again

This is another regression introduced after the Config class became
a Singleton.
This commit is contained in:
Fatih Aşıcı
2010-05-21 13:16:46 +00:00
parent d5e2978733
commit f817c21ace
+16 -14
View File
@@ -49,19 +49,6 @@ class Config(object):
self.set_options(options)
self.values = pisi.configfile.ConfigurationFile("/etc/pisi/pisi.conf")
destdir = self.get_option('destdir')
if destdir:
if destdir.strip().startswith('/'):
self.destdir = destdir
else:
self.destdir = pisi.util.join_path(os.getcwd(), destdir)
else:
self.destdir = self.values.general.destinationdirectory
if not os.path.exists(self.destdir):
ctx.ui.warning( _('Destination directory %s does not exist. Creating it.') % self.destdir)
os.makedirs(self.destdir)
# get the initial environment variables. this is needed for
# build process.
self.environ = copy.deepcopy(os.environ)
@@ -69,6 +56,9 @@ class Config(object):
def set_options(self, options):
self.options = options
# Reset __dest_dir to re-read from options
self.__dest_dir = None
def set_option(self, opt, val):
setattr(self.options, opt, val)
@@ -84,7 +74,19 @@ class Config(object):
# pkg_x_dir: per package directory for storing info type x
def dest_dir(self):
return self.destdir
if self.__dest_dir is None:
destdir = self.get_option('destdir')
if destdir:
self.__dest_dir = os.path.abspath(destdir)
else:
self.__dest_dir = self.values.general.destinationdirectory
if not os.path.exists(self.__dest_dir):
ctx.ui.warning(_("Destination directory %s does not exist. "
"Creating it.") % self.__dest_dir)
os.makedirs(self.__dest_dir)
return self.__dest_dir
def subdir(self, path):
subdir = pisi.util.join_path(self.dest_dir(), path)