self.outimage.append(os.path.join(destdir, f))
self.do_genchecksum(os.path.join(destdir, f))
- def create(self):
- """Install, configure and package an image.
-
- This method is a utility method which creates and image by calling some
- of the other methods in the following order - mount(), install(),
- configure(), unmount and package().
-
- """
- self.mount(None, self.cachedir)
- self.install()
- self.configure(self.repometadata)
- self.unmount()
- self.package(self.destdir)
-
def print_outimage_info(self):
msger.info("Your new image can be found here:")
self.outimage.sort()
import subprocess
from baseimager import BaseImageCreator
-from mic.utils.fs_related import makedirs
from mic import msger
class FsImageCreator(BaseImageCreator):
self._fstype = None
self._fsopts = None
- def _stage_final_image(self):
- """ nothing to do"""
- pass
-
def package(self, destdir = "."):
- self._stage_final_image()
+ destdir = os.path.abspath(os.path.expanduser(destdir))
if not os.path.exists(destdir):
- makedirs(destdir)
+ os.makedirs(destdir)
- destdir = os.path.abspath(os.path.expanduser(destdir))
if self._recording_pkgs:
self._save_recording_pkgs(destdir)
- msger.info("Copying %s to %s, please be patient to wait" % (self._instroot, destdir + "/" + self.name))
+ msger.info("Copying %s to %s ..." % (self._instroot, destdir + "/" + self.name))
args = ['cp', "-af", self._instroot, destdir + "/" + self.name ]
subprocess.call(args)
elif os.path.exists("/usr/lib/anaconda-runtime/implantisomd5"):
implantisomd5 = "/usr/lib/anaconda-runtime/implantisomd5"
else:
- msger.warn("isomd5sum not installed; not setting up mediacheck")
+ msger.warning("isomd5sum not installed; not setting up mediacheck")
implantisomd5 = ""
return
-#!/usr/bin/python
-import sys
-import subprocess
+#!/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 mic.utils.cmdln as cmdln
-import mic.utils.errors as errors
-import mic.configmgr as configmgr
-import mic.pluginmgr as pluginmgr
-import mic.imager.fs as fs
-import mic.chroot as chroot
+from mic import configmgr, pluginmgr, chroot, msger
+from mic.utils import cmdln, errors
+from mic.imager import fs
from mic.pluginbase import ImagerPlugin
-
class FsPlugin(ImagerPlugin):
name = 'fs'
${cmd_usage}
${cmd_option_list}
"""
- if len(args) == 0:
- return
+
+ if not args:
+ raise errors.Usage("More arguments needed")
+
if len(args) == 1:
ksconf = args[0]
else:
#Download the source packages ###private options
if opts.include_src:
installed_pkgs = creator.get_installed_packages()
- print '--------------------------------------------------'
- print 'Generating the image with source rpms included, The number of source packages is %d.' %(len(installed_pkgs))
+ msger.info('--------------------------------------------------')
+ msger.info('Generating the image with source rpms included, The number of source packages is %d.' %(len(installed_pkgs)))
if not misc.SrcpkgsDownload(installed_pkgs, createopts["repomd"], creator._instroot, createopts["cachedir"]):
- print "Source packages can't be downloaded"
+ msger.warning("Source packages can't be downloaded")
creator.configure(createopts["repomd"])
creator.unmount()
raise errors.CreatorError("failed to create image : %s" % e)
finally:
creator.cleanup()
- print "Finished."
+ msger.info("Finished.")
return 0
try:
chroot.chroot(target, None, "/bin/env HOME=/root /bin/bash")
except:
- print >> sys.stderr, "Failed to chroot to %s." % target
+ msger.warning("Failed to chroot to %s." % target)
finally:
chroot.cleanup_after_chroot("dir", None, None, None)
return 1
pkgmgr = None
plgmgr = pluginmgr.PluginMgr()
for (key, pcls) in plgmgr.get_plugins('backend').iteritems():
- if key == createopts['pkgmgr']:
+ if key == creatoropts['pkgmgr']:
pkgmgr = pcls
break
pkgmgr = None
plgmgr = pluginmgr.PluginMgr()
for (key, pcls) in plgmgr.get_plugins('backend').iteritems():
- if key == createopts['pkgmgr']:
+ if key == creatoropts['pkgmgr']:
pkgmgr = pcls
break
pkgmgr = None
plgmgr = pluginmgr.PluginMgr()
for (key, pcls) in plgmgr.get_plugins('backend').iteritems():
- if key == createopts['pkgmgr']:
+ if key == creatoropts['pkgmgr']:
pkgmgr = pcls
break
pkgmgr = None
plgmgr = pluginmgr.PluginMgr()
for (key, pcls) in plgmgr.get_plugins('backend').iteritems():
- if key == createopts['pkgmgr']:
+ if key == creatoropts['pkgmgr']:
pkgmgr = pcls
break
sys.exit(mic.main())
except errors.Usage, msg:
- msger.error("Usage error: %s\n" % msg)
+ msger.error("<usage> %s\n" % msg)
except errors.ConfigError, msg:
- msger.error("Config error: %s\n" % msg)
+ msger.error("<config> %s\n" % msg)
except errors.CreatorError, msg:
- msger.error("Creator error: %s\n" % msg)
+ msger.error("<creator> %s\n" % msg)