Esempio n. 1
0
File: raw.py Progetto: tizenpdk/mic
    def _stage_final_image(self):
        """Stage the final system image in _outdir.
           write meta data
        """
        self._resparse()
        self.image_files.update({'disks': self.__disks.keys()})

        if not (self.compress_image or self.pack_to):
            for imgfile in os.listdir(self.__imgdir):
                if imgfile.endswith('.raw'):
                    for disk in self.__disks.keys():
                        if imgfile.find(disk) != -1:
                            self.image_files.setdefault(disk, {}).update(
                                   {'image': imgfile})
                            self.image_files.setdefault('image_files',
                                   []).append(imgfile)

        if self.compress_image:
            for imgfile in os.listdir(self.__imgdir):
                if imgfile.endswith('.raw') or imgfile.endswith('bin'):
                    imgpath = os.path.join(self.__imgdir, imgfile)
                    msger.info("Compressing image %s" % imgfile)
                    compressing(imgpath, self.compress_image)
                if imgfile.endswith('.raw') and not self.pack_to:
                    for disk in self.__disks.keys():
                        if imgfile.find(disk) != -1:
                            imgname = '%s.%s' % (imgfile, self.compress_image)
                            self.image_files.setdefault(disk, {}).update(
                                   {'image': imgname})
                            self.image_files.setdefault('image_files',
                                    []).append(imgname)

        if self.pack_to:
            dst = os.path.join(self._outdir, self.pack_to)
            msger.info("Pack all raw images to %s" % dst)
            packing(dst, self.__imgdir)
            self.image_files.update({'image_files': self.pack_to})
        else:
            msger.debug("moving disks to stage location")
            for imgfile in os.listdir(self.__imgdir):
                src = os.path.join(self.__imgdir, imgfile)
                dst = os.path.join(self._outdir, imgfile)
                msger.debug("moving %s to %s" % (src,dst))
                shutil.move(src,dst)

        self._write_image_xml()
Esempio n. 2
0
    def _stage_final_image(self):
        """Stage the final system image in _outdir.
           write meta data
        """
        self._resparse()
        self.image_files.update({'disks': self.__disks.keys()})

        if not (self.compress_image or self.pack_to):
            for imgfile in os.listdir(self.__imgdir):
                if imgfile.endswith('.raw'):
                    for disk in self.__disks.keys():
                        if imgfile.find(disk) != -1:
                            self.image_files.setdefault(disk, {}).update(
                                   {'image': imgfile})
                            self.image_files.setdefault('image_files',
                                   []).append(imgfile)

        if self.compress_image:
            for imgfile in os.listdir(self.__imgdir):
                if imgfile.endswith('.raw') or imgfile.endswith('bin'):
                    imgpath = os.path.join(self.__imgdir, imgfile)
                    msger.info("Compressing image %s" % imgfile)
                    compressing(imgpath, self.compress_image)
                if imgfile.endswith('.raw') and not self.pack_to:
                    for disk in self.__disks.keys():
                        if imgfile.find(disk) != -1:
                            imgname = '%s.%s' % (imgfile, self.compress_image)
                            self.image_files.setdefault(disk, {}).update(
                                   {'image': imgname})
                            self.image_files.setdefault('image_files',
                                    []).append(imgname)

        if self.pack_to:
            dst = os.path.join(self._outdir, self.pack_to)
            msger.info("Pack all raw images to %s" % dst)
            packing(dst, self.__imgdir)
            self.image_files.update({'image_files': self.pack_to})
        else:
            msger.debug("moving disks to stage location")
            for imgfile in os.listdir(self.__imgdir):
                src = os.path.join(self.__imgdir, imgfile)
                dst = os.path.join(self._outdir, imgfile)
                msger.debug("moving %s to %s" % (src,dst))
                shutil.move(src,dst)

        self._write_image_xml()
Esempio n. 3
0
File: loop.py Progetto: 01org/mic
    def _stage_final_image(self):

        if self.pack_to or self.shrink_image:
            self._resparse(0)
        else:
            self._resparse()

        for item in self._instloops:
            imgfile = os.path.join(self._imgdir, item['name'])
            if item['fstype'] == "ext4":
                runner.show('/sbin/tune2fs -O ^huge_file,extents,uninit_bg %s '
                            % imgfile)
            self.image_files.setdefault('partitions', {}).update(
                    {item['mountpoint']: item['label']})
            if self.compress_image:
                compressing(imgfile, self.compress_image)
                self.image_files.setdefault('image_files', []).append(
                                '.'.join([item['name'], self.compress_image]))
            else:
                self.image_files.setdefault('image_files', []).append(item['name'])

        if not self.pack_to:
            for item in os.listdir(self._imgdir):
                shutil.move(os.path.join(self._imgdir, item),
                            os.path.join(self._outdir, item))
        else:
            msger.info("Pack all loop images together to %s" % self.pack_to)
            dstfile = os.path.join(self._outdir, self.pack_to)
            packing(dstfile, self._imgdir)
            self.image_files['image_files'] = [self.pack_to]


        if self.pack_to:
            mountfp_xml = os.path.splitext(self.pack_to)[0]
            mountfp_xml = misc.strip_end(mountfp_xml, '.tar') + ".xml"
        else:
            mountfp_xml = self.name + ".xml"
        # save mount points mapping file to xml
        save_mountpoints(os.path.join(self._outdir, mountfp_xml),
                         self._instloops,
                         self.target_arch)
