From e2df90ae070128ca4383211f7df641762a41a549 Mon Sep 17 00:00:00 2001 From: "A. Murat Eren" Date: Sun, 16 Apr 2006 22:26:05 +0000 Subject: [PATCH] fixex #2559 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --create-debug opsiyonu ile build esnasında oluşturulacak debug dosyaları on-the-fly oluşturulan bir PAKET-debug.pisi paketine doldurulacak. sonra oynarsınız onla işte. daha sonra tekrar dönülüp temizlenecek bir iki FIXME var kod içerisinde, hemen kızmayın ;) --- pisi/build.py | 42 ++++++++++++++++++++++++++++++++++++++---- pisi/cli/commands.py | 4 +++- pisi/constants.py | 6 +++++- pisi/util.py | 8 ++++---- 4 files changed, 50 insertions(+), 10 deletions(-) diff --git a/pisi/build.py b/pisi/build.py index 4a9e84a5..6aa5799c 100644 --- a/pisi/build.py +++ b/pisi/build.py @@ -75,8 +75,9 @@ def check_path_collision(package, pkgList): # collide. Exp: # pinfo.path: /usr/share # path.path: /usr/share/doc - if path.path.endswith(ctx.const.ar_file_suffix) and ctx.get_option('create_static'): - # don't throw collision error for ar files. + if (path.path.endswith(ctx.const.ar_file_suffix) and ctx.get_option('create_static')) or \ + (path.path.endswith(ctx.const.debug_file_suffix) and ctx.get_option('create_debug')): + # don't throw collision error for these files. # we'll handle this in gen_files_xml.. continue if util.subpath(pinfo.path, path.path): @@ -488,6 +489,28 @@ class Builder: return static_package_obj + def generate_debug_package_object(self): + debug_files = [] + for root, dirs, files in os.walk(self.pkg_install_dir()): + for f in files: + if f.endswith(ctx.const.debug_file_suffix): + debug_files.append(util.join_path(root, f)) + + if not len(debug_files): + return None + + static_package_obj = pisi.specfile.Package() + static_package_obj.name = self.spec.source.name + ctx.const.debug_name_suffix + # FIXME: find a better way to deal with the summary and description constants. + static_package_obj.summary['en'] = u'Debug files for %s' % (self.spec.source.name) + static_package_obj.description['en'] = u'Debug files for %s' % (self.spec.source.name) + static_package_obj.partOf = 'library:debug' + for f in debug_files: + static_package_obj.files.append(pisi.specfile.Path(path = f[len(self.pkg_install_dir()):], fileType = "debug")) + static_package_obj.packageDependencies.append(pisi.dependency.Dependency(package = self.spec.source.name)) + + return static_package_obj + def strip_install_dir(self): """strip install directory""" ctx.ui.action(_("Stripping files..")) @@ -555,11 +578,17 @@ class Builder: def add_path(path): # add the files under material path for fpath, fhash in util.get_file_hashes(path, collisions, install_dir): - if ctx.get_option('create_static') \ + if ctx.get_option('create_static') \ and fpath.endswith(ctx.const.ar_file_suffix) \ and not package.name.endswith(ctx.const.static_name_suffix) \ and util.is_ar_file(fpath): - # if this is an ar file, and this package is not a -static package, + # if this is an ar file, and this package is not a static package, + # don't include this file into the package. + continue + if ctx.get_option('create_debug') \ + and fpath.endswith(ctx.const.debug_file_suffix) \ + and not package.name.endswith(ctx.const.debug_name_suffix): + # if this is a debug file, and this package is not a debug package, # don't include this file into the package. continue frpath = util.removepathprefix(install_dir, fpath) # relative path @@ -672,6 +701,11 @@ class Builder: if obj: self.spec.packages.append(obj) + if ctx.get_option('create_debug'): + obj = self.generate_debug_package_object() + if obj: + self.spec.packages.append(obj) + package_names = [] old_package_names = [] diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index 94d2376d..c1a385b7 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -361,7 +361,9 @@ unpack, setup, build, install, package self.parser.add_option("-B", "--ignore-comar", action="store_true", default=False, help=_("bypass comar configuration agent")) self.parser.add_option("-S", "--create-static", action="store_true", - default=False, help=_("automatically create a *-static package with ar files")) + default=False, help=_("automatically create a static package with ar files")) + self.parser.add_option("-g", "--create-debug", action="store_true", + default=False, help=_("automatically create a debug package with debug files")) def run(self): diff --git a/pisi/constants.py b/pisi/constants.py index 5a0e5f00..b25ae03a 100644 --- a/pisi/constants.py +++ b/pisi/constants.py @@ -49,9 +49,13 @@ class Constants: self.__c.package_suffix = ".pisi" self.__c.xdelta_suffix = ".xdelta" + # suffix for auto generated debug packages + self.__c.debug_name_suffix = "-debug" + self.__c.debug_file_suffix = ".debug" + # suffix for auto generated ar packages self.__c.static_name_suffix = "-static" # an admissible use of constant - self.__c.ar_file_suffix = ".a" + self.__c.ar_file_suffix = ".a" # directory suffixes for build self.__c.work_dir_suffix = "/work" # these, too, because we might wanna change 'em diff --git a/pisi/util.py b/pisi/util.py index 239a38a4..cd14e3af 100644 --- a/pisi/util.py +++ b/pisi/util.py @@ -525,13 +525,13 @@ def strip_file(filepath): def save_elf_debug(f): """copy debug info into file.debug file""" - p = os.popen("objcopy --only-keep-debug %s %s.debug" % (f, f)) + p = os.popen("objcopy --only-keep-debug %s %s%s" % (f, f, ctx.const.debug_file_suffix)) ret = p.close() if ret: ctx.ui.warning(_("objcopy (keep-debug) command failed for file '%s'!") % f) """mark binary/shared objects to use file.debug""" - p = os.popen("objcopy --add-gnu-debuglink=%s.debug %s" % (f, f)) + p = os.popen("objcopy --add-gnu-debuglink=%s%s %s" % (f, ctx.const.debug_file_suffix, f)) ret = p.close() if ret: ctx.ui.warning(_("objcopy (add-debuglink) command failed for file '%s'!") % f) @@ -541,13 +541,13 @@ def strip_file(filepath): return True elif "SB executable" in o: - if ctx.config.values.build.debug == "True": + if ctx.get_option('create_debug'): save_elf_debug(filepath) run_strip(filepath) return True elif "SB shared object" in o: - if ctx.config.values.build.debug == "True": + if ctx.get_option('create_debug'): save_elf_debug(filepath) run_strip(filepath, "--strip-unneeded") # FIXME: warn for TEXTREL