From: JF Ding Date: Tue, 13 Sep 2011 02:13:22 +0000 (-0700) Subject: hide the private part X-Git-Tag: 0.1~121 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8143cdab7345e9dfb5110529daa772b9cb599405;p=tools%2Fmic.git hide the private part --- diff --git a/plugins/imager/slp_plugin.py b/plugins/imager/slp_plugin.py deleted file mode 100644 index 4812e3e..0000000 --- a/plugins/imager/slp_plugin.py +++ /dev/null @@ -1,177 +0,0 @@ -#!/usr/bin/python -tt -# -# Copyright 2011 Intel, Inc. -# -# This copyrighted material is made available to anyone wishing to use, modify, -# copy, or redistribute it subject to the terms and conditions of the GNU -# General Public License v.2. This program is distributed in the hope that it -# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the -# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat -# trademarks that are incorporated in the source code or documentation are not -# subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. -# - -import os - -from mic import kickstart, msger, configmgr, pluginmgr -from mic.utils import errors, misc, fs_related as fs -from mic.imager.loop import LoopImageCreator - -from mic.pluginbase import ImagerPlugin -class SLPlugin(ImagerPlugin): - name = 'slp' - - @classmethod - def do_create(self, subcmd, opts, *args): - """${cmd_name}: create slp image - - ${cmd_usage} - ${cmd_option_list} - """ - - if not args: - raise errors.Usage("More arguments needed") - - if len(args) != 1: - raise errors.Usage("Extra arguments given") - - cfgmgr = configmgr.getConfigMgr() - creatoropts = cfgmgr.create - ksconf = args[0] - - recording_pkgs = None - if creatoropts['release'] is not None: - recording_pkgs = "name" - ksconf = misc.save_ksconf_file(ksconf, creatoropts['release']) - name = os.path.splitext(os.path.basename(ksconf))[0] - creatoropts['outdir'] = "%s/%s-%s/" % (creatoropts['outdir'], name, creatoropts['release']) - cfgmgr._ksconf = ksconf - - # try to find the pkgmgr - pkgmgr = None - for (key, pcls) in pluginmgr.PluginMgr().get_plugins('backend').iteritems(): - if key == creatoropts['pkgmgr']: - pkgmgr = pcls - break - - if not pkgmgr: - raise errors.CreatorError("Can't find package manager: %s" % creatoropts['pkgmgr']) - - creator = SLPImageCreator(creatoropts, pkgmgr) - - if recording_pkgs is not None: - creator._recording_pkgs = recording_pkgs - - try: - creator.check_depend_tools() - creator.mount(None, creatoropts["cachedir"]) - creator.install() - creator.configure(creatoropts["repomd"]) - creator.unmount() - creator.package(creatoropts["outdir"]) - - if creatoropts['release'] is not None: - misc.create_release(ksconf, creatoropts['outdir'], creatoropts['name'], creator.outimage, creatoropts['release']) - creator.print_outimage_info() - - except errors.CreatorError: - raise - finally: - creator.cleanup() - - msger.info("Finished.") - return 0 - -class SLPImageCreator(LoopImageCreator): - """ SLPImageCreator is based on LoopImageCreator with the ability to - support multiple partitions in kickstart file. And each partition - will be created as a separated loop image. - """ - - def __init__(self, creatoropts = None, pkgmgr = None): - LoopImageCreator.__init__(self, creatoropts, pkgmgr) - - if not self.ks: - msger.error('No kickstart file specified') - - allloops = [] - for part in sorted(kickstart.get_partitions(self.ks), - key = lambda p: p.mountpoint): - label = part.label - - mp = part.mountpoint - if mp == '/': - # the base image - if not label: - label = self.name - else: - mp = mp.rstrip('/') - if not label: - msger.warning('no "label" specified for loop img at %s, use the mountpoint as the name' % mp) - label = mp.split('/')[-1] - - imgname = misc.strip_end(label,'.img') + '.img' - allloops.append({ - 'mountpoint': mp, - 'label': label, - 'name': imgname, - 'size': part.size or 4096L * 1024 * 1024, - 'fstype': part.fstype or 'ext4', - 'loop': None, # to be created in _mount_instroot - }) - - self._allloops = allloops # list of dict of image_name:loop_device - - def _mount_instroot(self, base_on = None): - self._check_imgdir() - self._base_on(base_on) - imgdir = os.path.dirname(self._image) - - for loop in self._allloops: - fstype = loop['fstype'] - mp = os.path.join(self._instroot, loop['mountpoint'].lstrip('/')) - size = loop['size'] * 1024L * 1024L - imgname = loop['name'] - - if fstype in ("ext2", "ext3", "ext4"): - MyDiskMount = fs.ExtDiskMount - elif fstype == "btrfs": - MyDiskMount = fs.BtrfsDiskMount - else: - msger.error('Cannot support fstype: %s' % fstype) - - loop['loop'] = MyDiskMount(fs.SparseLoopbackDisk(os.path.join(imgdir, imgname), size), - mp, - fstype, - self._blocksize, - loop['label']) - - try: - msger.verbose('Mounting image "%s" on "%s"' %(imgname, mp)) - fs.makedirs(mp) - loop['loop'].mount() - except errors.MountError, e: - raise - - self._instloops = self._allloops - - def _stage_final_image(self): - import tarfile - - imgdir = os.path.dirname(self._image) - curdir = os.getcwd() - os.chdir(imgdir) - self._resparse(0) - - tar = tarfile.open(os.path.join(self._outdir, 'platform.tar'), 'w') - for item in self._instloops: - tar.add(item['name']) - tar.close() - - os.chdir(curdir) diff --git a/setup.py b/setup.py index 2263faf..27bf713 100644 --- a/setup.py +++ b/setup.py @@ -72,7 +72,6 @@ setup(name=MOD_NAME, "plugins/imager/liveusb_plugin.py", "plugins/imager/loop_plugin.py", "plugins/imager/raw_plugin.py", - "plugins/imager/slp_plugin.py", ]), ("/usr/lib/mic/plugins/backend", ["plugins/backend/zypppkgmgr.py", "plugins/backend/yumpkgmgr.py",