Beispiel #1
0
def get_file_command(layer_tar_file, layer_file, command):
    '''Given an ImageLayer object's tar_file property and a FileData object
    from that layer, along with the command, return the command in list form
    with the target file appended at the end'''
    cmd_list = get_exec_command(command)
    file_path = os.path.join(
        rootfs.get_untar_dir(layer_tar_file), layer_file.path)
    cmd_list.append(file_path)
    return cmd_list
Beispiel #2
0
def get_filesystem_command(layer_obj, command):
    '''Given an ImageLayer object and a command in the form of a string,
    return the command in list form  with the target directory of the layer.
    This assumes that the layer tarball is untarred, which should have happened
    during the loading of the Image object'''
    # in most cases, the external tool has a CLI where the target directory
    # is the last token in the command. So the most straightforward way
    # to perform this operation is to append the target directory
    cmd_list = get_exec_command(command)
    cmd_list.append(rootfs.get_untar_dir(layer_obj.tar_file))
    return cmd_list
Beispiel #3
0
def get_os_release(base_layer):
    """Assuming that the layer tarball is untarred are ready to be inspected,
    get the OS information from the os-release file"""
    return find_os_release(rootfs.get_untar_dir(base_layer.tar_file))
Beispiel #4
0
def get_shell(layer):
    '''Find the shell if any on the layer filesystem. Assume that the layer
    has already been unpacked. If there is no shell, return an empty string'''
    cwd = rootfs.get_untar_dir(layer.tar_file)
    return find_shell(cwd)