def customize_image(self, image=None):
     if self.config.boot_part != self.config.root_part:
         with image_partition_mounted(image, self.config.boot_part) as boot_mnt:
             with image_partition_mounted(image, self.config.root_part) as rootfs_mnt:
                 self._customize_image(image, boot_mnt, rootfs_mnt)
     else:
         with image_partition_mounted(image, self.config.boot_part) as boot_mnt:
             self._customize_image(image, boot_mnt, boot_mnt)
Beispiel #2
0
 def customize_image(self, image=None):
     if self.config.boot_part != self.config.root_part:
         with image_partition_mounted(image, self.config.boot_part) as boot_mnt:
             with image_partition_mounted(image, self.config.root_part) as rootfs_mnt:
                 self._customize_image(image, boot_mnt, rootfs_mnt)
     else:
         with image_partition_mounted(image, self.config.boot_part) as boot_mnt:
             self._customize_image(image, boot_mnt, boot_mnt)
Beispiel #3
0
    def mount(self, partition):
        device = self.device

        remote_sd_image = self.device._sd_image
        remote_sd_location = os.path.dirname(remote_sd_image)
        remote_sd_name = os.path.basename(remote_sd_image)

        dir_mount_point = os.path.join(device.scratch_dir, self.host)
        if not os.path.exists(dir_mount_point):
            os.makedirs(dir_mount_point)

        local_sd_image = os.path.join(dir_mount_point, remote_sd_name)

        run = device.context.run_command

        run('sshfs %s:%s %s %s -o IdentityFile=%s' %
            (self.host, remote_sd_location, dir_mount_point, self.ssh_options,
             self.identity_file),
            failok=False)

        try:
            with image_partition_mounted(local_sd_image,
                                         partition) as mount_point:
                yield mount_point
        finally:
            run('fusermount -u %s' % dir_mount_point, failok=False)
Beispiel #4
0
    def _customize_android(self):
        self.deployment_data = deployment_data.android

        with image_partition_mounted(self._sd_image, self.DATA_PARTITION) as d:
            wallpaper = '%s/%s' % (d, self.ANDROID_WALLPAPER)
            # delete the android active wallpaper as slows things down
            self.context.run_command('sudo rm -f %s' % wallpaper)

        with image_partition_mounted(self._sd_image, self.SYS_PARTITION) as d:
            with open('%s/etc/mkshrc' % d, 'a') as f:
                f.write('\n# LAVA CUSTOMIZATIONS\n')
                # make sure PS1 is what we expect it to be
                f.write('PS1="%s"\n' % self.tester_ps1)
                if not self.config.enable_network_after_boot_android:
                    # fast model usermode networking does not support ping
                    f.write('alias ping="echo LAVA-ping override 1 received"\n')
Beispiel #5
0
    def extract_tarball(self, tarball_url, partition, directory='/'):
        logging.info('extracting %s to target', tarball_url)

        self._check_power_state()
        with image_partition_mounted(self._sd_image, partition) as mntdir:
            tb = download_image(tarball_url, self.context, decompress=False)
            extract_tar(tb, '%s/%s' % (mntdir, directory))
    def extract_tarball(self, tarball_url, partition, directory='/'):
        logging.info('extracting %s to target', tarball_url)

        self._check_power_state()
        with image_partition_mounted(self._sd_image, partition) as mntdir:
            tb = download_image(tarball_url, self.context, decompress=False)
            extract_tar(tb, '%s/%s' % (mntdir, directory))
    def _customize_android(self):
        self.deployment_data = deployment_data.android

        with image_partition_mounted(self._sd_image, self.DATA_PARTITION) as d:
            wallpaper = '%s/%s' % (d, self.ANDROID_WALLPAPER)
            # delete the android active wallpaper as slows things down
            self.context.run_command('sudo rm -f %s' % wallpaper)

        with image_partition_mounted(self._sd_image, self.SYS_PARTITION) as d:
            with open('%s/etc/mkshrc' % d, 'a') as f:
                f.write('\n# LAVA CUSTOMIZATIONS\n')
                # make sure PS1 is what we expect it to be
                f.write('PS1="%s"\n' % self.tester_ps1)
                if not self.config.enable_network_after_boot_android:
                    # fast model usermode networking does not support ping
                    f.write('alias ping="echo LAVA-ping override 1 received"\n')
