[csw-devel] SF.net SVN: gar:[20153] csw/mgar/gar/v2/lib/python

chninkel at users.sourceforge.net chninkel at users.sourceforge.net
Thu Jan 17 09:20:17 CET 2013


Revision: 20153
          http://gar.svn.sourceforge.net/gar/?rev=20153&view=rev
Author:   chninkel
Date:     2013-01-17 08:20:15 +0000 (Thu, 17 Jan 2013)
Log Message:
-----------
gar/v2: fixed binary dump info retrieval for relocatable packages

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/inspective_package.py
    csw/mgar/gar/v2/lib/python/inspective_package_test.py

Modified: csw/mgar/gar/v2/lib/python/inspective_package.py
===================================================================
--- csw/mgar/gar/v2/lib/python/inspective_package.py	2013-01-17 07:35:51 UTC (rev 20152)
+++ csw/mgar/gar/v2/lib/python/inspective_package.py	2013-01-17 08:20:15 UTC (rev 20153)
@@ -179,21 +179,15 @@
     binaries_dump_info = []
     basedir = self.GetBasedir()
     for binary in self.ListBinaries():
-      # Relocatable packages complicate things. Binaries returns paths with
-      # the basedir, but files in reloc are in paths without the basedir, so
-      # we need to strip that bit.
-      binary_in_tmp_dir = binary
+      binary_abs_path = os.path.join(self.directory, self.GetFilesDir(), binary)
       if basedir:
-        binary_in_tmp_dir = binary_in_tmp_dir[len(basedir):]
-        binary_in_tmp_dir = binary_in_tmp_dir.lstrip("/")
-      binary_abs_path = os.path.join(self.directory, self.GetFilesDir(), binary_in_tmp_dir)
-      binary_base_name = os.path.basename(binary_in_tmp_dir)
+        binary = os.path.join(basedir, binary)
+      binary_base_name = os.path.basename(binary)
+
       args = [common_constants.DUMP_BIN, "-Lv", binary_abs_path]
       retcode, stdout, stderr = shell.ShellCommand(args, env)
       binary_data = ldd_emul.ParseDumpOutput(stdout)
       binary_data["path"] = binary
-      if basedir:
-        binary_data["path"] = os.path.join(basedir, binary_data["path"])
       binary_data["base_name"] = binary_base_name
       binaries_dump_info.append(binary_data)
     return binaries_dump_info

Modified: csw/mgar/gar/v2/lib/python/inspective_package_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/inspective_package_test.py	2013-01-17 07:35:51 UTC (rev 20152)
+++ csw/mgar/gar/v2/lib/python/inspective_package_test.py	2013-01-17 08:20:15 UTC (rev 20153)
@@ -22,6 +22,53 @@
 \t\t(file /tmp/pkg_GqCk0P/CSWkdeartworkgcc/root/opt/csw/kde-gcc/bin/kslideshow.kss size=0x28; file /opt/csw/kde-gcc/lib/libqt-mt.so.3 size=0x20)
 """
 
+DUMP_OUTPUT = '''
+  **** DYNAMIC SECTION INFORMATION ****
+.dynamic:
+[INDEX] Tag         Value
+[1]     NEEDED          libXext.so.0
+[2]     NEEDED          libX11.so.4
+[3]     NEEDED          libsocket.so.1
+[4]     NEEDED          libnsl.so.1
+[5]     NEEDED          libc.so.1
+[6]     INIT            0x80531e4
+[7]     FINI            0x8053200
+[8]     HASH            0x80500e8
+[9]     STRTAB          0x8050cb0
+[10]    STRSZ           0x511
+[11]    SYMTAB          0x80504e0
+[12]    SYMENT          0x10
+[13]    CHECKSUM        0x9e8
+[14]    VERNEED         0x80511c4
+[15]    VERNEEDNUM      0x2
+[16]    PLTSZ           0x1a0
+[17]    PLTREL          0x11
+[18]    JMPREL          0x8051224
+[19]    REL             0x8051214
+[20]    RELSZ           0x1b0
+[21]    RELENT          0x8
+[22]    DEBUG           0
+[23]    FEATURE_1       PARINIT
+[24]    FLAGS           0
+[25]    FLAGS_1         0
+[26]    PLTGOT          0x806359c
+'''
+
+BINARY_DUMP_INFO = {
+  'base_name': 'foo',
+  'RUNPATH RPATH the same': True,
+  'runpath': (),
+  'RPATH set': False,
+  'needed sonames': (
+    'libXext.so.0',
+    'libX11.so.4',
+    'libsocket.so.1',
+    'libnsl.so.1',
+    'libc.so.1'),
+  'path': 'opt/csw/bin/foo',
+  'RUNPATH set': False,
+  }
+
 ELFDUMP_OUTPUT = '''
 Version Definition Section:  .SUNW_version
      index  version                     dependency
@@ -86,6 +133,7 @@
   }
 
 
+
 class InspectivePackageUnitTest(mox.MoxTestBase):
 
   def testListBinaries(self):
@@ -135,6 +183,49 @@
     }
     self.assertEqual([u'foo-file'], ip.ListBinaries())
 
+  def testGetBinaryDumpInfoRoot(self):
+    fake_binary = 'opt/csw/bin/foo'
+    fake_package_path = '/fake/path/CSWfoo'
+
+    ip = inspective_package.InspectivePackage(fake_package_path)
+    self.mox.StubOutWithMock(ip, 'ListBinaries')
+    self.mox.StubOutWithMock(ip, 'GetBasedir')
+    self.mox.StubOutWithMock(ip, 'GetFilesDir')
+    ip.ListBinaries().AndReturn([fake_binary])
+    ip.GetBasedir().AndReturn('')
+    ip.GetFilesDir().AndReturn('root')
+
+    self.mox.StubOutWithMock(shell, 'ShellCommand')
+    args = [common_constants.DUMP_BIN,
+            '-Lv',
+            os.path.join(fake_package_path, "root", fake_binary)]
+    shell.ShellCommand(args, mox.IgnoreArg()).AndReturn((0, DUMP_OUTPUT, ""))
+    self.mox.ReplayAll()
+
+    self.assertEqual([BINARY_DUMP_INFO], ip.GetBinaryDumpInfo())
+
+  def testGetBinaryDumpInfoReloc(self):
+    fake_binary = 'bin/foo'
+    fake_package_path = '/fake/path/CSWfoo'
+
+    ip = inspective_package.InspectivePackage(fake_package_path)
+    self.mox.StubOutWithMock(ip, 'ListBinaries')
+    self.mox.StubOutWithMock(ip, 'GetBasedir')
+    self.mox.StubOutWithMock(ip, 'GetFilesDir')
+    ip.ListBinaries().AndReturn([fake_binary])
+    ip.GetBasedir().AndReturn('opt/csw')
+    ip.GetFilesDir().AndReturn('reloc')
+
+    self.mox.StubOutWithMock(shell, 'ShellCommand')
+    args = [common_constants.DUMP_BIN,
+            '-Lv',
+            os.path.join(fake_package_path, "reloc", fake_binary)]
+    shell.ShellCommand(args, mox.IgnoreArg()).AndReturn((0, DUMP_OUTPUT, ""))
+    self.mox.ReplayAll()
+
+    self.assertEqual([BINARY_DUMP_INFO], ip.GetBinaryDumpInfo())
+
+
   def testGetBinaryElfInfoRoot(self):
     fake_binary = 'opt/csw/lib/libssl.so.1.0.0'
     fake_package_path = '/fake/path/CSWfoo'

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list