Example #1
0
 def execute(self):
     if 'Installed-Size' not in self.__attrs:
         self.__attrs['Installed-Size'] = math.ceil(
             sum(
                 os.path.getsize(os.path.join(p, f))
                 for p, _, files in os.walk(str(self.__path))
                 for f in files) / 1024)
     with open(str(self.__control.path()), 'w') as f:
         for k, v in self.__attrs.items():
             print('%s: %s' % (k, v), file=f)
     if self.__cleanup_source_directory:
         self.cleanup_source_directory(self.__path)
     os.chmod(str(self.__path / 'DEBIAN'), 0o755)
     os.chmod(str(self.__path / 'DEBIAN/control'), 0o644)
     try:
         os.chmod(str(self.__path / 'DEBIAN/postinst'), 0o755)
     except:
         pass
     env = {
         'PATH': os.environ['PATH'],
     }
     if self.__preload is not None:
         path = drake.path_root() / self.__preload.path()
         env['LD_PRELOAD'] = str(path)
     return self.cmd('Package %s' % self.__target, self.command, env=env)
Example #2
0
 def execute(self):
   if 'Installed-Size' not in self.__attrs:
     self.__attrs['Installed-Size'] = math.ceil(sum(
       os.path.getsize(os.path.join(p, f))
       for p, _, files in os.walk(str(self.__path))
       for f in files) / 1024)
   with open(str(self.__control.path()), 'w') as f:
     for k, v in self.__attrs.items():
       print('%s: %s' % (k, v), file = f)
   if self.__cleanup_source_directory:
     self.cleanup_source_directory(self.__path)
   os.chmod(str(self.__path / 'DEBIAN'), 0o755)
   os.chmod(str(self.__path / 'DEBIAN/control'), 0o644)
   try:
     os.chmod(str(self.__path / 'DEBIAN/postinst'), 0o755)
   except:
     pass
   env = {
     'PATH': os.environ['PATH'],
   }
   if self.__preload is not None:
     path = drake.path_root() / self.__preload.path()
     env['LD_PRELOAD'] = str(path)
   return self.cmd('Package %s' % self.__target,
                   self.command, env = env)
Example #3
0
 def execute(self):
   env = dict(self.__env)
   import os
   env.update(os.environ)
   # Patch
   if self.__patch is not None:
     patch_path = str(drake.path_root() / self.__patch.path())
     patch_cmd = ['patch', '-N', '-p', '1', '-i', patch_path],
     if not self.cmd('Patch %s' % self.work_directory,
                     patch_cmd,
                     cwd = self.work_directory):
       return False
   # Configure step
   if self.__configure is not None:
      if not self.cmd('Configure %s' % self.work_directory,
                      self.command_configure,
                      cwd = self.work_directory,
                      env = env,
                      leave_stdout = self.__configure_stdout):
          return False
   # Build step
   if not self.cmd('Build %s' % self.work_directory,
                   self.command_build,
                   cwd = self.work_directory,
                   env = env,
                   leave_stdout = self.__build_stdout):
     return False
   for target in self.__targets:
     path = target.path().without_prefix(self.work_directory)
     if isinstance(target, drake.cxx.DynLib):
       rpath = '.'
     elif isinstance(target, drake.cxx.Executable):
       rpath = '../lib'
     else:
       continue
     with drake.WritePermissions(target):
       cmd = self.__toolkit.rpath_set_command(target.path(), rpath)
       if self.__toolkit.os is not drake.os.windows:
         if not self.cmd('Fix rpath for %s' % target.path(), cmd):
           return False
       if self.__toolkit.os is drake.os.macos:
         cmd = ['install_name_tool',
                '-id', '@rpath/%s' % target.name().basename(),
                 str(target.path())]
         if not self.cmd('Fix rpath for %s' % target.path(), cmd):
           return False
         lib_dependecies = self.parse_otool_libraries(target.path())
         for dep in lib_dependecies:
           if dep.basename() in (t.path().basename() for t in self.__targets):
             cmd = [
               'install_name_tool',
               '-change',
               str(dep),
               '@rpath/%s' % dep.basename(),
               str(target.path()),
             ]
             if not self.cmd('Fix dependency name for %s' % target.path(), cmd):
               return False
   return True
Example #4
0
 def execute(self):
   os.chmod(str(self.__path / 'DEBIAN'), 0o755)
   os.chmod(str(self.__path / 'DEBIAN/control'), 0o644)
   try:
     os.chmod(str(self.__path / 'DEBIAN/postinst'), 0o755)
   except:
     pass
   env = {}
   if self.__preload is not None:
     path = drake.path_root() / self.__preload.path()
     env['LD_PRELOAD'] = str(path)
   return self.cmd('Package %s' % self.__target,
                   self.command, env = env)
