(self, tarfiles, destdir)
return status
Untar all container layers. Each layer is extracted
        and permissions are changed to avoid file permission
        issues when extracting the next layer.
Untar all container layers. Each layer is extracted
        and permissions are changed to avoid file permission
        issues when extracting the next layer.
Untar all container layers . Each layer is extracted and permissions are changed to avoid file permission issues when extracting the next layer .
def _untar_layers(self, tarfiles, destdir):
        """Untar all container layers. Each layer is extracted
        and permissions are changed to avoid file permission
        issues when extracting the next layer.
        """
        if not (tarfiles and destdir):
            return False
        status = True
        gid = str(HostInfo.gid)
        optional_flags = ["--wildcards", "--delay-directory-restore", ]
        for option in optional_flags:
            if not HostInfo().cmd_has_option("tar", option):
                optional_flags.remove(option)
        for tarf in tarfiles:
            if tarf != '-':
                self._apply_whiteouts(tarf, destdir)
            verbose = ''
            if Msg.level >= Msg.VER:
                verbose = 'v'
                Msg().out("Info: extracting:", tarf, l=Msg.INF)
            cmd = ["tar", "-C", destdir, "-x" + verbose,
                   "--one-file-system", "--no-same-owner", "--overwrite",
                   "--exclude=dev/*", "--exclude=etc/udev/devices/*",
                   "--no-same-permissions", r"--exclude=.wh.*",
                   ] + optional_flags + ["-f", tarf]
            if subprocess.call(cmd, stderr=Msg.chlderr, close_fds=True):
                Msg().err("Error: while extracting image layer")
                status = False
            cmd = ["find", destdir,
                   "(", "-type", "d", "!", "-perm", "-u=x", "-exec",
                   "chmod", "u+x", "{}", ";", ")", ",",
                   "(", "!", "-perm", "-u=w", "-exec", "chmod",
                   "u+w", "{}", ";", ")", ",",
                   "(", "!", "-perm", "-u=r", "-exec", "chmod",
                   "u+r", "{}", ";", ")", ",",
                   "(", "!", "-gid", gid, "-exec", "chgrp", gid,
                   "{}", ";", ")", ",",
                   "(", "-name", ".wh.*", "-exec", "rm", "-f",
                   "--preserve-root", "{}", ";", ")"]
            if subprocess.call(cmd, stderr=Msg.chlderr, close_fds=True):
                status = False
                Msg().err("Error: while modifying attributes of image layer")
        return status
def _untar_layers ( self , tarfiles , destdir ) : if not ( tarfiles and destdir ) : return False status = True gid = str ( HostInfo . gid ) optional_flags = [ "--wildcards" , "--delay-directory-restore" , ] for option in optional_flags : if not HostInfo ( ) . cmd_has_option ( "tar" , option ) : optional_flags . remove ( option ) for tarf in tarfiles : if tarf != '-' : self . _apply_whiteouts ( tarf , destdir ) verbose = '' if Msg . level >= Msg . VER : verbose = 'v' Msg ( ) . out ( "Info: extracting:" , tarf , l = Msg . INF ) cmd = [ "tar" , "-C" , destdir , "-x" + verbose , "--one-file-system" , "--no-same-owner" , "--overwrite" , "--exclude=dev/*" , "--exclude=etc/udev/devices/*" , "--no-same-permissions" , r"--exclude=.wh.*" , ] + optional_flags + [ "-f" , tarf ] if subprocess . call ( cmd , stderr = Msg . chlderr , close_fds = True ) : Msg ( ) . err ( "Error: while extracting image layer" ) status = False cmd = [ "find" , destdir , "(" , "-type" , "d" , "!" , "-perm" , "-u=x" , "-exec" , "chmod" , "u+x" , "{}" , ";" , ")" , "," , "(" , "!" , "-perm" , "-u=w" , "-exec" , "chmod" , "u+w" , "{}" , ";" , ")" , "," , "(" , "!" , "-perm" , "-u=r" , "-exec" , "chmod" , "u+r" , "{}" , ";" , ")" , "," , "(" , "!" , "-gid" , gid , "-exec" , "chgrp" , gid , "{}" , ";" , ")" , "," , "(" , "-name" , ".wh.*" , "-exec" , "rm" , "-f" , "--preserve-root" , "{}" , ";" , ")" ] if subprocess . call ( cmd , stderr = Msg . chlderr , close_fds = True ) : status = False Msg ( ) . err ( "Error: while modifying attributes of image layer" ) return status