Пример #1
0
 def _apply_whiteouts(self, tarf, destdir):
     """The layered filesystem of docker uses whiteout files
     to identify files or directories to be removed.
     The format is .wh.<filename>
     """
     verbose = ""
     if Msg.level >= Msg.VER:
         verbose = 'v'
         Msg().out("Info: applying whiteouts:", tarf, l=Msg.INF)
     wildcards = [
         "--wildcards",
     ]
     if not HostInfo().cmd_has_option("tar", wildcards[0]):
         wildcards = []
     cmd = ["tar", "t" + verbose] + wildcards + ["-f", tarf, r"*/.wh.*"]
     whiteouts = Uprocess().get_output(cmd, True)
     if not whiteouts:
         return
     for wh_filename in whiteouts.split('\n'):
         if wh_filename:
             wh_basename = os.path.basename(wh_filename.strip())
             wh_dirname = os.path.dirname(wh_filename)
             if wh_basename == ".wh..wh..opq":
                 if not os.path.isdir(destdir + '/' + wh_dirname):
                     continue
                 for f_name in os.listdir(destdir + '/' + wh_dirname):
                     rm_filename = destdir + '/' \
                         + wh_dirname + '/' + f_name
                     FileUtil(rm_filename).remove(recursive=True)
             elif wh_basename.startswith(".wh."):
                 rm_filename = destdir + '/' \
                     + wh_dirname + '/' \
                     + wh_basename.replace(".wh.", "", 1)
                 FileUtil(rm_filename).remove(recursive=True)
     return
Пример #2
0
 def _get_ld_config(self):
     """Get get directories from container ld.so.cache"""
     cmd = ["ldconfig", "-p", "-C", "%s/%s" % \
            (self._container_root, Config.conf['ld_so_cache']), ]
     ld_dict = dict()
     ld_data = Uprocess().get_output(cmd)
     if not ld_data:
         return []
     for line in ld_data.split('\n'):
         match = re.search("([^ ]+) => ([^ ]+)", line)
         if match:
             ld_dict[self._container_root + \
                     os.path.dirname(match.group(2))] = True
     return list(ld_dict.keys())
Пример #3
0
 def _find_host_dir_ldconfig(self, arch="x86-64"):
     """Find host nvidia libraries via ldconfig"""
     dir_list = set()
     ld_data = Uprocess().get_output(["ldconfig", "-p"])
     if ld_data:
         regexp = "[ |\t]%s[^ ]* .*%s.*=> (/.*)"
         for line in ld_data.split('\n'):
             for lib in self._nvidia_main_libs:
                 match = re.search(regexp % (lib, arch), line)
                 if match:
                     dir_list.add(
                         os.path.realpath(os.path.dirname(match.group(1))) +
                         '/')
     Msg().out("Info: List nvidia libs via ldconfig", dir_list, l=Msg.DBG)
     return dir_list