Example #5
0
 def __find_lib(self, lib, lib_path, cxx_toolkit, static):
   # Suffixes
   suffixes = ['-mt', '']
   if static:
     suffixes.append('-mt-s')
     suffixes.append('-s')
   if isinstance(cxx_toolkit, drake.cxx.VisualToolkit):
     suffix = '-vc%s0-mt-%s_%s' % (cxx_toolkit.version,
                                   self.version.major,
                                   self.version.minor)
     suffixes = [suffix] + suffixes
   if cxx_toolkit.os is drake.os.macos:
     suffix = '-%s_%s' % (self.version.major, self.version.minor)
     suffixes = [suffix] + suffixes
   mgw = '-mgw-mt-%s_%s' % (self.version.major, self.version.minor)
   suffixes += [mgw]
   # Variants
   variants = ['']
   if lib == 'thread' and cxx_toolkit.os is drake.os.windows:
     variants.append('_win32')
   if isinstance(lib, str):
     lib = (lib,)
   for lib, suffix, variant in itertools.product(lib, suffixes, variants):
     libname = 'boost_%s%s%s' % (lib, variant, suffix)
     tests = []
     if static:
       filename = cxx_toolkit.libname_static(self.__cfg, libname)
       tests.append(lib_path / filename)
     else:
       filename = cxx_toolkit.libname_dyn(libname, self.__cfg)
       tests.append(lib_path / ('%s.%s' % (filename, self.__version)))
       tests.append(lib_path / filename)
     for test in tests:
       # Look for a node if we build our own boost.
       if test.absolute():
         drake_path = test.without_prefix(drake.path_root())
       else:
         drake_path = test
       node = drake.Drake.current.nodes.get(drake_path, None)
       if node is not None:
         return node
       # Otherwise look on the filesystem.
       if test.exists():
         path = os.path.realpath(str(test))
         if static:
           return drake.cxx.StaticLib(path)
         else:
           return drake.cxx.DynLib(path)
   raise Exception(
     'Unable to find %s Boost %s library in %s' % \
     ('static' if static else 'dynamic', lib, lib_path))
Example #6
0
 def __find_lib(self, lib, lib_path, cxx_toolkit, static):
   # Suffixes
   suffixes = ['-mt', '']
   if static:
     suffixes.append('-mt-s')
     suffixes.append('-s')
   if isinstance(cxx_toolkit, drake.cxx.VisualToolkit):
     suffix = '-vc%s0-mt-%s_%s' % (cxx_toolkit.version,
                                   self.version.major,
                                   self.version.minor)
     suffixes = [suffix] + suffixes
   if cxx_toolkit.os is drake.os.macos:
     suffix = '-%s_%s' % (self.version.major, self.version.minor)
     suffixes = [suffix] + suffixes
   mgw = '-mgw-mt-%s_%s' % (self.version.major, self.version.minor)
   suffixes += [mgw]
   # Variants
   variants = ['']
   if lib == 'thread' and cxx_toolkit.os is drake.os.windows:
     variants.append('_win32')
   if isinstance(lib, str):
     lib = (lib,)
   for lib, suffix, variant in itertools.product(lib, suffixes, variants):
     libname = 'boost_%s%s%s' % (lib, variant, suffix)
     tests = []
     if static:
       filename = cxx_toolkit.libname_static(self.__cfg, libname)
       tests.append(lib_path / filename)
     else:
       filename = cxx_toolkit.libname_dyn(libname, self.__cfg)
       tests.append(lib_path / ('%s.%s' % (filename, self.__version)))
       tests.append(lib_path / filename)
     for test in tests:
       # Look for a node if we build our own boost.
       if test.absolute():
         drake_path = test.without_prefix(drake.path_root())
       else:
         drake_path = test
       node = drake.Drake.current.nodes.get(drake_path, None)
       if node is not None:
         return node
       # Otherwise look on the filesystem.
       if test.exists():
         path = os.path.realpath(str(test))
         if static:
           return drake.cxx.StaticLib(path)
         else:
           return drake.cxx.DynLib(path)
   raise Exception(
     'Unable to find %s Boost %s library in %s' % \
     ('static' if static else 'dynamic', lib, lib_path))
Example #7
0
 def execute(self):
   env = dict(self.__env)
   import os
   env.update(os.environ)
   with drake.CWDPrinter(drake.path_root() / drake.path_build() / self.work_directory):
     # Patch
     if self.__patch is not None:
       patch_path = str(drake.path_root() / self.__patch.path())
       patch_cmd = ['patch', '-N', '-p', '1', '-i', patch_path],
       if not self.cmd('Patch %s' % self.work_directory,
                       patch_cmd,
                       cwd = self.work_directory):
         return False
     # Configure step
     if self.__configure is not None:
        if not self.cmd('Configure %s' % self.work_directory,
                        self.command_configure,
                        cwd = self.work_directory,
                        env = env,
                        leave_stdout = False):
            return False
     # Build step
     if not self.cmd('Build %s' % self.work_directory,
                     self.command_build,
                     cwd = self.work_directory,
                     env = env,
                     leave_stdout = False):
       return False
   for target in self.__targets:
     path = target.path().without_prefix(self.work_directory)
     if isinstance(target, drake.cxx.DynLib):
       rpath = '.'
     elif isinstance(target, drake.cxx.Executable):
       rpath = '../lib'
     else:
       continue
     with drake.WritePermissions(target):
       cmd = self.__toolkit.rpath_set_command(target.path(), rpath)
       if self.__toolkit.os is not drake.os.windows:
         if not self.cmd('Fix rpath for %s' % target.path(), cmd):
           return False
       # On OS X, we ensure that the library id and paths to dependency
       # libraries are correct.
       if self.__toolkit.os is drake.os.macos:
         cmd = ['install_name_tool',
                '-id', '@rpath/%s' % target.name().basename(),
                 str(target.path())]
         if not self.cmd('Fix rpath for %s' % target.path(), cmd):
           return False
         lib_dependecies = self.parse_otool_libraries(target.path())
         for dep in lib_dependecies:
           if dep.basename() in (t.path().basename() for t in self.__targets):
             cmd = [
               'install_name_tool',
               '-change',
               str(dep),
               '@rpath/%s' % dep.basename(),
               str(target.path()),
             ]
             if not self.cmd('Fix dependency name for %s' % target.path(), cmd):
               return False
   return True