Example #1
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()
Example #2
0
File: raw.py Project: 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()
Example #3
0
File: loop.py Project: 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)
Example #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)
Example #5
0
File: liveusb.py Project: 01org/mic
    def _stage_final_image(self):
        try:
            isodir = self._get_isodir()
            fs_related.makedirs(isodir + "/LiveOS")

            minimal_size = self._resparse()

            if not self.skip_minimize:
                fs_related.create_image_minimizer(isodir + "/LiveOS/osmin.img",
                                                  self._image,
                                                  minimal_size)

            if self.skip_compression:
                shutil.move(self._image,
                            isodir + "/LiveOS/ext3fs.img")
            else:
                fs_related.makedirs(os.path.join(
                                        os.path.dirname(self._image),
                                        "LiveOS"))
                shutil.move(self._image,
                            os.path.join(os.path.dirname(self._image),
                                         "LiveOS", "ext3fs.img"))
                fs_related.mksquashfs(os.path.dirname(self._image),
                           isodir + "/LiveOS/squashfs.img")

                self._create_usbimg(isodir)

                if self.pack_to:
                    self.image_files.update({'image_files': self.pack_to})
                    usbimg = os.path.join(self._outdir, self.name + ".usbimg")
                    packimg = os.path.join(self._outdir, self.pack_to)
                    packing(packimg, usbimg)
                    os.unlink(usbimg)
                else:
                    self.image_files.update({'image_files': self.name + ".usbimg"})

        finally:
            shutil.rmtree(isodir, ignore_errors = True)
            self._set_isodir(None)
Example #6
0
File: livecd.py Project: 01org/mic
    def _stage_final_image(self):
        try:
            fs_related.makedirs(self.__ensure_isodir() + "/LiveOS")

            minimal_size = self._resparse()

            if not self.skip_minimize:
                fs_related.create_image_minimizer(self.__isodir + \
                                                      "/LiveOS/osmin.img",
                                                  self._image,
                                                  minimal_size)

            if self.skip_compression:
                shutil.move(self._image, self.__isodir + "/LiveOS/ext3fs.img")
            else:
                fs_related.makedirs(os.path.join(
                                        os.path.dirname(self._image),
                                        "LiveOS"))
                shutil.move(self._image,
                            os.path.join(os.path.dirname(self._image),
                                         "LiveOS", "ext3fs.img"))
                fs_related.mksquashfs(os.path.dirname(self._image),
                           self.__isodir + "/LiveOS/squashfs.img")

            self.__create_iso(self.__isodir)

            if self.pack_to:
                isoimg = os.path.join(self._outdir, self.name + ".iso")
                packimg = os.path.join(self._outdir, self.pack_to)
                packing(packimg, isoimg)
                os.unlink(isoimg)
                self.image_files.update({'image_files': [self.pack_to]})
            else:
                self.image_files.update({'image_files': [self.name + ".iso"]})

        finally:
            shutil.rmtree(self.__isodir, ignore_errors = True)
            self.__isodir = None
Example #7
0
    def _stage_final_image(self):
        try:
            fs_related.makedirs(self.__ensure_isodir() + "/LiveOS")

            minimal_size = self._resparse()

            if not self.skip_minimize:
                fs_related.create_image_minimizer(self.__isodir + \
                                                      "/LiveOS/osmin.img",
                                                  self._image,
                                                  minimal_size)

            if self.skip_compression:
                shutil.move(self._image, self.__isodir + "/LiveOS/ext3fs.img")
            else:
                fs_related.makedirs(
                    os.path.join(os.path.dirname(self._image), "LiveOS"))
                shutil.move(
                    self._image,
                    os.path.join(os.path.dirname(self._image), "LiveOS",
                                 "ext3fs.img"))
                fs_related.mksquashfs(os.path.dirname(self._image),
                                      self.__isodir + "/LiveOS/squashfs.img")

            self.__create_iso(self.__isodir)

            if self.pack_to:
                isoimg = os.path.join(self._outdir, self.name + ".iso")
                packimg = os.path.join(self._outdir, self.pack_to)
                packing(packimg, isoimg)
                os.unlink(isoimg)
                self.image_files.update({'image_files': [self.pack_to]})
            else:
                self.image_files.update({'image_files': [self.name + ".iso"]})

        finally:
            shutil.rmtree(self.__isodir, ignore_errors=True)
            self.__isodir = None
Example #8
0
    def _stage_final_image(self):
        try:
            isodir = self._get_isodir()
            fs_related.makedirs(isodir + "/LiveOS")

            minimal_size = self._resparse()

            if not self.skip_minimize:
                fs_related.create_image_minimizer(isodir + "/LiveOS/osmin.img",
                                                  self._image, minimal_size)

            if self.skip_compression:
                shutil.move(self._image, isodir + "/LiveOS/ext3fs.img")
            else:
                fs_related.makedirs(
                    os.path.join(os.path.dirname(self._image), "LiveOS"))
                shutil.move(
                    self._image,
                    os.path.join(os.path.dirname(self._image), "LiveOS",
                                 "ext3fs.img"))
                fs_related.mksquashfs(os.path.dirname(self._image),
                                      isodir + "/LiveOS/squashfs.img")

                self._create_usbimg(isodir)

                if self.pack_to:
                    self.image_files.update({'image_files': self.pack_to})
                    usbimg = os.path.join(self._outdir, self.name + ".usbimg")
                    packimg = os.path.join(self._outdir, self.pack_to)
                    packing(packimg, usbimg)
                    os.unlink(usbimg)
                else:
                    self.image_files.update(
                        {'image_files': self.name + ".usbimg"})

        finally:
            shutil.rmtree(isodir, ignore_errors=True)
            self._set_isodir(None)
Example #9
0
File: loop.py Project: 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)