From a1ddfe8c80cda1866ec704f7218f006f59045a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20A=C5=9F=C4=B1c=C4=B1?= Date: Sat, 19 Jun 2010 14:28:50 +0000 Subject: [PATCH] Change package format to use XZ compression Version of the new package format is 1.2. Delta support is not ready yet. --- pisi/archive.py | 3 ++- pisi/constants.py | 3 +++ pisi/operations/build.py | 23 ++++++++++++++++------- pisi/package.py | 18 ++++++++++++++---- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/pisi/archive.py b/pisi/archive.py index ce64f9c7..cdf3a88b 100644 --- a/pisi/archive.py +++ b/pisi/archive.py @@ -463,7 +463,8 @@ class ArchiveZip(ArchiveBase): self.zip_obj.writestr(attr, dest) else: comp_type = zipfile.ZIP_DEFLATED - if file_name.endswith(ctx.const.lzma_suffix): + if file_name.endswith((ctx.const.lzma_suffix, + ctx.const.xz_suffix)): comp_type = zipfile.ZIP_STORED self.zip_obj.write(file_name, arc_name, comp_type) diff --git a/pisi/constants.py b/pisi/constants.py index 5cf9e9ad..e357f289 100644 --- a/pisi/constants.py +++ b/pisi/constants.py @@ -53,6 +53,8 @@ class Constants: # suffix for lzma self.__c.lzma_suffix = ".lzma" + # suffix for xz + self.__c.xz_suffix = ".xz" self.__c.partial_suffix = ".part" @@ -87,6 +89,7 @@ class Constants: self.__c.metadata_xml = "metadata.xml" self.__c.install_tar = "install.tar" self.__c.install_tar_lzma = "install.tar.lzma" + self.__c.install_tar_xz = "install.tar.xz" self.__c.mirrors_conf = "/etc/pisi/mirrors.conf" self.__c.sandbox_conf = "/etc/pisi/sandbox.conf" self.__c.blacklist = "/etc/pisi/blacklist" diff --git a/pisi/operations/build.py b/pisi/operations/build.py index 6eee4b4c..00fd73e9 100644 --- a/pisi/operations/build.py +++ b/pisi/operations/build.py @@ -166,8 +166,8 @@ class Builder: """Provides the package build and creation routines""" #FIXME: this class and every other class must use URLs as paths! - package_formats = ("1.0", "1.1") - default_package_format = "1.1" + package_formats = ("1.0", "1.1", "1.2") + default_package_format = "1.2" @staticmethod def from_name(name): @@ -1122,19 +1122,28 @@ class Builder: orgname = util.join_path("debug", finfo.path) pkg.add_to_package(orgname, arcname) pkg.close() - else: # default package format is 1.1, so make it fallback. + else: + if self.target_package_format == "1.1": + archive_format = "tarlzma" + archive_suffix = ctx.const.lzma_suffix + else: + archive_format = "tarxz" + archive_suffix = ctx.const.xz_suffix + + archive_name = ctx.const.install_tar + archive_suffix + ctx.build_leftover = util.join_path(self.pkg_dir(), - ctx.const.install_tar_lzma) - tar = archive.ArchiveTar(ctx.const.install_tar_lzma, "tarlzma") + archive_name) + tar = archive.ArchiveTar(archive_name, archive_format) for finfo in files.list: orgname = util.join_path("install", finfo.path) if package.debug_package: orgname = util.join_path("debug", finfo.path) tar.add_to_archive(orgname, finfo.path) tar.close() - pkg.add_to_package(ctx.const.install_tar_lzma) + pkg.add_to_package(archive_name) pkg.close() - os.unlink(ctx.const.install_tar_lzma) + os.unlink(archive_name) ctx.build_leftover = None os.chdir(c) diff --git a/pisi/package.py b/pisi/package.py index 9413f604..11c9c941 100644 --- a/pisi/package.py +++ b/pisi/package.py @@ -119,10 +119,20 @@ class Package: ctx.ui.notify(pisi.ui.desktopfile, desktopfile=tarinfo.name) - if self.impl.has_file(ctx.const.install_tar_lzma): - lzmafile = self.impl.open(ctx.const.install_tar_lzma) - tar = archive.ArchiveTar(fileobj=lzmafile, - arch_type="tarlzma", + # TODO: Read metadata to get package format + + archive_name = None + if self.impl.has_file(ctx.const.install_tar_xz): + archive_name = ctx.const.install_tar_xz + archive_format = "tarxz" + elif self.impl.has_file(ctx.const.install_tar_lzma): + archive_name = ctx.const.install_tar_lzma + archive_format = "tarlzma" + + if archive_name: + archive_file = self.impl.open(archive_name) + tar = archive.ArchiveTar(fileobj=archive_file, + arch_type=archive_format, no_same_permissions=False, no_same_owner=False) tar.unpack_dir(outdir, callback=callback)