Beispiel #8
0
    def _customize_android(self, img):
        self.deployment_data = deployment_data.android

        sys_part = self.config.sys_part_android_org
        with image_partition_mounted(img, sys_part) as d:
            with open('%s/etc/mkshrc' % d, 'a') as f:
                f.write('\n# LAVA CUSTOMIZATIONS\n')
                f.write('PS1="%s"\n' % self.tester_ps1)
    def _customize_android(self, img):
        self.deployment_data = deployment_data.android

        sys_part = self.config.sys_part_android_org
        with image_partition_mounted(img, sys_part) as d:
            with open('%s/etc/mkshrc' % d, 'a') as f:
                f.write('\n# LAVA CUSTOMIZATIONS\n')
                f.write('PS1="%s"\n' % self.tester_ps1)
def _extract_partition(image, partno, tarfile):
    """Mount a partition and produce a tarball of it

    :param image: The image to mount
    :param partno: The index of the partition in the image
    :param tarfile: path and filename of the tgz to output
    """
    with image_partition_mounted(image, partno) as mntdir:
        mk_targz(tarfile, mntdir, asroot=True)
Beispiel #11
0
def _extract_partition(image, partno, tarfile):
    """Mount a partition and produce a tarball of it

    :param image: The image to mount
    :param partno: The index of the partition in the image
    :param tarfile: path and filename of the tgz to output
    """
    with image_partition_mounted(image, partno) as mntdir:
        mk_targz(tarfile, mntdir, asroot=True)
 def file_system(self, partition, directory):
     if self._ramdisk_boot:
         if self._reset_boot:
             self._booted = False
             self._reset_boot = False
             raise Exception("Operation timed out, resetting platform!")
         elif not self._booted:
             self.context.client.boot_linaro_image()
         pat = self.tester_ps1_pattern
         incrc = self.tester_ps1_includes_rc
         runner = NetworkCommandRunner(self, pat, incrc)
         with self._busybox_file_system(runner, directory) as path:
             yield path
     else:
         with image_partition_mounted(self._sd_image, partition) as mntdir:
             path = '%s/%s' % (mntdir, directory)
             ensure_directory(path)
             yield path
 def file_system(self, partition, directory):
     if self._ramdisk_boot:
         if self._reset_boot:
             self._reset_boot = False
             if self._in_test_shell:
                 self._in_test_shell = False
                 raise Exception("Operation timed out, resetting platform!")
         elif not self._booted:
             self.context.client.boot_linaro_image()
         pat = self.tester_ps1_pattern
         incrc = self.tester_ps1_includes_rc
         runner = NetworkCommandRunner(self, pat, incrc)
         with self._busybox_file_system(runner, directory) as path:
             yield path
     else:
         self._check_power_state()
         with image_partition_mounted(self._sd_image, partition) as mntdir:
             path = '%s/%s' % (mntdir, directory)
             ensure_directory(path)
             yield path
