+Release 0.28.17 - Wed Aug. 10 2022 - Biao Wang <biao716.wang@samsung.com>
+=====================================================================
+ * Add --block-recommends option to allow not install recommended packages
+
+Release 0.28.16 - Thu Feb. 10 2022 - Biao Wang <biao716.wang@samsung.com>
+=====================================================================
+ * Add postscripts-maxruntime option to set the max run time for post scripts
+
+Release 0.28.15 - Mon Jul. 05 2021 - Biao Wang <biao716.wang@samsung.com>
+=====================================================================
+ * Don't install recommended packages in mic
+
+Release 0.28.14 - Fri May. 14 2021 - Biao Wang <biao716.wang@samsung.com>
+=====================================================================
+ * Encrypt user password with SHA512 instead of MD5.
+ * Fix pylint error, reimport glob.
+
+Release 0.28.13 - Tue Mar. 23 2021 - Biao Wang <biao716.wang@samsung.com>
+=====================================================================
+ * Add new option for squashfs file system to support M1 feature.
+
+Release 0.28.12 - Feb Jan. 05 2021 - Biao Wang <biao716.wang@samsung.com>
+=====================================================================
+ * Support to create image with f2fs file system.
+ * Fix the bug that no print last installed package.
+ * Remove urlgrabber directory from mic.
+
+Release 0.28.11 - Thu Nov. 05 2020 - Biao Wang <biao716.wang@samsung.com>
+=====================================================================
+ * add dependece for yum directly.
+ * fix run error issue for parser repomd.xml when here is group type.
+ * Refine code, remove duplicated code
+ * Separate qcow plugin scripts
+
+Release 0.28.10 - Tue Jul. 21 2020 - Biao Wang <biao716.wang@samsung.com>
+=====================================================================
+ * Create btrfs images with the metadata single option.
+ * Refine code with SAM tools check.
+
+Release 0.28.9 - Wed Jun. 17 2020 - Yan Meng <yan11.meng@samsung.com>
+=====================================================================
+ * increase max loop device number in mic.
+ * fix build error with Typeerror.
+ * Fix the bug that truncates existing inittab file.
+
+Release 0.28.8 - Thu May. 7 2020 - Yan Meng <yan11.meng@samsung.com>
+=====================================================================
+ * remove unnecessary /etc/fstab file.
+
+Release 0.28.7 - Mon Feb. 17 2020 - Yan Meng <yan11.meng@samsung.com>
+=====================================================================
+ * fix pylint errors for mic
+ * add option for mic to skip set hosts when create
+ * skip set hosts by mic when /etc/hosts exists
+
Release 0.28.6 - Fri Feb. 15 2019 - Jin Xiao <jin.xiao@samsung.com>
=====================================================================
* new distribution support: Ubuntu 18.04.
+mic (0.28.17) unstable; urgency=low
+ * Add --block-recommends option to allow not install recommended packages
+
+ -- Biao Wang <biao716.wang@samsung.com> Wed, 10 Aug 2022 15:00:00 +0800
+
+mic (0.28.16) unstable; urgency=low
+ * Add postscripts-maxruntime option to set the max run time for post scripts.
+
+ -- Biao Wang <biao716.wang@samsung.com> Thu, 10 Feb 2022 15:00:00 +0800
+
+mic (0.28.15) unstable; urgency=low
+ * Don't install recommended packages in mic.
+
+ -- Biao Wang <biao716.wang@samsung.com> Mon, 05 Jul 2021 15:00:00 +0800
+
+mic (0.28.14) unstable; urgency=low
+ * Encrypt user password with SHA512 instead of MD5.
+ * Fix pylint error, reimport glob.
+
+ -- Biao Wang <biao716.wang@samsung.com> Fri, 14 May 2021 15:00:00 +0800
+
+
+mic (0.28.13) unstable; urgency=low
+ * Add new option for squashfs file system to support M1 feature.
+
+ -- Biao Wang <biao716.wang@samsung.com> Tue, 23 Mar 2021 15:00:00 +0800
+
+mic (0.28.12) unstable; urgency=low
+ * Support to create image with f2fs file system.
+ * Fix the bug that no print last installed package.
+ * Remove urlgrabber directory from mic.
+
+ -- Biao Wang <biao716.wang@samsung.com> Fri, 05 Feb 2021 15:00:00 +0800
+
+mic (0.28.11) unstable; urgency=low
+ * add dependece for yum directly.
+ * fix run error issue for parser repomd.xml when here is group type.
+ * Refine code, remove duplicated code
+ * Separate qcow plugin scripts
+
+ -- Biao Wang <biao716.wang@samsung.com> Thu, 05 Nov 2020 15:00:00 +0800
+
+mic (0.28.10) unstable; urgency=low
+ * Create btrfs images with the metadata single option.
+ * Refine code with SAM tools check.
+
+ -- Biao Wang <biao716.wang@samsung.com> Tue, 21 Jul 2020 15:00:00 +0800
+
+mic (0.28.9) unstable; urgency=low
+ * increase max loop device number in mic.
+ * fix build error with Typeerror.
+ * Fix the bug that truncates existing inittab file.
+
+ -- Yan Meng <yan11.meng@samsung.com> Wed, 17 Jun 2020 15:00:00 +0800
+
+mic (0.28.8) unstable; urgency=low
+ * remove unnecessary /etc/fstab file.
+
+ -- Yan Meng <yan11.meng@samsung.com> Thu, 7 May 2020 15:00:00 +0800
+
+mic (0.28.7) unstable; urgency=low
+ * fix pylint errors for mic
+ * add option for mic to skip set hosts when create
+ * skip set hosts by mic when /etc/hosts exists
+
+ -- Yan Meng <yan11.meng@samsung.com> Mon, 17 Feb 2020 15:00:00 +0800
+
mic (0.28.6) unstable; urgency=low
* new distribution support: Ubuntu 18.04.
python-urlgrabber,
cpio,
bzip2,
- gzip
+ gzip,
+ yum
Conflicts:
mic2
Description: image creator for Linux distributions
+MIC Image Creator 0.28.17 Release Notes
+======================================
+Released Aug 10 2022
+
+This release note documents the changes included in the new release. And
+the release contains new features.
+
+new features
+--------------------------
+ * Add --block-recommends option to block install recommends packages.
+
+MIC Image Creator 0.28.16 Release Notes
+======================================
+Released Feb 10 2022
+
+This release note documents the changes included in the new release. And
+the release contains new features.
+
+new features
+--------------------------
+ * Add postscripts-maxruntime option to set the max run time for post scripts.
+
+MIC Image Creator 0.28.15 Release Notes
+======================================
+Released Jul 05 2021
+
+This release note documents the changes included in the new release. And
+the release contains new features.
+
+new features
+--------------------------
+ * Don't install recommended packages in mic.
+
+MIC Image Creator 0.28.14 Release Notes
+======================================
+Released May 14 2021
+
+This release note documents the changes included in the new release. And
+the release contains new features.
+
+new features
+--------------------------
+ * Encrypt user password with SHA512 instead of MD5.
+ * Fix pylint error, reimport glob.
+
+MIC Image Creator 0.28.13 Release Notes
+======================================
+Released Mar 23 2021
+
+This release note documents the changes included in the new release. And
+the release contains new features.
+
+new features
+--------------------------
+ * Add new option for squashfs to support M1 feature.
+
+MIC Image Creator 0.28.12 Release Notes
+======================================
+Released Feb 05 2021
+
+This release note documents the changes included in the new release. And
+the release contains new features.
+
+new features
+--------------------------
+ * Support to create image with f2fs file system.
+ * Fix the bug that no print last installed package.
+ * Remove urlgrabber directory from mic.
+
+MIC Image Creator 0.28.11 Release Notes
+======================================
+Released Nov 05 2020
+
+This release note documents the changes included in the new release. And
+the release contains new features.
+
+new features
+--------------------------
+ * add dependece for yum directly.
+ * fix run error issue for parser repomd.xml when here is group type.
+ * Refine code, remove duplicated code
+ * Separate qcow plugin scripts
+
+MIC Image Creator 0.28.10 Release Notes
+======================================
+Released Jul 21 2020
+
+This release note documents the changes included in the new release. And
+the release contains new features.
+
+new features
+--------------------------
+ * Create btrfs images with the metadata single option.
+ * Refine code with SAM tools check.
+
+MIC Image Creator 0.28.9 Release Notes
+======================================
+Released Jun 17 2020
+
+This release note documents the changes included in the new release. And
+the release contains new features.
+
+Bug Fixes
+--------------------------
+ * increase max loop device number in mic.
+ * fix build error with Typeerror.
+ * Fix the bug that truncates existing inittab file.
+
+MIC Image Creator 0.28.8 Release Notes
+======================================
+Released May 7 2020
+
+This release note documents the changes included in the new release. And
+the release contains new features.
+
+Bug Fixes
+--------------------------
+ * remove unnecessary /etc/fstab file.
+
+MIC Image Creator 0.28.7 Release Notes
+======================================
+Released Feb 17 2020
+
+This release note documents the changes included in the new release. And
+the release contains new features.
+
+new features
+--------------------------
+ * add option for mic to skip set hosts when create.
+
+Bug Fixes
+--------------------------
+ * fix pylint errors for mic.
+ * skip set hosts by mic when /etc/hosts exists.
+
MIC Image Creator 0.28.6 Release Notes
======================================
Released Feb 15 2019
Released Sep 28 2018
This release note documents the changes included in the new release. And
-the release contains new features, enhancements and bug fixes.
+the release contains new features.
new features
--------------------------
# We don't want people using this class by itself.
if self.__class__ is KickstartCommand:
- raise TypeError, "KickstartCommand is an abstract class."
+ raise TypeError ("KickstartCommand is an abstract class.")
KickstartObject.__init__(self, *args, **kwargs)
"""Parse the list of args and set data on the KickstartCommand object.
This method must be provided by all subclasses.
"""
- raise TypeError, "parse() not implemented for KickstartCommand"
+ raise TypeError ("parse() not implemented for KickstartCommand")
def apply(self, instroot="/"):
"""Write out the configuration related to the KickstartCommand object.
def __init__(self, writePriority=None, *args, **kwargs):
# We don't want people using this class by itself.
if self.__class__ is KickstartCommand:
- raise TypeError, "DeprecatedCommand is an abstract class."
+ raise TypeError ("DeprecatedCommand is an abstract class.")
# Create a new DeprecatedCommand instance.
KickstartCommand.__init__(self, writePriority, *args, **kwargs)
# We don't want people using this class by itself.
if self.__class__ is BaseHandler:
- raise TypeError, "BaseHandler is an abstract class."
+ raise TypeError ("BaseHandler is an abstract class.")
KickstartObject.__init__(self, *args, **kwargs)
cmd = args[0]
if not self.commands.has_key(cmd):
- raise KickstartParseError, formatErrorMsg(lineno, msg=_("Unknown command: %s" % cmd))
+ raise KickstartParseError (formatErrorMsg(lineno, msg=_("Unknown command: %s" % cmd)))
elif self.commands[cmd] != None:
self.commands[cmd].currentCmd = cmd
self.commands[cmd].currentLine = self.currentLine
def __init__(self, *args, **kwargs):
"""Create a new BaseData instance.
-
- lineno -- Line number in the ks-file where this object was defined
+
+ lineno -- Line number in the ks-file where this object was defined
"""
# We don't want people using this class by itself.
if self.__class__ is BaseData:
- raise TypeError, "BaseData is an abstract class."
+ raise TypeError ("BaseData is an abstract class.")
KickstartObject.__init__(self, *args, **kwargs)
self.lineno = 0
def parse(self, args):
if len(args) > 0:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "autopart")
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "autopart"))
self.autopart = True
return self
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if len(extra) != 2:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("device command requires two arguments: module type and name"))
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("device command requires two arguments: module type and name")))
self.moduleOpts = opts.moduleOpts
self.type = extra[0]
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if len(extra) != 1:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("%s command requires a single argument: %s") % ("device", "module name"))
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("%s command requires a single argument: %s") % ("device", "module name")))
dd = F8_DeviceData()
self._setToObj(self.op, opts, dd)
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if len(extra) > 0:
- raise KickstartParseError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % self.currentCmd)
+ raise KickstartParseError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % self.currentCmd))
if self.currentCmd == "cmdline":
self.displayMode = DISPLAY_MODE_CMDLINE
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if len(extra) > 1:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one partition may be specified for driverdisk command."))
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one partition may be specified for driverdisk command.")))
if len(extra) == 1 and opts.source:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --source and partition may be specified for driverdisk command."))
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --source and partition may be specified for driverdisk command.")))
if not extra and not opts.source:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --source or partition must be specified for driverdisk command."))
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of --source or partition must be specified for driverdisk command.")))
ddd = self.handler.DriverDiskData()
self._setToObj(self.op, opts, ddd)
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if len(extra) > 1:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one partition may be specified for driverdisk command."))
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one partition may be specified for driverdisk command.")))
if len(extra) == 1 and opts.source:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --source and partition may be specified for driverdisk command."))
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --source and partition may be specified for driverdisk command.")))
elif len(extra) == 1 and opts.biospart:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --biospart and partition may be specified for driverdisk command."))
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --biospart and partition may be specified for driverdisk command.")))
elif opts.source and opts.biospart:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --biospart and --source may be specified for driverdisk command."))
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --biospart and --source may be specified for driverdisk command.")))
if not extra and not opts.source and not opts.biospart:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --source, --biospart, or partition must be specified for driverdisk command."))
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of --source, --biospart, or partition must be specified for driverdisk command.")))
ddd = self.handler.DriverDiskData()
self._setToObj(self.op, opts, ddd)
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if len(extra) > 0:
mapping = {"command": "fcoe", "options": extra}
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping))
self._setToObj(self.op, opts, zd)
zd.lineno = self.lineno
def parse(self, args):
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
-
+
if len(extra) != 0:
mapping = {"command": "firewall", "options": extra}
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)
-
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping))
+
self._setToSelf(self.op, opts)
return self
if errorCheck:
if (len(self.ignoredisk) == 0 and len(self.onlyuse) == 0) or (len(self.ignoredisk) > 0 and (len(self.onlyuse) > 0)):
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --drives or --only-use must be specified for ignoredisk command."))
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of --drives or --only-use must be specified for ignoredisk command.")))
return retval
if self.interactive:
howmany += 1
if howmany != 1:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --drives , --only-use , or --interactive must be specified for ignoredisk command."))
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of --drives , --only-use , or --interactive must be specified for ignoredisk command.")))
return retval
def parse(self, args):
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if len(extra) > 0:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "interactive")
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "interactive"))
self.interactive = True
return self
if len(extra) != 0:
mapping = {"command": "iscsi", "options": extra}
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping))
dd = self.handler.IscsiData()
self._setToObj(self.op, opts, dd)
def parse(self, args):
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if len(extra) != 1:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "iscsiname")
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "iscsiname"))
self.iscsiname = extra[0]
return self
if self.skip:
self.key = KS_INSTKEY_SKIP
elif len(extra) != 1:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "key")
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "key"))
else:
self.key = extra[0]
return op
def parse(self, args):
- (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
+ (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if len(extra) != 1:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "keyboard")
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "keyboard"))
self.keyboard = extra[0]
return self
def parse(self, args):
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if len(extra) != 1:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "lang")
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "lang"))
self.lang = extra[0]
return self
def parse(self, args):
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if len(extra) > 0:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "lilocheck")
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "lilocheck"))
self.check = True
return self
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if opts.port and not opts.host:
- raise KickstartParseError, formatErrorMsg(self.lineno, msg=_("Can't specify --port without --host."))
+ raise KickstartParseError (formatErrorMsg(self.lineno, msg=_("Can't specify --port without --host.")))
self._setToSelf(self.op, opts)
return self
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if len(extra) == 0:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Mount point required for %s") % "logvol")
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Mount point required for %s") % "logvol"))
lvd = self.handler.LogVolData()
self._setToObj(self.op, opts, lvd)
def parse(self, args):
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if len(extra) > 0:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "mediacheck")
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "mediacheck"))
self.mediacheck = True
return self
if self.currentCmd == "harddrive":
if self.biospart is None and self.partition is None or \
self.biospart is not None and self.partition is not None:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of biospart or partition options must be specified."))
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of biospart or partition options must be specified.")))
return self
if extra:
mapping = {"cmd": "monitor", "options": extra}
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(cmd)s command: %(options)s") % mapping)
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(cmd)s command: %(options)s") % mapping))
self._setToSelf(self.op, opts)
return self
self._setToSelf(self.op, opts)
if len(extra) != 1:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "mouse")
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "mouse"))
self.mouse = extra[0]
return self
for path in mpath.paths:
if path.device == dd.device:
mapping = {"device": path.device, "multipathdev": path.mpdev}
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Device '%(device)s' is already used in multipath '%(multipathdev)s'") % mapping)
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Device '%(device)s' is already used in multipath '%(multipathdev)s'") % mapping))
if mpath.name == dd.mpdev:
parent = x
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if len(extra) == 0:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Mount point required for %s") % "raid")
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Mount point required for %s") % "raid"))
if len(extra) == 1:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Partitions required for %s") % "raid")
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Partitions required for %s") % "raid"))
rd = self.handler.RaidData()
self._setToObj(self.op, opts, rd)
def parse(self, args):
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
-
+
if len(extra) != 0:
mapping = {"command": "repo", "options": extra}
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping))
# This is lame, but I can't think of a better way to make sure only
# one of these two is specified.
if opts.baseurl and opts.mirrorlist:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --baseurl and --mirrorlist may be specified for repo command."))
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --baseurl and --mirrorlist may be specified for repo command.")))
if self.urlRequired and not opts.baseurl and not opts.mirrorlist:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --baseurl or --mirrorlist must be specified for repo command."))
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of --baseurl or --mirrorlist must be specified for repo command.")))
rd = self.handler.RepoData()
self._setToObj(self.op, opts, rd)
def methodToRepo(self):
if not self.handler.method.url:
- raise KickstartError, formatErrorMsg(self.handler.method.lineno, msg=_("Method must be a url to be added to the repo list."))
+ raise KickstartError (formatErrorMsg(self.handler.method.lineno, msg=_("Method must be a url to be added to the repo list.")))
reponame = "ks-method-url"
repourl = self.handler.method.url
rd = self.handler.RepoData(name=reponame, baseurl=repourl)
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if opts.nomount and opts.romount:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --nomount and --romount may be specified for rescue command."))
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --nomount and --romount may be specified for rescue command.")))
self._setToSelf(self.op, opts)
self.rescue = True
self._setToSelf(self.op, opts)
if len(extra) != 1:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("A single argument is expected for the %s command") % "rootpw")
+ raise KickstartValueError ( formatErrorMsg(self.lineno, msg=_("A single argument is expected for the %s command") % "rootpw"))
self.password = extra[0]
return self
self._setToSelf(self.op, opts)
if len(self.disabled) == 0 and len(self.enabled) == 0:
- raise KickstartParseError, formatErrorMsg(self.lineno, msg=_("One of --disabled or --enabled must be provided."))
+ raise KickstartParseError (formatErrorMsg(self.lineno, msg=_("One of --disabled or --enabled must be provided.")))
return self
def parse(self, args):
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if len(extra) > 0:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "skipx")
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "skipx"))
self.skipx = True
return self
ud.lineno = self.lineno
if len(extra) != 1:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("A single argument is expected for the %s command") % "sshpw")
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("A single argument is expected for the %s command") % "sshpw"))
ud.password = extra[0]
if ud in self.dataList():
self._setToSelf(self.op, opts)
if len(extra) != 1:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("A single argument is expected for the %s command") % "timezone")
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("A single argument is expected for the %s command") % "timezone"))
self.timezone = extra[0]
return self
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if len(extra) > 1:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s only takes one argument") % "updates")
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s only takes one argument") % "updates"))
elif len(extra) == 0:
self.url = "floppy"
else:
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if len(extra) > 0:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade")
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade"))
if self.currentCmd == "upgrade":
self.upgrade = True
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if len(extra) > 0:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade")
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade"))
if (opts.root_device is not None) and (opts.root_device == ""):
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not accept empty parameter %s") % ("upgrade", "--root-device"))
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not accept empty parameter %s") % ("upgrade", "--root-device")))
else:
self.root_device = opts.root_device
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if extra:
mapping = {"command": "xconfig", "options": extra}
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping))
self._setToSelf(self.op, opts)
return self
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
if len(extra) > 0:
- raise KickstartParseError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "zerombr")
+ raise KickstartParseError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "zerombr"))
self.zerombr = True
return self
def error(self, msg):
if self.lineno != None:
- raise KickstartParseError, formatErrorMsg(self.lineno, msg=msg)
+ raise KickstartParseError ( formatErrorMsg(self.lineno, msg=msg))
else:
- raise KickstartParseError, msg
+ raise KickstartParseError ( msg)
def keys(self):
retval = []
for option in filter(lambda o: isinstance(o, Option), self.option_list):
if option.required and not seen(self, option):
- raise KickstartValueError, formatErrorMsg(self.lineno, _("Option %s is required") % option)
+ raise KickstartValueError (formatErrorMsg(self.lineno, _("Option %s is required") % option))
elif seen(self, option) and usedTooNew(self, option):
mapping = {"option": option, "intro": versionToString(option.introduced),
"version": versionToString(self.version)}
try:
ksurl = ll.split(' ')[1]
except:
- raise KickstartParseError, formatErrorMsg(lineno, msg=_("Illegal url for %%ksappend: %s") % ll)
+ raise KickstartParseError (formatErrorMsg(lineno, msg=_("Illegal url for %%ksappend: %s") % ll))
try:
url = grabber.urlopen(ksurl)
- except grabber.URLGrabError, e:
- raise KickstartError, formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file: %s") % e.strerror)
+ except grabber.URLGrabError as e:
+ raise KickstartError (formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file: %s") % e.strerror))
else:
# Sanity check result. Sometimes FTP doesn't catch a file
# is missing.
try:
if url.size < 1:
- raise KickstartError, formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file"))
+ raise KickstartError (formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file")))
except:
- raise KickstartError, formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file"))
+ raise KickstartError (formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file")))
# If that worked, write the remote file to the output kickstart
# file in one burst. Then close everything up to get ready to
"""
try:
fh = urlopen(f)
- except grabber.URLGrabError, e:
- raise KickstartError, formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % e.strerror)
+ except grabber.URLGrabError as e:
+ raise KickstartError (formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % e.strerror))
rc = _preprocessStateMachine (iter(fh.readlines()))
fh.close()
(opts, extra) = op.parse_args(args=line.split())
if opts.nodefaults and opts.optional:
- raise KickstartValueError, _("Group cannot specify both --nodefaults and --optional")
+ raise KickstartValueError (_("Group cannot specify both --nodefaults and --optional"))
# If the group name has spaces in it, we have to put it back together
# now.
handle it.
"""
if not obj.sectionOpen:
- raise TypeError, "no sectionOpen given for section %s" % obj
+ raise TypeError ("no sectionOpen given for section %s" % obj)
if not obj.sectionOpen.startswith("%"):
- raise TypeError, "section %s tag does not start with a %%" % obj.sectionOpen
+ raise TypeError ("section %s tag does not start with a %%" % obj.sectionOpen)
self._sections[obj.sectionOpen] = obj
if line == "":
# This section ends at the end of the file.
if self.version >= version.F8:
- raise KickstartParseError, formatErrorMsg(lineno, msg=_("Section does not end with %%end."))
+ raise KickstartParseError (formatErrorMsg(lineno, msg=_("Section does not end with %%end.")))
self._finalize(obj)
except StopIteration:
elif args and (self._validState(args[0]) or args[0] in ["%include", "%ksappend"]):
# This is an unterminated section.
if self.version >= version.F8:
- raise KickstartParseError, formatErrorMsg(lineno, msg=_("Section does not end with %%end."))
+ raise KickstartParseError (formatErrorMsg(lineno, msg=_("Section does not end with %%end.")))
# Finish up. We do not process the header here because
# kicking back out to STATE_COMMANDS will ensure that happens.
"""
try:
fn()
- except Exception, msg:
+ except Exception as msg:
if self.errorsAreFatal:
raise
else:
- print msg
+ print (msg)
def _isBlankOrComment(self, line):
return line.isspace() or line == "" or line.lstrip()[0] == '#'
continue
if len(args) == 1 or not args[1]:
- raise KickstartParseError, formatErrorMsg(lineno)
+ raise KickstartParseError (formatErrorMsg(lineno))
self._includeDepth += 1
# here.
newSection = args[0]
if not self._validState(newSection):
- raise KickstartParseError, formatErrorMsg(lineno, msg=_("Unknown kickstart section: %s" % newSection))
+ raise KickstartParseError (formatErrorMsg(lineno, msg=_("Unknown kickstart section: %s" % newSection)))
self._state = newSection
obj = self._sections[self._state]
try:
s = urlread(f)
- except grabber.URLGrabError, e:
- raise KickstartError, formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % e.strerror)
+ except grabber.URLGrabError as e:
+ raise KickstartError (formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % e.strerror))
self.readKickstartFromString(s, reset=False)
import os, sys
-__version__ = "0.28.6"
+__version__ = "0.28.17"
cur_path = os.path.dirname(__file__) or '.'
sys.path.insert(0, cur_path + '/3rdparty')
# * Used builtin function (W0141)
# * Invalid name for type (C0103)
# * Popen has no '%s' member (E1101)
-# pylint: disable=W0142, W0612, W0141, C0103, E1101
+# pylint: disable= W0612, C0103, E1101
""" Compression and Archiving
@retval: the path of the compressed file
"""
if not os.path.isfile(file_path):
- raise OSError, "can't compress a file not existed: '%s'" % file_path
+ raise OSError ("can't compress a file not existed: '%s'" % file_path)
try:
func = _COMPRESS_FORMATS[compress_format]
except KeyError:
- raise ValueError, "unknown compress format '%s'" % compress_format
+ raise ValueError ("unknown compress format '%s'" % compress_format)
return func(file_path, True)
def decompress(file_path, decompress_format=None):
@retval: the path of the decompressed file
"""
if not os.path.isfile(file_path):
- raise OSError, "can't decompress a file not existed: '%s'" % file_path
+ raise OSError ("can't decompress a file not existed: '%s'" % file_path)
(file_name, file_ext) = os.path.splitext(file_path)
for key, suffixes in _COMPRESS_SUFFIXES.iteritems():
try:
func = _COMPRESS_FORMATS[decompress_format]
except KeyError:
- raise ValueError, "unknown decompress format '%s'" % decompress_format
+ raise ValueError ("unknown decompress format '%s'" % decompress_format)
return func(file_path, False)
cmdln = ["tar", "-C", target_dir, "-xf", archive_name]
(returncode, stdout, stderr) = _call_external(cmdln)
if returncode != 0:
- raise OSError, os.linesep.join([stdout, stderr])
+ raise OSError (os.linesep.join([stdout, stderr]))
def _imp_tarfile(archive_name, target_name):
""" Archive the directory or the file with tarfile module
@retval: the archiving result
"""
if not os.path.exists(target_name):
- raise OSError, "archive object does not exist: '%s'" % target_name
+ raise OSError ("archive object does not exist: '%s'" % target_name)
for aformat, suffixes in _ARCHIVE_SUFFIXES.iteritems():
if filter(archive_name.endswith, suffixes):
archive_format = aformat
break
else:
- raise ValueError, "unknown archive suffix '%s'" % archive_name
+ raise ValueError ("unknown archive suffix '%s'" % archive_name)
try:
func, kwargs = _ARCHIVE_FORMATS[archive_format]
except KeyError:
- raise ValueError, "unknown archive format '%s'" % archive_format
+ raise ValueError ("unknown archive format '%s'" % archive_format)
archive_name = os.path.abspath(archive_name)
target_name = os.path.abspath(target_name)
raise exception if fail to extract archive
"""
if not os.path.exists(archive_name):
- raise OSError, "archived object does not exist: '%s'" % archive_name
+ raise OSError ("archived object does not exist: '%s'" % archive_name)
archive_name = os.path.abspath(archive_name)
target_name = os.path.abspath(target_name)
if os.path.exists(target_name) and not os.path.isdir(target_name):
- raise OSError, "%s should be directory where extracted files locate"\
- % target_name
+ raise OSError ("%s should be directory where extracted files locate"\
+ % target_name)
if not os.path.exists(target_name):
os.makedirs(target_name)
import subprocess
import rpm
import glob
+import errno
from mic import msger
from mic.utils import errors, proxy, misc
# list means some errors happened in the transaction and non-empty
# list that there were errors preventing the ts from starting...
if errs is not None:
- raise errors.BootstrapError("Transaction couldn't start: %s" % '\n'.join(errs))
+ raise errors.BootstrapError("Transaction couldn't start: %s" % errs)
def run_pkg_script(self, pkg, prog, script, arg):
mychroot = lambda: os.chroot(self.rootdir)
script = script.replace('\r', '')
os.write(tmpfd, script)
os.close(tmpfd)
- os.chmod(tmpfp, 0700)
+ os.chmod(tmpfp, 0o700)
try:
script_fp = os.path.join('/tmp', os.path.basename(tmpfp))
subprocess.call([prog, script_fp, arg], preexec_fn=mychroot)
- except (OSError, IOError), err:
+ except (OSError, IOError) as err:
msger.warning(str(err))
finally:
os.unlink(tmpfp)
pkgmgr.optionals = list(optlist)
map(pkgmgr.selectPackage, pkglist + list(optlist))
pkgmgr.runInstall()
- except (OSError, IOError, errors.CreatorError), err:
+ except (OSError, IOError, errors.CreatorError) as err:
raise errors.BootstrapError("%s" % err)
def run(self, cmd, chdir, rootdir=None, bindmounts=None):
gloablmounts = None
try:
proxy.set_proxy_environ()
- gloablmounts = setup_chrootenv(rootdir, bindmounts)
+ #globalmounts is no useless, remove it, currently function always return none.
+ setup_chrootenv(rootdir, bindmounts)
sync_timesetting(rootdir)
sync_passwdfile(rootdir)
sync_hostfile(rootdir)
# add additional information to original exception
value, tb = sys.exc_info()[1:]
value = '%s: %s' % (value, ' '.join(cmd))
- raise RuntimeError, value, tb
+ raise RuntimeError (value, tb)
finally:
#if self.logfile and os.path.isfile(self.logfile):
# msger.log(file(self.logfile).read())
msger.info("Launching shell. Exit to continue.\n"
"----------------------------------")
- globalmounts = setup_chrootenv(chrootdir, bindmounts)
+ #globalmounts is no useless, remove it, currently function always return none.
+ setup_chrootenv(chrootdir, bindmounts)
subprocess.call(execute, preexec_fn = mychroot, shell=True)
- except OSError, err:
+ except OSError as err:
raise errors.CreatorError("chroot err: %s" % str(err))
finally:
configmgr.chroot['saveto'] = args.saveto\r
\r
imagetype = misc.get_image_type(targetimage)\r
- if imagetype in ("ext3fsimg", "ext4fsimg", "btrfsimg"):\r
+ if imagetype in ("ext3fsimg", "ext4fsimg", "btrfsimg", "f2fsimg"):\r
imagetype = "loop"\r
\r
chrootclass = None\r
rpm.setVerbosity(rpm.RPMLOG_DEBUG)\r
except ImportError:\r
pass\r
-\r
#check the imager type\r
createrClass = None\r
for subcmd, klass in pluginmgr.get_plugins('imager').iteritems():\r
if args.pkgmgr is not None:\r
configmgr.create['pkgmgr'] = args.pkgmgr\r
\r
+ if args.skip_set_hosts:\r
+ configmgr.create['skip_set_hosts']=args.skip_set_hosts\r
+ if args.postscripts_maxruntime:\r
+ configmgr.create['postscripts_maxruntime']=int(args.postscripts_maxruntime)\r
+ if args.block_recommends:\r
+ configmgr.create['block_recommends']=args.block_recommends\r
if args.runtime:\r
configmgr.set_runtime(args.runtime)\r
\r
"run_script": None,
"tpk_install": None,
"use_mic_in_bootstrap": False,
+ "skip_set_hosts": False,
+ "postscripts_maxruntime": 120,
+ "block_recommends": False,
},
'chroot': {
"saveto": None,
try:
self.__siteconf = siteconf
self._parse_siteconf(siteconf)
- except ConfigParser.Error, error:
+ except ConfigParser.Error as error:
raise errors.ConfigError("%s" % error)
def __get_siteconf(self):
return self.__siteconf
import tarfile
import glob
import json
+import errno
from datetime import datetime
import rpm
import time
from mic.archive import get_archive_suffixes
from mic.conf import configmgr
from mic.utils.grabber import myurlgrab
-#post script max run time
-MAX_RUN_TIME = 120
class BaseImageCreator(object):
"""Installs a system to a chroot directory.
f = open(namefile, "w")
f.write(content)
f.close()
- self.outimage.append(namefile);
+ self.outimage.append(namefile)
# if 'content', save more details
if 'content' in self._recording_pkgs:
os.makedirs(self.workdir)
self.__builddir = tempfile.mkdtemp(dir = self.workdir,
prefix = "imgcreate-")
- except OSError, (err, msg):
+ except OSError as msg:
raise CreatorError("Failed create build directory in %s: %s" %
(self.tmpdir, msg))
def __create_minimal_dev(self):
"""Create a minimal /dev so that we don't corrupt the host /dev"""
origumask = os.umask(0000)
- devices = (('null', 1, 3, 0666),
- ('urandom',1, 9, 0666),
- ('random', 1, 8, 0666),
- ('full', 1, 7, 0666),
- ('ptmx', 5, 2, 0666),
- ('tty', 5, 0, 0666),
- ('zero', 1, 5, 0666))
+ devices = (('null', 1, 3, 0o666),
+ ('urandom',1, 9, 0o666),
+ ('random', 1, 8, 0o666),
+ ('full', 1, 7, 0o666),
+ ('ptmx', 5, 2, 0o666),
+ ('tty', 5, 0, 0o666),
+ ('zero', 1, 5, 0o666))
links = (("/proc/self/fd", "/dev/fd"),
("/proc/self/fd/0", "/dev/stdin"),
os.unlink(self._instroot + "/etc/mtab")
os.symlink("../proc/mounts", self._instroot + "/etc/mtab")
- self.__write_fstab()
+ #self.__write_fstab()
# get size of available space in 'instroot' fs
self._root_fs_avail = misc.get_filesystem_avail(self._instroot)
#self.__localinst_packages(pkg_manager)
self.__check_packages(pkg_manager)
- BOOT_SAFEGUARD = 256L * 1024 * 1024 # 256M
+ BOOT_SAFEGUARD = 256 * 1024 * 1024 # 256M
checksize = self._root_fs_avail
if checksize:
checksize -= BOOT_SAFEGUARD
if self.multiple_partitions:
pkg_manager._add_prob_flags(rpm.RPMPROB_FILTER_DISKSPACE)
pkg_manager.runInstall(checksize)
- except CreatorError, e:
+ except CreatorError as e:
raise
except KeyboardInterrupt:
raise
msger.info("Running sign scripts ...")
if os.path.exists(self._instroot + "/tmp"):
shutil.rmtree(self._instroot + "/tmp")
- os.mkdir (self._instroot + "/tmp", 0755)
+ os.mkdir (self._instroot + "/tmp", 0o755)
for s in kickstart.get_sign_scripts(self.ks):
(fd, path) = tempfile.mkstemp(prefix = "ks-runscript-",
dir = self._instroot + "/tmp")
os.write(fd, '\n')
os.write(fd, 'exit 0\n')
os.close(fd)
- os.chmod(path, 0700)
+ os.chmod(path, 0o700)
env = self._get_sign_scripts_env()
oldoutdir = os.getcwd()
if p.returncode != 0:
raise CreatorError("Failed to execute %%sign script "
"with '%s'" % (s.interp))
- except OSError, (err, msg):
+ except OSError as msg:
raise CreatorError("Failed to execute %%sign script "
"with '%s' : %s" % (s.interp, msg))
finally:
msger.info("Running post scripts ...")
if os.path.exists(self._instroot + "/tmp"):
shutil.rmtree(self._instroot + "/tmp")
- os.mkdir (self._instroot + "/tmp", 0755)
+ os.mkdir (self._instroot + "/tmp", 0o755)
for s in kickstart.get_post_scripts(self.ks):
(fd, path) = tempfile.mkstemp(prefix = "ks-postscript-",
dir = self._instroot + "/tmp")
os.write(fd, '\n')
os.write(fd, 'exit 0\n')
os.close(fd)
- os.chmod(path, 0700)
+ os.chmod(path, 0o700)
env = self._get_post_scripts_env(s.inChroot)
if 'PATH' not in env:
else:
preexec = self._chroot
script = "/tmp/" + os.path.basename(path)
-
start_time = time.time()
try:
try:
while p.poll() == None:
msger.info(p.stdout.readline().strip())
end_time = time.time()
- if (end_time - start_time)/60 > MAX_RUN_TIME:
- raise CreatorError("Your post script is executed more than "+MAX_RUN_TIME+"mins, please check it!")
+ if (end_time - start_time)/60 > configmgr.create['postscripts_maxruntime']:
+ raise CreatorError("Your post script is executed more than %d mins, please check it!" % configmgr.create['postscripts_maxruntime'])
if p.returncode != 0:
raise CreatorError("Failed to execute %%post script "
"with '%s'" % (s.interp))
- except OSError, (err, msg):
+ except OSError as msg:
raise CreatorError("Failed to execute %%post script "
"with '%s' : %s" % (s.interp, msg))
finally:
# find . | cpio --create --'format=newc' | gzip > ../ramdisk.img
runner.show('find . | cpio --create %s | gzip > %s' % (item['cpioopts'], tmp_cpio_imgfile))
os.chdir(oldoutdir)
- except OSError, (errno, msg):
+ except OSError as msg:
raise CreatorError("Create image by cpio error: %s" % msg)
def copy_cpio_image(self):
# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import os
+import sys
import glob
import shutil
'label': label,
'fslabel':fslabel,
'name': imgname,
- 'size': part.size or 4096L * 1024 * 1024,
+ 'size': part.size or 4096 * 1024 * 1024,
'fstype': part.fstype or 'ext3',
'fsopts': part.fsopts or None,
'aft_fstype': aft_fstype or None,
'extopts': part.extopts or None,
+ 'f2fsopts': part.f2fsopts or None,
'vdfsopts': part.vdfsopts or None,
'squashfsopts': part.squashfsopts or None,
+ 'squashfsoptions_maxsize': part.squashfsoptions_maxsize or None,
'cpioopts': part.cpioopts or None,
'loop': None, # to be created in _mount_instroot
'uuid': part.uuid or None,
if self.ks:
self.__image_size = kickstart.get_image_size(self.ks,
- 4096L * 1024 * 1024)
+ 4096 * 1024 * 1024)
else:
self.__image_size = 0
"mountpoint": "/",
"label": self.name,
"name": imgname,
- "size": self.__image_size or 4096L,
+ "size": self.__image_size or 4096,
"fstype": self.__fstype or "ext3",
+ "f2fsopts": None,
"extopts": None,
"loop": None,
"uuid": None,
fstype = loop['fstype']
fsopt = loop['fsopts']
mp = os.path.join(self._instroot, loop['mountpoint'].lstrip('/'))
- size = loop['size'] * 1024L * 1024L
+ size = loop['size'] * 1024 * 1024
imgname = loop['name']
if fstype in ("ext2", "ext3", "ext4"):
MyDiskMount = fs.BtrfsDiskMount
elif fstype in ("vfat", "msdos"):
MyDiskMount = fs.VfatDiskMount
+ elif fstype == "f2fs":
+ MyDiskMount = fs.F2fsDiskMount
else:
raise MountError('Cannot support fstype: %s' % fstype)
if fstype in ("ext2", "ext3", "ext4"):
loop['loop'].extopts = loop['extopts']
+ elif fstype == "f2fs":
+ loop['loop'].f2fsopts = loop['f2fsopts']
try:
msger.verbose('Mounting image "%s" on "%s"' % (imgname, mp))
loop['loop'].uuid:
loop['kspart'].uuid = loop['loop'].uuid
- except MountError, e:
+ except MountError as e:
raise
def _unmount_instroot(self):
else:
runner.show("%s " % args)
+ if item['squashfsoptions_maxsize']:
+ squashfsoptions_maxsize=int(item['squashfsoptions_maxsize']) * 1024 * 1024
+ imgsize = os.stat(self._imgdir+"/"+item['label']+fs_suffix).st_size
+ if imgsize > squashfsoptions_maxsize:
+ msger.error("squashfs img size is too large (%d > %d)" % (imgsize, squashfsoptions_maxsize))
+ sys.exit()
+
if item['aft_fstype'] == "vdfs":
##FIXME temporary code - replace this with fs.mkvdfs()
if item['vdfsopts']:
--- /dev/null
+#
+# Copyright (c) 2014 Intel, Inc.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; version 2 of the License
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty 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., 59
+# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+import os
+import shutil
+
+from mic.imager.loop import LoopImageCreator
+from mic.utils import errors, fs_related, runner
+
+class QcowImageCreator(LoopImageCreator):
+ img_format = 'qcow'
+
+ def __init__(self, creatoropts=None, pkgmgr=None):
+ LoopImageCreator.__init__(self, creatoropts, pkgmgr)
+ self.cmd_qemuimg = 'qemu-img'
+
+ def _stage_final_image(self):
+ try:
+ self.cmd_qemuimg = fs_related.find_binary_path('qemu-img')
+ except errors.CreatorError:
+ return LoopImageCreator._stage_final_image(self)
+
+ self._resparse()
+
+ imgfile = None
+ for item in self._instloops:
+ if item['mountpoint'] == '/':
+ 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']})
+ imgfile = os.path.join(self._imgdir, item['name'])
+
+ if imgfile:
+ qemuimage = imgfile + ".x86"
+ runner.show("%s convert -O qcow2 %s %s"
+ % (self.cmd_qemuimg, imgfile, qemuimage))
+ os.unlink(imgfile)
+ os.rename(qemuimage, imgfile)
+
+ for item in os.listdir(self._imgdir):
+ shutil.move(os.path.join(self._imgdir, item),
+ os.path.join(self._outdir, item))
% (rootdev, options)
if footlabel == 0:
syslinux_conf += "\tmenu default\n"
- footlabel += 1;
+ footlabel += 1
msger.debug("Writing syslinux config %s/boot/extlinux/extlinux.conf" \
% self._instroot)
if not self.__instloop is None:
try:
self.__instloop.cleanup()
- except MountError, err:
+ except MountError as err:
msger.warning("%s" % err)
def _resparse(self, size = None):
from custom_commands import desktop, micrepo, micboot, partition, installerfw
from mic.utils.safeurl import SafeURL
-
AUTH_URL_PTN = r"(?P<scheme>.*)://(?P<username>.*)(:?P<password>.*)?@(?P<url>.*)"
def wrapper(*kargs, **kwargs):
try:
func(*kargs, **kwargs)
- except (OSError, IOError, errors.KsError), err:
+ except (OSError, IOError, errors.KsError) as err:
cfgcls = kargs[0].__class__.__name__
if msger.ask("Failed to apply %s, skip and continue?" % cfgcls):
msger.warning("%s" % err)
try:
ks.readKickstart(path)
- except (kserrors.KickstartParseError, kserrors.KickstartError), err:
+ except (kserrors.KickstartParseError, kserrors.KickstartError) as err:
if msger.ask("Errors occured on kickstart file, skip and continue?"):
msger.warning("%s" % err)
pass
subprocess.call([lncmd, "-s",
self.path(tz_midst),
self.path(tz_dest)])
- except (IOError, OSError), (errno, msg):
+ except (IOError, OSError) as msg:
raise errors.KsError("Timezone setting error: %s" % msg)
class AuthConfig(KickstartConfig):
p1 = subprocess.Popen(["/bin/echo", "%s:%s" %(user, password)],
stdout = subprocess.PIPE,
preexec_fn = self.chroot)
- p2 = subprocess.Popen(["/usr/sbin/chpasswd", "-m"],
+ p2 = subprocess.Popen(["/usr/sbin/chpasswd", "-c","SHA512"],
stdin = p1.stdout,
stdout = subprocess.PIPE,
preexec_fn = self.chroot)
@apply_wrapper
def apply(self, user):
for userconfig in user.userList:
+ #There exist root user already.
+ if userconfig.name == "root":
+ msger.debug("root user, just set root user groups attribution")
+ if userconfig.groups:
+ self.call(["/usr/sbin/usermod", "-a", "-G", "%s" % string.join(userconfig.groups, ","), "root"])
+ continue
self.addUser(userconfig)
class ServicesConfig(KickstartConfig):
@apply_wrapper
def apply(self, ksxconfig):
if ksxconfig.startX and os.path.exists(self.path("/etc/inittab")):
- f = open(self.path("/etc/inittab"), "rw+")
+ f = open(self.path("/etc/inittab"), "r+")
buf = f.read()
buf = buf.replace("id:3:initdefault", "id:5:initdefault")
f.seek(0)
p = self.path("/etc/sysconfig/network-scripts/ifcfg-" + network.device)
f = file(p, "w+")
- os.chmod(p, 0644)
+ os.chmod(p, 0o644)
f.write("DEVICE=%s\n" % network.device)
f.write("BOOTPROTO=%s\n" % network.bootProto)
p = self.path("/etc/sysconfig/network-scripts/keys-" + network.device)
f = file(p, "w+")
- os.chmod(p, 0600)
+ os.chmod(p, 0o600)
f.write("KEY=%s\n" % network.wepkey)
f.close()
def write_sysconfig(self, useipv6, hostname, gateway):
path = self.path("/etc/sysconfig/network")
f = file(path, "w+")
- os.chmod(path, 0644)
+ os.chmod(path, 0o644)
f.write("NETWORKING=yes\n")
path = self.path("/etc/hosts")
f = file(path, "w+")
- os.chmod(path, 0644)
+ os.chmod(path, 0o644)
f.write("127.0.0.1\t\t%s\n" % localline)
f.write("::1\t\tlocalhost6.localdomain6 localhost6\n")
f.close()
path = self.path("/etc/resolv.conf")
f = file(path, "w+")
- os.chmod(path, 0644)
+ os.chmod(path, 0o644)
for ns in (nameservers):
if ns:
nameservers = network.nameserver.split(",")
self.write_sysconfig(useipv6, hostname, gateway)
- self.write_hosts(hostname)
+
+ #to avoid import error because of import each other
+ from mic.conf import configmgr
+ path=self.path("/etc/hosts")
+ if configmgr.create['skip_set_hosts'] == False and os.path.exists(path) == False:
+ self.write_hosts(hostname)
self.write_resolv(nodns, nameservers)
def use_installerfw(ks, feature):
if p.mountpoint == "/" and p.size:
__size = p.size
if __size > 0:
- return int(__size) * 1024L * 1024L
+ return int(__size) * 1024 * 1024
else:
return default
def _getParser(self):
try:
- op = KSOptionParser(lineno=self.lineno)
+ #ingnore this pylit error, the lineno argument exist in olg version. using this way can compate old version.
+ op = KSOptionParser(lineno=self.lineno) #pylint: disable=unexpected-keyword-arg
except TypeError:
# the latest version has not lineno argument
op = KSOptionParser()
(opts, extra) = self.op.parse_args(args=args)
if extra:
- m = _("Unexpected arguments to %(command)s command: %(options)s") \
+ m = ("Unexpected arguments to %(command)s command: %(options)s") \
% {"command": "desktop", "options": extra}
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=m)
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg=m))
self._setToSelf(self.op, opts)
if len(extra) != 1:
msg = "Kickstart command \"%s\" requires one " \
"argumet - a list of legacy features to disable" % self.currentCmd
- raise KickstartValueError, formatErrorMsg(self.lineno, msg = msg)
+ raise KickstartValueError (formatErrorMsg(self.lineno, msg = msg))
self.features = extra[0].split(",")
self.deleteRemovedAttrs()
self.align = kwargs.get("align", None)
self.extopts = kwargs.get("extopts", None)
+ self.f2fsopts = kwargs.get("f2fsopts", None)
self.part_type = kwargs.get("part_type", None)
self.uuid = kwargs.get("uuid", None)
self.exclude_image = kwargs.get("exclude_from_image", False)
self.vdfsopts = kwargs.get("vdfsopts", None)
self.squashfsopts = kwargs.get("squashfsopts", None)
+ self.squashfsoptions_maxsize = kwargs.get("squashfsoptions_maxsize", None)
self.cpioopts = kwargs.get("cpioopts", None)
self.no_shrink = kwargs.get("no_shrink", False)
self.init_expand = kwargs.get("init_expand", False)
retval += " --align"
if self.extopts:
retval += " --extoptions=%s" % self.extopts
+ if self.f2fsopts:
+ retval += " --f2fsoptions=%s" % self.f2fsopts
if self.part_type:
retval += " --part-type=%s" % self.part_type
if self.uuid:
retval += " --vdfsoptions=%s" % self.vdfsopts
if self.squashfsopts:
retval += " --squashfsoptions=%s" % self.squashfsopts
+ if self.squashfsoptions_maxsize:
+ retval += " --squashfsoptions_maxsize=%s" % self.squashfsoptions_maxsize
if self.cpioopts:
retval += " --cpiooptions=%s" % self.cpioopts
if self.no_shrink:
default=None)
op.add_option("--extoptions", type="string", action="store", dest="extopts",
default=None)
+ op.add_option("--f2fsoptions", type="string", action="store", dest="f2fsopts",
+ default=None)
op.add_option("--part-type", type="string", action="store", dest="part_type",
default=None)
op.add_option("--uuid", dest="uuid", action="store", type="string")
default=None)
op.add_option("--squashfsoptions", type="string", action="store", dest="squashfsopts",
default=None)
+ op.add_option("--squashfsoptions_maxsize", type="string", action="store", dest="squashfsoptions_maxsize",
+ default=None)
op.add_option("--cpiooptions", type="string", action="store", dest="cpioopts",
default=None)
op.add_option("--no-shrink", action="store_true", dest="no_shrink", default=False)
self.plugin_dirs[pdir] = True
msger.debug("Plugin module %s:%s imported"\
% (mod, pymod.__file__))
- except ImportError, err:
+ except ImportError as err:
msg = 'Failed to load plugin %s/%s: %s' \
% (os.path.basename(pdir), mod, err)
msger.verbose(msg)
def show_plugins(cls):
for cls in cls.plugins[cls.mic_plugin_type]:
- print cls
+ print (cls)
def get_plugins(cls):
return cls.plugins
# with this program; if not, write to the Free Software Foundation, Inc., 59
# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-from __future__ import with_statement
import os
import sys
import glob
from mic.utils.fs_related import find_binary_path, makedirs
from mic.chroot import setup_chrootenv, cleanup_chrootenv, ELF_arch
+from mic.plugin import pluginmgr
+
_libc = ctypes.cdll.LoadLibrary(None)
_errno = ctypes.c_int.in_dll(_libc, "errno")
_libc.personality.argtypes = [ctypes.c_ulong]
return (os.stat("/").st_ino != 2)
def bootstrap_mic(argv=None):
-
-
def mychroot():
os.chroot(rootdir)
os.chdir(cwd)
bindmounts = get_bindmounts(cropts)
ret = bsenv.run(argv, cwd, rootdir, bindmounts)
- except errors.BootstrapError, err:
+ except errors.BootstrapError as err:
raise errors.CreatorError("Failed to download/install bootstrap package " \
"or the package is in bad format: %s" % err)
- except RuntimeError, err:
+ except RuntimeError as err:
#change exception type but keep the trace back
- value, tb = sys.exc_info()[1:]
- raise errors.CreatorError, value, tb
+ value,tb = sys.exc_info()[1:]
+ raise errors.CreatorError((value,tb))
else:
sys.exit(ret)
finally:
for key, value in micpaths.items():
try:
safecopy(value, _path(eval(key)), False, ["*.pyc", "*.pyo"])
- except (OSError, IOError), err:
+ except (OSError, IOError) as err:
raise errors.BootstrapError(err)
# auto select backend
wf.write(conf_str)
# chmod +x /usr/bin/mic
- os.chmod(_path(binpth), 0777)
+ os.chmod(_path(binpth), 0o777)
# correct python interpreter
mic_cont = file(_path(binpth)).read()
makedirs(os.path.dirname(dst))
shutil.copy2(src, dst)
+
+def prepare_create(args):
+ """
+ Usage:
+ ${name} ${cmd_name} <ksfile> [OPTS]
+
+ ${cmd_option_list}
+ """
+
+ if args is None:
+ raise errors.Usage("Invalid arguments.")
+
+ creatoropts = configmgr.create
+ ksconf = args.ksfile
+
+ if creatoropts['runtime'] == 'bootstrap':
+ configmgr._ksconf = ksconf
+ bootstrap_mic()
+
+ recording_pkgs = []
+ if len(creatoropts['record_pkgs']) > 0:
+ recording_pkgs = creatoropts['record_pkgs']
+
+ if creatoropts['release'] is not None:
+ if 'name' not in recording_pkgs:
+ recording_pkgs.append('name')
+ if 'vcs' not in recording_pkgs:
+ recording_pkgs.append('vcs')
+
+ configmgr._ksconf = ksconf
+
+ # try to find the pkgmgr
+ pkgmgr = None
+ backends = pluginmgr.get_plugins('backend')
+ if 'auto' == creatoropts['pkgmgr']:
+ for key in configmgr.prefer_backends:
+ if key in backends:
+ pkgmgr = backends[key]
+ break
+ else:
+ for key in backends.keys():
+ if key == creatoropts['pkgmgr']:
+ pkgmgr = backends[key]
+ break
+
+ if not pkgmgr:
+ raise errors.CreatorError("Can't find backend: %s, "
+ "available choices: %s" %
+ (creatoropts['pkgmgr'],
+ ','.join(backends.keys())))
+ return creatoropts, pkgmgr, recording_pkgs
+
"""
try:
os.makedirs(dirname)
- except OSError, err:
+ except OSError as err:
if err.errno != errno.EEXIST:
raise
def mkvdfs(in_img, out_img, fsoptions):
""" This function is incomplete. """
fullpathmkvdfs = find_binary_path("mkfs.vdfs")
-# args = fullpathmkvdfs + " -i -r "+ in_img + " -z 1024M -s " + out_img
+# args = fullpathmkvdfs + " -i -r "+ in_img + " -z 1024M -s " + out_img
args = fullpathmkvdfs + " " + fsoptions + " -r " + in_img + " " + out_img
msger.verbose("vdfs args: %s" % args)
runner.show("%s --help" % fullpathmkvdfs)
-# if not sys.stdout.isatty():
+# if not sys.stdout.isatty():
# args.append("-no-progress")
# runner.show("%s --help" % fullpathmkvdfs)
ret = runner.show(args)
try:
makedirs(self.dest)
- except OSError, err:
+ except OSError as err:
if err.errno == errno.ENOSPC:
msger.warning("No space left on device '%s'" % err.filename)
return
msger.debug("Extending sparse file %s to %d" % (self.lofile, size))
if create:
- fd = os.open(self.lofile, flags, 0644)
+ fd = os.open(self.lofile, flags, 0o644)
else:
fd = os.open(self.lofile, flags)
os.ftruncate(fd, size)
except:
# may be limited by 2G in 32bit env
- os.ftruncate(fd, 2**31L)
+ os.ftruncate(fd, 2**31)
os.close(fd)
if self.rmdir and not self.mounted:
try:
os.rmdir(self.mountdir)
- except OSError, e:
+ except OSError as e:
pass
self.rmdir = False
self.mounted = True
+class F2fsDiskMount(DiskMount):
+ """A DiskMount object that is able to format/resize f2fs filesystems."""
+ def __init__(self, disk, mountdir, fstype, blocksize, fslabel, rmmountdir=True, skipformat = False, fsopts = None, fsuuid=None):
+ self.__check_f2fs()
+ DiskMount.__init__(self, disk, mountdir, fstype, rmmountdir)
+ self.blocksize = blocksize
+ self.fslabel = fslabel.replace("/", "")
+ self.uuid = fsuuid or None
+ self.skipformat = skipformat
+ self.fsopts = fsopts
+ self.__f2fsopts = None
+ self.blkidcmd = find_binary_path("blkid")
+ self.dumpe2fs = find_binary_path("dump." + self.fstype)
+ self.fsckcmd = find_binary_path("fsck." + self.fstype)
+ self.resizecmd = find_binary_path("resize." + self.fstype)
+
+ def __get_f2fsopts(self):
+ return self.__f2f2opts
+
+ def __set_f2fsopts(self, val):
+ if val is None:
+ self.__f2fsopts = None
+ else:
+ self.__f2fsopts = val
+ f2fsopts = property(__get_f2fsopts, __set_f2fsopts)
+
+ def __check_f2fs(self):
+ found = False
+ """ Need to load f2fs module to mount it """
+ load_module("f2fs")
+ for line in open("/proc/filesystems").xreadlines():
+ if line.find("f2fs") > -1:
+ found = True
+ break
+ if not found:
+ raise MountError("Your system can't mount f2fs filesystem, please make sure your kernel has f2fs support and the module f2fs.ko has been loaded.")
+
+ def __parse_field(self, output, field):
+ for line in output.split(" "):
+ if line.startswith(field + "="):
+ return line[len(field) + 1:].strip().replace("\"", "")
+
+ raise KeyError("Failed to find field '%s' in output" % field)
+
+ def __format_filesystem(self):
+ if self.skipformat:
+ msger.debug("Skip filesystem format.")
+ return
+
+ msger.verbose("Formating %s filesystem on %s" % (self.fstype, self.disk.device))
+
+ cmdlist = [self.mkfscmd, "-l", self.fslabel]
+ if self.__f2fsopts:
+ cmdlist.extend(self.__f2fsopts.split())
+ cmdlist.extend([self.disk.device])
+
+ rc, errout = runner.runtool(cmdlist, catch=2)
+ if rc != 0:
+ raise MountError("Error creating %s filesystem on disk %s:\n%s" %
+ (self.fstype, self.disk.device, errout))
+
+ self.uuid = self.__parse_field(runner.outs([self.blkidcmd, self.disk.device]), "UUID")
+
+ def __resize_filesystem(self, size = None):
+ msger.info("Resizing filesystem ...")
+ current_size = os.stat(self.disk.lofile)[stat.ST_SIZE]
+
+ if size is None:
+ size = self.disk.size
+
+ if size == current_size:
+ return
+
+ if size > current_size:
+ self.disk.expand(size=size)
+
+ self.__fsck()
+
+ return size
+
+ def __create(self):
+ resize = False
+ if not self.disk.fixed() and self.disk.exists():
+ resize = True
+
+ self.disk.create()
+
+ if resize:
+ self.__resize_filesystem()
+ else:
+ self.__format_filesystem()
+
+ def mount(self, options = None, init_expand = False):
+ self.__create()
+ if init_expand:
+ expand_size = long(self.disk.size * 1.5)
+ msger.info("Initial partition size expanded : %ld -> %ld" % (self.disk.size, expand_size))
+ self.__resize_filesystem(expand_size)
+ self.disk.reread_size()
+ DiskMount.mount(self, options)
+
+ def __fsck(self):
+ msger.info("Checking filesystem %s" % self.disk.lofile)
+ runner.quiet([self.fsckcmd, self.disk.lofile])
+
+ def __get_size_from_filesystem(self):
+ return self.disk.size
+
+ def __resize_to_minimal(self):
+ msger.info("Resizing filesystem to minimal ...")
+ self.__fsck()
+
+ return self.__get_size_from_filesystem()
+
+ def resparse(self, size = None):
+ self.cleanup()
+ if size == 0:
+ minsize = 0
+ else:
+ minsize = self.__resize_to_minimal()
+ self.disk.truncate(minsize)
+ self.__resize_filesystem(size)
+ return minsize
+
class ExtDiskMount(DiskMount):
"""A DiskMount object that is able to format/resize ext[23] filesystems."""
def __init__(self, disk, mountdir, fstype, blocksize, fslabel, rmmountdir=True, skipformat = False, fsopts = None, fsuuid=None):
resize2fs(self.disk.lofile, size)
if size and size != os.stat(self.disk.lofile)[stat.ST_SIZE]:
- raise MountError("Failed to resize filesystem %s to " % (self.disk.lofile, size))
+ raise MountError("Failed to resize filesystem %s to %d " % (self.disk.lofile, size))
return size
return
msger.verbose("Formating %s filesystem on %s" % (self.fstype, self.disk.device))
- rc = runner.show([self.mkfscmd, "-L", self.fslabel, self.disk.device])
+ rc = runner.show([self.mkfscmd, "-L", self.fslabel, "-m", "single", self.disk.device])
if rc != 0:
raise MountError("Error creating %s filesystem on disk %s" % (self.fstype,self.disk.device))
imgloop = LoopbackDisk(image, None) # Passing bogus size - doesn't matter
cowloop = SparseLoopbackDisk(os.path.join(os.path.dirname(path), "osmin"),
- 64L * 1024L * 1024L)
+ 64 * 1024 * 1024)
snapshot = DeviceMapperSnapshot(imgloop, cowloop)
return 10
fint = lambda x: x[9:].isdigit() and int(x[9:]) or 0
- maxid = 1 + max(filter(lambda x: x<100,
+ maxid = 1 + max(filter(lambda x: x<256,
map(fint, glob.glob("/dev/loop[0-9]*"))))
if maxid < 10: maxid = 10
- if maxid >= 100: raise
+ if maxid >= 256:
+ raise Exception("maxid >= 256")
return maxid
def _kpseek(self, device):
try:
self.cleanup()
self.device = None
- except MountError, e:
+ except MountError as e:
raise CreatorError("%s" % e)
def cleanup(self):
DEVICE_LOCKFILE = "/var/lock/__mic_loopdev.lock"
def get_loop_device(losetupcmd, lofile):
- global DEVICE_PIDFILE_DIR
- global DEVICE_LOCKFILE
-
import fcntl
makedirs(os.path.dirname(DEVICE_LOCKFILE))
fp = open(DEVICE_LOCKFILE, 'w')
with open(pidfile, 'w') as wf:
wf.write(str(os.getpid()))
- except MountError, err:
+ except MountError as err:
raise CreatorError("%s" % str(err))
except:
raise
if entry['index'] >= header['entries_cnt']:
raise MountError("Partition table at LBA %d has only %d " \
- "records cannot change record number %d" % \
+ "records cannot change record number " % \
(header['entries_cnt'], entry['index']))
# Read raw GPT header
raw_hdr = self._read_disk(header['hdr_offs'], _GPT_HEADER_SIZE)
http_headers=(('Pragma', 'no-cache'),),
quote=0,
progress_obj=progress_obj)
- except grabber.URLGrabError, err:
+ except grabber.URLGrabError as err:
tmp = SafeURL(url)
msg = str(err)
pass
def unhide_loopdev_presentation():
- global _LOOP_RULE_PTH
+ #global _LOOP_RULE_PTH
if not _LOOP_RULE_PTH:
return
def remove_temp_ks():
try:
os.unlink(ksconf)
- except OSError, err:
+ except OSError as err:
msger.warning('Failed to remove temp ks file:%s:%s' % (ksconf, err))
import atexit
if file_header[0:len(vdi_flag)] == vdi_flag:
return maptab["vdi"]
+ #Checking f2fs fs type.
+ blkidcmd = find_binary_path("blkid")
+ out = runner.outs([blkidcmd, '-o', 'value', '-s', 'TYPE', path])
+ if out == "f2fs":
+ return "f2fsimg"
output = runner.outs(['file', path])
isoptn = re.compile(r".*ISO 9660 CD-ROM filesystem.*(bootable).*")
usbimgptn = re.compile(r".*x86 boot sector.*active.*")
break
for elm in root.getiterator("%sdata" % ns):
- if elm.attrib["type"] in ("group_gz", "group"):
+ #"group" type has no "open-checksum" filed, remove it.
+ if elm.attrib["type"] == "group_gz":
filepaths['comps'] = elm.find("%slocation" % ns).attrib['href']
checksums['comps'] = elm.find("%sopen-checksum" % ns).text
sumtypes['comps'] = elm.find("%sopen-checksum" % ns).attrib['type']
ns = root.getroot().tag
ns = ns[0:ns.rindex("}")+1]
for elm in root.getiterator("%spackage" % ns):
- if elm.find("%sname" % ns).text == pkg:
- if elm.find("%sarch" % ns).text in arches:
- if repo["priority"] != None:
- tmpprior = int(repo["priority"])
- if tmpprior < priority:
- priority = tmpprior
- location = elm.find("%slocation" % ns)
- pkgpath = "%s" % location.attrib['href']
- target_repo = repo
- break
- elif tmpprior > priority:
- break
- version = elm.find("%sversion" % ns)
- tmpver = "%s-%s" % (version.attrib['ver'], version.attrib['rel'])
- if tmpver > ver:
- ver = tmpver
+ if elm.find("%sname" % ns).text == pkg and elm.find("%sarch" % ns).text in arches:
+ if repo["priority"] != None:
+ tmpprior = int(repo["priority"])
+ if tmpprior < priority:
+ priority = tmpprior
location = elm.find("%slocation" % ns)
pkgpath = "%s" % location.attrib['href']
target_repo = repo
- break
+ break
+ elif tmpprior > priority:
+ break
+ version = elm.find("%sversion" % ns)
+ tmpver = "%s-%s" % (version.attrib['ver'], version.attrib['rel'])
+ if tmpver > ver:
+ ver = tmpver
+ location = elm.find("%slocation" % ns)
+ pkgpath = "%s" % location.attrib['href']
+ target_repo = repo
+ break
if repo["primary"].endswith(".sqlite"):
con = sqlite.connect(repo["primary"])
if arch:
def is_statically_linked(binary):
return ", statically linked, " in runner.outs(['file', binary])
-def setup_qemu_emulator(rootdir, arch):
- qemu_emulators = []
- # mount binfmt_misc if it doesn't exist
- if not os.path.exists("/proc/sys/fs/binfmt_misc"):
- modprobecmd = find_binary_path("modprobe")
- runner.show([modprobecmd, "binfmt_misc"])
- if not os.path.exists("/proc/sys/fs/binfmt_misc/register"):
- mountcmd = find_binary_path("mount")
- runner.show([mountcmd, "-t", "binfmt_misc", "none", "/proc/sys/fs/binfmt_misc"])
-
- # qemu_emulator is a special case, we can't use find_binary_path
- # qemu emulator should be a statically-linked executable file
+def get_qemu_arm_binary(arch):
if arch == "aarch64":
node = "/proc/sys/fs/binfmt_misc/aarch64"
if os.path.exists("/usr/bin/qemu-arm64") and is_statically_linked("/usr/bin/qemu-arm64"):
if not os.path.exists("/usr/bin/%s" % arm_binary):
raise CreatorError("Please install a statically-linked %s" % arm_binary)
+ return (arm_binary, node)
+
+def setup_qemu_emulator(rootdir, arch):
+ qemu_emulators = []
+ # mount binfmt_misc if it doesn't exist
+ if not os.path.exists("/proc/sys/fs/binfmt_misc"):
+ modprobecmd = find_binary_path("modprobe")
+ runner.show([modprobecmd, "binfmt_misc"])
+ if not os.path.exists("/proc/sys/fs/binfmt_misc/register"):
+ mountcmd = find_binary_path("mount")
+ runner.show([mountcmd, "-t", "binfmt_misc", "none", "/proc/sys/fs/binfmt_misc"])
+
+ # qemu_emulator is a special case, we can't use find_binary_path
+ # qemu emulator should be a statically-linked executable file
+ arm_binary, node = get_qemu_arm_binary(arch)
qemu_emulator = "/usr/bin/%s" % arm_binary
if not os.path.exists(rootdir + "/usr/bin"):
_my_noproxy_list = []
def set_proxy_environ():
- global _my_noproxy, _my_proxies
if not _my_proxies:
return
for key in _my_proxies.keys():
ipint = 0
shift = 24
for dec in ip.split("."):
+ if not dec.isdigit():
+ continue
ipint |= int(dec) << shift
shift -= 8
return ipint
c_result = os.popen(cmd).readlines()
if len(c_result) == 0:
continue
- except Exception,e:
+ except Exception as e:
msger.warning(str(e))
continue
to_list = c_result[0].strip("\n").split(",")
shift = 24
netmask = 0
for dec in mask.split("."):
+ if not dec.isdigit():
+ continue
netmask |= int(dec) << shift
shift -= 8
ip &= netmask
elif what == rpm.RPMCALLBACK_INST_PROGRESS:
if h is not None:
- percent = (self.total_installed*100L)/self.total_actions
+ percent = (self.total_installed*100)/self.total_actions
if total > 0:
try:
hdr, rpmloc = h
try:
hdr = ts.hdrFromFdno(fdno)
- except rpm.error, e:
+ except rpm.error as e:
if str(e) == "public key not availaiable":
value = 1
if str(e) == "public key not available":
(sout, serr) = p.communicate()
# combine stdout and stderr, filter None out
out = ''.join(filter(None, [sout, serr]))
- except OSError, e:
+ except OSError as e:
if e.errno == 2:
# [Errno 2] No such file or directory
raise errors.CreatorError('Cannot run command: %s, lost dependency?' % cmd)
+* Thu Aug 10 2022 Biao Wang <biao716.wang@samsung.com> - 0.28.17
+ * Add block-recommends option to block install recommends packages.
+
+* Thu Feb 10 2022 Biao Wang <biao716.wang@samsung.com> - 0.28.16
+ * Add postscripts-maxruntime option to set the max run time for post scripts.
+
+* Mon Jul 05 2021 Biao Wang <biao716.wang@samsung.com> - 0.28.15
+ * Don't install recommended packages in mic.
+
+* Fri May 14 2021 Biao Wang <biao716.wang@samsung.com> - 0.28.14
+ * Encrypt user password with SHA512 instead of MD5.
+ * Fix pylint error, reimport glob.
+
+* Tue Mar 23 2021 Biao Wang <biao716.wang@samsung.com> - 0.28.13
+ * Add new squashfs option for squashfs file system.
+
+* Fri Feb 05 2021 Biao Wang <biao716.wang@samsung.com> - 0.28.12
+ * Support to create image with f2fs file system.
+ * Fix the bug that no print last installed package.
+ * Remove urlgrabber directory from mic.
+
+* Thu Nov 05 2020 Biao Wang <biao716.wang@samsung.com> - 0.28.11
+ * add dependece for yum directly.
+ * fix run error issue for parser repomd.xml when here is group type.
+ * Refine code, remove duplicated code
+ * Separate qcow plugin scripts
+
+* Tue Jul 21 2020 Biao Wang <biao716.wang@samsung.com> - 0.28.10
+ * Create btrfs images with the metadata single option.
+ * Refine code with SAM tools check.
+
+* Wed Jun 17 2020 Yan Meng <yan11.meng@samsung.com> - 0.28.9
+ * increase max loop device number in mic.
+ * fix build error with Typeerror.
+ * Fix the bug that truncates existing inittab file.
+
+* Thu May 7 2020 Yan Meng <yan11.meng@samsung.com> - 0.28.8
+ * remove unnecessary /etc/fstab file.
+
+* Mon Feb 17 2020 Yan Meng <yan11.meng@samsung.com> - 0.28.7
+ * fix pylint errors for mic.
+ * add option for mic to skip set hosts when create.
+ * skip set hosts by mic when /etc/hosts exists.
+
* Fri Feb 15 2019 Jin Xiao <jin.xiao@samsung.com> - 0.28.6
* new distribution support: Ubuntu 18.04.
Name: mic
Summary: Image Creator for Linux Distributions
-Version: 0.28.6
-Release: 0
+Version: 0.28.17
+Release: %{?release_prefix}%{?opensuse_bs:<CI_CNT>.<B_CNT>}%{!?opensuse_bs:0}
Group: Development/Tools
License: GPLv2
BuildArch: noarch
URL: http://www.tizen.org
Source0: %{name}_%{version}.tar.gz
-%if 0%{?tizen_version:1}
-Source1001: mic.manifest
-%endif
Requires: python >= 2.6
Requires: python-urlgrabber >= 3.9.0
+Requires: yum
%if 0%{?suse_version} || 0%{?tizen_version:1}
Requires: python-xml
%endif
Requires: gzip
Requires: bzip2
-%if 0%{?tizen_version:1}
-Requires: qemu-linux-user
-%else
-Requires: qemu-arm-static
-%endif
-
BuildRequires: python-devel
%if ! 0%{?tizen_version:1}
BuildRequires: python-docutils
%endif
-%if ! 0%{?centos_version}
-BuildRequires:fdupes
-%endif
+Obsoletes: mic2
+
+BuildRoot: %{_tmppath}/%{name}_%{version}-build
%description
The tool mic is used to create and manipulate images for Linux distributions.
%prep
%setup -q -n %{name}-%{version}
-%if 0%{?tizen_version:1}
-cp %{SOURCE1001} .
-%endif
%build
CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build
-%if ! 0%{?tizen_version:1}
make man
-%endif
%install
-rm -rf %{buildroot}
+rm -rf $RPM_BUILD_ROOT
%if 0%{?suse_version}
-%{__python} setup.py install --root=%{buildroot} --prefix=%{_prefix}
+%{__python} setup.py install --root=$RPM_BUILD_ROOT --prefix=%{_prefix}
%else
-%{__python} setup.py install --root=%{buildroot} -O1
+%{__python} setup.py install --root=$RPM_BUILD_ROOT -O1
%endif
# install man page
mkdir -p %{buildroot}/%{_prefix}/share/man/man1
-%if ! 0%{?tizen_version:1}
install -m644 doc/mic.1 %{buildroot}/%{_prefix}/share/man/man1
-%endif
# install bash completion
install -d -m0755 %{buildroot}/%{_sysconfdir}/bash_completion.d/
install -d -m0755 %{buildroot}/%{_sysconfdir}/zsh_completion.d/
install -Dp -m0755 etc/zsh_completion.d/_%{name} %{buildroot}/%{_sysconfdir}/zsh_completion.d/
-%if ! 0%{?centos_version}
-%fdupes %{buildroot}
-%endif
-
-
%files
-%if 0%{?tizen_version:1}
-%manifest %{name}.manifest
-%endif
%defattr(-,root,root,-)
-%if ! (0%{?suse_version} || 0%{?centos_version})
-%license COPYING
-%endif
%doc doc/*
-%doc README.rst AUTHORS ChangeLog
+%doc README.rst AUTHORS COPYING ChangeLog
%if ! 0%{?tizen_version:1}
%{_mandir}/man1/*
%endif
import M2Crypto
m2c_connection = M2Crypto.SSL.Connection.clientPostConnectionCheck
M2Crypto.SSL.Connection.clientPostConnectionCheck = None
- except ImportError, err:
+ except ImportError as err:
raise CreatorError("%s, please try to install python-m2crypto" % str(err))
proxy = None
f.write(conf)
f.close()
- os.chmod(confpath, 0644)
+ os.chmod(confpath, 0o644)
def _cleanupRpmdbLocks(self, installroot):
# cleans up temporary files left by bdb so that differing
return None
except yum.Errors.InstallError:
return "No package(s) available to install"
- except yum.Errors.RepoError, e:
+ except yum.Errors.RepoError as e:
raise CreatorError("Unable to download from repo : %s" % (e,))
- except yum.Errors.YumBaseError, e:
+ except yum.Errors.YumBaseError as e:
raise CreatorError("Unable to install: %s" % (e,))
def deselectPackage(self, pkg):
self.selectPackage(p)
return None
- except (yum.Errors.InstallError, yum.Errors.GroupsError), e:
+ except (yum.Errors.InstallError, yum.Errors.GroupsError) as e:
return e
- except yum.Errors.RepoError, e:
+ except yum.Errors.RepoError as e:
raise CreatorError("Unable to download from repo : %s" % (e,))
- except yum.Errors.YumBaseError, e:
+ except yum.Errors.YumBaseError as e:
raise CreatorError("Unable to install: %s" % (e,))
def addRepository(self, name, url = None, mirrorlist = None, proxy = None,
ts = rpmUtils.transaction.initReadOnlyTransaction()
try:
hdr = rpmUtils.miscutils.hdrFromPackage(ts, pkg)
- except rpmUtils.RpmUtilsError, e:
- raise yum.Errors.MiscError, \
- 'Could not open local rpm file: %s: %s' % (pkg, e)
+ except rpmUtils.RpmUtilsError as e:
+ raise yum.Errors.MiscError \
+ ('Could not open local rpm file: %s: %s' % (pkg, e))
self.deselectPackage(hdr['name'])
yum.YumBase.installLocal(self, pkg, po, updateonly)
os.environ["LD_PRELOAD"] = ""
try:
(res, resmsg) = self.buildTransaction()
- except yum.Errors.RepoError, e:
+ except yum.Errors.RepoError as e:
raise CreatorError("Unable to download from repo : %s" %(e,))
if res != 2:
raise CreatorError("No enough space used for downloading.")
# record the total size of installed pkgs
- pkgs_total_size = 0L
+ pkgs_total_size = 0
for x in dlpkgs:
if hasattr(x, 'installedsize'):
pkgs_total_size += int(x.installedsize)
raise CreatorError("mic failes to install some packages")
self._cleanupRpmdbLocks(self.conf.installroot)
- except rpmUtils.RpmUtilsError, e:
+ except rpmUtils.RpmUtilsError as e:
raise CreatorError("mic does NOT support delta rpm: %s" % e)
- except yum.Errors.RepoError, e:
+ except yum.Errors.RepoError as e:
raise CreatorError("Unable to download from repo : %s" % e)
- except yum.Errors.YumBaseError, e:
+ except yum.Errors.YumBaseError as e:
raise CreatorError("Unable to install: %s" % e)
finally:
msger.disable_logstderr()
}
try:
self.__pkgs_vcsinfo[lname] = hdr['VCS']
- except ValueError, KeyError:
+ except ValueError as KeyError:
self.__pkgs_vcsinfo[lname] = None
return self.__pkgs_vcsinfo
import rpm
import glob
-import zypp
+import zypp #pylint: disable=import-error
if not hasattr(zypp, 'PoolQuery') or \
not hasattr(zypp.RepoManager, 'loadSolvFile'):
raise ImportError("python-zypp in host system cannot support PoolQuery or "
def _cleanupRpmdbLocks(self, installroot):
# cleans up temporary files left by bdb so that differing
# versions of rpm don't cause problems
- import glob
for f in glob.glob(installroot + "/var/lib/rpm/__db*"):
os.unlink(f)
self.__build_repo_cache(name)
- except RuntimeError, e:
+ except RuntimeError as e:
raise CreatorError(str(e))
msger.verbose('repo: %s was added' % name)
if download_count > 0:
msger.info("Downloading packages ...")
self.downloadPkgs(dlpkgs, download_count)
- except CreatorError, e:
+ except CreatorError as e:
raise CreatorError("Package download failed: %s" %(e,))
try:
self.installPkgs(dlpkgs)
except (RepoError, RpmError):
raise
- except Exception, e:
+ except Exception as e:
raise CreatorError("Package installation failed: %s" % (e,))
def getVcsInfo(self):
self.repo_manager.loadFromCache(repo)
self.Z = zypp.ZYppFactory_instance().getZYpp()
+ if configmgr.create['block_recommends']:
+ msger.info("zypp not install recommend packages")
+ self.Z.resolver().setOnlyRequires(True)
self.Z.initializeTarget(zypp.Pathname(self.instroot))
self.Z.target().load()
for e in errors:
msger.warning(e[0])
raise RepoError('Could not run transaction.')
+ def show_unresolved_dependencies_msg(self, unresolved_dependencies):
+ for pkg, need, needflags, sense, key in unresolved_dependencies:
+
+ package = '-'.join(pkg)
+
+ if needflags == rpm.RPMSENSE_LESS:
+ deppkg = ' < '.join(need)
+ elif needflags == rpm.RPMSENSE_EQUAL:
+ deppkg = ' = '.join(need)
+ elif needflags == rpm.RPMSENSE_GREATER:
+ deppkg = ' > '.join(need)
+ else:
+ deppkg = '-'.join(need)
+
+ if sense == rpm.RPMDEP_SENSE_REQUIRES:
+ msger.warning("[%s] Requires [%s], which is not provided" \
+ % (package, deppkg))
+
+ elif sense == rpm.RPMDEP_SENSE_CONFLICTS:
+ msger.warning("[%s] Conflicts with [%s]" % (package, deppkg))
def installPkgs(self, package_objects):
if not self.ts:
raise RepoError('Could not run transaction.')
else:
- for pkg, need, needflags, sense, key in unresolved_dependencies:
- package = '-'.join(pkg)
-
- if needflags == rpm.RPMSENSE_LESS:
- deppkg = ' < '.join(need)
- elif needflags == rpm.RPMSENSE_EQUAL:
- deppkg = ' = '.join(need)
- elif needflags == rpm.RPMSENSE_GREATER:
- deppkg = ' > '.join(need)
- else:
- deppkg = '-'.join(need)
-
- if sense == rpm.RPMDEP_SENSE_REQUIRES:
- msger.warning("[%s] Requires [%s], which is not provided" \
- % (package, deppkg))
-
- elif sense == rpm.RPMDEP_SENSE_CONFLICTS:
- msger.warning("[%s] Conflicts with [%s]" % (package, deppkg))
-
+ self.show_unresolved_dependencies_msg(unresolved_dependencies)
raise RepoError("Unresolved dependencies, transaction failed.")
def __initialize_transaction(self):
-#!/usr/bin/python -tt
+#! /usr/bin/python2
#
# Copyright (c) 2011 Intel, Inc.
#
from mic import chroot, msger, rt_util
from mic.utils import misc, errors, fs_related, runner
from mic.imager import fs
-from mic.conf import configmgr
from mic.plugin import pluginmgr
from mic.pluginbase import ImagerPlugin
def do_create(self, args):
"""${cmd_name}: create fs image
- Usage:
- ${name} ${cmd_name} <ksfile> [OPTS]
-
- ${cmd_option_list}
"""
-
- if args is None:
- raise errors.Usage("Invalid arguments.")
-
- creatoropts = configmgr.create
- ksconf = args.ksfile
-
- if creatoropts['runtime'] == 'bootstrap':
- configmgr._ksconf = ksconf
- rt_util.bootstrap_mic()
-
- recording_pkgs = []
- if len(creatoropts['record_pkgs']) > 0:
- recording_pkgs = creatoropts['record_pkgs']
-
- if creatoropts['release'] is not None:
- if 'name' not in recording_pkgs:
- recording_pkgs.append('name')
- if 'vcs' not in recording_pkgs:
- recording_pkgs.append('vcs')
-
- configmgr._ksconf = ksconf
-
- # try to find the pkgmgr
- pkgmgr = None
- backends = pluginmgr.get_plugins('backend')
- if 'auto' == creatoropts['pkgmgr']:
- for key in configmgr.prefer_backends:
- if key in backends:
- pkgmgr = backends[key]
- break
- else:
- for key in backends.keys():
- if key == creatoropts['pkgmgr']:
- pkgmgr = backends[key]
- break
-
- if not pkgmgr:
- raise errors.CreatorError("Can't find backend: %s, "
- "available choices: %s" %
- (creatoropts['pkgmgr'],
- ','.join(backends.keys())))
+ creatoropts, pkgmgr, recording_pkgs = rt_util.prepare_create(args)
creator = fs.FsImageCreator(creatoropts, pkgmgr)
creator._include_src = args.include_src
creator.package(creatoropts["destdir"])
creator.create_manifest()
if creatoropts['release'] is not None:
- creator.release_output(ksconf, creatoropts['destdir'],
+ creator.release_output(args.ksfile, creatoropts['destdir'],
creatoropts['release'])
creator.print_outimage_info()
except errors.CreatorError:
cmd = creatoropts['run_script']
try:
runner.show(cmd)
- except OSError,err:
+ except OSError as err:
msger.warning(str(err))
from mic import chroot, msger, rt_util
from mic.utils import misc, fs_related, errors, runner
-from mic.conf import configmgr
from mic.plugin import pluginmgr
from mic.imager.loop import LoopImageCreator, load_mountpoints
@classmethod
def do_create(self, args):
"""${cmd_name}: create loop image
-
- Usage:
- ${name} ${cmd_name} <ksfile> [OPTS]
-
- ${cmd_option_list}
"""
- if args is None:
- raise errors.Usage("Invalid arguments")
-
- creatoropts = configmgr.create
- ksconf = args.ksfile
-
- if creatoropts['runtime'] == "bootstrap":
- configmgr._ksconf = ksconf
- rt_util.bootstrap_mic()
-
- recording_pkgs = []
- if len(creatoropts['record_pkgs']) > 0:
- recording_pkgs = creatoropts['record_pkgs']
-
- if creatoropts['release'] is not None:
- if 'name' not in recording_pkgs:
- recording_pkgs.append('name')
- if 'vcs' not in recording_pkgs:
- recording_pkgs.append('vcs')
-
- configmgr._ksconf = ksconf
-
- # try to find the pkgmgr
- pkgmgr = None
- backends = pluginmgr.get_plugins('backend')
- if 'auto' == creatoropts['pkgmgr']:
- for key in configmgr.prefer_backends:
- if key in backends:
- pkgmgr = backends[key]
- break
- else:
- for key in backends.keys():
- if key == creatoropts['pkgmgr']:
- pkgmgr = backends[key]
- break
-
- if not pkgmgr:
- raise errors.CreatorError("Can't find backend: %s, "
- "available choices: %s" %
- (creatoropts['pkgmgr'],
- ','.join(backends.keys())))
+ creatoropts, pkgmgr, recording_pkgs = rt_util.prepare_create(args)
creator = LoopImageCreator(creatoropts,
pkgmgr,
creator.create_manifest()
if creatoropts['release'] is not None:
- creator.release_output(ksconf,
+ creator.release_output(args.ksfile,
creatoropts['destdir'],
creatoropts['release'])
creator.print_outimage_info()
cmd = creatoropts['run_script']
try:
runner.show(cmd)
- except OSError,err:
+ except OSError as err:
msger.warning(str(err))
msger.info("Finished.")
raise errors.CreatorError("Cannot support fstype: %s" % fstype)
name = os.path.join(tmpdir, name)
- size = size * 1024L * 1024L
+ size = size * 1024 * 1024
loop = myDiskMount(fs_related.SparseLoopbackDisk(name, size),
os.path.join(mntdir, mp.lstrip('/')),
fstype, size, label)
raise errors.CreatorError("damaged tarball for loop images")
img = target
- imgsize = misc.get_file_size(img) * 1024L * 1024L
+ imgsize = misc.get_file_size(img) * 1024 * 1024
imgtype = misc.get_image_type(img)
if imgtype == "btrfsimg":
fstype = "btrfs"
elif imgtype in ("ext3fsimg", "ext4fsimg"):
fstype = imgtype[:4]
myDiskMount = fs_related.ExtDiskMount
+ elif imgtype == "f2fsimg":
+ fstype = "f2fs"
+ myDiskMount = fs_related.F2fsDiskMount
else:
raise errors.CreatorError("Unsupported filesystem type: %s" \
% imgtype)
import shutil
from mic import msger, rt_util
-from mic.conf import configmgr
from mic.plugin import pluginmgr
from mic.pluginbase import ImagerPlugin
-from mic.imager.loop import LoopImageCreator
-from mic.utils import errors, fs_related, runner
-
-class QcowImageCreator(LoopImageCreator):
- img_format = 'qcow'
-
- def __init__(self, creatoropts=None, pkgmgr=None):
- LoopImageCreator.__init__(self, creatoropts, pkgmgr)
- self.cmd_qemuimg = 'qemu-img'
-
- def _stage_final_image(self):
- try:
- self.cmd_qemuimg = fs_related.find_binary_path('qemu-img')
- except errors.CreatorError:
- return LoopImageCreator._stage_final_image(self)
-
- self._resparse()
-
- imgfile = None
- for item in self._instloops:
- if item['mountpoint'] == '/':
- 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']})
- imgfile = os.path.join(self._imgdir, item['name'])
-
- if imgfile:
- qemuimage = imgfile + ".x86"
- runner.show("%s convert -O qcow2 %s %s"
- % (self.cmd_qemuimg, imgfile, qemuimage))
- os.unlink(imgfile)
- os.rename(qemuimage, imgfile)
-
- for item in os.listdir(self._imgdir):
- shutil.move(os.path.join(self._imgdir, item),
- os.path.join(self._outdir, item))
+from mic.imager.qcow import QcowImageCreator
+from mic.utils import errors, runner
class QcowPlugin(ImagerPlugin):
name = 'qcow'
@classmethod
def do_create(cls, args):
"""${cmd_name}: create qcow image
-
- Usage:
- ${name} ${cmd_name} <ksfile> [OPTS]
-
- ${cmd_option_list}
"""
- if args is None:
- raise errors.Usage("Invalid arguments")
-
- creatoropts = configmgr.create
- ksconf = args.ksfile
-
- if creatoropts['runtime'] == "bootstrap":
- configmgr._ksconf = ksconf
- rt_util.bootstrap_mic()
-
- recording_pkgs = []
- if len(creatoropts['record_pkgs']) > 0:
- recording_pkgs = creatoropts['record_pkgs']
-
- if creatoropts['release'] is not None:
- if 'name' not in recording_pkgs:
- recording_pkgs.append('name')
- if 'vcs' not in recording_pkgs:
- recording_pkgs.append('vcs')
-
- configmgr._ksconf = ksconf
-
- # try to find the pkgmgr
- pkgmgr = None
- backends = pluginmgr.get_plugins('backend')
- if 'auto' == creatoropts['pkgmgr']:
- for key in configmgr.prefer_backends:
- if key in backends:
- pkgmgr = backends[key]
- break
- else:
- for key in backends.keys():
- if key == creatoropts['pkgmgr']:
- pkgmgr = backends[key]
- break
-
- if not pkgmgr:
- raise errors.CreatorError("Can't find backend: %s, "
- "available choices: %s" %
- (creatoropts['pkgmgr'],
- ','.join(backends.keys())))
+
+ creatoropts, pkgmgr, recording_pkgs = rt_util.prepare_create(args)
creator = QcowImageCreator(creatoropts,
pkgmgr)
creator.create_manifest()
if creatoropts['release'] is not None:
- creator.release_output(ksconf,
+ creator.release_output(args.ksfile,
creatoropts['destdir'],
creatoropts['release'])
creator.print_outimage_info()
if creatoropts['run_script']:
cmd = creatoropts['run_script']
try:
- runner.show(cmd)
- except OSError,err:
+ runner.show(cmd)
+ except OSError as err:
msger.warning(str(err))
from mic import chroot, msger, rt_util
from mic.utils import misc, fs_related, errors, runner
-from mic.conf import configmgr
from mic.plugin import pluginmgr
from mic.utils.partitionedfs import PartitionedMount
@classmethod
def do_create(self, args):
"""${cmd_name}: create raw image
-
- Usage:
- ${name} ${cmd_name} <ksfile> [OPTS]
-
- ${cmd_option_list}
"""
- creatoropts = configmgr.create
- ksconf = args.ksfile
-
- if creatoropts['runtime'] == "bootstrap":
- configmgr._ksconf = ksconf
- rt_util.bootstrap_mic()
-
- recording_pkgs = []
- if len(creatoropts['record_pkgs']) > 0:
- recording_pkgs = creatoropts['record_pkgs']
-
- if creatoropts['release'] is not None:
- if 'name' not in recording_pkgs:
- recording_pkgs.append('name')
- if 'vcs' not in recording_pkgs:
- recording_pkgs.append('vcs')
-
- configmgr._ksconf = ksconf
-
- # try to find the pkgmgr
- pkgmgr = None
- backends = pluginmgr.get_plugins('backend')
- if 'auto' == creatoropts['pkgmgr']:
- for key in configmgr.prefer_backends:
- if key in backends:
- pkgmgr = backends[key]
- break
- else:
- for key in backends.keys():
- if key == creatoropts['pkgmgr']:
- pkgmgr = backends[key]
- break
-
- if not pkgmgr:
- raise errors.CreatorError("Can't find backend: %s, "
- "available choices: %s" %
- (creatoropts['pkgmgr'],
- ','.join(backends.keys())))
+ creatoropts, pkgmgr, recording_pkgs = rt_util.prepare_create(args)
creator = raw.RawImageCreator(creatoropts, pkgmgr, args.compress_image,
args.generate_bmap, args.fstab_entry)
creator.package(creatoropts["destdir"])
creator.create_manifest()
if creatoropts['release'] is not None:
- creator.release_output(ksconf, creatoropts['destdir'], creatoropts['release'])
+ creator.release_output(args.ksfile, creatoropts['destdir'], creatoropts['release'])
creator.print_outimage_info()
except errors.CreatorError:
cmd = creatoropts['run_script']
try:
runner.show(cmd)
- except OSError,err:
+ except OSError as err:
msger.warning(str(err))
@classmethod
def do_chroot(cls, target, cmd=[]):
img = target
- imgsize = misc.get_file_size(img) * 1024L * 1024L
+ imgsize = misc.get_file_size(img) * 1024 * 1024
partedcmd = fs_related.find_binary_path("parted")
disk = fs_related.SparseLoopbackDisk(img, imgsize)
imgmnt = misc.mkdtemp()
# not recognize properly.
# TODO: Can we make better assumption?
fstype = "btrfs"
- elif partition_info[5] in [ "ext2", "ext3", "ext4", "btrfs" ]:
+ elif partition_info[5] in [ "ext2", "ext3", "ext4", "btrfs", "f2fs" ]:
fstype = partition_info[5]
elif partition_info[5] in [ "fat16", "fat32" ]:
fstype = "vfat"
if rootpart and rootpart == line[0]:
mountpoint = '/'
- elif not root_mounted and fstype in [ "ext2", "ext3", "ext4", "btrfs" ]:
+ elif not root_mounted and fstype in [ "ext2", "ext3", "ext4", "btrfs", "f2fs" ]:
# TODO: Check that this is actually the valid root partition from /etc/fstab
mountpoint = "/"
root_mounted = True
@classmethod
def do_unpack(cls, srcimg):
- srcimgsize = (misc.get_file_size(srcimg)) * 1024L * 1024L
+ srcimgsize = (misc.get_file_size(srcimg)) * 1024 * 1024
srcmnt = misc.mkdtemp("srcmnt")
disk = fs_related.SparseLoopbackDisk(srcimg, srcimgsize)
srcloop = PartitionedMount(srcmnt, skipformat = True)
MOD_NAME + '/3rdparty/pykickstart',
MOD_NAME + '/3rdparty/pykickstart/commands',
MOD_NAME + '/3rdparty/pykickstart/handlers',
- MOD_NAME + '/3rdparty/pykickstart/urlgrabber',
]
IMAGER_PLUGINS = glob.glob(os.path.join("plugins", "imager", "*.py"))
def testChroot(self):
try:
chroot.chroot(TEST_CHROOT_DIR, None, 'exit')
- except Exception, e:
+ except Exception as e:
raise self.failureException(e)
if __name__ == "__main__":
parent_parser.add_argument('--tpk_install', action='store', dest='tpk_install',
default=None, help='Copy tpk file to /usr/apps/.preload-tpk')
parent_parser.add_argument('--rpm-debug', action='store_true', dest='rpm_debug', help='Set debug mode for rpm install')
+ parent_parser.add_argument('--skip-set-hosts', action='store_true', dest='skip_set_hosts', default=False, help='choose to skip set hosts by mic')
+ parent_parser.add_argument('--postscripts-maxruntime', dest='postscripts_maxruntime', default=120, help='max run time for post scripts')
+ parent_parser.add_argument('--block-recommends', action='store_true', dest='block_recommends', default=False, help='Do not install recommended packages')
parser.set_defaults(alias="cr")