Esempio n. 4
0
    def _stage_final_image(self):

        if self.pack_to or self.shrink_image:
            self._resparse(0)
        else:
            self._resparse()

        for item in self._instloops:
            imgfile = os.path.join(self._imgdir, item['name'])
            if item['fstype'] == "ext4":
                runner.show(
                    '/sbin/tune2fs -O ^huge_file,extents,uninit_bg %s ' %
                    imgfile)
            self.image_files.setdefault('partitions', {}).update(
                {item['mountpoint']: item['label']})
            if self.compress_image:
                compressing(imgfile, self.compress_image)
                self.image_files.setdefault('image_files', []).append('.'.join(
                    [item['name'], self.compress_image]))
            else:
                self.image_files.setdefault('image_files',
                                            []).append(item['name'])

        if not self.pack_to:
            for item in os.listdir(self._imgdir):
                shutil.move(os.path.join(self._imgdir, item),
                            os.path.join(self._outdir, item))
        else:
            msger.info("Pack all loop images together to %s" % self.pack_to)
            dstfile = os.path.join(self._outdir, self.pack_to)
            packing(dstfile, self._imgdir)
            self.image_files['image_files'] = [self.pack_to]

        if self.pack_to:
            mountfp_xml = os.path.splitext(self.pack_to)[0]
            mountfp_xml = misc.strip_end(mountfp_xml, '.tar') + ".xml"
        else:
            mountfp_xml = self.name + ".xml"
        # save mount points mapping file to xml
        save_mountpoints(os.path.join(self._outdir, mountfp_xml),
                         self._instloops, self.target_arch)
Esempio n. 5
0
File: loop.py Progetto: tizenpdk/mic
    def _stage_final_image(self):

        if self.pack_to or self.shrink_image:
            self._resparse(0)
        else:
            self._resparse()

        for item in self._instloops:
            imgfile = os.path.join(self._imgdir, item['name'])

            if item['aft_fstype'] in AFTER_MNT_FS.keys():
                mountpoint = misc.mkdtemp()
                ext4img = os.path.join(self._imgdir, item['name'])
                runner.show('mount -t ext4 %s %s' % (ext4img, mountpoint))
                runner.show('ls -al %s' % (mountpoint))
#                item['loop'].mount(None, 'not_create')
#                point_mnt = os.path.join(self._instroot, item['mountpoint'].lstrip('/'))

                fs_suffix = AFTER_MNT_FS[item['aft_fstype']]
                if item['aft_fstype'] == "squashfs":
#                    fs.mksquashfs(mountpoint, self._outdir+"/"+item['label']+fs_suffix)
                    args = "mksquashfs " + mountpoint + " " + self._imgdir+"/"+item['label']+fs_suffix
                    if item['squashfsopts']:
                        squashfsopts=item['squashfsopts'].replace(',', ' ')
                        runner.show("mksquashfs --help")
                        runner.show("%s %s" % (args, squashfsopts))
                    else:
                        runner.show("%s " % args)

                if item['aft_fstype'] == "vdfs":
                    ##FIXME temporary code - replace this with fs.mkvdfs()
                    if item['vdfsopts']:
                        vdfsopts=item['vdfsopts'].replace(',', ' ')
                    else:
                        vdfsopts="-i -z 1024M"

                    fullpathmkvdfs = "mkfs.vdfs" #find_binary_path("mkfs.vdfs")
                    runner.show("%s --help" % fullpathmkvdfs)
#                    fs.mkvdfs(mountpoint, self._outdir+"/"+item['label']+fs_suffix, vdfsopts)
                    runner.show('%s %s -r %s %s' % (fullpathmkvdfs, vdfsopts, mountpoint, self._imgdir+"/"+item['label']+fs_suffix))

                runner.show('umount %s' % mountpoint)
#               os.unlink(mountpoint)
                runner.show('mv %s %s' % (self._imgdir+"/"+item['label']+fs_suffix, self._imgdir+"/"+item['label']+".img") )
                runner.show('ls -al %s' % self._imgdir)

            if item['fstype'] == "ext4":
                if not item['cpioopts']:
                    runner.show('/sbin/tune2fs -O ^huge_file,extents,uninit_bg %s '
                            % imgfile)
                    runner.quiet(["/sbin/e2fsck", "-f", "-y", imgfile])
            self.image_files.setdefault('partitions', {}).update(
                    {item['mountpoint']: item['label']})
            if self.compress_image:
                compressing(imgfile, self.compress_image)
                self.image_files.setdefault('image_files', []).append(
                                '.'.join([item['name'], self.compress_image]))
            else:
                self.image_files.setdefault('image_files', []).append(item['name'])

        for item in os.listdir(self._imgdir):
            imgfile = os.path.join(self._imgdir, item)
            imgsize = os.path.getsize(imgfile)
            msger.info("filesystem size of %s : %s bytes" % (item, imgsize))

        self.run_sign_scripts()
        if not self.pack_to:
            for item in os.listdir(self._imgdir):
                shutil.move(os.path.join(self._imgdir, item),
                            os.path.join(self._outdir, item))
        else:
            msger.info("Pack all loop images together to %s" % self.pack_to)
            dstfile = os.path.join(self._outdir, self.pack_to)
            packing(dstfile, self._imgdir)
            self.image_files['image_files'] = [self.pack_to]


        if self.pack_to:
            mountfp_xml = os.path.splitext(self.pack_to)[0]
            mountfp_xml = misc.strip_end(mountfp_xml, '.tar') + ".xml"
        else:
            mountfp_xml = self.name + ".xml"
        # save mount points mapping file to xml
        save_mountpoints(os.path.join(self._outdir, mountfp_xml),
                         self._instloops,
                         self.target_arch)