Beispiel #14
0
    def mount(self, partition):
        device = self.device

        remote_sd_image = self.device._sd_image
        remote_sd_location = os.path.dirname(remote_sd_image)
        remote_sd_name = os.path.basename(remote_sd_image)

        dir_mount_point = os.path.join(device.scratch_dir, self.host)
        if not os.path.exists(dir_mount_point):
            os.makedirs(dir_mount_point)

        local_sd_image = os.path.join(dir_mount_point, remote_sd_name)

        run = device.context.run_command

        run('sshfs %s:%s %s %s -o IdentityFile=%s' % (self.host, remote_sd_location, dir_mount_point, self.ssh_options, self.identity_file), failok=False)

        try:
            with image_partition_mounted(local_sd_image, partition) as mount_point:
                yield mount_point
        finally:
            run('fusermount -u %s' % dir_mount_point, failok=False)
    def _read_boot_cmds(self, image=None, boot_tgz=None):
        boot_file_path = None

        if not self.config.read_boot_cmds_from_image:
            return

        # If we have already obtained boot commands dynamically, then return.
        if self.__boot_cmds_dynamic__ is not None:
            logging.debug("We already have boot commands in place.")
            return

        if image:
            boot_part = self.config.boot_part
            # Read boot related file from the boot partition of image.
            with image_partition_mounted(image, boot_part) as mnt:
                for boot_file in self.config.boot_files:
                    boot_path = os.path.join(mnt, boot_file)
                    if os.path.exists(boot_path):
                        boot_file_path = boot_path
                        break

        elif boot_tgz:
            tmp_dir = mkdtemp()
            extracted_files = extract_tar(boot_tgz, tmp_dir)
            for boot_file in self.config.boot_files:
                for file_path in extracted_files:
                    if boot_file == os.path.basename(file_path):
                        boot_file_path = file_path
                        break

        if boot_file_path and os.path.exists(boot_file_path):
            with open(boot_file_path, 'r') as f:
                boot_cmds = self._rewrite_boot_cmds(f.read())
                self.__boot_cmds_dynamic__ = boot_cmds
        else:
            logging.debug("Unable to read boot commands dynamically.")
Beispiel #16
0
    def _read_boot_cmds(self, image=None, boot_tgz=None):
        boot_file_path = None

        if not self.config.read_boot_cmds_from_image:
            return

        # If we have already obtained boot commands dynamically, then return.
        if self.__boot_cmds_dynamic__ is not None:
            logging.debug("We already have boot commands in place.")
            return

        if image:
            boot_part = self.config.boot_part
            # Read boot related file from the boot partition of image.
            with image_partition_mounted(image, boot_part) as mnt:
                for boot_file in self.config.boot_files:
                    boot_path = os.path.join(mnt, boot_file)
                    if os.path.exists(boot_path):
                        boot_file_path = boot_path
                        break

        elif boot_tgz:
            tmp_dir = mkdtemp()
            extracted_files = extract_tar(boot_tgz, tmp_dir)
            for boot_file in self.config.boot_files:
                for file_path in extracted_files:
                    if boot_file == os.path.basename(file_path):
                        boot_file_path = file_path
                        break

        if boot_file_path and os.path.exists(boot_file_path):
            with open(boot_file_path, 'r') as f:
                boot_cmds = self._rewrite_boot_cmds(f.read())
                self.__boot_cmds_dynamic__ = boot_cmds
        else:
            logging.debug("Unable to read boot commands dynamically.")
Beispiel #17
0
 def file_system(self, partition, directory):
     self._check_power_state()
     with image_partition_mounted(self._sd_image, partition) as mntdir:
         path = '%s/%s' % (mntdir, directory)
         ensure_directory(path)
         yield path
Beispiel #18
0
 def file_system(self, partition, directory):
     self._check_power_state()
     with image_partition_mounted(self._sd_image, partition) as mntdir:
         path = '%s/%s' % (mntdir, directory)
         ensure_directory(path)
         yield path
Beispiel #19
0
 def _copy_needed_files_from_partition(self, partno, subdir):
     with image_partition_mounted(self._sd_image, partno) as mntdir:
         subdir = os.path.join(mntdir, subdir)
         self._copy_needed_files_from_directory(subdir)
 def _copy_needed_files_from_partition(self, partno, subdir):
     with image_partition_mounted(self._sd_image, partno) as mntdir:
         subdir = os.path.join(mntdir, subdir)
         self._copy_needed_files_from_directory(subdir)