From 76e1f27bf103ad845ce0044d039b32a3bb434fdb Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Fri, 2 Jun 2006 20:45:47 +0000 Subject: [PATCH] .lzma, install.tar, install.tar.lzma strings to constants. --- pisi/archive.py | 9 +++++---- pisi/build.py | 8 ++++---- pisi/constants.py | 5 +++++ pisi/package.py | 6 +++--- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/pisi/archive.py b/pisi/archive.py index deeec989..f47c74ab 100644 --- a/pisi/archive.py +++ b/pisi/archive.py @@ -91,8 +91,9 @@ class ArchiveTar(ArchiveBase): rmode = 'r:bz2' elif self.type == 'tarlzma': rmode = 'r:' - self.file_path = self.file_path.rstrip('.lzma') - ret, out, err = util.run_batch("lzma d %s %s" % (self.file_path + '.lzma', self.file_path)) + self.file_path = self.file_path.rstrip(ctx.const.lzma_suffix) + ret, out, err = util.run_batch("lzma d %s %s" % (self.file_path + ctx.const.lzma_suffix, + self.file_path)) if ret != 0: #FIXME: see bug #2836 raise LZMAError(out) @@ -103,7 +104,7 @@ class ArchiveTar(ArchiveBase): oldwd = os.getcwd() os.chdir(target_dir) - install_tar_path = util.join_path(ctx.config.tmp_dir(), "install.tar") + install_tar_path = util.join_path(ctx.config.tmp_dir(), ctx.const.install_tar) for tarinfo in self.tar: # Installing packages (especially shared libraries) is a # bit tricky. You should also change the inode if you @@ -137,7 +138,7 @@ class ArchiveTar(ArchiveBase): wmode = 'w:bz2' elif self.type == 'tarlzma': wmode = 'w:' - self.file_path = self.file_path.rstrip('.lzma') + self.file_path = self.file_path.rstrip(ctx.const.lzma_suffix) else: raise ArchiveError(_("Archive type not recognized")) self.tar = tarfile.open(self.file_path, wmode) diff --git a/pisi/build.py b/pisi/build.py index 51df491d..805c6d05 100644 --- a/pisi/build.py +++ b/pisi/build.py @@ -814,17 +814,17 @@ class Builder: pkg.add_to_package(orgname, arcname) pkg.close() else: # default package format is 1.1, so make it fallback. - ctx.build_leftover = join(self.pkg_dir(), "install.tar.lzma") - tar = archive.ArchiveTar("install.tar.lzma", "tarlzma") + ctx.build_leftover = join(self.pkg_dir(), ctx.const.install_tar_lzma) + tar = archive.ArchiveTar(ctx.const.install_tar_lzma, "tarlzma") for finfo in files.list: orgname = arcname = join("install", finfo.path) if package.debug_package: orgname = join("debug", finfo.path) tar.add_to_archive(orgname, arcname.lstrip("install")) tar.close() - pkg.add_to_package("install.tar.lzma") + pkg.add_to_package(ctx.const.install_tar_lzma) pkg.close() - os.unlink("install.tar.lzma") + os.unlink(ctx.const.install_tar_lzma) ctx.build_leftover = None os.chdir(c) diff --git a/pisi/constants.py b/pisi/constants.py index 5ff479be..1e29d64f 100644 --- a/pisi/constants.py +++ b/pisi/constants.py @@ -49,6 +49,9 @@ class Constants: self.__c.package_suffix = ".pisi" self.__c.xdelta_suffix = ".xdelta" + # suffix for lzma + self.__c.lzma_suffix = ".lzma" + # suffix for auto generated debug packages self.__c.debug_name_suffix = "-debug" self.__c.debug_file_suffix = ".debug" @@ -74,6 +77,8 @@ class Constants: self.__c.comar_dir = "comar" self.__c.files_xml = "files.xml" self.__c.metadata_xml = "metadata.xml" + self.__c.install_tar = "install.tar" + self.__c.install_tar_lzma = "install.tar.lzma" # functions in actions_file self.__c.setup_func = "setup" diff --git a/pisi/package.py b/pisi/package.py index ebe89794..fffde9d6 100644 --- a/pisi/package.py +++ b/pisi/package.py @@ -118,9 +118,9 @@ class Package: self.impl.unpack_dir(dir, outdir) def extract_install(self, outdir): - if self.impl.has_file('install.tar.lzma'): - self.extract_file('install.tar.lzma', ctx.config.tmp_dir()) - tar = archive.ArchiveTar(join(ctx.config.tmp_dir(), 'install.tar.lzma'), 'tarlzma') + if self.impl.has_file(ctx.const.install_tar_lzma): + self.extract_file(ctx.const.install_tar_lzma, ctx.config.tmp_dir()) + tar = archive.ArchiveTar(join(ctx.config.tmp_dir(), ctx.const.install_tar_lzma), 'tarlzma') tar.unpack_dir(outdir) else: self.extract_dir_flat('install', outdir)