(self, xmode, force=False)
return bool(status)
Set execution mode
Set execution mode
Set execution mode
def set_mode(self, xmode, force=False):
        """Set execution mode"""
        status = False
        prev_xmode = self.get_mode()
        elfpatcher = ElfPatcher(self.localrepo, self.container_id)
        filebind = FileBind(self.localrepo, self.container_id)
        futil_croot = FileUtil(self.container_orig_root)
        orig_path = futil_croot.getdata('r').strip()
        if xmode not in self.valid_modes:
            Msg().err("Error: invalid execmode:", xmode)
            return status

        if not (force or xmode != prev_xmode):
            return True

        if prev_xmode[0] in ('R', 'S') and xmode[0] != 'R':
            filebind.restore()

        if xmode[0] == 'F':
            if force or prev_xmode[0] in ("P", "R", "S"):
                futil_cont = FileUtil(self.container_root)
                status = (futil_cont.links_conv(force, True, orig_path)
                          and elfpatcher.get_ld_libdirs(force))

        if xmode in ('P1', 'P2', 'F1', 'R1', 'R2', 'R3', 'S1'):
            if prev_xmode in ('P1', 'P2', 'F1', 'R1', 'R2', 'R3', 'S1'):
                status = True
            elif force or prev_xmode in ("F2", "F3", "F4"):
                status = ((elfpatcher.restore_ld() or force) and
                          elfpatcher.restore_binaries())
            if xmode[0] == 'R':
                filebind.setup()
        elif xmode in ("F2", ):
            if force or prev_xmode in ("F3", "F4"):
                status = elfpatcher.restore_binaries()
            if force or prev_xmode in ('P1', 'P2', 'F1', 'R1',
                                       'R2', 'R3', 'S1'):
                status = elfpatcher.patch_ld()
        elif xmode in ("F3", "F4"):
            if force or prev_xmode in ('P1', 'P2', 'F1', 'F2',
                                       'R1', 'R2', 'R3', 'S1'):
                status = (elfpatcher.patch_ld() and
                          elfpatcher.patch_binaries())
            elif prev_xmode in ("F3", "F4"):
                status = True

        if xmode[0] in ("P", "R", "S"):
            if force or (status and prev_xmode.startswith("F")):
                futil = FileUtil(self.container_root)
                status = futil.links_conv(force, False, orig_path)

        if status or force:
            futil = FileUtil(self.container_execmode)
            status = futil.putdata(xmode, "w")

        if status or force:
            futil = FileUtil(self.container_orig_root)
            status = futil.putdata(os.path.realpath(self.container_root), "w")

        if (not status) and (not force):
            Msg().err("Error: container setup failed")

        return bool(status)
def set_mode ( self , xmode , force = False ) : status = False prev_xmode = self . get_mode ( ) elfpatcher = ElfPatcher ( self . localrepo , self . container_id ) filebind = FileBind ( self . localrepo , self . container_id ) futil_croot = FileUtil ( self . container_orig_root ) orig_path = futil_croot . getdata ( 'r' ) . strip ( ) if xmode not in self . valid_modes : Msg ( ) . err ( "Error: invalid execmode:" , xmode ) return status if not ( force or xmode != prev_xmode ) : return True if prev_xmode [ 0 ] in ( 'R' , 'S' ) and xmode [ 0 ] != 'R' : filebind . restore ( ) if xmode [ 0 ] == 'F' : if force or prev_xmode [ 0 ] in ( "P" , "R" , "S" ) : futil_cont = FileUtil ( self . container_root ) status = ( futil_cont . links_conv ( force , True , orig_path ) and elfpatcher . get_ld_libdirs ( force ) ) if xmode in ( 'P1' , 'P2' , 'F1' , 'R1' , 'R2' , 'R3' , 'S1' ) : if prev_xmode in ( 'P1' , 'P2' , 'F1' , 'R1' , 'R2' , 'R3' , 'S1' ) : status = True elif force or prev_xmode in ( "F2" , "F3" , "F4" ) : status = ( ( elfpatcher . restore_ld ( ) or force ) and elfpatcher . restore_binaries ( ) ) if xmode [ 0 ] == 'R' : filebind . setup ( ) elif xmode in ( "F2" , ) : if force or prev_xmode in ( "F3" , "F4" ) : status = elfpatcher . restore_binaries ( ) if force or prev_xmode in ( 'P1' , 'P2' , 'F1' , 'R1' , 'R2' , 'R3' , 'S1' ) : status = elfpatcher . patch_ld ( ) elif xmode in ( "F3" , "F4" ) : if force or prev_xmode in ( 'P1' , 'P2' , 'F1' , 'F2' , 'R1' , 'R2' , 'R3' , 'S1' ) : status = ( elfpatcher . patch_ld ( ) and elfpatcher . patch_binaries ( ) ) elif prev_xmode in ( "F3" , "F4" ) : status = True if xmode [ 0 ] in ( "P" , "R" , "S" ) : if force or ( status and prev_xmode . startswith ( "F" ) ) : futil = FileUtil ( self . container_root ) status = futil . links_conv ( force , False , orig_path ) if status or force : futil = FileUtil ( self . container_execmode ) status = futil . putdata ( xmode , "w" ) if status or force : futil = FileUtil ( self . container_orig_root ) status = futil . putdata ( os . path . realpath ( self . container_root ) , "w" ) if ( not status ) and ( not force ) : Msg ( ) . err ( "Error: container setup failed" ) return bool ( status )